diff --git a/CHANGELOG.md b/CHANGELOG.md index f1a7676..acef0d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Don't set RTL text plugin if already in progress - Add branch name to screenshots if looking at branch pattern - Add precompile option +- Add download screenshot button ## 0.17.0 diff --git a/dist/bundle.css b/dist/bundle.css index 5bc2706..2a27ba6 100644 --- a/dist/bundle.css +++ b/dist/bundle.css @@ -1,5 +1,5 @@ -.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0,0,0,0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgba(0,0,0,.05)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%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.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%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 (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-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}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgba(0,0,0,.05)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-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}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} .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;-moz-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,.mapboxgl-ctrl-bottom-left,.mapboxgl-ctrl-bottom-right,.mapboxgl-ctrl-left,.mapboxgl-ctrl-right,.mapboxgl-ctrl-top,.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{left:50%;top:0;transform:translateX(-50%)}.mapboxgl-ctrl-top-right{right:0;top:0}.mapboxgl-ctrl-right{right:0;top:50%;transform:translateY(-50%)}.mapboxgl-ctrl-bottom-right{bottom:0;right:0}.mapboxgl-ctrl-bottom{bottom:0;left:50%;transform:translateX(-50%)}.mapboxgl-ctrl-bottom-left{bottom:0;left:0}.mapboxgl-ctrl-left{left:0;top:50%;transform:translateY(-50%)}.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 .mapboxgl-ctrl{float:left;margin:10px 0}.mapboxgl-ctrl-top-right .mapboxgl-ctrl{float:right;margin:10px 10px 0 0}.mapboxgl-ctrl-bottom-right .mapboxgl-ctrl,.mapboxgl-ctrl-right .mapboxgl-ctrl{float:right;margin:0 10px 10px 0}.mapboxgl-ctrl-bottom .mapboxgl-ctrl{float:left;margin:10px 0}.mapboxgl-ctrl-bottom-left .mapboxgl-ctrl,.mapboxgl-ctrl-left .mapboxgl-ctrl{float:left;margin:0 0 10px 10px}.mapboxgl-ctrl-group{background:#fff;border-radius:4px}.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px #0000001a}@media (-ms-high-contrast:active){.mapboxgl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.mapboxgl-ctrl-group button{background-color:initial;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:initial}.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:#0000000d}.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-buildings-toggle .mapboxgl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M3.3335 11.6666C3.3335 12.5871 4.07969 13.3333 5.00016 13.3333C5.92064 13.3333 6.66683 12.5871 6.66683 11.6666L6.66683 6.66659L11.6668 6.66659C12.5873 6.66659 13.3335 5.92039 13.3335 4.99992C13.3335 4.07944 12.5873 3.33325 11.6668 3.33325H3.3335V11.6666Z' fill='currentColor'/%3E%3Cpath d='M26.6668 11.6666C26.6668 12.5871 25.9206 13.3333 25.0002 13.3333C24.0797 13.3333 23.3335 12.5871 23.3335 11.6666L23.3335 6.66659L18.3335 6.66659C17.413 6.66659 16.6668 5.92039 16.6668 4.99992C16.6668 4.07944 17.413 3.33325 18.3335 3.33325H26.6668L26.6668 11.6666Z' fill='currentColor'/%3E%3Cpath d='M13.3335 24.9999C13.3335 25.9204 12.5873 26.6666 11.6668 26.6666H3.3335V18.3333C3.3335 17.4128 4.07969 16.6666 5.00016 16.6666C5.92064 16.6666 6.66683 17.4128 6.66683 18.3333V23.3333H11.6668C12.5873 23.3333 13.3335 24.0794 13.3335 24.9999Z' fill='currentColor'/%3E%3Cpath d='M18.3335 26.6666C17.413 26.6666 16.6668 25.9204 16.6668 24.9999C16.6668 24.0794 17.413 23.3333 18.3335 23.3333H23.3335V18.3333C23.3335 17.4128 24.0797 16.6666 25.0002 16.6666C25.9206 16.6666 26.6668 17.4128 26.6668 18.3333V26.6666H18.3335Z' fill='currentColor'/%3E%3C/svg%3E");background-size:26px 26px}.mapboxgl-ctrl button.mapboxgl-ctrl-buildings-toggle.mapboxgl-ctrl-level-button-selected .mapboxgl-ctrl-icon{filter:invert(1) brightness(1)}.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:initial;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:#ffffff80;margin:0;padding:0 5px}@media screen{.mapboxgl-ctrl-attrib.mapboxgl-compact{background-color:#fff;border-radius:12px;box-sizing:initial;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-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:#ffffff80;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-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:#0000000d}.mapboxgl-ctrl-bottom-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{bottom:0;right:0}.mapboxgl-ctrl-right>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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}.mapboxgl-ctrl-left>.mapboxgl-ctrl-attrib.mapboxgl-compact:after{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:#000000bf;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:#ffffffbf;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 #0000;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:initial;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.mapboxgl-popup-close-button:hover{background-color:#0000000d}.mapboxgl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px #0000001a;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;-webkit-user-select:none;-moz-user-select: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 #00000059;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 #0000;transform:translateY(-28px) skewY(-20deg)}.mapboxgl-user-location-show-heading .mapboxgl-user-location-heading:after{border-right:7.5px solid #0000;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:#000000b3;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}.mapboxgl-ctrl-separator{background-color:#e0e0e0;height:1px}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button{color:#333;font-size:18px;font-weight:700;height:50px;width:50px}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button:first-child{border-top-left-radius:8px;border-top-right-radius:8px}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button:last-child{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button:hover{background-color:#f5f5f5}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected{background-color:#4a5568;color:#fff}.mapboxgl-ctrl button.mapboxgl-ctrl-level-button-selected:hover{background-color:#2d3748} +.maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0,0,0,0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgba(0,0,0,.05)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%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.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%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 (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-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}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgba(0,0,0,.05)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-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}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} .maplibregl-map{font:12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;overflow:hidden;position:relative;-webkit-tap-highlight-color:rgb(0,0,0,0)}.maplibregl-canvas{left:0;position:absolute;top:0}.maplibregl-map:fullscreen{height:100%;width:100%}.maplibregl-ctrl-group button.maplibregl-ctrl-compass{touch-action:none}.maplibregl-canvas-container.maplibregl-interactive,.maplibregl-ctrl-group button.maplibregl-ctrl-compass{cursor:grab;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-canvas-container.maplibregl-interactive.maplibregl-track-pointer{cursor:pointer}.maplibregl-canvas-container.maplibregl-interactive:active,.maplibregl-ctrl-group button.maplibregl-ctrl-compass:active{cursor:grabbing}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-canvas-container.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:pinch-zoom}.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan,.maplibregl-canvas-container.maplibregl-touch-zoom-rotate.maplibregl-touch-drag-pan .maplibregl-canvas{touch-action:none}.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures,.maplibregl-canvas-container.maplibregl-touch-drag-pan.maplibregl-cooperative-gestures .maplibregl-canvas{touch-action:pan-x pan-y}.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{pointer-events:none;position:absolute;z-index:2}.maplibregl-ctrl-top-left{left:0;top:0}.maplibregl-ctrl-top-right{right:0;top:0}.maplibregl-ctrl-bottom-left{bottom:0;left:0}.maplibregl-ctrl-bottom-right{bottom:0;right:0}.maplibregl-ctrl{clear:both;pointer-events:auto;transform:translate(0)}.maplibregl-ctrl-top-left .maplibregl-ctrl{float:left;margin:10px 0 0 10px}.maplibregl-ctrl-top-right .maplibregl-ctrl{float:right;margin:10px 10px 0 0}.maplibregl-ctrl-bottom-left .maplibregl-ctrl{float:left;margin:0 0 10px 10px}.maplibregl-ctrl-bottom-right .maplibregl-ctrl{float:right;margin:0 10px 10px 0}.maplibregl-ctrl-group{background:#fff;border-radius:4px}.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px rgba(0,0,0,.1)}@media (forced-colors:active){.maplibregl-ctrl-group:not(:empty){box-shadow:0 0 0 2px ButtonText}}.maplibregl-ctrl-group button{background-color:transparent;border:0;box-sizing:border-box;cursor:pointer;display:block;height:29px;outline:none;padding:0;width:29px}.maplibregl-ctrl-group button+button{border-top:1px solid #ddd}.maplibregl-ctrl button .maplibregl-ctrl-icon{background-position:50%;background-repeat:no-repeat;display:block;height:100%;width:100%}@media (forced-colors:active){.maplibregl-ctrl-icon{background-color:transparent}.maplibregl-ctrl-group button+button{border-top:1px solid ButtonText}}.maplibregl-ctrl button::-moz-focus-inner{border:0;padding:0}.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl button:disabled{cursor:not-allowed}.maplibregl-ctrl button:disabled .maplibregl-ctrl-icon{opacity:.25}@media (hover:hover){.maplibregl-ctrl button:not(:disabled):hover{background-color:rgba(0,0,0,.05)}}.maplibregl-ctrl button:not(:disabled):active{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-group button:focus:focus-visible{box-shadow:0 0 2px 2px #0096ff}.maplibregl-ctrl-group button:focus:not(:focus-visible){box-shadow:none}.maplibregl-ctrl-group button:focus:first-child{border-radius:4px 4px 0 0}.maplibregl-ctrl-group button:focus:last-child{border-radius:0 0 4px 4px}.maplibregl-ctrl-group button:focus:only-child{border-radius:inherit}.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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 13z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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.5'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-3zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-shrink .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' 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-1zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-compass .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 29 29'%3E%3Cpath d='m10.5 14 4-8 4 8z'/%3E%3Cpath fill='%23ccc' d='m10.5 16 4 8 4-8z'/%3E%3C/svg%3E")}}.maplibregl-ctrl button.maplibregl-ctrl-globe .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%23333' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-globe-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%2333b5e5' viewBox='0 0 22 22'%3E%3Ccircle cx='11' cy='11' r='8.5'/%3E%3Cpath d='M17.5 11c0 4.819-3.02 8.5-6.5 8.5S4.5 15.819 4.5 11 7.52 2.5 11 2.5s6.5 3.681 6.5 8.5Z'/%3E%3Cpath d='M13.5 11c0 2.447-.331 4.64-.853 6.206-.262.785-.562 1.384-.872 1.777-.314.399-.58.517-.775.517s-.461-.118-.775-.517c-.31-.393-.61-.992-.872-1.777C8.831 15.64 8.5 13.446 8.5 11s.331-4.64.853-6.206c.262-.785.562-1.384.872-1.777.314-.399.58-.517.775-.517s.461.118.775.517c.31.393.61.992.872 1.777.522 1.565.853 3.76.853 6.206Z'/%3E%3Cpath d='M11 7.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138q.07-.058.224-.138c.299-.151.763-.302 1.379-.434C7.378 5.666 9.091 5.5 11 5.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138q-.07.058-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428ZM4.486 6.436ZM11 16.5c-1.909 0-3.622-.166-4.845-.428-.616-.132-1.08-.283-1.379-.434a1.3 1.3 0 0 1-.224-.138 1.3 1.3 0 0 1 .224-.138c.299-.151.763-.302 1.379-.434C7.378 14.666 9.091 14.5 11 14.5s3.622.166 4.845.428c.616.132 1.08.283 1.379.434.105.053.177.1.224.138a1.3 1.3 0 0 1-.224.138c-.299.151-.763.302-1.379.434-1.223.262-2.936.428-4.845.428Zm-6.514-1.064ZM11 12.5c-2.46 0-4.672-.222-6.255-.574-.796-.177-1.406-.38-1.805-.59a1.5 1.5 0 0 1-.39-.272.3.3 0 0 1-.047-.064.3.3 0 0 1 .048-.064c.066-.073.189-.167.389-.272.399-.21 1.009-.413 1.805-.59C6.328 9.722 8.54 9.5 11 9.5s4.672.222 6.256.574c.795.177 1.405.38 1.804.59.2.105.323.2.39.272a.3.3 0 0 1 .047.064.3.3 0 0 1-.048.064 1.4 1.4 0 0 1-.389.272c-.399.21-1.009.413-1.804.59-1.584.352-3.796.574-6.256.574Zm-8.501-1.51v.002zm0 .018v.002zm17.002.002v-.002zm0-.018v-.002z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%23333' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-terrain-enabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='%2333b5e5' viewBox='0 0 22 22'%3E%3Cpath d='m1.754 13.406 4.453-4.851 3.09 3.09 3.281 3.277.969-.969-3.309-3.312 3.844-4.121 6.148 6.886h1.082v-.855l-7.207-8.07-4.84 5.187L6.169 6.57l-5.48 5.965v.871ZM.688 16.844h20.625v1.375H.688Zm0 0'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23333' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23aaa' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting .maplibregl-ctrl-icon{animation:maplibregl-spin 2s linear infinite}@media (forced-colors:active){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23fff' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23999' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e58978' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%2333b5e5' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23e54e33' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl button.maplibregl-ctrl-geolocate .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3C/svg%3E")}.maplibregl-ctrl button.maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='29' height='29' fill='%23666' viewBox='0 0 20 20'%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-1m0 2.5a3.5 3.5 0 1 1 0 7 3.5 3.5 0 1 1 0-7'/%3E%3Ccircle cx='10' cy='10' r='2'/%3E%3Cpath fill='red' d='m14 5 1 1-9 9-1-1z'/%3E%3C/svg%3E")}}@keyframes maplibregl-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%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.maplibregl-ctrl-logo.maplibregl-compact{width:14px}@media (forced-colors:active){a.maplibregl-ctrl-logo{background-color:transparent;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}@media (forced-colors:active) and (prefers-color-scheme:light){a.maplibregl-ctrl-logo{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='23' fill='none'%3E%3Cpath fill='%23000' fill-opacity='.4' fill-rule='evenodd' d='M17.408 16.796h-1.827l2.501-12.095h.198l3.324 6.533.988 2.19.988-2.19 3.258-6.533h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.929 5.644h-.098l-2.914-5.644-.757-1.71-.345 1.71zm1.958-3.42-.726 3.663a1.255 1.255 0 0 1-1.232 1.011h-1.827a1.255 1.255 0 0 1-1.229-1.509l2.501-12.095a1.255 1.255 0 0 1 1.23-1.001h.197a1.25 1.25 0 0 1 1.12.685l3.19 6.273 3.125-6.263a1.25 1.25 0 0 1 1.123-.695h.181a1.255 1.255 0 0 1 1.227.991l1.443 6.71a5 5 0 0 1 .314-.787l.009-.016a4.6 4.6 0 0 1 1.777-1.887c.782-.46 1.668-.667 2.611-.667a4.6 4.6 0 0 1 1.7.32l.306.134c.21-.16.474-.256.759-.256h1.694a1.255 1.255 0 0 1 1.212.925 1.255 1.255 0 0 1 1.212-.925h1.711c.284 0 .545.094.755.252.613-.3 1.312-.45 2.075-.45 1.356 0 2.557.445 3.482 1.4q.47.48.763 1.064V4.701a1.255 1.255 0 0 1 1.255-1.255h1.86A1.255 1.255 0 0 1 54.44 4.7v9.194h2.217c.19 0 .37.043.532.118v-4.77c0-.356.147-.678.385-.906a2.42 2.42 0 0 1-.682-1.71c0-.665.267-1.253.735-1.7a2.45 2.45 0 0 1 1.722-.674 2.43 2.43 0 0 1 1.705.675q.318.302.504.683V4.7a1.255 1.255 0 0 1 1.255-1.255h1.744A1.255 1.255 0 0 1 65.812 4.7v3.335a4.8 4.8 0 0 1 1.526-.246c.938 0 1.817.214 2.59.69a4.47 4.47 0 0 1 1.67 1.743v-.98a1.255 1.255 0 0 1 1.256-1.256h1.777c.233 0 .451.064.639.174a3.4 3.4 0 0 1 1.567-.372c.346 0 .861.02 1.285.232a1.25 1.25 0 0 1 .689 1.004 4.7 4.7 0 0 1 .853-.588c.795-.44 1.675-.647 2.61-.647 1.385 0 2.65.39 3.525 1.396.836.938 1.168 2.173 1.168 3.528q-.001.515-.056 1.051a1.255 1.255 0 0 1-.947 1.09l.408.952a1.255 1.255 0 0 1-.477 1.552c-.418.268-.92.463-1.458.612-.613.171-1.304.244-2.049.244-1.06 0-2.043-.207-2.886-.698l-.015-.008c-.798-.48-1.419-1.135-1.818-1.963l-.004-.008a5.8 5.8 0 0 1-.548-2.512q0-.429.053-.843a1.3 1.3 0 0 1-.333-.086l-.166-.004c-.223 0-.426.062-.643.228-.03.024-.142.139-.142.59v3.883a1.255 1.255 0 0 1-1.256 1.256h-1.777a1.255 1.255 0 0 1-1.256-1.256V15.69l-.032.057a4.8 4.8 0 0 1-1.86 1.833 5.04 5.04 0 0 1-2.484.634 4.5 4.5 0 0 1-1.935-.424 1.25 1.25 0 0 1-.764.258h-1.71a1.255 1.255 0 0 1-1.256-1.255V7.687a2.4 2.4 0 0 1-.428.625c.253.23.412.561.412.93v7.553a1.255 1.255 0 0 1-1.256 1.255h-1.843a1.25 1.25 0 0 1-.894-.373c-.228.23-.544.373-.894.373H51.32a1.255 1.255 0 0 1-1.256-1.255v-1.251l-.061.117a4.7 4.7 0 0 1-1.782 1.884 4.77 4.77 0 0 1-2.485.67 5.6 5.6 0 0 1-1.485-.188l.009 2.764a1.255 1.255 0 0 1-1.255 1.259h-1.729a1.255 1.255 0 0 1-1.255-1.255v-3.537a1.255 1.255 0 0 1-1.167.793h-1.679a1.25 1.25 0 0 1-.77-.263 4.5 4.5 0 0 1-1.945.429c-.885 0-1.724-.21-2.495-.632l-.017-.01a5 5 0 0 1-1.081-.836 1.255 1.255 0 0 1-1.254 1.312h-1.81a1.255 1.255 0 0 1-1.228-.99l-.782-3.625-2.044 3.939a1.25 1.25 0 0 1-1.115.676h-.098a1.25 1.25 0 0 1-1.116-.68l-2.061-3.994zM35.92 16.63l.207-.114.223-.15q.493-.356.735-.785l.061-.118.033 1.332h1.678V9.242h-1.694l-.033 1.267q-.133-.329-.526-.658l-.032-.028a3.2 3.2 0 0 0-.668-.428l-.27-.12a3.3 3.3 0 0 0-1.235-.23q-1.136-.001-1.974.493a3.36 3.36 0 0 0-1.3 1.382q-.445.89-.444 2.074 0 1.2.51 2.107a3.8 3.8 0 0 0 1.382 1.381 3.9 3.9 0 0 0 1.893.477q.795 0 1.455-.33zm-2.789-5.38q-.576.675-.575 1.762 0 1.102.559 1.794.576.675 1.645.675a2.25 2.25 0 0 0 .934-.19 2.2 2.2 0 0 0 .468-.29l.178-.161a2.2 2.2 0 0 0 .397-.561q.244-.5.244-1.15v-.115q0-.708-.296-1.267l-.043-.077a2.2 2.2 0 0 0-.633-.709l-.13-.086-.047-.028a2.1 2.1 0 0 0-1.073-.285q-1.052 0-1.629.692zm2.316 2.706c.163-.17.28-.407.28-.83v-.114c0-.292-.06-.508-.15-.68a.96.96 0 0 0-.353-.389.85.85 0 0 0-.464-.127c-.4 0-.56.114-.664.239l-.01.012c-.148.174-.275.45-.275.945 0 .506.122.801.27.99.097.11.266.224.68.224.303 0 .504-.09.687-.269zm7.545 1.705a2.6 2.6 0 0 0 .331.423q.319.33.755.548l.173.074q.65.255 1.49.255 1.02 0 1.844-.493a3.45 3.45 0 0 0 1.316-1.4q.493-.904.493-2.089 0-1.909-.988-2.913-.988-1.02-2.584-1.02-.898 0-1.575.347a3 3 0 0 0-.415.262l-.199.166a3.4 3.4 0 0 0-.64.82V9.242h-1.712v11.553h1.729l-.017-5.134zm.53-1.138q.206.29.48.5l.155.11.053.034q.51.296 1.119.297 1.07 0 1.645-.675.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.435 0-.835.16a2 2 0 0 0-.284.136 2 2 0 0 0-.363.254 2.2 2.2 0 0 0-.46.569l-.082.162a2.6 2.6 0 0 0-.213 1.072v.115q0 .707.296 1.267l.135.211zm.964-.818a1.1 1.1 0 0 0 .367.385.94.94 0 0 0 .476.118c.423 0 .59-.117.687-.23.159-.194.28-.478.28-.95 0-.53-.133-.8-.266-.952l-.021-.025c-.078-.094-.231-.221-.68-.221a1 1 0 0 0-.503.135l-.012.007a.86.86 0 0 0-.335.343c-.073.133-.132.324-.132.614v.115a1.4 1.4 0 0 0 .14.66zm15.7-6.222q.347-.346.346-.856a1.05 1.05 0 0 0-.345-.79 1.18 1.18 0 0 0-.84-.329q-.51 0-.855.33a1.05 1.05 0 0 0-.346.79q0 .51.346.855.345.346.856.346.51 0 .839-.346zm4.337 9.314.033-1.332q.191.403.59.747l.098.081a4 4 0 0 0 .316.224l.223.122a3.2 3.2 0 0 0 1.44.322 3.8 3.8 0 0 0 1.875-.477 3.5 3.5 0 0 0 1.382-1.366q.527-.89.526-2.09 0-1.184-.444-2.073a3.24 3.24 0 0 0-1.283-1.399q-.823-.51-1.942-.51a3.5 3.5 0 0 0-1.527.344l-.086.043-.165.09a3 3 0 0 0-.33.214q-.432.315-.656.707a2 2 0 0 0-.099.198l.082-1.283V4.701h-1.744v12.095zm.473-2.509a2.5 2.5 0 0 0 .566.7q.117.098.245.18l.144.08a2.1 2.1 0 0 0 .975.232q1.07 0 1.645-.675.576-.69.576-1.778 0-1.102-.576-1.777-.56-.691-1.645-.692a2.2 2.2 0 0 0-1.015.235q-.22.113-.415.282l-.15.142a2.1 2.1 0 0 0-.42.594q-.223.479-.223 1.1v.115q0 .705.293 1.26zm2.616-.293c.157-.191.28-.479.28-.967 0-.51-.13-.79-.276-.961l-.021-.026c-.082-.1-.232-.225-.67-.225a.87.87 0 0 0-.681.279l-.012.011c-.154.155-.274.38-.274.807v.115c0 .285.057.499.144.669a1.1 1.1 0 0 0 .367.405c.137.082.28.123.455.123.423 0 .59-.118.686-.23zm8.266-3.013q.345-.13.724-.14l.069-.002q.493 0 .642.099l.247-1.794q-.196-.099-.717-.099a2.3 2.3 0 0 0-.545.063 2 2 0 0 0-.411.148 2.2 2.2 0 0 0-.4.249 2.5 2.5 0 0 0-.485.499 2.7 2.7 0 0 0-.32.581l-.05.137v-1.48h-1.778v7.553h1.777v-3.884q0-.546.159-.943a1.5 1.5 0 0 1 .466-.636 2.5 2.5 0 0 1 .399-.253 2 2 0 0 1 .224-.099zm9.784 2.656.05-.922q0-1.743-.856-2.698-.838-.97-2.584-.97-1.119-.001-2.007.493a3.46 3.46 0 0 0-1.4 1.382q-.493.906-.493 2.106 0 1.07.428 1.975.428.89 1.332 1.432.906.526 2.255.526.973 0 1.668-.185l.044-.012.135-.04q.613-.184.984-.421l-.542-1.267q-.3.162-.642.274l-.297.087q-.51.131-1.3.131-.954 0-1.497-.444a1.6 1.6 0 0 1-.192-.193q-.366-.44-.512-1.234l-.004-.021zm-5.427-1.256-.003.022h3.752v-.138q-.011-.727-.288-1.118a1 1 0 0 0-.156-.176q-.46-.428-1.316-.428-.986 0-1.494.604-.379.45-.494 1.234zm-27.053 2.77V4.7h-1.86v12.095h5.333V15.15zm7.103-5.908v7.553h-1.843V9.242h1.843z'/%3E%3Cpath fill='%23fff' d='m19.63 11.151-.757-1.71-.345 1.71-1.12 5.644h-1.827L18.083 4.7h.197l3.325 6.533.988 2.19.988-2.19L26.839 4.7h.181l2.6 12.095h-1.81l-1.218-5.644-.362-1.71-.658 1.71-2.93 5.644h-.098l-2.913-5.644zm14.836 5.81q-1.02 0-1.893-.478a3.8 3.8 0 0 1-1.381-1.382q-.51-.906-.51-2.106 0-1.185.444-2.074a3.36 3.36 0 0 1 1.3-1.382q.839-.494 1.974-.494a3.3 3.3 0 0 1 1.234.231 3.3 3.3 0 0 1 .97.575q.396.33.527.659l.033-1.267h1.694v7.553H37.18l-.033-1.332q-.279.593-1.02 1.053a3.17 3.17 0 0 1-1.662.444zm.296-1.482q.938 0 1.58-.642.642-.66.642-1.711v-.115q0-.708-.296-1.267a2.2 2.2 0 0 0-.807-.872 2.1 2.1 0 0 0-1.119-.313q-1.053 0-1.629.692-.575.675-.575 1.76 0 1.103.559 1.795.577.675 1.645.675zm6.521-6.237h1.711v1.4q.906-1.597 2.83-1.597 1.596 0 2.584 1.02.988 1.005.988 2.914 0 1.185-.493 2.09a3.46 3.46 0 0 1-1.316 1.399 3.5 3.5 0 0 1-1.844.493q-.954 0-1.662-.329a2.67 2.67 0 0 1-1.086-.97l.017 5.134h-1.728zm4.048 6.22q1.07 0 1.645-.674.577-.69.576-1.762 0-1.119-.576-1.777-.558-.675-1.645-.675-.592 0-1.12.296-.51.28-.822.823-.296.527-.296 1.234v.115q0 .708.296 1.267.313.543.823.855.51.296 1.119.297z'/%3E%3Cpath fill='%23e1e3e9' d='M51.325 4.7h1.86v10.45h3.473v1.646h-5.333zm7.12 4.542h1.843v7.553h-1.843zm.905-1.415a1.16 1.16 0 0 1-.856-.346 1.17 1.17 0 0 1-.346-.856 1.05 1.05 0 0 1 .346-.79q.346-.329.856-.329.494 0 .839.33a1.05 1.05 0 0 1 .345.79 1.16 1.16 0 0 1-.345.855q-.33.346-.84.346zm7.875 9.133a3.17 3.17 0 0 1-1.662-.444q-.723-.46-1.004-1.053l-.033 1.332h-1.71V4.701h1.743v4.657l-.082 1.283q.279-.658 1.086-1.119a3.5 3.5 0 0 1 1.778-.477q1.119 0 1.942.51a3.24 3.24 0 0 1 1.283 1.4q.445.888.444 2.072 0 1.201-.526 2.09a3.5 3.5 0 0 1-1.382 1.366 3.8 3.8 0 0 1-1.876.477zm-.296-1.481q1.069 0 1.645-.675.577-.69.577-1.778 0-1.102-.577-1.776-.56-.691-1.645-.692a2.12 2.12 0 0 0-1.58.659q-.642.641-.642 1.694v.115q0 .71.296 1.267a2.4 2.4 0 0 0 .807.872 2.1 2.1 0 0 0 1.119.313zm5.927-6.237h1.777v1.481q.263-.757.856-1.217a2.14 2.14 0 0 1 1.349-.46q.527 0 .724.098l-.247 1.794q-.149-.099-.642-.099-.774 0-1.416.494-.626.493-.626 1.58v3.883h-1.777V9.242zm9.534 7.718q-1.35 0-2.255-.526-.904-.543-1.332-1.432a4.6 4.6 0 0 1-.428-1.975q0-1.2.493-2.106a3.46 3.46 0 0 1 1.4-1.382q.889-.495 2.007-.494 1.744 0 2.584.97.855.956.856 2.7 0 .444-.05.92h-5.43q.18 1.005.708 1.45.542.443 1.497.443.79 0 1.3-.131a4 4 0 0 0 .938-.362l.542 1.267q-.411.263-1.119.46-.708.198-1.711.197zm1.596-4.558q.016-1.02-.444-1.432-.46-.428-1.316-.428-1.728 0-1.991 1.86z'/%3E%3Cpath d='M5.074 15.948a.484.657 0 0 0-.486.659v1.84a.484.657 0 0 0 .486.659h4.101a.484.657 0 0 0 .486-.659v-1.84a.484.657 0 0 0-.486-.659zm3.56 1.16H5.617v.838h3.017z' style='fill:%23fff;fill-rule:evenodd;stroke-width:1.03600001'/%3E%3Cg style='stroke-width:1.12603545'%3E%3Cpath d='M-9.408-1.416c-3.833-.025-7.056 2.912-7.08 6.615-.02 3.08 1.653 4.832 3.107 6.268.903.892 1.721 1.74 2.32 2.902l-.525-.004c-.543-.003-.992.304-1.24.639a1.87 1.87 0 0 0-.362 1.121l-.011 1.877c-.003.402.104.787.347 1.125.244.338.688.653 1.23.656l4.142.028c.542.003.99-.306 1.238-.641a1.87 1.87 0 0 0 .363-1.121l.012-1.875a1.87 1.87 0 0 0-.348-1.127c-.243-.338-.688-.653-1.23-.656l-.518-.004c.597-1.145 1.425-1.983 2.348-2.87 1.473-1.414 3.18-3.149 3.2-6.226-.016-3.59-2.923-6.684-6.993-6.707m-.006 1.1v.002c3.274.02 5.92 2.532 5.9 5.6-.017 2.706-1.39 4.026-2.863 5.44-1.034.994-2.118 2.033-2.814 3.633-.018.041-.052.055-.075.065q-.013.004-.02.01a.34.34 0 0 1-.226.084.34.34 0 0 1-.224-.086l-.092-.077c-.699-1.615-1.768-2.669-2.781-3.67-1.454-1.435-2.797-2.762-2.78-5.478.02-3.067 2.7-5.545 5.975-5.523m-.02 2.826c-1.62-.01-2.944 1.315-2.955 2.96-.01 1.646 1.295 2.988 2.916 2.999h.002c1.621.01 2.943-1.316 2.953-2.961.011-1.646-1.294-2.988-2.916-2.998m-.005 1.1c1.017.006 1.829.83 1.822 1.89s-.83 1.874-1.848 1.867c-1.018-.006-1.829-.83-1.822-1.89s.83-1.874 1.848-1.868m-2.155 11.857 4.14.025c.271.002.49.305.487.676l-.013 1.875c-.003.37-.224.67-.495.668l-4.14-.025c-.27-.002-.487-.306-.485-.676l.012-1.875c.003-.37.224-.67.494-.668' style='color:%23000;font-style:normal;font-variant:normal;font-weight:400;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:evenodd;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:%23000;solid-opacity:1;vector-effect:none;fill:%23000;fill-opacity:.4;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-9.415-.316C-12.69-.338-15.37 2.14-15.39 5.207c-.017 2.716 1.326 4.041 2.78 5.477 1.013 1 2.081 2.055 2.78 3.67l.092.076a.34.34 0 0 0 .225.086.34.34 0 0 0 .227-.083l.019-.01c.022-.009.057-.024.074-.064.697-1.6 1.78-2.64 2.814-3.634 1.473-1.414 2.847-2.733 2.864-5.44.02-3.067-2.627-5.58-5.901-5.601m-.057 8.784c1.621.011 2.944-1.315 2.955-2.96.01-1.646-1.295-2.988-2.916-2.999-1.622-.01-2.945 1.315-2.955 2.96s1.295 2.989 2.916 3' style='clip-rule:evenodd;fill:%23e1e3e9;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3Cpath d='M-11.594 15.465c-.27-.002-.492.297-.494.668l-.012 1.876c-.003.371.214.673.485.675l4.14.027c.271.002.492-.298.495-.668l.012-1.877c.003-.37-.215-.672-.485-.674z' style='clip-rule:evenodd;fill:%23fff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:2.47727823;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:.4' transform='translate(15.553 2.85)scale(.88807)'/%3E%3C/g%3E%3C/svg%3E")}}.maplibregl-ctrl.maplibregl-ctrl-attrib{background-color:hsla(0,0%,100%,.5);margin:0;padding:0 5px}@media screen{.maplibregl-ctrl-attrib.maplibregl-compact{background-color:#fff;border-radius:12px;box-sizing:content-box;color:#000;margin:10px;min-height:20px;padding:2px 24px 2px 0;position:relative}.maplibregl-ctrl-attrib.maplibregl-compact-show{padding:2px 28px 2px 8px;visibility:visible}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show{border-radius:12px;padding:2px 8px 2px 28px}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner{display:none}.maplibregl-ctrl-attrib-button{background-color:hsla(0,0%,100%,.5);background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button{-webkit-appearance:none;-moz-appearance:none;appearance:none;list-style:none}.maplibregl-ctrl-attrib summary.maplibregl-ctrl-attrib-button::-webkit-details-marker{display:none}.maplibregl-ctrl-bottom-left .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-top-left .maplibregl-ctrl-attrib-button{left:0}.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button,.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner{display:block}.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-button{background-color:rgba(0,0,0,.05)}.maplibregl-ctrl-bottom-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;right:0}.maplibregl-ctrl-top-right>.maplibregl-ctrl-attrib.maplibregl-compact:after{right:0;top:0}.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{left:0;top:0}.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact:after{bottom:0;left:0}}@media screen and (forced-colors:active){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='%23fff' fill-rule='evenodd' viewBox='0 0 20 20'%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 (forced-colors:active) and (prefers-color-scheme:light){.maplibregl-ctrl-attrib.maplibregl-compact:after{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill-rule='evenodd' viewBox='0 0 20 20'%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")}}.maplibregl-ctrl-attrib a{color:rgba(0,0,0,.75);text-decoration:none}.maplibregl-ctrl-attrib a:hover{color:inherit;text-decoration:underline}.maplibregl-attrib-empty{display:none}.maplibregl-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}.maplibregl-popup{display:flex;left:0;pointer-events:none;position:absolute;top:0;will-change:transform}.maplibregl-popup-anchor-top,.maplibregl-popup-anchor-top-left,.maplibregl-popup-anchor-top-right{flex-direction:column}.maplibregl-popup-anchor-bottom,.maplibregl-popup-anchor-bottom-left,.maplibregl-popup-anchor-bottom-right{flex-direction:column-reverse}.maplibregl-popup-anchor-left{flex-direction:row}.maplibregl-popup-anchor-right{flex-direction:row-reverse}.maplibregl-popup-tip{border:10px solid transparent;height:0;width:0;z-index:1}.maplibregl-popup-anchor-top .maplibregl-popup-tip{align-self:center;border-bottom-color:#fff;border-top:none}.maplibregl-popup-anchor-top-left .maplibregl-popup-tip{align-self:flex-start;border-bottom-color:#fff;border-left:none;border-top:none}.maplibregl-popup-anchor-top-right .maplibregl-popup-tip{align-self:flex-end;border-bottom-color:#fff;border-right:none;border-top:none}.maplibregl-popup-anchor-bottom .maplibregl-popup-tip{align-self:center;border-bottom:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip{align-self:flex-start;border-bottom:none;border-left:none;border-top-color:#fff}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip{align-self:flex-end;border-bottom:none;border-right:none;border-top-color:#fff}.maplibregl-popup-anchor-left .maplibregl-popup-tip{align-self:center;border-left:none;border-right-color:#fff}.maplibregl-popup-anchor-right .maplibregl-popup-tip{align-self:center;border-left-color:#fff;border-right:none}.maplibregl-popup-close-button{background-color:transparent;border:0;border-radius:0 3px 0 0;cursor:pointer;position:absolute;right:0;top:0}.maplibregl-popup-close-button:hover{background-color:rgba(0,0,0,.05)}.maplibregl-popup-content{background:#fff;border-radius:3px;box-shadow:0 1px 2px rgba(0,0,0,.1);padding:15px 10px;pointer-events:auto;position:relative}.maplibregl-popup-anchor-top-left .maplibregl-popup-content{border-top-left-radius:0}.maplibregl-popup-anchor-top-right .maplibregl-popup-content{border-top-right-radius:0}.maplibregl-popup-anchor-bottom-left .maplibregl-popup-content{border-bottom-left-radius:0}.maplibregl-popup-anchor-bottom-right .maplibregl-popup-content{border-bottom-right-radius:0}.maplibregl-popup-track-pointer{display:none}.maplibregl-popup-track-pointer *{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.maplibregl-map:hover .maplibregl-popup-track-pointer{display:flex}.maplibregl-map:active .maplibregl-popup-track-pointer{display:none}.maplibregl-marker{left:0;position:absolute;top:0;transition:opacity .2s;will-change:transform}.maplibregl-user-location-dot,.maplibregl-user-location-dot:before{background-color:#1da1f2;border-radius:50%;height:15px;width:15px}.maplibregl-user-location-dot:before{animation:maplibregl-user-location-dot-pulse 2s infinite;content:"";position:absolute}.maplibregl-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}@keyframes maplibregl-user-location-dot-pulse{0%{opacity:1;transform:scale(1)}70%{opacity:0;transform:scale(3)}to{opacity:0;transform:scale(1)}}.maplibregl-user-location-dot-stale{background-color:#aaa}.maplibregl-user-location-dot-stale:after{display:none}.maplibregl-user-location-accuracy-circle{background-color:#1da1f233;border-radius:100%;height:1px;width:1px}.maplibregl-crosshair,.maplibregl-crosshair .maplibregl-interactive,.maplibregl-crosshair .maplibregl-interactive:active{cursor:crosshair}.maplibregl-boxzoom{background:#fff;border:2px dotted #202020;height:0;left:0;opacity:.5;position:absolute;top:0;width:0}.maplibregl-cooperative-gesture-screen{align-items:center;background:rgba(0,0,0,.4);color:#fff;display:flex;font-size:1.4em;inset:0;justify-content:center;line-height:1.2;opacity:0;padding:1rem;pointer-events:none;position:absolute;transition:opacity 1s ease 1s;z-index:99999}.maplibregl-cooperative-gesture-screen.maplibregl-show{opacity:1;transition:opacity .05s}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:none}@media (hover:none),(pointer:coarse){.maplibregl-cooperative-gesture-screen .maplibregl-desktop-message{display:none}.maplibregl-cooperative-gesture-screen .maplibregl-mobile-message{display:block}}.maplibregl-pseudo-fullscreen{height:100%!important;left:0!important;position:fixed!important;top:0!important;width:100%!important;z-index:99999} .mapboxgl-ctrl-group:not(:empty), .maplibregl-ctrl-group:not(:empty) { box-shadow: 0 0 6px 2px rgb(0 0 0 / 8%); diff --git a/dist/bundle.js b/dist/bundle.js index bb06d73..5c675c9 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -6,7 +6,7 @@ function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArr * @author Alex Milevski * @license MIT * @preserve - */function fd(e,t,i,n){const r=[],o=0===n?(e,t,i,n,r,o)=>{e.push(new Te(o,i+(o-t)/(n-t)*(r-i)))}:(e,t,i,n,r,o)=>{e.push(new Te(t+(o-i)/(r-i)*(n-t),o))};for(const s of e){const e=[];for(const r of s){if(r.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,u,t):h>i?d=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=r[r.length-1];const l=0===n?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&&r.push(e)}return r}function md(e,t){const i=_d(e),n=_d([t]),r=pd.intersection(i,n);return null==r?[]:Ad(r)}function gd(e,t){const i=65536;let n=_d(e,i);const r=[];for(;t.valid();t.next()){const[e,n]=t.get(),o=e.x*i,s=e.y*i,a=n.x*i,l=n.y*i,c=a-o,u=l-s,h=Math.hypot(c,u);if(0===h)continue;const d=Math.trunc(u/h*3),p=-Math.trunc(c/h*3);r.push([[[o,s],[a,l],[a+d,l+p],[o+d,s+p],[o,s]]])}return r.length>0&&(n=pd.diff(n,r)),Ad(n,1/i)}function _d(e,t=1){return[e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Ad(e,t=1){return e.map(e=>e.map((e,i)=>{const n=e.map(e=>new Te(e[0]*t,e[1]*t).round());return i>0&&n.reverse(),n}))}class yd{constructor(e,t){this.layoutVertexArray=new pa,this.indexArray=new Fa,this.lineIndexArray=new Ia,this.triangleSegments=new hl,this.lineSegments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new ga)}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Sh.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,i,n,r,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,n,r,o,void 0,s)}}class vd{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,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.lut=e.lut,this.bufferData=new yd(e,!1),this.elevationBufferData=new yd(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("fill",this.layers,this.pixelRatio,t);const r=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,u=Ic(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(s,i,n),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=sd("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n,r,o,s){this.bufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevationBufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,n,r,o,s,this.worldview)}addFeatures(e,t,i,n,r,o){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,o,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,i,n,r,o=[],s,a){const l=id(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,t,i,n,r){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,n,r,this.worldview))}addElevatedRoadFeature(e,t,i,n,r){const o=new Array,s=tu.getElevationFeature(e,r);if(!s)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:n};for(const t of o)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ud(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let n=0;e.properties.hasOwnProperty(zc)&&(n=+e.properties[zc]);for(const e of t.polygons)this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,e,i,t.elevationFeature,n)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const r=new iu(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,r,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a)}}addElevatedGeometry(e,t,i,n,r,o){const s={elevation:i,elevationSampler:t,bias:n,index:r,featureInfo:o},[a,l]=this.addGeometry(e,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=null;i&&(o=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=o&&(n=o,r=o));const s=(e,s,a)=>{if(null!=i)if(s.push(e),null!=o)t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),n=Math.min(n,o),r=Math.max(r,o)}};for(const n of e){let e=0;for(const t of n)e+=t.length;const r=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),o=r.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(a.length/2);const r=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=r.vertexLength;i&&h.push(t.layoutVertexArray.length-d),s(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),a.push(e[0].x),a.push(e[0].y);for(let i=1;i0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,n=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,n,e);const r=h.length;if(r>0){for(let o=0;o=i&&c.max.x<=r&&c.min.y>=n&&c.max.y<=o?a:l).push(t)}if(a.length===e.length)return e;const c=[new Te(i,n),new Te(r,n),new Te(r,o),new Te(i,o),new Te(i,n)],u=a;for(const e of l)u.push(...md(e,c));return u}}let xd,bd,wd,Td;es(vd,"FillBucket",{omit:["layers","patternFeatures"]}),es(yd,"FillBufferData"),es(ud,"ElevatedStructures");class Ed{constructor(e,t,i,n){if(this.triangleCount=t.length/3,this.min=new Te(0,0),this.max=new Te(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[r,o]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let c=0;for(;cthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Cd(e.x-this.min.x,this.xScale,this.cellsX),n=Cd(e.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Cd(e.x-this.min.x,this.xScale,this.cellsX),r=Cd(t.x-this.min.x,this.xScale,this.cellsX),o=Cd(e.y-this.min.y,this.yScale,this.cellsY),s=Cd(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=n;t<=r;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;ee.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){}populate(e,t,i,n){const r=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Bc(o,i,n),patterns:{}};r.push(u)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,n,r,o,s){}destroy(){}addFeature(e,t,i,n,r,o=[],s){for(const e of id(t,2)){const t=[],i=[],n=[],r=new Te(1/0,1/0),o=new Te(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&n.push(i.length/2);for(let e=0;et===e)}(n,e.clipScope)}function Ud(e,t){return e.x-t.x||e.y-t.y}function Nd(e,t){return 0===Ud(e.min,t.min)&&0===Ud(e.max,t.max)}function Vd(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Te((e.x+o.x*Nn)*a-s.x*Nn,(e.y+o.y*Nn)*a-s.y*Nn))}return Qd(i,r,e.indices,0,e.indices.length,0,0)}function Zd(e,t,i,n){const r=Math.pow(2,n.z-i.z);return new Te((e+i.x*Nn)*r-n.x*Nn,(t+i.y*Nn)*r-n.y*Nn)}function Wd(e,t){const i=[];t.grid.queryPoint(e,i);const n=t.indices,r=t.vertices;for(let t=0;t0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const Xd=Mc.types,Jd=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Yd=["fill-extrusion-flood-light-ground-radius"],ep=Math.pow(2,13),tp=Math.pow(2,15)-1,ip=new Te(0,1),np=2147483648,rp=7,op=450;function sp(e,t,i,n,r,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(n*ep)<<1)+r,Math.round(a))}function ap(e,t,i){e.emplaceBack(t.x*Nn,t.y*Nn,i?1:0)}function lp(e,t,i,n,r,o){e.emplaceBack(t.x,t.y,(i.x<<1)+n,(i.y<<1)+r,o)}function cp(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class up{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class hp{constructor(){this.centroidXY=new Te(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 Te(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Te(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new Te(this.max.x-this.min.x,this.max.y-this.min.y)}}class dp{constructor(){this.acc=new Te(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 n=!!this.borders;t.xe.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Nn)&&t.x===i.x)!=((0===t.y||t.y===Nn)&&t.y===i.y)&&this.processBorderOverlap(t,i),n&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,di(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Nn!=e.x>Nn&&this.addBorderIntersection(1,di(t.y,e.y,(Nn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,di(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Nn!=e.y>Nn&&this.addBorderIntersection(3,di(t.x,e.x,(Nn-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];ti[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 Te(0,0):new Te(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 pp(e,t){const i=e.add(t)._unit(),n=Fe(e.x*i.x+e.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*tp*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const fp=[e=>e.x<0,e=>e.x>Nn,e=>e.y<0,e=>e.y>Nn];function mp(e,t,i,n){const r=[4];if(0===n)return r;i._mult(n);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(fp[e](t)){r.push(e);break}return r}class gp{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ya,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yd.includes(e)),this._segments=new hl,this.hiddenByLandmarkVertexArray=new Wa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new hl}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,n=!1){const r=e.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,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=pp(t.sub(e[r-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let i=0;ie+t,0);let o=0;for(let e=0;e<=4;e++){const t=r[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new hl);const r={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+o,vertexLength:n.vertexLength,primitiveLength:t};i.get().push(r)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ld.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.groundRadiusBuffer&&this.groundRadiusBuffer.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 _p{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,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 Fa,this.footprintVertices=new pa,this.footprintSegments=[],this.layoutVertexArray=new ma,this.centroidVertexArray=new ol,this.wallVertexArray=new al,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Jd.includes(e)),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new gp(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.features=[],this.hasPattern=od("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=yc(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ic(r,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Bc(r,i,n),properties:r.properties,type:r.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===Xd[c.type];if(this.hasPattern)this.features.push({featureId:r.id,feature:sd("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const o of Kd(e,h))this.addFeature(r.id,c,[o],s,i,{},t.availableImages,n,t.brightness);else this.addFeature(r.id,c,c.geometry,s,i,{},t.availableImages,n,t.brightness);t.featureIndex.insert(r,c.geometry,s,a,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,n,r,o){for(const{featureId:e,feature:s}of this.features){const a="Polygon"===Xd[s.type],{geometry:l}=s;if(this.wallMode)for(const c of l)for(const l of Kd(c,a))this.addFeature(e,s,[l],s.index,t,i,n,r,o);else this.addFeature(e,s,l,s.index,t,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,this.worldview),this.groundEffect.update(e,t,r,i,n,o,s,this.worldview)}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,kd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Rd.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Fd.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,Pd.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,n,r,o,s,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Te(0,0),new Te(Nn,Nn)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Xd[t.type],f=new dp;f.centroidDataIndex=this.centroidData.length;const m=new hp;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=t.properties.building_id);const g=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},r);let A;if(m.height=_,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ta),this.wallMode){if(d)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;A=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let n=0;n=0}(e);i||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return n;let l,c,u,h,d,p=0;for(;p0;let _="miter";const A=2;"miter"===_&&m>A&&(_="bevel"),"bevel"===_&&(m>100&&(_="flipbevel"),m{const a=new Te(e.x,e.y),l=new Te(e.x,e.y);a.x+=t.x*n,a.y+=t.y*n,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),r.push(a),o.push(l)};if("miter"===_)n._mult(m),y(l,n,0,0);else if("flipbevel"===_)n=d.mult(-1),y(l,n,0,0),y(l,n.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=g?e:0,i=g?0:e;c&&y(l,h,t,i),u&&y(l,d,t,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:id(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||(x=t[0]).every(e=>e.x<=0)||x.every(e=>e.x>=Nn)||x.every(e=>e.y<=0)||x.every(e=>e.y>=Nn))&&v.splice(e,1)}var x;let b;if(d)b=Cp(v,u,r);else{b=[];for(const e of v)b.push({polygon:e,bounds:u})}const w=p?this.edgeRadius:0,T=w>0&&this.zoom<17,E=(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 b){let i=0,n=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new up;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const n=[],s=[];i=o.vertexLength;for(let i=0;i4&&wp(s[s.length-2],s[0],s[1]),l=w?yp(s[s.length-2],s[0],s[1],w):0;const u=[];let _,v,x;v=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,n=0;e0?1:0,I=c.dist(p);if(n+I>32768&&(n=0),w){x=T.sub(p)._perp()._unit();let e=vp(c,p,T,Ap(v,x),w);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=x,g&&this.zoom>=17&&(E(u,c)||u.push(c),E(u,p)||u.push(p))}const M=o.vertexLength,P=s.length>4&&wp(c,p,T);let R=Tp(n,a,b);if(sp(this.layoutVertexArray,c.x,c.y,S,B,0,0,R),sp(this.layoutVertexArray,c.x,c.y,S,B,0,1,R),this.wallMode){const t=y(e-1,s),i=A.joinNormals[e-1];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(n+=I,R=Tp(n,P,!b),a=P,sp(this.layoutVertexArray,p.x,p.y,S,B,0,0,R),sp(this.layoutVertexArray,p.x,p.y,S,B,0,1,R),this.wallMode){const t=y(e,s),i=A.joinNormals[e];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(M+0,M+1,M+2),this.indexArray.emplaceBack(M+1,M+3,M+2),o.primitiveLength+=2,w){const n=i+(1===e?s.length-2:e-2),r=1===e?i:n+1;if(this.indexArray.emplaceBack(M+1,n,M+3),this.indexArray.emplaceBack(n,r,M+3),o.primitiveLength+=2,void 0===_&&(_=M),!xp(T,s[e],t)){const t=e===s.length-1?_:o.vertexLength;this.indexArray.emplaceBack(M+2,M+3,t),this.indexArray.emplaceBack(M+3,t+1,t),this.indexArray.emplaceBack(M+3,r,t+1),o.primitiveLength+=3}b=!b}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,r),i=h.projectTilePoint(p.x,p.y,r),n=h.upVector(r,c.x,c.y),o=h.upVector(r,p.x,p.y);cp(e,t,n),cp(e,t,n),cp(e,i,o),cp(e,i,o)}}p&&(i+=s.length-1),g&&w&&this.zoom>=17&&(0!==u.length&&E(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?ip:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;tNn),r=2*n+(+(i.min.x+i.max.x>Nn)^n);for(let n=0;ne.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let i=0,n=0,r=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;r++}const o=e.length;for(;n!==e.length;){i=e[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let t=a;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t[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/Nn,d[1]=e.min.y/Nn,p[0]=e.max.x/Nn,p[1]=e.max.y/Nn;const t=h(c,u,d),s=h(c,u,p);if(0===new Jc([t[0],t[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(e,t){const i=e.centroid(),n=t.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Te(Fe(i.x,1,Nn-1)<<3|r,Fe(i.y,1,Nn-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Te(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Te(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Te((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=2147483647,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,n=e.flags&np?ip:e.centroidXY,r=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||r!==n.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(n=!n)}s=i}}return n}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Nn)*Nn+(t+Nn);if(this.partLookup.hasOwnProperty(r)){const e=this.partLookup[r];return e?{height:e.height,hidden:!!(e.flags&np)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||this.footprintContainsPoint(e,t,o)&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&np));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function Ap(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function yp(e,t,i,n){const r=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return vp(e,t,i,Ap(r,o),n)}function vp(e,t,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(i)/3,r*o/n)}function xp(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function bp(e,t){return e.xt[1].x||e.yt[1].y}function wp(e,t,i){if(e.x<0||e.x>=Nn||t.x<0||t.x>=Nn||i.x<0||i.x>=Nn)return!1;const n=i.sub(t),r=n.perp(),o=e.sub(t);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y<0}function Tp(e,t,i){const n=t?2|e:-3&e;return i?1|n:-2&n}function Ep(){const e=Math.PI/32,t=Math.tan(e),i=ic;return i*Math.sqrt(1+2*t*t)-i}function Cp(e,t,i){const n=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),u=l-c,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Te(0===i?u:n.x,1===i?u:n.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,(e,t,r)=>{if(0===e)return.5*(t+r);{const e=pc((i.y+t/Nn)/n);return(uc(.5*(pc((i.y+r/Nn)/n)+e))*n-i.y)*Nn}})}function Sp(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a=s[i]&&(n=t,s=e),n[i]r&&Rp(n,s,i,r),n[i]o&&Rp(s,n,i,o)}}function Fp(e,t,i,n,r,o){const s=[];for(let a=0;a=n&&d.x>=n||(u.x>=n?u=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=n&&(d=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=r&&d.y>=r||(u.y>=r?u=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round():d.y>=r&&(d=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round()),c&&u.equals(c[c.length-1])||(c=[u],s.push(c),o&&o.push({progress:{min:f+Dp(m,g,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:g})),c.push(d),o&&(o[o.length-1].progress.max=f+Dp(m,g,d)*p,o[o.length-1].nextPoint=g)))))}if(o&&h>0)for(let e=u;ee.t-t.t);let s=0,a=0,l=[];for(n.push(l);s!==e.length;){if(a===o.length){for(;s!==e.length;)0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++)}}function Dp(e,t,i){return e.x!==t.x?(i.x-e.x)/(t.x-e.x):e.y!==t.y?(i.y-e.y)/(t.y-e.y):0}function Op(e,t){return e.x*t.x+e.y*t.y}function zp(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=Ep();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],A=[];for(const h of _){const d=h.x+r.x,_=h.y+r.y,y=e.projection.projectTilePoint(d,_,u),v=e.projection.upVector(u,h.x,h.y);let x=i,b=n;if(s){const e=Vp(d,_,i,n,s,a,l,c);x+=e.base,b+=e.top}0!==i?g(f,y.x+v[0]*p*x,y.y+v[1]*p*x,y.z+v[2]*p*x):g(f,y.x,y.y,y.z),g(m,y.x+v[0]*p*b,y.y+v[1]*p*b,y.z+v[2]*p*b),j(f,f,o),j(m,m,o),t.push(new Mp(f[0],f[1],f[2])),A.push(new Mp(m[0],m[1],m[2]))}h.push(t),d.push(A)}return[h,d]}(e,t,i,n,r,o,s,a,l,c,u):s?function(e,t,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+n.x,d=c.y+n.y,f=Vp(u,d,t,i,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(g)}c.push(e),u.push(p)}return[c,u]}(t,i,n,r,o,s,a,l,c):function(e,t,i,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+n.x,s=o.y+n.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=m+a,v=g+l,x=_+c,b=Math.max(A+u,1e-5),w=m+h,T=g+d,E=_+p,C=Math.max(A+f,1e-5);e.push(new Mp(y/b,v/b,x/b)),i.push(new Mp(w/C,T/C,E/C))}o.push(e),s.push(i)}return[o,s]}(t,i,n,r,o)}function Vp(e,t,i,n,r,o,s,a){const l=s*r.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/rp-op):s*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),o=10*(t[0]-8*n),s=10*(t[1]-8*r),a=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(n,r),d=2*c+1,p=2*u+1,f=function(e,t,i,n,r){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+r,i,!0),e.getElevationAtPixel(t,i+r,!0),e.getElevationAtPixel(t+n,i+r,!0)]}(e,h.x-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),A=Math.min(.25,.5*l*(m+g)/d),y=Math.min(.25,.5*l*_/p);return a+Math.max(A*o,y*s)}(r,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+n,l+i+2):l+n}}class jp{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 Gp{constructor(){this.tasks={},this.taskQueue=[],Ve(["process"],this),this.invoker=new jp(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=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===n){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||Xe(self)){const e=this.callbacks[i],n=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(rs(t.error)):i(null,rs(t.data)))}else{const i=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?ns(t):null,data:ns(n,i)},i)}:()=>{},r=rs(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:o}=r;this.parent.getWorkerSource(t.sourceMapId,e[0],i,o)[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Qp={workerUrl:"",workerClass:null,workerParams:void 0};const $p="mapboxgl_preloaded_worker_pool";class Zp{constructor(){this.active={}}acquire(e,t=Zp.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$p]}numActive(){return Object.keys(this.active).length}}Zp.workerCount=2;class Wp{constructor(e,t,i="Worker",n=Zp.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ue();const r=this.workerPool.acquire(this.id,n);for(let e=0;e{this.ready=!0})}broadcast(e,t,i){Oe(this.actors,(i,n)=>{i.send(e,t,n)},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)}}let qp,Kp;function Xp(){return qp||(qp=new Zp),qp}Wp.Actor=Hp;class Jp{constructor(e){this.module=e}createIntArray(e){const t=new Int32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heap32.set(t,i/t.BYTES_PER_ELEMENT),i}createFloatArray(e){const t=new Float32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heapF32.set(t,i/t.BYTES_PER_ELEMENT),i}createStringBuffer(e){const t=this.module.malloc(e.length+1);for(let i=0;ie.arrayBuffer()).then(e=>{t.buffers[i]=e})}function Tf(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ef(e,t,i,n){if(e.uri){const r=bf(e.uri,n);return fetch(r).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{t.images[i]=e})}if(void 0!==e.bufferView){const n=Tf(t,e.bufferView),r=new Blob([n],{type:e.mimeType});return createImageBitmap(r).then(e=>{t.images[i]=e})}}function Cf(e,t=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===vf){const i=new Uint32Array(e,t);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(xf.decode(i.subarray(r,r+s))),r+=s,r{const e=[],t=a&&a.includes(gf),r=a&&a.includes(Af);if(t&&e.push(function(){if(!tf)return null!=Yp?Yp:(Yp=function(e){let t,i=null;function n(){t=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(e,i,n){return t.copyWithin(e,i,i+n)},c:function(e){const r=t.length,o=Math.max(e>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(e){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:g,e:_,yb:A,zb:y,Ab:v,Bb:x,Db:b,Gb:w}=e.instance.exports;i=_;const T=(()=>{let e=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(e),i+=n,n=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(n=l,c=s=o(l));for(let e=0;e{tf=e,Yp=void 0}))}()),r&&e.push(function(){if(rf)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors()}),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,n,r,o,s){const a=e.exports.sbrk,l=n+3&-4,c=a(l*r),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,n,r,u,o.length);if(0===d&&s&&s(c,l,r),i.set(h.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[r[a]],e,i,o,s,t.exports[n[l]])}}}(fetch(uf()));return e.ready.then(()=>{rf=e})}()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)_f(t,n);if(r&&s&&l)for(const e of l)yf(e,n);return n})})}function Sf(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>Cf(t,0,e))}function Bf(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function If(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Mf{constructor(e,t,i,n){this.context=e,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=s+i,c=a+n;!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Bf(this.format),If(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Bf(this.format),If(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,t,i=!1){const{context:n}=this,{gl:r}=n;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&&!i?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR: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,n,r){const{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),t!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n),r!==this.compareMode&&(r?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,r)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Pf{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Rf=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),Lf=ha([{name:"a_color_3f",components:3,type:"Float32"}]),Ff=ha([{name:"a_color_4f",components:4,type:"Float32"}]),kf=ha([{name:"a_uv_2f",components:2,type:"Float32"}]),Df=ha([{name:"a_normal_3f",components:3,type:"Float32"}]),Of=ha([{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"}]),zf=ha([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Uf(e,t){const i=Vf(e.projection,e.zoom,e.width,e.height),n=function(e,t,i,n,r){const o=new rc(i.lng-180*jf,i.lat),s=new rc(i.lng+180*jf,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),u=-Math.atan2(l.y-a.y,l.x-a.x),d=vc.fromLngLat(i);d.y=Fe(d.y,-1+jf,1-jf);const f=d.toLngLat(),m=e.project(f.lng,f.lat),_=vc.fromLngLat(f);_.x+=jf;const A=_.toLngLat(),y=e.project(A.lng,A.lat),v=Hf(y.x-m.x,y.y-m.y,u),x=vc.fromLngLat(f);x.y+=jf;const b=x.toLngLat(),w=e.project(b.lng,b.lat),T=Hf(w.x-m.x,w.y-m.y,u),E=Math.abs(v.x)/Math.abs(T.y),C=c([]);g(C,C,-u*(1-(r?0:n)));const S=c([]);return p(S,S,[1,1-(1-E)*n,1]),S[4]=-T.x/T.y*n,g(S,S,u),h(S,C,S),S}(e.projection,0,e.center,i,t),r=Nf(e);return p(n,n,[r,r,1]),n}function Nf(e){const t=e.projection,i=Vf(e.projection,e.zoom,e.width,e.height),n=Gf(t,e.center),r=Gf(t,rc.convert(t.center));return Math.pow(2,n*i+(1-i)*r)}function Vf(e,t,i,n,r=1/0){const o=e.range;if(!o)return 0;const s=Math.min(r,Math.max(i,n)),a=Math.log2(s/1024);return ke(o[0]+a,o[1]+a,t)}const jf=1/4e4;function Gf(e,t){const i=Fe(t.lat,-mc,mc),n=new rc(t.lng-180*jf,i),r=new rc(t.lng+180*jf,i),o=e.project(n.lng,i),s=e.project(r.lng,i),a=vc.fromLngLat(n),l=vc.fromLngLat(r),c=s.x-o.x,u=s.y-o.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Hf(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}function Qf(e,t,i){c(e),g(e,e,Be(t[2])),f(e,e,Be(t[0])),m(e,e,Be(t[1])),p(e,e,i),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function $f(e,t,i,n,r,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[n[0]-t[0],n[1]-t[1],0];if(T(l)<1e-12||T(c)<1e-12)return te(e);const u=N([],l,c);z(u,u),B(c,n,t),l[2]=(o-r)*a,c[2]=(s-r)*a;const h=l;return N(h,l,c),z(h,h),le(e,u,h)}function Zf(e,t,i=!1){const n=th(t.zoom),r=function(e,t,i){const n=t.worldSize,r=[e[12],e[13],e[14]],o=pc(r[1]/n),s=dc(r[0]/n),a=c([]),l=hc(1,o)*n,u=hc(1,0)*n*_c(o,t.zoom),f=1/Ju(n);let m=u*f;if(i){const e=Vf(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,n,e)}const g=tc(o,s);S(g,g,R([],z([],g),l*m*r[2]));const _=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const n=N([],i,t);return N(i,t,n),0===D(i)&&(i=[0,1,0],N(n,t,i)),z(n,n),z(i,i),z(t,t),[n[0],n[1],n[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(g);p(a,a,[m,m,m*l]),d(a,a,[-r[0],-r[1],-r[2]]);const A=h([],t.globeMatrix,_);return h(A,A,a),h(A,A,e),A}(e,t,i);if(n>0){const i=function(e,t){const i=t.worldSize,n=hc(1,0)*i*_c(t.center.lat,t.zoom)/Ju(i),r=hc(1,t.center.lat)*i,o=c([]);m(o,o,Be(t.center.lng)),f(o,o,Be(t.center.lat)),d(o,o,[0,0,$l]),p(o,o,[n,n,n*r]);const s=t.point;return d(o,o,[-s.x,-s.y,0]),h(o,o,e),h(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const n=(e,t,i)=>{const n=T(e),r=T(t),o=ju(e,t,i);return R(o,o,1/T(o)*di(n,r,i))},r=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=ju([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function Wf(e,t,i,n){const r=Jc.projectAabbCorners(n,i);let o=Number.MAX_VALUE;for(let e=0;e0||0===s&&i[0]*o[0]+i[1]*o[1]>=0&&i[0]*i[0]+i[1]*i[1]>o[0]*o[0]+o[1]*o[1])&&(n=t)}r=n}while(r!==i);return t.length>0&&t.push(t[0]),t}(r);if(ru(e,s))return o}const qf=64,Kf={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xf(e,t,i,n,r,o,s,a,l,u=!1){const f=i.zoom,m=i.project(n),g=_c(n.lat,f),_=1/g;c(e),d(e,e,[m.x+s[0]*_,m.y+s[1]*_,s[2]]);let A=1,y=1;const x=i.worldSize;if(u){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new vc(m.x/x,m.y/x),0));const t=Y([],[m.x,m.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;A=t,y=t*_c(i.center.lat,f)}else if("globe"===i.projection.name){const t=Zf(e,i),r=[0,0,0,1];Y(r,r,h([],i.projMatrix,t));const o=r[3]/i.cameraToCenterDistance,s=th(f),a=i.projection.pixelsPerMeter(n.lat,x)*_c(n.lat,f),l=i.projection.pixelsPerMeter(i.center.lat,x)*_c(i.center.lat,f);A=o/di(a,gc(i.center.lat),s),y=o*g/a,A*=l,y*=l}}else A=_;p(e,e,[A,A,y]);const b=[...e],w=t.orientation,T=[];if(Qf(T,[w[0]+(r?r[0]:0),w[1]+(r?r[1]:0),w[2]+(r?r[2]:0)],o),h(e,b,T),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(e,t,i,n,r){const o=t.elevation;if(!o)return 0;const s=Jc.projectAabbCorners(i,n),a=hc(1,r.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],n=[{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 r of n){const n=e[r.corners[0]],o=e[r.corners[1]],s=e[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])],l=N(a,a,[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])]);z(l,l),r.dotProductWithUp=U(l,i)}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(s,a),c=s[l[0]],u=s[l[1]],h=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new vc(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new vc(u[0]/t.worldSize,u[1]/t.worldSize),0),m=o.getAtPointOrZero(new vc(h[0]/t.worldSize,h[1]/t.worldSize),0),g=o.getAtPointOrZero(new vc(d[0]/t.worldSize,d[1]/t.worldSize),0),_=(p+g)/2,A=(f+m)/2;return _>A?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function em(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Rf.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Df.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kf.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Lf:Ff).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,zf.members,!0)),e.segments=hl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&Yf(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&Yf(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&Yf(n.normalTexture,t),n.occlusionTexture&&Yf(n.occlusionTexture,t,i),n.emissionTexture&&Yf(n.emissionTexture,t)}function tm(e,t,i){if(e.meshes)for(const n of e.meshes)em(n,t,i);if(e.children)for(const n of e.children)tm(n,t,i)}function im(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)im(t)}function nm(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)nm(t)}function rm(e,t){const i=e.json.bufferViews[t.bufferView],n=df[t.componentType];return new n(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==ff[t.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:ff[t.type]))}function om(e,t,i,n){const r=df[t.componentType],o=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:ff[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e0){for(let r=0;r0){o.texcoordArray=new ja;const e=t.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=rm(t,e);om(t,e,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const e=t.json.accessors[r._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=rm(t,e))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(rm(t,t.json.accessors[r._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){const e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new li(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new li(...i),alphaMode:n,alphaCutoff:r,normalTexture:o?t[o.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function am(e,t,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:c,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,i,n){var r=t[0],o=t[1],s=t[2],a=t[3],l=r+r,c=o+o,u=s+s,h=r*l,d=r*c,p=r*u,f=o*c,m=o*u,g=s*u,_=a*l,A=a*c,y=a*u,v=n[0],x=n[1],b=n[2];return e[0]=(1-(f+g))*v,e[1]=(d+y)*v,e[2]=(p-A)*v,e[3]=0,e[4]=(d-y)*x,e[5]=(1-(h+g))*x,e[6]=(m+_)*x,e[7]=0,e[8]=(p+A)*b,e[9]=(m-_)*b,e[10]=(1-(h+f))*b,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==a){d.meshes=i[a];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:n}=t.aabb;e[0]+=i[0]+n[0],e[1]+=i[1]+n[1]}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2)}if(c&&(c.id&&(d.id=c.id),c.lights&&(d.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let e=0;e0&&n.reverse();const o=Mh(n.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:n,indices:o}}function um(e,t){const i=[],n=[];let r=0;const o=[];for(const s of e){r=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:i,indices:n}}function hm(e){const t=function(e,t){const i=[],n=WebGL2RenderingContext;if(e.json.textures)for(const r of e.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,e.json.samplers[r.sampler]),i.push({image:t[r.source],sampler:o,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const n of e.json.meshes){const r=[];for(const i of n.primitives)r.push(sm(i,e,t));i.push(r)}return i}(e,t),{scenes:n,scene:r,nodes:o}=e.json,s=n?n[r||0].nodes:[...o.keys()],a=[];for(const t of s)a.push(am(o[t],e,i));return function(e,t,i){const n={},r=new Set;for(let o=0;o0){const t=Array.from(r.values()).sort((e,t)=>e-t);for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(a,s,e.json.nodes),a}function dm(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,n=e.aabb.min[1]-1,r=qf/(e.aabb.max[0]-i+2),o=qf/(e.aabb.max[1]-n+2);for(let s=0;se.heightmap[c*qf+l]&&(e.heightmap[c*qf+l]=a)}}function pm(e,t,i,n,r){i.reserve(i.length+4*e.length),n.reserve(n.length+10*e.length),r.reserve(r.length+10*e.length);let o=n.length;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*t,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),c=s.width-2*s.depth*t*(l+.01),u=L([],s.pos,a,c/2),h=L([],s.pos,a,-c/2),d=[u[0],u[1],u[2]+s.height],p=[h[0],h[1],h[2]+s.height],f=L([],s.normal,a,l);R(f,f,e);const m=L([],s.normal,a,-l);R(m,m,e),S(f,u,f),S(m,h,m),u[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const g=c/e/2;r.emplaceBack(-g-l,-1,g,.8),r.emplaceBack(g+l,-1,g,.8),r.emplaceBack(-g,0,g,1.3),r.emplaceBack(g,0,g,1.3),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(0,0,g,1.3),r.emplaceBack(0,0,g,1.3),r.emplaceBack(g+l,-1.2,g,.8),r.emplaceBack(g+l,-1.2,g,.8),i.emplaceBack(6+o,4+o,8+o),i.emplaceBack(7+o,9+o,5+o),i.emplaceBack(0+o,1+o,2+o),i.emplaceBack(1+o,3+o,2+o),o+=10}}function fm(e,t){const i={};i.indexArray=new Fa,i.vertexArray=new xa,i.colorArray=new Sa,pm(e,t,i.indexArray,i.vertexArray,i.colorArray);const n={defined:!0};n.emissiveFactor=li.black;const r={};return r.baseColorFactor=li.white,n.pbrMetallicRoughness=r,i.material=n,i.aabb=new Jc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}const mm=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),gm=ha([{name:"a_normal_3",components:3,type:"Int16"}]),_m=ha([{name:"a_centroid_3",components:3,type:"Int16"}]),Am=ha([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ym=ha([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),vm=ha([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),xm=ha([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),bm=ha([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wm=ha([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Tm=Mc.types,Em=32767;function Cm(e,t){const i=Nn+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return!1;return!0}class Sm{constructor(){this.layoutVertexArray=new xa,this.layoutAttenuationArray=new Sa,this.layoutColorArray=new Ia,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl}}class Bm{constructor(){this.layoutVertexArray=new xa,this.layoutNormalArray=new fa,this.layoutCentroidArray=new fa,this.layoutColorArray=new Ia,this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.layoutFloodLightDataArray=new Ha,this.layoutAOArray=new ga,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl,this.entranceBloom=new Sm}}class Im{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.featuresOnBorder=[],this.buildingFeatures=[],this.buildingWithoutFacade=new Bm,this.buildingWithFacade=new Bm,this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.buildingWithFacade.layoutFacadePaintArray=new Ia,this.buildingWithFacade.layoutFacadeDataArray=new wa,this.buildingWithFacade.layoutFacadeVerticalRangeArray=new Ia,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new gp(e),this.groundEffect.groundRadiusArray=new ga,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){}prepare(){return function(){if(null!=lf||null!=af)return null;if(null!=sf)return sf;const e=fetch(st.BUILDING_GEN_URL);return sf=function(e){let t,i,n,r;function o(){t=new Uint8Array(r.buffer),i=new Int32Array(r.buffer),n=new Float32Array(r.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const a=()=>{},l={a:{a:s,f:function(e){const i=t.length,n=Math.max(e>>>0,Math.ceil(1.2*i)),s=Math.ceil((n-i)/65536);try{return r.grow(s),o(),!0}catch(e){return!1}},g:s,b:a,c:a,d:a,e:a}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,l):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,l))).then(e=>{const s=e.instance.exports;return(0,s.g)(),r=s.f,o(),new Jp({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getColorsPtr:s.y,getColorsLength:s.z,getAOPtr:s.A,getAOLength:s.B,getUVPtr:s.C,getUVLength:s.D,getFauxFacadePtr:s.E,getFauxFacadeLength:s.F,getIndicesPtr:s.G,getIndicesLength:s.H,getBuildingPart:s.I,getRingCount:s.J,getRingPtr:s.K,getRingLength:s.L,free:s.M,malloc:s.N,heapU8:t,heap32:i,heapF32:n})})}(e).then(e=>(sf=null,lf=e,lf)).catch(e=>{Ze("Could not load building-gen"),sf=null,af=e}),sf}()}populate(e,t,i,n){const r=hf();if(!r)return;const o=yc(i);this.tileToMeter=o,this.brightness=t.brightness,r.setStyle({convertToMeters:!1,entranceColorRgb:[1,1,1],facadeGlazingColorRgb:[.5607843137254902,.6745098039215687,.7215686274509804],normalScale:[1,-1,o],ridgeHeight:3,roofColorRgb:[.886274516,.784313738,.713725507],tileToMeters:o,tileZoom:16,wallColorRgb:[.988235294,.933333337,.811764717]}),r.setAOOptions(!1,.3),r.setMetricOptions(!1,16),r.setStructuralOptions(!0),r.setFacadeClassifierOptions(3);const s=new Map,a=new Map;for(const{feature:t}of e){if("LineString"!==Tm[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry,r=Ic(t,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),r,i))continue;const o=e?r.geometry:Bc(t,i,n),l=[];for(const e of o)for(const t of e)l.push({x:t.x,y:t.y});const c={coordinates:l,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},u=t.properties.source_id;let h=a.get(u);h||(h=[],a.set(u,h)),h.push(c)}this.maxHeight=0;for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of e){if("LineString"===Tm[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry,d=Ic(l,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),d,i))continue;const p=e?d.geometry:Bc(l,i,n),f=id(p,500);if(!Cm(p,163))continue;const m=this.layers[0],g=m.layout.get("building-roof-shape").evaluate(l,{},i);if("flat"===g)continue;const _=m.layout.get("building-base").evaluate(l,{},i),A=m.layout.get("building-height").evaluate(l,{},i),y=m.layout.get("building-flood-light-ground-radius").evaluate(l,{},i),v=m.paint.get("building-ambient-occlusion-intensity"),x=y/this.tileToMeter;let b=m.layout.get("building-flood-light-wall-radius").evaluate(l,{},i);b=Fe(b,0,2048);const w=b/2048*Em,T=s.get(c);let E;E=a.has(T)?a.get(T):[];const C=0!==E.length&&m.layout.get("building-facade").evaluate(l,{},i);r.setFacadeOptions(4,!0),r.setFauxFacadeOptions(C,!1,1);let S=0,B=0,I=0,M=0,P=0,R=0;if(C){let e=Math.round(m.layout.get("building-facade-floors").evaluate(l,{},i));if(0===_){e=Math.max(1,e-(E.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0],r.setFacadeOptions(t,!0)}P=1.6803*t/o}else P=_/o;R=A/o,P=Math.min(P,R),I=m.layout.get("building-facade-unit-width").evaluate(l,{},i)/o,M=(R-P)/e,r.setFauxFacadeOptions(!0,!0,I);const t=m.layout.get("building-facade-window").evaluate(l,{},i);S=t[0],B=t[1]}const L=[],F=new Te(1/0,1/0),k=new Te(-1/0,-1/0),D=new Te(0,0);let O=0;for(const e of f)if(e.length>0){const t=[];for(const i of e){const e=[];for(let t=i.length-1;t>=0;t--){const n=i[t];e.push({x:n.x,y:n.y}),F.x=Math.min(F.x,n.x),F.y=Math.min(F.y,n.y),k.x=Math.max(k.x,n.x),k.y=Math.max(k.y,n.y),D.x+=n.x,D.y+=n.y,O++}t.push(e)}L.push({id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:g,coordinates:t})}D.x/=O||1,D.y/=O||1;const z=r.generateMesh(L,E);if("string"==typeof z){Ze(`Unable to generate building ${l.id}: ${z}`);continue}if(0===z.meshes.length||0===z.modifiedPolygonRings.length)continue;let U=0;for(const e of z.meshes)U+=e.positions.length/3;const N=C?this.buildingWithFacade:this.buildingWithoutFacade,V=N.segmentsBucket.prepareSegment(U,N.layoutVertexArray,N.indexArray),j=[];let G=null,H=0,Q=-1;const $=N.layoutVertexArray.length,Z=N.indexArray.length;let W=0;for(const e of z.meshes){const t=N.layoutVertexArray.length;if("entrance"===e.buildingPart){const t=new Array;for(let i=0;iNn||F.y<0||k.y>Nn)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=Mh(K,null,2),t=new Ed(X,e,8,256);let i=l.id;l.properties&&l.properties.hasOwnProperty("building_id")&&(i=l.properties.building_id);const n={vertices:X,indices:e,grid:t,min:J,max:Y,buildingId:i,hiddenFlags:0,indicesOffset:Z,indicesLength:q,bloomIndicesOffset:H,bloomIndicesLength:Q,groundEffectVertexOffset:ee,groundEffectVertexLength:te,hasFauxFacade:C,segment:V,height:W};void 0!==l.id&&this.featureFootprintLookup.set(l.id,this.footprints.length),this.footprints.push(n)}this.programConfigurations.populatePaintArrays(N.layoutVertexArray.length,l,u,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(l,u,{},t.availableImages,i,t.brightness),t.featureIndex.insert(l,p,u,h,this.index,$)}this.groundEffect.prepareBorderSegments(),this.evaluate(this.layers[0],{})}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s),this.groundEffect.update(e,t,r,i,n,o,s),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,mm.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,gm.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,_m.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,wm.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,vm.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,xm.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,mm.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,bm.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,t,i=!0){let n=!1;const r=i?t:0,o=0|(i?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],i=e.hiddenFlags&o|r;e.hiddenFlags!==i&&(e.hiddenFlags=i,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16))};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,i=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0))};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,Am.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,ym.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Am.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const i=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.buildingFeatures){const r=t[n.promoteId],o=n.feature;o.properties["building-part"]="roof";const s=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),c=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="window";const u=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,r=s;"roof"===e.part?(r=s,t=a):"wall"===e.part?(r=l,t=c):"facade_glazing"===e.part?(r=u,t=h):"entrance"===e.part&&(r=d,t=p),t=Fe(t,0,1);for(let o=0;ot.max.x||n.max.xt.max.y||n.max.ys.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=i||Wd(o,s)&&(i=s.height,this.footprintLookup[r]=s,n=0!==s.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.footprintLookup[r]=void 0}}function Mm(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const i=e[0],n=e[e.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+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 n="round"===t,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new xa,this.patternVertexArray=new xa,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new hl,this.maxLineLength=0,this.zOffsetVertexArray=new xa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:Nn/64,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("line",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("line-sort-key");this.tileToMeter=yc(i);const o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&t?"none":"offset","offset"===this.elevationType&&"none"===o&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i):void 0,d={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(o,i,n),patterns:{},sortKey:h};a.push(d)}r&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const n of a){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(u&&this.addFeatureDashes(n,l),this.hasPattern){const e=sd("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures);c.insert(e[o].feature,r,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else{const t=r.value,i=n.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[n.id]=[t.getKey(s,a)]}}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}addFeatures(e,t,i,n,r,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n,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,Om)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Um)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Fm.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,km),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let i,n;if(t&&t>0?(i=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(i)&&e.properties.hasOwnProperty(n))return{start:+e.properties[i],end:+e.properties[n]}}addFeature(e,t,i,n,r,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),"road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,a,c,u,h,d)){const[r,o]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n,s,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Fp(e,-t,-t,Nn+t,Nn+t)}clipRuntimeLinesToTile(e,t){const i=[];return[Fp(e,-t,-t,Nn+t,Nn+t,i),i]}addElevatedRoadFeature(e,t,i,n,r,o,s,a){const l=[],c=tu.getElevationFeature(e,n);if(c){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,c,i);for(const e of n)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,r,o,s,a);const l=new iu(i,t.elevationTileID);if(t.elevation)for(let e=n;e>1,this.layoutVertexArray.int16[6*e+1]>>1),n=l.pointElevation(i,t.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0)}else this.fillNonElevatedRoadSegment(n)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const n=[],r=1/yc(i);for(const i of e)kp(i,new Yc(t,r),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:ot(e.min,t,i),max:ot(e.max,t,i)}}(a.progress,{min:0,max:1},i),e>0&&(n=(i.max-i.min)/e)}const r=+t.properties.mapbox_clip_feature_len,o=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(r)||Number.isNaN(o)){for(let t=0;t=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,M=this.overscaling<=16?15*Nn/(512*this.overscaling):0;if(i&&"round"===a)if(Co&&(a="bevel"),"bevel"===a&&(C>2&&(a="flipbevel"),C2*M){const t=g.sub(g.sub(_)._mult(M/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,y,0,0,m,w),_=t}this.updateDistance(_,g),T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);const t=g.dist(A);if(t>2*M){const e=g.add(A.sub(g)._mult(M/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,v,0,0,m,w),g=e}}else T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);else if("flipbevel"===a){if(C>100)T=v.mult(-1);else{const e=C*y.add(v).mag()/y.sub(v).mag();T._perp()._mult(e*(I?-1:1))}this.addCurrentVertex(g,T,0,0,m,w),this.addCurrentVertex(g,T.mult(-1),0,0,m,w)}else if("bevel"===a||"fakeround"===a){null!=w&&_&&this.addCurrentVertex(g,b||y,-1,-1,m,w);const e=g.dist(_)<=2*M&&"bevel"!==a,t=T.mult(I?1:-1);t._mult(C);const i=v.mult(I?-1:1),n=y.mult(I?-1:1),r=this.evaluateLineProgressFeatures(this.distance);if(null==w&&(this.addHalfVertex(g,t.x,t.y,!1,!I,0,m,r),e||this.addHalfVertex(g,t.x+2*n.x,t.y+2*n.y,!1,I,0,m,r)),"fakeround"===a){const e=Math.round(180*S/Math.PI/20);this.addHalfVertex(g,n.x,n.y,!1,I,0,m,r);for(let t=0;t1){this.lineSoFar=e.w;const d=(t.x-e.x)/u,p=(t.y-e.y)/u,f=(t.z-e.z)/u,m=(t.w-e.w)/u;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function Qm(e,t,i){return e.xi||e.yi}let $m,Zm;function Wm(e,t,i){return t*(Nn/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}es(Hm,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const qm=(e,t,i)=>(1-i)*e+i*t;function Km(e,t){return 1/Wm(e,1,t.tileZoom)}function Xm(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Jm=e=>{const t=[];Ym(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");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");const n="none"===e.layout.get("line-join").constantOr("miter"),r=!!e.paint.get("line-pattern").constantOr(1);return n&&r&&t.push("LINE_JOIN_NONE"),t};function Ym(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let eg;const tg=()=>eg||(eg={layout:$m||($m=new Os({"line-cap":new ks(zs.layout_line["line-cap"]),"line-join":new ks(zs.layout_line["line-join"]),"line-miter-limit":new Fs(zs.layout_line["line-miter-limit"]),"line-round-limit":new Fs(zs.layout_line["line-round-limit"]),"line-sort-key":new ks(zs.layout_line["line-sort-key"]),"line-z-offset":new ks(zs.layout_line["line-z-offset"]),"line-elevation-reference":new Fs(zs.layout_line["line-elevation-reference"]),"line-cross-slope":new Fs(zs.layout_line["line-cross-slope"]),visibility:new Fs(zs.layout_line.visibility),"line-width-unit":new Fs(zs.layout_line["line-width-unit"])})),paint:Zm||(Zm=new Os({"line-opacity":new ks(zs.paint_line["line-opacity"]),"line-color":new ks(zs.paint_line["line-color"]),"line-translate":new Fs(zs.paint_line["line-translate"]),"line-translate-anchor":new Fs(zs.paint_line["line-translate-anchor"]),"line-width":new ks(zs.paint_line["line-width"]),"line-gap-width":new ks(zs.paint_line["line-gap-width"]),"line-offset":new ks(zs.paint_line["line-offset"]),"line-blur":new ks(zs.paint_line["line-blur"]),"line-dasharray":new ks(zs.paint_line["line-dasharray"]),"line-pattern":new ks(zs.paint_line["line-pattern"]),"line-pattern-cross-fade":new Fs(zs.paint_line["line-pattern-cross-fade"]),"line-gradient":new Ds(zs.paint_line["line-gradient"]),"line-trim-offset":new Fs(zs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Fs(zs.paint_line["line-trim-fade-range"]),"line-trim-color":new Fs(zs.paint_line["line-trim-color"]),"line-emissive-strength":new Fs(zs.paint_line["line-emissive-strength"]),"line-border-width":new ks(zs.paint_line["line-border-width"]),"line-border-color":new ks(zs.paint_line["line-border-color"]),"line-occlusion-opacity":new Fs(zs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},eg);class ig extends ks{possiblyEvaluate(e,t){return t=new Es(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let ng;function rg(e,t){return t>0?t+2*e:e}const og=ha([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sg=ha([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ag=ha([{name:"a_projected_pos",components:4,type:"Float32"}],4);ha([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const lg=ha([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),cg=ha([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ug=ha([{name:"a_texb",components:2,type:"Uint16"}]),hg=ha([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dg=ha([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ha([{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 pg=ha([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fg=ha([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ha([{name:"triangle",components:3,type:"Uint16"}]),ha([{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"}]),ha([{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"},{type:"Uint16",name:"elevationFeatureIndex"}]),ha([{type:"Float32",name:"offsetX"}]),ha([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var mg=24;function gg(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Ts.applyArabicShaping&&(e=Ts.applyArabicShaping(e)),e}(e.text,t,i)}),e}const _g={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Ag(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function yg(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const vg=4294967296,xg=1/vg,bg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let wg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*vg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*vg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Tg(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&bg?bg.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Eg(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Eg(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Cg,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Sg,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Mg,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Bg,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ig,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Pg,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Rg,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lg,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Fg,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Tg(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Eg(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Cg(e,t){for(let i=0;i=0&&i>=e&&Hg[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 jg;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(Vg.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gg(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m=1){const g=jg.fromFeature(e,r,m);h===Ng.vertical&&g.verticalizePunctuation(d);let _=[];const A=function(e,t,i,n,r,o){if(!e)return[];const s=[],a=function(e,t,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>x&&(x=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const n=t[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(y=o.metrics,C=8203!==m?mg:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*_;b-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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function h_(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=di(n.x,r.x,u),d=di(n.y,r.y,u),p=new c_(h,d,0,r.angleTo(n),i);return!s||u_(e,p,a,s,t)?p:void 0}l+=o}}function m_(e,t,i,n,r,o,s,a,l){const c=d_(n,o,s),u=p_(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new c_(_,A,0,m,t);n&&!u_(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=g_(e,h/2,i,n,r,o,s,!0,l)),p}function __(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e1?s-1:s,wh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),wh.copy(n.data,l,{x:0,y:h-s},{x:a,y:c-s},{width:u,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a,y:c+h},{width:u,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:u-s,y:h-s},{x:a-s,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:h-s},{x:a+u,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c+h},{width:s,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c+h},{width:s,height:s},i)}this.lut=i,this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(e,t,i,n){for(const[r,o]of e.entries()){const{bin:e,imagePosition:s,imageVariant:a}=v_(r,o,i);t.set(r,s),n.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n of e.getUpdatedImages(i)){for(const r of this.iconPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.iconPositions.get(r),o,t,null)}}for(const r of this.patternPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.patternPositions.get(r),o,t,this.lut)}}}}patchUpdatedImage(e,t,i,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,o]=e.tl,s=e.sdf;if(this.lut||s){const e={width:t.data.width,height:t.data.height},a=new wh(e);wh.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,n,s),i.update(a,{position:{x:r,y:o}})}else i.update(t.data,{position:{x:r,y:o}})}}es(y_,"ImagePosition"),es(x_,"ImageAtlas");const b_=1e20;function w_(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=b_}for(let a=0,l=0;a{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const s=Math.floor(t/256);if(256*s>65535)return Ze("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=r.requests[s];a||(a=r.requests[s]=[],S_.loadGlyphRange(e,s,n,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((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null})})},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==C_.none&&(this.localGlyphMode===C_.all?!!this.localFontFamily:!!this.localFontFamily&&(os["CJK Unified Ideographs"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os.Katakana(e)||os["CJK Symbols and Punctuation"](e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs Extension B"](e)||os.Osage(e)))}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),r=e.tinySDF=new S_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*E_,buffer:3*E_,radius:8*E_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new bh({width:a,height:l},s),metrics:{width:c/E_,height:u/E_,left:h/E_,top:d/E_-27,advance:p/E_,localGlyph:!0}}}}S_.loadGlyphRange=function(e,t,i,n,r){const o=256*t,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),kt.Glyphs);Ut(a,(e,t)=>{if(e)r(e);else if(t){const e={},i=function(e){return new wg(e).readFields(Dg,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},S_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(b_,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}w_(_,0,0,c,u,c,this.f,this.v,this.z),w_(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e{const d=k_(n.stretch-A,y,u,e.left*r),p=D_(n.fixed-b,w,n.stretch,f),g=k_(o.stretch-v,x,h,e.top*r),_=D_(o.fixed-T,E,o.stretch,m),C=k_(l.stretch-A,y,u,e.left*r),S=D_(l.fixed-b,w,l.stretch,f),B=k_(c.stretch-v,x,h,e.top*r),I=D_(c.fixed-T,E,c.stretch,m),M=new Te(d,g),P=new Te(C,g),R=new Te(C,B),L=new Te(d,B),F=new Te(p/a,_/a),k=new Te(S/a,I/a),D=t*Math.PI/180;if(D){const e=Math.sin(D),t=Math.cos(D),i=[t,-e,e,t];M._matMult(i),P._matMult(i),L._matMult(i),R._matMult(i)}const O=n.stretch+n.fixed,z=l.stretch+l.fixed,U=o.stretch+o.fixed,N=c.stretch+c.fixed,V=e.imageSecondary;return{tl:M,tr:P,bl:L,br:R,texPrimary:{x:s.paddedRect.x+B_+O,y:s.paddedRect.y+B_+U,w:z-O,h:N-U},texSecondary:V?{x:V.paddedRect.x+B_+O,y:V.paddedRect.y+B_+U,w:z-O,h:N-U}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:k,minFontScaleX:w/a/u,minFontScaleY:E/a/h,isSDF:i}};if(n&&(s.stretchX||s.stretchY)){const e=L_(d,g,f),t=L_(p,_,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-n,s-r);let c=l/2;const u=new Un([],U_);if(0===l)return new Te(n,r);for(let t=n;th.d||!h.d)&&(h=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(c=n.h/2,u.push(new N_(n.p.x-c,n.p.y-c,c,e)),u.push(new N_(n.p.x+c,n.p.y-c,c,e)),u.push(new N_(n.p.x-c,n.p.y+c,c,e)),u.push(new N_(n.p.x+c,n.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function U_(e,t){return t.max-e.max}class N_{constructor(e,t,i,n){this.p=new Te(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,pu(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const V_=Object.keys,j_=Number.POSITIVE_INFINITY,G_=Math.sqrt(2);function H_(e,t,i,n){const r=e.collisionPadding||[0,0,0,0],o={top:e.top-r[1],bottom:e.bottom+r[3],left:e.left-r[0],right:e.right+r[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0}(o,n),i&&function(e,t){if(!t)return;const i=Be(t),n=new Te(e.left,e.top),r=new Te(e.right,e.top),o=new Te(e.left,e.bottom),s=new Te(e.right,e.bottom);n._rotateAround(i,new Te(0,0)),r._rotateAround(i,new Te(0,0)),o._rotateAround(i,new Te(0,0)),s._rotateAround(i,new Te(0,0)),e.left=Math.min(n.x,r.x,o.x,s.x),e.right=Math.max(n.x,r.x,o.x,s.x),e.top=Math.min(n.y,r.y,o.y,s.y),e.bottom=Math.max(n.y,r.y,o.y,s.y)}(o,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function Q_(e,[t,i]){let n=0,r=0;if(i===j_){t<0&&(t=0);const i=t/G_;switch(e){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=t;break;case"right":n=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}}return[n,r]}function $_(e,t,i,n,r,o,s,a,l,c,u){const h=e.layers[0],d=h.appearances;if(0===d.length)return{iconBBox:null,iconVerticalBBox:null};let p=null,f=null;const m=n.get("icon-rotate").evaluate(r,{},o);t&&(p=H_(t,p,m,s),i)&&(f=H_(i,f,m+90,s));const[g,_]=n.get("icon-size-scale-range"),A=Fe(1,g,_);for(const i of d){const n=i.getUnevaluatedProperties(),d=void 0!==n._values["icon-image"].value,g=void 0!==n._values["icon-size"].value,_=void 0!==n._values["icon-offset"].value,y=void 0!==n._values["icon-rotate"].value;if(d||g||_||y){const v=_?h.getAppearanceValueAndResolveTokens(i,"icon-offset",r,o,[]):null,x=v&&Array.isArray(v)?v:a,b=y?h.getAppearanceValueAndResolveTokens(i,"icon-rotate",r,o,[]):null,w="number"==typeof b?b:m,T=g?h.getAppearanceValueAndResolveTokens(i,"icon-size",r,o,[]):null,E="number"==typeof T?T*l.iconScaleFactor:s;let C=null,S=null,B=null;if(d){const t=h.getAppearanceValueAndResolveTokens(i,"icon-image",r,o,[]);if(t){const i=e.getResolvedImageFromTokens(t),s=n._values["icon-size"],a=q_(i,s_(e.zoom,s,e.worldview),s,o,e.zoom,r,e.pixelRatio,A,e.worldview);B=c.get(a.iconPrimary.toString())}}else t&&(B=t.imagePrimary);B&&(C=e_(B,null,x,u),e.allowVerticalPlacement&&(S=e_(B,null,x,u))),C&&(p=H_(C,p,w,E)),S&&(f=H_(S,f,w+90,E))}}return{iconBBox:p,iconVerticalBBox:f}}function Z_(e,t,i,n,r,o,s,a,l){if(!t||!t.usvg)return;const c=r_(n),u=r_(r),h="both"!==o&&"width"!==o||!i_(n)?1:u.width/c.width,d="both"!==o&&"height"!==o||!n_(n)?1:u.height/c.height;i.scaleSelf(h,d);const p=i.toString();s.set(p,i),a.set(p,t);const{imagePosition:f}=v_(p,t,A_);l.set(p,f)}function W_(e,t,i,n,r,o,s,a,l){if(!e)return;const c=function(e,t,i,n,r,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Es(e.maxZoom,{worldview:o}),i).evaluate(r,{},i),s=t.possiblyEvaluate(new Es(e.minZoom,{worldview:o}),i).evaluate(r,{},i);return Math.max(n,s)}return t.possiblyEvaluate(new Es(n,{worldview:o})).evaluate(r,{},i)}(t,i,n,r,o,l);return e.scaleSelf(c*a*s)}function q_(e,t,i,n,r,o,s,a,l){return{iconPrimary:W_(e.getPrimary(),t,i,n,r,o,s,a,l),iconSecondary:W_(e.getSecondary(),t,i,n,r,o,s,a,l)}}function K_(e,t,i){if(!t)return;const n=i.get(e.toString()),r=i.get(t.toString());n&&r&&(n.paddedRect.w===r.paddedRect.w&&n.paddedRect.h===r.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==r.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`))}function X_(e,t,i,n){if(!e)return;const r=t.get(i.toString());if(e.imagePrimary=r,n){const i=t.get(n.toString());e.imageSecondary=i}}function J_(e,t){for(const i in e.horizontal)Y_(e.horizontal[i],t);Y_(e.vertical,t)}function Y_(e,t){if(e)for(const i of e.positionedLines)for(const e of i.positionedGlyphs)if(null!==e.image){const i=e.image.toString();e.rect=t.get(i).paddedRect}}function eA(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 tA(e,t,i,n,r,o,s,a,l){const c=sA(o.horizontal)||o.vertical,u=i.get("icon-text-fit-padding").evaluate(n,{},r);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&o.vertical&&(h=t_(t,o.vertical,l,u,a,s)),c&&(d=t_(t,c,l,u,a,s))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function iA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){let b=s.textMaxSize.evaluate(t,{},d);void 0===b?b=a*s.textScaleFactor:b*=s.textScaleFactor;const w=e.layers[0].layout,T=mg,E=a*s.textScaleFactor/T,C=sA(i.horizontal)||i.vertical;if("none"!==g&&e.appearanceFeatureData&&t.index18&&k>2&&(k>>=1),Math.max(Nn/(512*k),1)*w.get("symbol-spacing")),M=w.get("text-padding")*e.tilePixelRatio,P=w.get("icon-padding")*e.tilePixelRatio,R=Be(w.get("text-max-angle")),L="map"===w.get("icon-rotation-alignment")&&"point"!==y,F=I/2;var k;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);const D=t.properties?+t.properties[Oc]:null,O=D&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(D):65535,z=(a,l,y)=>{if(l.x<0||l.x>=Nn||l.y<0||l.y>=Nn)return;let b=null;if(S){const{x:e,y:t,z:i}=p.projectTilePoint(l.x,l.y,y);b={anchor:new c_(e,t,i,0,void 0),up:p.upVector(y,l.x,l.y)}}!function(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M){const P=e.addToLineVertexArray(t,n);let R,L,F,k,D,O,z,U=0,N=0,V=0,j=0,G=-1,H=-1;const Q={};let $=Jt("");const Z=i?i.anchor:t,W="none"!==S;let q=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(v,{},T);q=e[0]*mg,K=e[1]*mg}else q=l.layout.get("text-radial-offset").evaluate(v,{},T)*mg,K=j_;if(e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)O=lA(e),a&&(z=lA(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},T)+90;F=aA(c,Z,t,u,h,d,e,p,i,m),a&&(k=aA(c,Z,t,u,h,d,a,_,i,null,M))}}if(o){const n=e.iconSizeData,r=l.layout.get("icon-rotate").evaluate(v,{},T),s=M_(o,r,b,W,x.iconScaleFactor),p=a?M_(a,r,b,W,x.iconScaleFactor):void 0;L=aA(c,Z,t,u,h,d,o,_,r,null,I);const f=function(e,t,i,n,r,o,s,a){const l=e.layers[0],c=l.appearances;let u=t.length;if(i&&(u=Math.max(u,i.length)),0===c.length)return u;const[h,d]=n.get("icon-size-scale-range"),p=Fe(1,h,d);for(const t of c){const i=t.getUnevaluatedProperties();if(void 0!==i._values["icon-image"].value){const n=l.getAppearanceValueAndResolveTokens(t,"icon-image",r,o,[]);if(n){const t=e.getResolvedImageFromTokens(n);if(t){const n=i._values["icon-size"],l=q_(t,s_(e.zoom,n,e.worldview),n,o,e.zoom,r,e.pixelRatio,p,e.worldview),c=s.get(l.iconPrimary.toString());u=Math.max(u,P_(c,a))}}}}return u}(e,s,p,l.layout,v,T,e.iconAtlasPositions,W);U=4*f;let m=null;"source"===n.kind?(m=[o_*l.layout.get("icon-size").evaluate(v,{},T)*x.iconScaleFactor],m[0]>rA&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)):"composite"===n.kind&&(m=[o_*x.compositeIconSizes[0].evaluate(v,{},T)*x.iconScaleFactor,o_*x.compositeIconSizes[1].evaluate(v,{},T)*x.iconScaleFactor],(m[0]>rA||m[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,y,A,v,void 0,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),G=e.icon.placedSymbolArray.length-1,p&&(N=4*f,e.addSymbols(e.icon,p,m,y,A,v,Ng.vertical,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),H=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=n,a=r.horizontal[o];R||($=Jt(a.text),f?D=lA(a):R=aA(c,Z,t,u,h,d,a,p,l.layout.get("text-rotate").evaluate(v,{},T),m));const g=1===a.positionedLines.length;if(V+=oA(e,i,t,a,s,l,f,v,m,P,r.vertical?Ng.horizontal:Ng.horizontalOnly,g?V_(r.horizontal):[o],Q,G,x,w,T,e.symbolInstances.length,E),g)break}r.vertical&&(j+=oA(e,i,t,r.vertical,s,l,f,v,m,P,Ng.vertical,["vertical"],Q,H,x,w,T,e.symbolInstances.length,E));let X=-1;const J=(e,t)=>e?Math.max(e,t):t;X=J(D,X),X=J(O,X),X=J(z,X);const Y=X>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("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,Z.x,Z.y,Z.z,Q.right>=0?Q.right:-1,Q.center>=0?Q.center:-1,Q.left>=0?Q.left:-1,Q.vertical>=0?Q.vertical:-1,G,H,$,void 0!==R?R:e.collisionBoxArray.length,void 0!==R?R+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,void 0!==L?L:e.collisionBoxArray.length,void 0!==L?L+1:e.collisionBoxArray.length,k||e.collisionBoxArray.length,k?k+1:e.collisionBoxArray.length,u,V,j,U,N,Y,0,q,K,X,0,W?1:0,B)}(e,l,b,a,i,n,o,r,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,A,c,0,P,L,_,t,s,u,h,d,f,m,g,O,v,x)};if("line"===y)for(const r of Fp(t.geometry,0,0,Nn,Nn)){const t=m_(r,I,R,i.vertical||C,n,T,B,e.overscaling,Nn);for(const i of t)C&&cA(e,C.text,F,i)||z(r,i,d)}else if("line-center"===y){for(const e of t.geometry)if(e.length>1){const t=f_(e,R,i.vertical||C,n,T,B);t&&z(e,t,d)}}else if("Polygon"===t.type)for(const e of id(t.geometry,0)){const t=z_(e,16);z(e[0],new c_(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new c_(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new c_(t.x,t.y,0,0,void 0),d)}const nA=255,rA=nA*o_;function oA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=function(e,t,i,n,r,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,p=h/d;let f=t.top-i[1];for(let e=0;erA&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[o_*f.compositeTextSizes[0].evaluate(a,{},g)*f.textScaleFactor,o_*f.compositeTextSizes[1].evaluate(a,{},g)*f.textScaleFactor],(x[0]>rA||x[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,l,s,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,g,A,!1,_,y.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function sA(e){for(const t in e)return e[t];return null}function aA(e,t,i,n,r,o,s,a,l,c,u){let h,d,p,f;if(h=u?u.top:s.top,d=u?u.bottom:s.bottom,p=u?u.left:s.left,f=u?u.right:s.right,Yg(s)&&s.collisionPadding){const e=s.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3]}if(l){const e=new Te(p,h),t=new Te(f,h),i=new Te(p,d),n=new Te(f,d),r=Be(l);let o=new Te(0,0);c&&(o=new Te(c[0],c[1])),e._rotateAround(r,o),t._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),p=Math.min(e.x,t.x,i.x,n.x),f=Math.max(e.x,t.x,i.x,n.x),h=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,h,f,d,a,n,r,o),e.length-1}function lA(e){Yg(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 cA(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])y&&(v(e,c,n,r,a,l),v(c,i,a,l,o,s))}v(h,d,n,o,r,o),v(d,p,r,o,r,s),v(p,f,r,s,n,s),v(f,h,n,s,n,o),m-=y,g-=y,_+=y,A+=y;const x=1/Math.max(_-m,A-g);return{scale:x,x:m*x,y:g*x,x2:_*x,y2:A*x,projection:t}}function dA(e,{x:t,y:i},n=0){return new Te(((t-n)*e.scale-e.x)*Nn,(i*e.scale-e.y)*Nn)}const pA=c(new Float32Array(16));class fA{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 rc(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i,n=!0){return e._coordinatePoint(e.locationCoordinate(t,i),n)}pixelsPerMeter(e,t){return hc(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return uA(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const r=e.horizonLineFromTop(!1),o=new Te(t,Math.max(r,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,n))}pointCoordinate3D(e,t,i){const n=new Te(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-wA+i&&(t=-wA+i):t>wA-i&&(t=wA-i);const o=r/Math.pow(TA(t),n);let s=o*Math.sin(n*e),a=r-o*Math.cos(n*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:n}=this,r=n-t,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Fe(Ie(a/i)+this.center[0],-180,180),c=Fe(Ie(2*Math.atan(Math.pow(n/s,1/i))-wA),-mc,mc);return new rc(l,this.southernCenter?-c:c)}}class CA extends fA{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:cc(e),y:uc(t),z:0}}unproject(e,t){const i=dc(e),n=pc(t);return new rc(i,n)}}const SA=Be(mc);class BA extends fA{project(e,t){const i=(t=Be(t))*t,n=i*i;return{x:.5*((e=Be(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const e=o*o;r=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=Fe(i-r,-SA,SA)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=Fe(Ie(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ie(i);return new rc(s,a)}}const IA=Be(mc);class MA extends fA{project(e,t){t=Be(t),e=Be(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,s=.5*(e*n+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,n=t=(2*(1-t)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(r*h)*Math.sqrt(1/m):0,A=.5*(2*_*r*d+2*i/Math.PI)-e,y=.5*(_*o+n)-t,v=.5*g*(u*f+_*r*h*c)+1/Math.PI,x=g*(p*l/4-_*o*d),b=.125*g*(l*d-_*o*u*p),w=.5*g*(c*h+_*f*r)+.5,T=x*b-w*v;s=(y*x-A*w)/T,a=(A*b-y*v)/T,i=Fe(i-s,-Math.PI,Math.PI),n=Fe(n-a,-IA,IA)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new rc(Ie(i),Ie(n))}}class PA extends fA{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Be(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:n}=this;return{x:Be(e)*n*i+.5,y:-Math.sin(Be(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=Fe(Ie((e-.5)/i)/n,-180,180),s=Math.asin(Fe(r*n,-1,1)),a=Fe(Ie(s),-mc,mc);return new rc(o,a)}}class RA extends CA{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 n=Zu(e,t,i);return j(n,n,Ku(Vu(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,i){const n=tc(t.lat,t.lng),r=z([],n),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;L(n,n,r,hc(1,0)*Nn*o);const s=c(new Float64Array(16));return h(s,e.pixelMatrix,e.globeMatrix),j(n,n,s),new Te(n[0],n[1])}pixelsPerMeter(e,t){return hc(1,0)*t}pixelSpaceConversion(e,t,i){const n=hc(1,e)*t,r=di(hc(1,45)*t,n,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const n=Xu(Vu(i.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=Ku(Vu(t));return m(n,n,Be(i.lng)),f(n,n,Be(i.lat)),p(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return zu(e,t,i,!0)||new vc(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(e,t){return!zu(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,o=e._camera.forward(),s=S([],R([],o,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=R([],r.up(),u),d=R([],r.right(),u*c),p=z([],S([],S([],o,h),d)),f=[];let m;if(new Qc(s,p).closestPointOnSphere(l,a,f)){const t=S([],f,l),i=Z([],t,s);m=Math.cos(e.fovAboveCenter)*T(i)}else{const e=Z([],s,l),t=Z([],l,s);z(t,t);const i=T(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(U(o,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=th(e.zoom);if(i>0){const n=uA(e,hc(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return di(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Zu(t,i,e,1)}upVectorScale(e){return{metersToTile:Du(Wu(Vu(e)))}}}function LA(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new CA(e);case"equirectangular":return new bA(e);case"naturalEarth":return new BA(e);case"equalEarth":return new xA(e);case"winkelTripel":return new MA(e);case"albers":return i?new PA(e):new mA(e);case"lambertConformalConic":return i?new PA(e):new EA(e);case"globe":return new RA(e)}throw new Error(`Invalid projection name: ${e.name}`)}const FA=Mc.types,kA=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function DA(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=a?Math.min(rA,Math.round(a[0])):0,f=a?Math.min(rA,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,s,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function OA(e,t,i){e.emplaceBack(t,i)}function zA(e,t,i,n,r,o,s){e.emplaceBack(t,i,n,r,o,s)}const UA=(e,t,i,n)=>{for(let r=0;r0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,ug.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,lg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,cg.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&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(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}es(jA,"SymbolBuffers");class GA{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new La,this.collisionVertexArrayExt=new Sa}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,dg.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}es(GA,"CollisionBuffers");class HA{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=c([]),this.placementViewportMatrix=c([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.textSizeData=s_(this.zoom,t["text-size"],this.worldview),this.iconSizeData=s_(this.zoom,t["icon-size"],this.worldview);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.lut=e.lut,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"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>Ng[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=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();return!(!t||0===t.length)&&t.some(t=>null!=t.getProperty(e))}createArrays(){this.text=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new tl,this.lineVertexArray=new il,this.symbolInstances=new el}calculateGlyphDependencies(e,t,i,n,r){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&r&&e<=65535){const e=_g[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,n,r,o){let s=1;const a=e.getUnevaluatedProperties()._values["icon-size"],l=s_(this.zoom,a,this.worldview),c=l_(l,t);if("constant"!==l.kind&&"camera"!==l.kind||(s=c.uSize),"composite"===l.kind){const{minZoom:e,maxZoom:t}=l,o=a.possiblyEvaluate(new Es(e,{worldview:this.worldview}),n),u=a.possiblyEvaluate(new Es(t,{worldview:this.worldview}),n),h=o.evaluate(i,{},n,r);s=h+(u.evaluate(i,{},n,r)-h)*c.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new Es(this.zoom,{worldview:this.worldview}),n).evaluate(i,{},n,r)),s*o}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!jd(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?zi.build(e):e}populate(e,t,i,n){const r=this.layers[0],o=r.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[u,h]=o.get("icon-size-scale-range"),d=Fe(t.scaleFactor||1,u,h),p=("constant"!==l.value.kind||l.value.value instanceof Di&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=this.hasAnyAppearanceProperty("icon-image"),g=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!p&&!f&&!m)return;const _=t.iconDependencies,A=t.glyphDependencies,y=t.availableImages,v=new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),x=e=>{const t=e.id.toString();_.has(t)?_.get(t).push(e):_.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=r._featureFilter.needGeometry,b=Ic(e,h);if(!r._featureFilter.filter(v,b,i))continue;if(h||(b.geometry=Bc(e,i,n)),s&&1!==e.type&&i.z<=5){const e=b.geometry,t=.98078528056,n=(e,n)=>U(Zu(e.x,e.y,i,1),Zu(n.x,n.y,i,1)){if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,E,b,i,y,B,d);t&&x(t)}),w){const e=a.evaluate(b,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ng.vertical)>=0;for(const i of w.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio),t=e.id.toString(),n=_.get(t)||[];n.push(e),_.set(t,n)}else{const n=ss(w.toString()),r=i.fontStack||e,o=A[r]=A[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n)}}}if("line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e)}}else o.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}getCombinedIconPrimary(e,t,i,n,r,o,s){let a,l;const c=e.getUnevaluatedProperties();if(void 0!==c._values["icon-image"].value){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,n,r);a=this.getResolvedImageFromTokens(o)}else{const e=t.getValueAndResolveTokens("icon-image",i,n,r);a=this.getResolvedImageFromTokens(e)}if(a){const e=c._values["icon-size"]||t._unevaluatedLayout._values["icon-size"];l=q_(a,s_(this.zoom,e,this.worldview),e,n,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(e,t,i,n){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const r=this.layers[0];let o=!1,s=0;const a=r.layout,[l,c]=a.get("icon-size-scale-range"),u=Fe(1,l,c);for(let a=0;a=0){const a=c.id,h=t&&void 0!==a?t[String(a)]:void 0,d={type:"Point",id:c.id,properties:c.properties,geometry:[]},p=this.layers[0].appearances&&this.layers[0].appearances.find(t=>t.isActive({globals:n,feature:d,canonical:e,featureState:h}));if(c.activeAppearance===p)continue;if(p){c.activeAppearance=p;const t={sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:c.properties,type:"Point",id:c.id};if(!p.hasCachedIconPrimary()){const n=this.getCombinedIconPrimary(p,r,d,e,i,t,u);p.setCachedIconPrimary(n)}const a=p.getCachedIconPrimary();if(!a)continue;const h=a.toString(),f=this.iconAtlasPositions&&this.iconAtlasPositions.get(h);if(f){const t=r.getAppearanceValueAndResolveTokens(p,"icon-offset",d,e,i),a=t&&Array.isArray(t)?t:[0,0];let h=e_(f,void 0,a,r.layout.get("icon-anchor").evaluate(d,{},e));const m=r.getAppearanceValueAndResolveTokens(p,"icon-rotate",d,e,i),g="number"==typeof m?m:0,_=f.sdf,A=r.layout.get("icon-text-fit").constantOr("none");"none"!==A&&c.textShaping&&c.iconTextFitPadding&&c.fontScale&&(h=t_(h,c.textShaping,A,c.iconTextFitPadding,a,c.fontScale));const y=this.calculateEffectiveAppearanceIconSize(p,n.zoom,d,e,i,u),v=0,x=1+(Math.min(rA,Math.round(y*o_))<<1),b=M_(h,g,_,"none"!==A,u);c.isUsingAppearanceVertexData||(c.isUsingAppearanceVertexData=!0,c.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let e=0;e0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,c.activeAppearance=null;else if(c.isUsingAppearanceVertexData){const e=12,t=c.layoutBasedVertexData.length/e;for(let i=0;i0||u>0,f=h>0,m=this.elevationFeatures[s.elevationFeatureIndex];if(m){const e=new Te(s.tileAnchorX,s.tileAnchorY),c=.075+m.pointElevation(e);s.zOffset!==c&&(t=!0,s.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,n),h=le(ee(),E(0,0,1),u);H(a,a,h),H(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(r=r||p,o=o||f)}if(p&&(UA(this.text.orientationVertexArray,c,a,l),UA(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=s;e>=0&&UA(this.icon.orientationVertexArray,h,a,l),t>=0&&UA(this.icon.orientationVertexArray,d,a,l)}}r||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(e,t,n)=>{i+=t,i>e.length&&e.resize(i);for(let r=-t;r<0;r++)e.emplace(r+i,n)},t=(e,t,i)=>{n+=t,n>e.length&&e.resize(n);for(let r=-t;r<0;r++)e.emplace(r+n,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,n=0;for(let i=0;i0;if((r>0||o>0)&&(e(this.text.zOffsetVertexArray,r,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=n;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,n.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,t,i,n,r){!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,!1),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,t,i,n){return!!(e&&t&&i)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(e,t,i,n)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=LA(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,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,x=e.segments.prepareSegment(4*_,y,A,this.canOverlap?o.sortKey:void 0),b=this.glyphOffsetArray.length,w=x.vertexLength,T=this.allowVerticalPlacement&&s===Ng.vertical?Math.PI/2:0,E=o.text&&o.text.sections;for(let n=0;n=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=a_(this.textSizeData,e,r)/mg;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=a_(this.iconSizeData,e,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(e,t,i,n){e.emplaceBack(t,-i,-i,n),e.emplaceBack(t,i,-i,n),e.emplaceBack(t,i,i,n),e.emplaceBack(t,-i,i,n)}_updateTextDebugCollisionBoxes(e,t,i,n,r,o,s){for(let s=n;s0}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),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.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:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),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)}}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let i;return this.elevationFeatures&&ti in e?String(e[i]):"")}let $A,ZA,WA;es(HA,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),HA.addDynamicAttributes=NA;class qA{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:_i,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}}es(qA,"FormatSectionOverride",{omit:["defaultValue"]});const KA=()=>WA||(WA={layout:$A||($A=new Os({"symbol-placement":new Fs(zs.layout_symbol["symbol-placement"]),"symbol-spacing":new Fs(zs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fs(zs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(zs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fs(zs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Fs(zs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Fs(zs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Fs(zs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Fs(zs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fs(zs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fs(zs.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-size-scale-range":new Fs(zs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ks(zs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(zs.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-image-use-theme":new Fs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-padding":new Fs(zs.layout_symbol["icon-padding"]),"icon-keep-upright":new Fs(zs.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"]),"icon-anchor":new ks(zs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fs(zs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fs(zs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fs(zs.layout_symbol["text-rotation-alignment"]),"text-field":new ks(zs.layout_symbol["text-field"]),"text-font":new ks(zs.layout_symbol["text-font"]),"text-size":new ks(zs.layout_symbol["text-size"]),"text-size-scale-range":new Fs(zs.layout_symbol["text-size-scale-range"]),"text-max-width":new ks(zs.layout_symbol["text-max-width"]),"text-line-height":new ks(zs.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(zs.layout_symbol["text-letter-spacing"]),"text-justify":new ks(zs.layout_symbol["text-justify"]),"text-radial-offset":new ks(zs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fs(zs.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(zs.layout_symbol["text-anchor"]),"text-max-angle":new Fs(zs.layout_symbol["text-max-angle"]),"text-writing-mode":new Fs(zs.layout_symbol["text-writing-mode"]),"text-rotate":new ks(zs.layout_symbol["text-rotate"]),"text-padding":new Fs(zs.layout_symbol["text-padding"]),"text-keep-upright":new Fs(zs.layout_symbol["text-keep-upright"]),"text-transform":new ks(zs.layout_symbol["text-transform"]),"text-offset":new ks(zs.layout_symbol["text-offset"]),"text-allow-overlap":new Fs(zs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Fs(zs.layout_symbol["text-ignore-placement"]),"text-optional":new Fs(zs.layout_symbol["text-optional"]),visibility:new Fs(zs.layout_symbol.visibility)})),paint:ZA||(ZA=new Os({"icon-opacity":new ks(zs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(zs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(zs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(zs.paint_symbol["text-emissive-strength"]),"icon-color":new ks(zs.paint_symbol["icon-color"]),"icon-halo-color":new ks(zs.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(zs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(zs.paint_symbol["icon-halo-blur"]),"icon-translate":new Fs(zs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fs(zs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Fs(zs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(zs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(zs.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(zs.paint_symbol["text-color"],{runtimeType:xi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ks(zs.paint_symbol["text-halo-color"]),"text-halo-width":new ks(zs.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(zs.paint_symbol["text-halo-blur"]),"text-translate":new Fs(zs.paint_symbol["text-translate"]),"text-translate-anchor":new Fs(zs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Fs(zs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Fs(zs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Fs(zs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Fs(zs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(zs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},WA);class XA extends aa{constructor(e,t,i,n){super(e,KA(),t,i,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=c([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(i=>{i.recalculate(e,t,this.iconImageUseTheme)}),"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()}getColorAdjustmentMatrix(e,t,i,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,i,n){e=rt(e),t=nt(t);const r=a(),o=e/3,s=1-2*o,l=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],c=.5-.5*t,u=n-i;return h(r,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),h(r,r,l),r}(e,t,i,n),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||jo(o.value)||!r?r:QA(t.properties,r)}getAppearanceValueAndResolveTokens(e,t,i,n,r){const o=e.getProperty(t);if(!o)return;const s=o.evaluate(i,{},n,r),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||jo(a.value)||!s||"string"!=typeof s?s:QA(i.properties,s)}createBucket(e){return new HA(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of KA().paint.overridableProperties){if(!XA.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new qA(t),n=new Vo(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new Ho("source",n):new Qo("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Rs(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&XA.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=KA().paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Di)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Gi&&Vi(t.value)===Ei?o(t.value.sections):t instanceof Zi?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new Ul(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let JA,YA,ey,ty;var iy=ha([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function ny(e,t,i,n,r,a,l,c){const u=[e,t,1,i,n,1,r,a,1],h=[l,c,1],d=o([],u),[p,f,m]=G(h,h,d);return s(u,u,[p,0,0,0,f,0,0,0,m])}function ry(e,t,i,n,r,a,l,c){const u=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1),h=ny(e,t,i,n,r,a,l,c);return s(h,h,o([],u))}(e,t,i,n,r,a,l,c);return[u[2]/u[8]/Nn,u[5]/u[8]/Nn]}function oy(e){return[e[0],Math.min(Math.max(e[1],-mc),mc)]}class sy extends ni{constructor(e,t,i,n){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(n),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Yt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ht(this.map._requestManager.transformRequest(this.url,kt.Image),(t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ei(t)):i&&(this.image=i instanceof HTMLImageElement?gt.getImageData(i):i,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 Pf(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 Yt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Pf||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const n of e)n[1]>i&&(i=n[1]),n[1]mc?this.onNorthPole=!0:n<-mc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(vc.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);const o=Math.max(n-t,r-i),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((t+n)/2*a);return l>1&&(l-=1),new Su(s,l,Math.floor((i+r)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Yt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Pf||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_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||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=hA(new Su(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,n=e[2].x-e[1].x,r=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-n*i,u=n*s-o*r,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=hA(this.tileID,this.map.transform.projection),[r,a,l,c]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return dA(n,t)._round()});this.perspectiveTransform=ry(r.x,r.y,a.x,a.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new ma;u.emplaceBack(r.x,r.y,0,0),u.emplaceBack(a.x,a.y,Nn,0),u.emplaceBack(c.x,c.y,0,Nn),u.emplaceBack(l.x,l.y,Nn,Nn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,iy.members),this.boundsSegments=hl.simpleSegment(0,0,4,2);const h=[],d=[oy((p=this.coordinates)[0]),oy(p[1]),oy(p[2]),oy(p[3])];var p;const[f,m,g,_]=function(e){let t=e[0][0],i=t,n=e[0][1],r=n;for(let o=1;oi&&(i=e[o][0]),e[o][1]r&&(r=e[o][1]);return[t,n,i-t,r-n]}(d);{const n=new ma,[r,a,l,c]=function(e){let t=e[0].x,i=t,n=e[0].y,r=n;for(let o=1;oi&&(i=e[o].x),e[o].yr&&(r=e[o].y);return[t,n,i-t,r-n]}(i),u=e=>[(e.x-r)/l,(e.y-a)/c],[d,p,A,y]=i.map(u),v=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1);return s(u,u,o([],ny(e,t,i,n,r,a,l,c)))}(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=ry(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);const x=(e,t)=>{h.push(e.lng);const i=Math.round((e.lng-f)/g*Nn),r=Math.round((e.lat-m)/_*Nn),o=u(t),s=G([],[o[0],o[1],1],v),a=Math.round(s[0]/s[2]*Nn),l=Math.round(s[1]/s[2]*Nn);n.emplaceBack(i,r,a,l)},b=i[3].x-i[0].x,w=i[3].y-i[0].y,T=i[2].x-i[1].x,E=i[2].y-i[1].y;for(let e=0;e<65;e++){const n=e/64,r=[i[0].x+n*b,i[0].y+n*w],o=[i[1].x+n*T,i[1].y+n*E],s=o[0]-r[0],a=o[1]-r[1];for(let e=0;e<65;e++){const i=e/64,n={x:r[0]+s*i,y:r[1]+a*i};x(t.projection.unproject(n.x,n.y),n)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,iy.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new Fa;const n=(e,n,r)=>{i.emplaceBack(e,n,r);const o=h[e],s=h[n],a=h[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,r=i+1,o=i+65,s=o+1;n(i,o,r),n(r,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},(e,t)=>t);i.sort((t,i)=>e[t]-e[i]);const n=[],r=new Fa;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)<=a){const e=it(i,0,i.length,n+a);return e===i.length||s(e,tt(i,e+1,i.length,n+360-a)-e),o}nNn?n-Nn:n,new Te(Math.trunc(n),Math.trunc(i[t+1]))}translationForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+4],i[t+5],i[t+6]]}rotationScaleForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+10],i[t+11],i[t+12],i[t+13],i[t+14],i[t+15]]}transformForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+4],i[t+10],i[t+11],i[t+12],i[t+5],i[t+13],i[t+14],i[t+15],i[t+6],0,0,0,1]}}class by{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,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+1?0: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},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.tileToMeter=yc(i);const r=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=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Ic(o,r);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Bc(o,i,n),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Nn/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const n of this.modelUris){const r=e.getModel(n,t);if(!r)continue;const o=this.instancesPerModel[n];if(o){const e=.5*F(r.aabb.max,r.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Nn,Math.max(e/this.tileToMeter,Nn/32));i=Math.max(t,i)}}return i}update(e,t,i,n){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.uploaded=!1)}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 n=this.layers[0],r=t.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);$(t.rotation,s)&&$(t.scale,a)&&$(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,n){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(jd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],s=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;tNn;l=c?l-Nn:l;const u=Math.floor(l),h=Math.floor(s.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!zd(t,i,_y.Model,n)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=Wd(Zd(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Nn:l,o=o||d!==c}}}return o}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,Of.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()}const e=this.layers[0].modelManager;if(e&&this.modelUris&&this.modelsRequested)for(const t of this.modelUris)e.removeModel(t,"",!0)}addFeature(e,t,i){const n=this.layers[0],r=n.layout.get("model-id").evaluate(i,{},this.canonical);if(!r)return Ze(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),r;(yy(r,!1)||void 0!==this.styleDefinedModelURLs[r])&&(this.modelUris.includes(r)||this.modelUris.push(r)),this.instancesPerModel[r]||(this.instancesPerModel[r]=new xy);const o=this.instancesPerModel[r],s=o.instancedDataArray,a=new vy(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Nn||t.y<0||t.y>=Nn)continue;if(0!==this.lookupDim){const e=(this.lookupDim-1)/Nn,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 e=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=t.x,s.float32[16*e+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)),r}getModelUris(){return this.modelUris}evaluate(e,t,i,n){const r=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=r.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=r.paint.get("model-scale").evaluate(o,t,s),c=e.translation=r.paint.get("model-translation").evaluate(o,t,s),u=Object.assign({},r.paint.get("model-color").evaluate(o,t,s));u.a=r.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Qf(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t10?this.tileToMeter:yc(s,d)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[r]=c[2]}}}let wy,Ty;es(by,"ModelBucket",{omit:["layers"]}),es(xy,"PerModelAttributes"),es(vy,"ModelFeature");class Ey{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const n=i||e.findDEMTileFor(t);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Kf.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Kf.HasMapboxMeshFeatures),r&&(this.modelTraits|=Kf.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Py(e)),Iy(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&t.push({footprint:n.footprint,id:e})}}updateAppearances(e,t,i,n){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Ee(e,this.states))for(const t of i)this.evaluate(t,e);this.states=structuredClone(e)}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):tm(t,e,!0)}for(const e of t)im(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 n=e.transform.projectionOptions,r=e.style.getBrightness(),o=this.brightness!==r;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Ly(i.paint.get("model-color").value,o)||Ly(i.paint.get("model-color-mix-intensity").value,o)||Ly(i.paint.get("model-roughness").value,o)||Ly(i.paint.get("model-emissive-strength").value,o)||Ly(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=n,this.brightness=r;const e=this.getNodesInfo();for(const t of e)t.state=null;return!0}return!1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},n)}}evaluate(e,t){const i=this.getNodesInfo();for(const n of i){if(!n.node.meshes)continue;const i=n.feature,r=t&&t[i.id];if(Ee(r,n.state))continue;n.state=structuredClone(r);const o=n.node.meshes&&n.node.meshes[0].featureData,s=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,o){for(let t=0;t=e)continue;const h=Cy[c],d=Math.abs(h);d>a&&(s=h,a=d,l=r,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(n,i)+s*o;const h=t._dem.get(n+l,i+u),d=t._dem.get(n-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),Cy[r]=t._dem.set(n,i,a),Sy[r]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=gt.now())}setFilter(e){this.filter=e?js(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Es(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)im(t.node),nm(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!i.find(e=>e.footprint===t)}}getHeightAtTileCoord(e,t){const i=[],n=[0,0,0],r=c([]);for(const o of this.getNodesInfo()){const s=o.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};u(r,o.node.globalMatrix),n[0]=e,n[1]=t,j(n,n,r);const l=(n[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*qf|0,c=Math.min(63,(n[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*qf|0)*qf+Math.min(63,l),h=s.heightmap[c];if(!(h<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:h,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Te(e,t),new Te(e,t),i),i.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Ly(e,t){return e instanceof Ho&&!e.isLightConstant&&t}function Fy(e,t,i,n,r,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=di(l,255*i[0],i[3]),c=di(c,255*i[1],i[3]),u=di(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*n[3]),p=function(e){const t=Fe(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=Fe(r[0],0,1),m=Fe(r[1],0,1),g=Fe(r[2],0,1),_=Fe(r[3],0,1);let A,y,v,x;if(f!==m&&s!==o&&m!==f){const e=s-o;y=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Fe(r[4],-1,1);x=Math.pow(10,t),A=255*g<<8|255*_}else A=65535,y=0,v=1,x=1;if(e.emplaceBack(h,d,p,A,y,v,x),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&n.lights&&(d=new $a,d.resize(10*n.lights.length)),Fy(i.featureArray,r,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),r++}}es(Ry,"Tiled3dModelBucket",{omit:["layers"]}),es(Py,"Tiled3dModelFeature");const Dy=["id","tile","layer","source","sourceLayer","state"];class Oy{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=n,this.properties=e?e.properties:{},this.id=r}clone(){const e=new Oy(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(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};for(const t of Dy)void 0!==this[t]&&(e[t]=this[t]);return e}}class zy extends ni{constructor(e,t,i,n){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t,this._modelsInfo=new Map}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],n=this._modelsInfo.get(t);if(n){const e=n.model;e.position=null!=i.position?new rc(i.position[0],i.position[1]):new rc(0,0),e.orientation=null!=i.orientation?i.orientation:[0,0,0],n.modelSpec=i,zy.applyModelSpecification(e,i),e.computeBoundsAndApplyParent(),this.models.push(e)}else{const n=Sf(this.map._requestManager.transformRequest(i.uri,kt.Model).url).then(e=>{if(!e)return;const n=hm(e),r=new Jf(t,i.uri,i.position,i.orientation,n);zy.applyModelSpecification(r,i),r.computeBoundsAndApplyParent(),this.models.push(r),this._modelsInfo.set(t,{modelSpec:i,model:r})}).catch(e=>{this.fire(new ei(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)))});e.push(n)}}Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this._loaded=!0,this.fire(new ei(new Error(`Could not load models: ${e.message}`)))})}static applyModelSpecification(e,t){t.nodeOverrides&&zy.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&zy.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const i of t)e.nodeOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={orientation:[0,0,0]};if(i.hasOwnProperty("orientation")){const e=i.orientation;e&&(n.orientation=e)}e.nodeOverrides.set(t,n)})}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const i of t)e.materialOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={color:new li(1,1,1),colorMix:0,emissionStrength:0,opacity:1},r=i["model-color"];void 0!==r&&(n.color.r=r[0],n.color.g=r[1],n.color.b=r[2]);const o=i["model-color-mix-intensity"];void 0!==o&&(n.colorMix=o);const s=i["model-emissive-strength"];void 0!==s&&(n.emissionStrength=s);const a=i["model-opacity"];void 0!==a&&(n.opacity=a),e.materialOverrides.set(t,n)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){const e=ta(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(e){this.models=[];const t=new Map;for(const i in e){const n=e[i];if(this._modelsInfo.has(i)){const e=this._modelsInfo.get(i);e&&e.modelSpec.uri===n.uri&&t.set(i,e)}}this._modelsInfo=t,this._options.models=e,this._loaded=!1,this.load()}}function Uy(e,t,i,n){const r=1<e.polygon).flat());const g=p?a:null,[_,A]=Np(o,n,h,u,c,s,g,d,f,o.center.lat,e.tileID.canonical),y=e.queryGeometry;return Up(_,A,y.isPointQuery()?y.screenBounds:y.screenGeometry)}},building:class extends aa{constructor(e,t,i,n){super(e,{layout:Pm||(Pm=new Os({visibility:new Fs(zs.layout_building.visibility),"building-facade":new ks(zs.layout_building["building-facade"]),"building-facade-floors":new ks(zs.layout_building["building-facade-floors"]),"building-facade-unit-width":new ks(zs.layout_building["building-facade-unit-width"]),"building-facade-window":new ks(zs.layout_building["building-facade-window"]),"building-roof-shape":new ks(zs.layout_building["building-roof-shape"]),"building-height":new ks(zs.layout_building["building-height"]),"building-base":new ks(zs.layout_building["building-base"]),"building-flood-light-wall-radius":new ks(zs.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ks(zs.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ks(zs.layout_building["building-flip-roof-orientation"])})),paint:Rm||(Rm=new Os({"building-opacity":new Fs(zs.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Fs(zs.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Fs(zs.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Fs(zs.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Fs(zs.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Fs(zs.paint_building["building-vertical-scale"]),"building-cast-shadows":new Fs(zs.paint_building["building-cast-shadows"]),"building-color":new ks(zs.paint_building["building-color"]),"building-emissive-strength":new ks(zs.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Fs(zs.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Fs(zs.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Fs(zs.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Fs(zs.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Fs(zs.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Im(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(e){return!0}queryRadius(e){return 0}queryIntersectsFeature(e,t,i,n,r,o,s,a,l){let c=this.layout.get("building-height").evaluate(t,i);const u=this.layout.get("building-base").evaluate(t,i),h=e.tile.getBucket(this).getFootprint(t);if(h){if(0!==h.hiddenFlags)return!1;c=h.height}const[d,p]=Np(o,n,u,c,new Te(0,0),s,null,[0,0],1,o.center.lat,e.tileID.canonical),f=e.queryGeometry;return Up(d,p,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class extends aa{constructor(e,t,i,n){const r=tg();super(e,r,t,i,n),r.layout&&(this.layout=new Ls(r.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Br,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"]=(()=>{if(ng)return ng;const e=tg();return ng=new ig(e.paint.properties["line-width"].specification),ng.useIntegerZoom=!0,ng})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hm(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const n=Jm(this);return{config:new Ul(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,i=rg(vu("line-width",this,t),vu("line-gap-width",this,t)),n=vu("line-offset",this,t);return i/2+Math.abs(n)+xu(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,r,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=bu(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*rg(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&&(n=function(e,t){const i=[],n=new Te(0,0);for(let r=0;r=3)for(let t=0;t>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function hv(e,t,i){1===e?(t.rgb_color=uv(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function dv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function pv(e,t){return e.readFields(fv,{offset:0,opacity:255,rgb_color:jy},t)}function fv(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=uv(i.readVarint()))}function mv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function gv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(nv(i,i.readVarint()+i.pos))}function _v(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(nv(i,i.readVarint()+i.pos))}class Av{static calculate(e={},t=[]){const i=new Map,n=new Map;if(0===Object.keys(e).length)return i;t.forEach(e=>{n.set(e.name,e.rgb_color||new li(0,0,0))});for(const[t,r]of Object.entries(e))n.has(t)?i.set(n.get(t).toString(),r):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function yv(e,t=255,i){const n=t/255,r=e.toString(),o=i.has(r)?i.get(r).clone():e.clone();return o.a*=n,o.toString()}function vv(e,t){if(!mt()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}function xv(e,t){const i=Av.calculate(t.params,e.metadata?e.metadata.variables:[]),n=e.usvg_tree,r=n.width,o=n.height,s=t.transform?t.transform:new DOMMatrix,a=Math.max(1,Math.round(r*s.a)),l=Math.max(1,Math.round(o*s.d)),c=new DOMMatrix([a/r,0,0,l/o,0,0]),u=vv(a,l).getContext("2d");return bv(u,c,n,n,i),u.getImageData(0,0,a,l)}function bv(e,t,i,n,r){for(const o of n.children)wv(e,t,i,o,r)}function wv(e,t,i,n,r){n.group?(e.save(),function(e,t,i,n,r){const o=null!=n.mask_idx?i.masks[n.mask_idx]:null,s=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=Rv(n.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(n,null!=s,null!=o))return void bv(e,t,i,n,r);const a=vv(e.canvas.width,e.canvas.height),l=a.getContext("2d");bv(l,t,i,n,r),s&&Mv(l,t,i,s),o&&Pv(l,t,i,o,r),e.globalAlpha=n.opacity/255,e.drawImage(a,0,0)}(e,t,i,n.group,r),e.restore()):n.path&&(e.save(),function(e,t,i,n,r){e.setTransform(t),n.paint_order===$y.PAINT_ORDER_FILL_AND_STROKE?(Tv(e,i,n,r),Cv(e,i,n,r)):(Cv(e,i,n,r),Tv(e,i,n,r))}(e,t,i,n.path,r),e.restore())}function Tv(e,t,i,n){const r=i.fill;if(!r)return;const o=r.opacity/255;switch(e.save(),e.beginPath(),Lv(i,e),r.paint){case"rgb_color":e.fillStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Sv(e,i,o,n);break}case"radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Bv(e,i,o,n)}}e.fill(Ev(i)),e.restore()}function Ev(e){return e.rule===Gy.PATH_RULE_NON_ZERO?"nonzero":e.rule===Gy.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Cv(e,t,i,n){const r=i.stroke;if(!r)return;const o=Fv(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const s=r.opacity/255;switch(r.paint){case"rgb_color":e.strokeStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":e.strokeStyle=Sv(e,t.linear_gradients[r.linear_gradient_idx],s,n,!0);break;case"radial_gradient_idx":e.strokeStyle=Bv(e,t.radial_gradients[r.radial_gradient_idx],s,n,!0)}switch(r.linejoin){case Qy.LINE_JOIN_MITER_CLIP:case Qy.LINE_JOIN_MITER:e.lineJoin="miter";break;case Qy.LINE_JOIN_ROUND:e.lineJoin="round";break;case Qy.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(r.linecap){case Hy.LINE_CAP_BUTT:e.lineCap="butt";break;case Hy.LINE_CAP_ROUND:e.lineCap="round";break;case Hy.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(o)}function Sv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const{x1:o,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(o,s),u=new DOMPoint(a,l);if(r){const e=Rv(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return h}function Bv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const o=Rv(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(s,a),p=new DOMPoint(c,u),f=l,m=h;if(r){d=o.transformPoint(d),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e}const g=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)g.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return g}function Iv(e,t,i,n){const r=n.transform?Rv(n.transform).preMultiplySelf(t):t,o=vv(e.canvas.width,e.canvas.height),s=o.getContext("2d");for(const e of n.children)if(e.group)Iv(s,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(Fv(t),r),s.fill(i,Ev(t))}const a=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;a&&Mv(s,r,i,a),e.globalCompositeOperation="source-over",e.drawImage(o,0,0)}function Mv(e,t,i,n){const r=vv(e.canvas.width,e.canvas.height);Iv(r.getContext("2d"),t,i,n),e.globalCompositeOperation="destination-in",e.drawImage(r,0,0)}function Pv(e,t,i,n,r){if(0===n.children.length)return;const o=null!=n.mask_idx?i.masks[n.mask_idx]:null;o&&Pv(e,t,i,o,r);const s=e.canvas.width,a=e.canvas.height,l=vv(s,a),c=l.getContext("2d"),u=n.width,h=n.height,d=n.left,p=n.top,f=new Path2D,m=new Path2D;m.rect(d,p,u,h),f.addPath(m,t),c.clip(f);for(const e of n.children)wv(c,t,i,e,r);const g=c.getImageData(0,0,s,a),_=g.data;if(n.mask_type===Wy.MASK_TYPE_LUMINANCE)for(let e=0;e<_.length;e+=4)_[e+3]=_[e+3]/255*(.2126*_[e]+.7152*_[e+1]+.0722*_[e+2]);c.putImageData(g,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function Rv(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function Lv(e,t){const i=e.step;let n=e.diffs[0]*i,r=e.diffs[1]*i;t.moveTo(n,r);for(let o=0,s=2;ot[s])return null}else{const a=1/n[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>r&&(r=l),co)return null}return r}function Uv(e,t,i,n,r,o,s,a,l,c,u){const h=n-e,d=r-t,p=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,A=u[2]*f-u[0]*g,y=u[0]*m-u[1]*f,v=h*_+d*A+p*y;if(Math.abs(v)<1e-15)return null;const x=1/v,b=c[0]-e,w=c[1]-t,T=c[2]-i,E=(b*_+w*A+T*y)*x;if(E<0||E>1)return null;const C=w*p-T*d,S=T*h-b*p,B=b*d-w*h,I=(u[0]*C+u[1]*S+u[2]*B)*x;return I<0||E+I>1?null:(f*C+m*S+g*B)*x}function Nv(e,t,i){return(e-t)/(i-t)}function Vv(e,t,i,n,r,o,s,a,l){const c=1<{const o=n?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=a,r[2]=s,r[3]=l};let s=new Ov(n);const a=[];for(let t=0;t=1;n/=2){const e=i[i.length-1];s=new Ov(n);for(let t=0;t0;){const{idx:a,t:p,nodex:f,nodey:m,depth:g}=d.pop();if(this.leaves[a]){Vv(f,m,g,e,t,i,n,u,h);const a=1<=e[2])return p}continue}let _=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[_]=d),_++}}for(let e=0;e<_;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:g+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,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=n-1,s=e[o];let a=0,l=0;for(let e=0;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],n=Wv.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Th({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function ox(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&i)>>8|(240&n)<<4|61440&n,e[t+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4}return e;case"uint8":for(let t=0;t>6|(192&n)>>4|(192&r)>>2|192&o,e[t+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)<<2,e[t+2]=(12&i)>>2|12&n|(12&r)<<2|(12&o)<<4,e[t+3]=3&i|(3&n)<<2|(3&r)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}es(Wv,"DEMData"),es(jv,"DemMinMaxQuadTree",{omit:["dem"]});var sx=Uint8Array,ax=Uint16Array,lx=Int32Array,cx=new sx([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ux=new sx([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hx=new sx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dx=function(e,t){for(var i=new ax(31),n=0;n<31;++n)i[n]=t+=1<>1|(21845&Ax)<<1;_x[Ax]=((65280&(yx=(61680&(yx=(52428&yx)>>2|(13107&yx)<<2))>>4|(3855&yx)<<4))>>8|(255&yx)<<8)>>1}var vx=function(e,t,i){for(var n=e.length,r=0,o=new ax(t);r>l]=c;return s},xx=new sx(288);for(Ax=0;Ax<144;++Ax)xx[Ax]=8;for(Ax=144;Ax<256;++Ax)xx[Ax]=9;for(Ax=256;Ax<280;++Ax)xx[Ax]=7;for(Ax=280;Ax<288;++Ax)xx[Ax]=8;var bx=new sx(32);for(Ax=0;Ax<32;++Ax)bx[Ax]=5;var wx=vx(xx,9),Tx=vx(bx,5),Ex=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},Cx=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},Sx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Bx=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ix=function(e,t,i){var n=new Error(t||Bx[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Ix),!i)throw n;return n},Mx=new sx(0),Px="undefined"!=typeof TextDecoder&&new TextDecoder;try{Px.decode(Mx,{stream:!0})}catch(e){}const Rx={gzip_data:"gzip"};class Lx extends Error{constructor(e){super(e),this.name="MRTError"}}const Fx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},kx={uint32:1,uint16:2,uint8:4},Dx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Ox;class zx{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new Lx(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Lx("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length= ${i} but got buffer of length ${t.length}`);const n=new Ox(t.subarray(0,i)).readFields(qv,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Lx(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new Ux(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let n of e.blockIndices){const r=i.dataIndex[n],o=r.firstByte-e.firstByte,s=r.lastByte-e.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map(e=>e.filter)};i._blocksInProgress.add(n),t.push(a)}return new Nx(t,()=>{t.forEach(e=>i._blocksInProgress.delete(e.blockIndex))},(e,n)=>{if(t.forEach(e=>i._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e)})})}}class Ux{constructor({version:e,name:t,units:i,tileSize:n,pixelFormat:r,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new Lx(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Fx[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,kx[this.pixelFormat]],this._decodedBlocks=new kv(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return kx[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===e)return{bandIndex:t+r,blockIndex:i,blockBandIndex:r};t+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new Lx(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e);if(t<0)throw new Lx(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new Lx(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[t],o=this.bandShape.reduce((e,t)=>e*t,1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:r.offset,scale:r.scale}}}zx.setPbf=function(e){Ox=e};class Nx{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}zx.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(n,r+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Lx(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ix(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(r=e))+8>r.length&&Ix(6,"invalid gzip data"),function(e,t,i){var n=e.length;if(!n||t.f&&!t.l)return i||new sx(0);var r=!i,o=r||2!=t.i,s=t.i;r&&(i=new sx(3*n));var a,l,c=function(e){var t=i.length;if(e>t){var n=new sx(Math.max(2*t,e));n.set(i),i=n}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,_=8*n;do{if(!p){u=Cx(e,h,1);var A=Cx(e,h+1,3);if(h+=3,!A){var y=e[(M=4+((h+7)/8|0))-4]|e[M-3]<<8,v=M+y;if(v>n){s&&Ix(0);break}o&&c(d+y),i.set(e.subarray(M,v),d),t.b=d+=y,t.p=h=8*v,t.f=u;continue}if(1==A)p=wx,f=Tx,m=9,g=5;else if(2==A){var x=Cx(e,h,31)+257,b=Cx(e,h+10,15)+4,w=x+Cx(e,h+5,31)+1;h+=14;for(var T=new sx(w),E=new sx(19),C=0;C>4)<16)T[C++]=M;else{var R=0,L=0;for(16==M?(L=3+Cx(e,h,3),h+=2,R=T[C-1]):17==M?(L=3+Cx(e,h,7),h+=3):18==M&&(L=11+Cx(e,h,127),h+=7);L--;)T[C++]=R}}var F=T.subarray(0,x),k=T.subarray(x);m=Ex(F),g=Ex(k),p=vx(F,m),f=vx(k,g)}else Ix(1);if(h>_){s&&Ix(0);break}}o&&c(d+131072);for(var D=(1<>4;if((h+=15&R)>_){s&&Ix(0);break}if(R||Ix(2),U<256)i[d++]=U;else{if(256==U){z=h,p=null;break}var N=U-254;U>264&&(N=Cx(e,h,(1<<(G=cx[C=U-257]))-1)+fx[C],h+=G);var V=f[Sx(e,h)&O],j=V>>4;if(V||Ix(3),h+=15&V,k=gx[j],j>3){var G=ux[j];k+=Sx(e,h)&(1<_){s&&Ix(0);break}o&&c(d+131072);var H=d+N;if(da.length)&&(l=a.length),new sx(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new sx(((i=r)[(n=i.length)-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0))));var i,n,r,o;const s=Rx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then(e=>new Uint8Array(e))}(u,c).then(e=>(function(e,t){e.readFields(tx,t)}(new Ox(e),h),new Dx[o](h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":nx(e,s);break;case"zigzag_filter":rx(e);break;case"bitshuffle_filter":ox(e,o);break;default:throw new Lx(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},es(Nx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),es(zx,"MapboxRasterTile"),es(Ux,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class Vx{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new kc(new wg(this.rawTileData)).layers,this.sourceLayerCoder=new Vx(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){const{tilespaceGeometry:i,transform:n,tileTransform:r,pixelPosMatrix:o,availableImages:s,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,n,r)=>gu(i.bufferedTilespaceGeometry,e-l,t-l,n+l,r+l));u.sort(Hx);let h=null;n.elevation&&u.length>0&&(h=Ey.create(n.elevation,this.tileID));const d={};let p;for(let t=0;t(f||(f=Bc(e,this.tileID.canonical,r)),t.queryIntersectsFeature(i,e,s,f,this.z,n,o,h,a)))}return d}loadMatchingFeature(e,t,i,n,r,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!Qe(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(s),g=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ")}`);this.promoteIdExpression=e.value}i=this.promoteIdExpression.evaluate({zoom:0},e)}else i=e.properties[n];"boolean"==typeof i&&(i=Number(i))}return i}}function Gx(e,t,i,n,r){return je(e,(e,o)=>{const s=t instanceof Ls?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,void 0,r):s})}function Hx(e,t){return t-e}es(jx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Qx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class $x{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 n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Qx[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new $x(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=Qx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 Zx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)Xx(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];Xx(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Zx(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;Wx(e,t,s,n,r,o),Zx(e,t,i,n,s-1,1-o),Zx(e,t,i,s+1,r,1-o)}function Wx(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Wx(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(qx(e,t,n,i),t[2*r+o]>s&&qx(e,t,n,r);as;)l--}t[2*n+o]===s?qx(e,t,n,l):(l++,qx(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function qx(e,t,i,n){Kx(e,i,n),Kx(t,2*i,2*n),Kx(t,2*i+1,2*n+1)}function Kx(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Xx(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}e.$=Yi,e.A=Oi,e.B=ta,e.C=2,e.D=Wp,e.E=ni,e.F=y_,e.G=__,e.H=Ki,e.I=ri,e.J=Us,e.K=qi,e.L=Ji,e.M=Ro,e.N=Io,e.O=Po,e.P=Te,e.Q=jo,e.R=kt,e.S=Ns,e.T=Mf,e.U=Go,e.V=Ay,e.W=$o,e.X=yr,e.Y=_r,e.Z=Ar,e._=on,e.a=function(e){return st.API_CDN_URL_REGEX.test(e)},e.a$=ma,e.a0=Xi,e.a1=ai,e.a2=Vs,e.a3=class extends Ay{},e.a4=Lo,e.a5=Mo,e.a6=zs,e.a7=function(e){const t=e.value;return t?Xi(t)?yy(t,!0)?[]:[new Ay(e.key,t,`invalid url "${t}"`)]:[new Ay(e.key,t,`string expected, "${qi(t)}" found`)]:[]},e.a8=Bs,e.a9=Os,e.aA=Fe,e.aB=h,e.aC=Y,e.aD=$l,e.aE=mu,e.aF=cc,e.aG=bc,e.aH=function(e,t){const i={};for(let n=0;n{n(e,i)},t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,n)},t):e(i,n);setTimeout(()=>delete this.entries[e],3e3)})),()=>{r.result||(r.callbacks=r.callbacks.filter(e=>e!==n),r.callbacks.length||(r.cancel(),delete this.entries[e]))}}},e.aL=function(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const n=Ut(e.request,(e,n,r)=>{e?t(e):n&&t(null,{vectorTile:i?void 0:new kc(new wg(n)),rawData:n,responseHeaders:new Map(r.entries())})});return()=>{n.cancel(),t()}},t)},e.aM=function(e){return e?{cacheControl:e.get("Cache-Control"),expires:e.get("Expires")}:{cacheControl:void 0,expires:void 0}},e.aN=function(e){St++,St>xt&&(e.getActor().send("enforceCacheSizeLimit",vt),St=0)},e.aO=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aP=Iu,e.aQ=ly,e.aR=fy,e.aS=rc,e.aT=sy,e.aU=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t{}}},e.aV=Pf,e.aW=zy,e.aX=Ve,e.aY=hA,e.aZ=dc,e.a_=pc,e.aa=Fs,e.ab=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return Ke(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i),azimuthal:di(e.azimuthal,t.azimuthal,i),polar:di(e.polar,t.polar,i)}}},e.ac=Es,e.ad=Qo,e.ae=vc,e.af=j,e.ag=T,e.ah=ke,e.ai=Ls,e.aj=th,e.ak=di,e.al=Nn,e.am=pi,e.an=Be,e.ao=li,e.ap=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=Ke([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i)}}},e.aq=function(e,t,i=0,n=!0){const r=new Te(i,i),o=e.sub(r),s=t.add(r),a=[o,new Te(s.x,o.y),s,new Te(o.x,s.y)];return n&&a.push(o.clone()),a},e.ar=function(e,t){const i=[];for(let n=0;n1)return!1;const i=t.getSource().maxzoom,n=1<1)return t;const r=n.getSource().maxzoom,o=1<{const a=this.getAtTileOffset(e,r,o,s),l=n.upVector(e.canonical,r.x,r.y);return R(l,l,a*n.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,n){if(this.isUsingMockSource())return!1;const r=Ey.create(this,e,n);return!!r&&(t.forEach(e=>{e[2]=this.exaggeration()*r.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,n=t.tileID,r=1<0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!nh(e,new rc(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!nh(e,new rc(e.center.lat,-90))]},e.cM=function(e,t){const{scale:i}=e.tileTransform,n=i*Nn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var n=t[1],r=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=n*s,e[2]=r*a,e[3]=o*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[n,n])},e.cN=Vf,e.cO=x,e.cP=Uf,e.cQ=function(e){const t=Uf(e,!0);return n([],[t[0],t[1],t[4],t[5]])},e.cR=p,e.cS=$c,e.cT=f,e.cU=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return eh(t,i,e.worldSize,n,r)},e.cV=I,e.cW=Ie,e.cX=Mu,e.cY=_u,e.cZ=Zl,e.c_=function(e,t,i){let n=0;for(let i=0;i<2;++i){const r=0;e[i]>r&&(n+=(e[i]-r)*(e[i]-r)),t[i]0?Math.acos(i/n)*Se:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Se+90:0;return o<0&&(o+=360),[n,o,r]},e.d4=E,e.d5=Ke,e.d6=yc,e.d7=S,e.d8=Jc,e.d9=B,e.dA=Cl,e.dB=class extends vl{constructor(e){super(e),this.current=Il}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}}},e.dC=Pe,e.dD=function(e,t,i){const n=th(i.zoom),r=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!o},e.dE=function(e){const t=e.pixelsPerMeter,i=t/hc(1,e.center.lat),n=c(new Float64Array(16));return d(n,n,[e.point.x,e.point.y,0]),p(n,n,[i,i,t]),Float32Array.from(n)},e.dF=Qu,e.dG=function(e){const t=mc-5;e=Fe(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Be(e))),3);return Math.round(i*(Xl.length-1))},e.dH=function(e,t,i,n){const r=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),c=1<0){const e=180/n;s(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},e.dI=Vu,e.dJ=function(e,t,i){const n=c(new Float64Array(16)),r=(t/(1<({u_matrix:new Bl(e),u_texsize:new wl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_image:new xl(e),u_units_to_pixels:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e),u_pattern_transition:new bl(e)}),e.dW=e=>({u_matrix:new Bl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_units_to_pixels:new wl(e),u_dash_image:new xl(e),u_gradient_image:new xl(e),u_image_height:new bl(e),u_texsize:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e)}),e.dX=e=>({u_camera_to_center_distance:new bl(e),u_extrude_scale:new Pl(e),u_device_pixel_ratio:new bl(e),u_matrix:new Bl(e),u_inv_rot_matrix:new Bl(e),u_merc_center:new wl(e),u_tile_id:new Tl(e),u_zoom_transition:new bl(e),u_up_dir:new Tl(e),u_emissive_strength:new bl(e)}),e.dY=Ra,e.dZ=fg,e.d_=class{constructor(e,t,i,n){this.context=e,this.format=n,this.size=i,this.texture=e.gl.createTexture();const[r,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Bf(this.format),If(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.da=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.db=Sf,e.dc=hm,e.dd=Jf,e.de=yy,e.df=function(e,t){return e.readFields(qy,{icons:[]},t)},e.dg=Xp,e.dh=S_,e.di=C_,e.dj=Ot,e.dk=ys,e.dl=At,e.dm=Jt,e.dn=He,e.dp=function(e){const t=e.indexOf(ea);return t>=0?e.slice(0,t):e},e.dq=function(e){return e.indexOf(ea)>=0},e.dr=function(e){const t=e.lastIndexOf(ea);return t>=0?e.slice(t+1):""},e.ds=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.dt=function(e,t,i,n){return"custom"===e.type?new my(e,t):new Vy[e.type](e,t,i,n)},e.du=Ge,e.dv=function(e){const t=e.indexOf(ea);return t>=0?e.slice(t+1):""},e.dw=class extends Oy{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer)}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.dx=xs,e.dy=zt,e.dz=function(e){return e({pluginStatus:_s,pluginURL:As}),xs.on("pluginStateChange",e),e},e.e=st,e.e$=function([e,t,i]){const n=Math.hypot(e,t,i),r=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/n);return new rc(Ie(r),Ie(o))},e.e0=(e,t,i,n,r,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Yu(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:gt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:ah,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=n,c.u_merc_center=r,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const u=e.transform,h=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:Xm(e,t,i,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:r,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:Km(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:h,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}},e.e4=(e,t,i,n,r,o,s,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07;return{u_matrix:Xm(e,t,i,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:Ym(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Km(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:p,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:c}},e.e5=Ne,e.e6=Eh,e.e7=fc,e.e8=Pu,e.e9=_p,e.eA=Uy,e.eB=Xf,e.eC=Zf,e.eD=[1,1,1],e.eE=Ey,e.eF=K,e.eG=function(e,t,i,n){var r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},e.eH=Kf,e.eI=Ia,e.eJ=ja,e.eK=function(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m,g){var _=new i(16);return _[0]=e,_[1]=t,_[2]=n,_[3]=r,_[4]=o,_[5]=s,_[6]=a,_[7]=l,_[8]=c,_[9]=u,_[10]=h,_[11]=d,_[12]=p,_[13]=f,_[14]=m,_[15]=g,_},e.eL=ic,e.eM=Va,e.eN=Na,e.eO=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Te(1/0,1/0),max:new Te(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=Gd(new Te(0,0),new Te(Nn,Nn),e),n=[];if(t&&!Vd(i,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Vd(i,t))continue;const r=Hd(t.min,t.max,e);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(i).buckets[e.layer];n&&n.updateFootprints(i.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),n=e.getClipMask(),r=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Gd(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,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Ud(e.min,t.min)||Ud(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[t];e=i.priority!==n.priority||!Nd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Ee(i.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Dd&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e1){let t=0,i=e(t);for(;t!==i;){let n=t;const r=t;for(;n!==i;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.eP=Dd,e.eQ=class{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 pa,n=new Fa,r=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let n=e===o-1?e-2:0===e?e:e-1;return n+=i?24575:0,[n,t]};for(let e=0;e0?(_=2*Math.sqrt(g+1),e[3]=.25*_,e[0]=(d-f)/_,e[1]=(p-c)/_,e[2]=(l-u)/_):a>h&&a>m?(_=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/_,e[0]=.25*_,e[1]=(l+u)/_,e[2]=(p+c)/_):h>m?(_=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/_,e[0]=(l+u)/_,e[1]=.25*_,e[2]=(d+f)/_):(_=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/_,e[0]=(p+c)/_,e[1]=(d+f)/_,e[2]=.25*_),e},e.ez=function(e,i){var n=2*Math.acos(i[3]),r=Math.sin(n/2);return r>t?(e[0]=i[0]/r,e[1]=i[1]/r,e[2]=i[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.f0=J,e.f1=Gf,e.f2=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==Ye){const t=e.navigator?e.navigator.userAgent:null;Ye=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ye}(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/)))},e.f3=function(e,t){vt=e,xt=t},e.f4=nh,e.f5=ih,e.f6=function(e){const t=[0,0,0],i=c(new Float64Array(16));return h(i,e.pixelMatrix,e.globeMatrix),j(t,t,i),new Te(t[0],t[1])},e.f7=function(){const e=qp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release($p),qp=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()"))},e.f8=function(){Xp().acquire($p)},e.f9=bs,e.fA=Mc,e.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==vf){const i=new Uint32Array(e,0,7),[,,n,r,o,s]=i;t=i.byteLength+r+o+s+o,(n!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.")}return Cf(e,t)},e.fC=function(e,t){const i=hm(e);for(const e of i){for(const t of e.meshes)dm(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(fm(e.lights,t)))}return i},e.fD=Ry,e.fE=Xe,e.fF=Hp,e.fG=Ts,e.fH=ms,e.fI=function(e){Ct(),null!=wt&&wt.then(t=>{t.keys().then(i=>{for(let n=0;nZe(e.message))}).catch(e=>Ze(e.message))}).catch(e=>Ze(e.message))},e.fa=function(e,t,i=!1){if(_s===ms.deferred||_s===ms.loading||_s===ms.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");As=gt.resolveURL(e),_s=ms.deferred,gs=t,vs(),i||ws()},e.fb=function(e){nf=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setMeshoptUrl",nf)},e.fc=uf,e.fd=function(e){ef=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setDracoUrl",ef)},e.fe=cf,e.ff=Qp,e.fg=function(e){const t=Et();if(!t)return;const i=t.delete(yt);e&&i.then(()=>e()).catch(e)},e.fh=Zp,e.fi=es,e.fj=bh,e.fk=E_,e.fl=Vx,e.fm=jx,e.fn=Nm,e.fo=Oc,e.fp="hd_road_elevation",e.fq=tu,e.fr=je,e.fs=ld,e.ft=v_,e.fu=A_,e.fv=function(e,t,i,n,r,o,s,a=1,l,c,u){e.createArrays(),e.tilePixelRatio=Nn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};p.scaleFactor=a,p.textSizeScaleRange=h.get("text-size-scale-range"),p.iconSizeScaleRange=h.get("icon-size-scale-range");const[f,m]=p.textSizeScaleRange,[g,_]=p.iconSizeScaleRange;p.textScaleFactor=Fe(p.scaleFactor,f,m),p.iconScaleFactor=Fe(p.scaleFactor,g,_);const A=d["text-size"],y=d["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[A.possiblyEvaluate(new Es(t,{worldview:u}),o),A.possiblyEvaluate(new Es(i,{worldview:u}),o)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[y.possiblyEvaluate(new Es(t,{worldview:u}),o),y.possiblyEvaluate(new Es(i,{worldview:u}),o)]}p.layoutTextSize=A.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.layoutIconSize=y.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.textMaxSize=A.possiblyEvaluate(new Es(18,{worldview:u}),o);const v=h.get("symbol-placement"),x="map"===h.get("text-rotation-alignment")&&"point"!==v,b=h.get("text-size");let w=!1;const T=[];for(const s of e.features){const a=h.get("text-font").evaluate(s,{},o).join(","),f=b.evaluate(s,{},o)*p.textScaleFactor,m=p.layoutTextSize.evaluate(s,{},o)*p.textScaleFactor,g=p.layoutIconSize.evaluate(s,{},o)*p.iconScaleFactor,_={horizontal:{},vertical:void 0},A=s.text;let y,E=[0,0];if(A){const n=A.toString(),c=h.get("text-letter-spacing").evaluate(s,{},o)*mg,u=h.get("text-line-height").evaluate(s,{},o)*mg,d=as(n)?c:0,p=h.get("text-anchor").evaluate(s,{},o),g=h.get("text-variable-anchor");if(!g){const e=h.get("text-radial-offset").evaluate(s,{},o);if(e)E=Q_(p,[e*mg,j_]);else{const e=h.get("text-offset").evaluate(s,{},o);E=[e[0]*mg,e[1]*mg]}}let y=x?"center":h.get("text-justify").evaluate(s,{},o);const b="point"===v,w=b?h.get("text-max-width").evaluate(s,{},o)*mg:1/0,T=o=>{e.allowVerticalPlacement&&ss(n)&&(_.vertical=Gg(A,t,i,r,a,w,u,p,o,d,E,Ng.vertical,!0,m,f,l))};if(!x&&g){const e="auto"===y?g.map(e=>eA(e)):[y];let n=!1;for(let o=0;o=0||!ss(n)){const e=Gg(A,t,i,r,a,w,u,p,y,d,E,Ng.horizontal,!1,m,f,l);e&&(_.horizontal[y]=e)}T(b?"left":y)}}let C,S,B,I,M,P,R=!1;const L=h.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){const t=q_(s.icon,e.iconSizeData,d["icon-size"],o,e.zoom,s,l,p.iconScaleFactor,u);C=t.iconPrimary,B=t.iconSecondary;const i=C.toString();if(S=n.get(i),S&&(M=h.get("icon-offset").evaluate(s,{},o),P=h.get("icon-anchor").evaluate(s,{},o),y=e_(r.get(i),B?r.get(B.toString()):void 0,M,P),R=S.sdf,void 0===e.sdfIcons?e.sdfIcons=S.sdf:e.sdfIcons!==S.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(S.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),B){const e=B.toString();I=n.get(e)}}w=w||!(!s.icon||!s.icon.hasSecondary());const F=sA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!F&&F.iconsInText);const k=m*p.textScaleFactor/mg,{defaultShapedIcon:D,verticallyShapedIcon:O}=tA(e,y,h,s,o,_,k,M,L);"none"!==L&&y&&(i_(y)||n_(y))&&(Z_(0,S,C,y,D,L,c,n,r),Z_(0,I,B,y,D,L,c,n,r),O&&(Z_(0,S,C,y,O,L,c,n,r),Z_(0,I,B,y,O,L,c,n,r))),y=D;const{iconBBox:z,iconVerticalBBox:U}=$_(e,y,O,h,s,o,g,M,p,r,P);T.push({feature:s,shapedTextOrientations:_,shapedText:F,shapedIcon:y,iconPrimary:C,iconSecondary:B,iconOffset:M,iconAnchor:P,verticallyShapedIcon:O,layoutTextSize:m,layoutIconSize:g,textOffset:E,isSDFIcon:R,iconTextFit:L,iconCollisionBounds:z,iconVerticalCollisionBounds:U})}return{featureData:T,sizes:p,hasAnySecondaryIcon:w,textAlongLine:x,symbolPlacement:v}},e.fw=x_,e.fx=function(e,t,i,n,r,o,s,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of u){const{shapedIcon:i,verticallyShapedIcon:o,feature:u,shapedTextOrientations:m,shapedText:g,layoutTextSize:_,textOffset:A,isSDFIcon:y,iconPrimary:v,iconSecondary:x,iconTextFit:b,iconOffset:w,iconCollisionBounds:T,iconVerticalCollisionBounds:E}=t;X_(i,c.iconPositions,v,x),X_(o,c.iconPositions,v,x),J_(m,c.iconPositions),K_(v,x,c.iconPositions),(g||i)&&iA(e,u,m,i,o,l,d,_,0,A,y,n,r,s,a,h,b,w,p,f,T,E)}i&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray,d.textScaleFactor)},e.fy=kc,e.fz=Wv,e.g=function(e,t){return zt(Object.assign(e,{method:"GET"}),t)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return st.API_STYLE_REGEX.test(e)&&!lt(e)},e.j=at,e.k=Bt,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return zt(Object.assign(e,{type:"json"}),t)},e.n=Ht,e.o=gt,e.p=function(e,t){return zt(Object.assign(e,{method:"POST"}),t)},e.q=wh,e.r=mt,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=function(){return Kp||(Kp=new Zp),Kp},e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(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)},e.w=Ze,e.x=Dv,e.y=ei,e.z=Yt}),n(["./shared"],function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const n of e)t+=`${i(n)},`;return`${t}]`}let t="{";for(const n of Object.keys(e).sort())t+=`${n}:${i(e[n])},`;return`${t}}`}function n(t){let n="";for(const r of e.bw)n+=`/${i(t[r])}`;return n}class r{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,r,o){this._options=o;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.dt(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const r={};for(let o=0;othis._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}const o=1*e.fk;class s{constructor(t){const i={},n=[];for(const e in t){const r=t[e],s=i[e]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};n.push(a),s[e]=a}}const{w:r,h:s}=e.G(n),a=new e.fj({width:r||1,height:s||1});for(const n in t){const r=t[n];for(const t in r.glyphs){const s=r.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][t],c=s.metrics.localGlyph?o:1;e.fj.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}function a(e,t,i){e[t]?i&&(e[t].center=i):e[t]={floorIds:new Set,center:i||[0,0],floors:{}}}function l(e,t,i,n){for(const r of t)a(e,r),e[r].floors[i]=n,e[r].floorIds.add(i)}function c(e){return{id:e.properties.id.toString(),center:e.properties.center.toString().split(";").map(Number)}}function u(e){return{id:e.properties.id.toString(),isDefault:!!e.properties.is_default&&e.properties.is_default,connections:e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:e.properties.building_ids?new Set(e.properties.building_ids.toString().split(";")):new Set,name:e.properties.name.toString(),zIndex:e.properties.z_index}}function h(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function d(e){return h(e,["type","id","name"])&&"building"===e.properties.type}function p(e){return h(e,["type","id","name","z_index"])&&"floor"===e.properties.type}e.fi(s,"GlyphAtlas");class f{constructor(t){this.tileID=new e.aP(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.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor}parse(t,i,n,r,o,h){this.status="parsing",this.data=t,this.collisionBoxArray=new e.b2;const f=new e.fl(Object.keys(t.layers).sort()),g=new e.fm(this.tileID,this.promoteId);g.bucketLayerIDs=[];const _={},A=new e.fn(256,256),y={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:A,availableImages:n,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const i=this.indoor.indoorState.activeFloorsVisible,n=function(t,i,n){const r=function(t,i){if(!t)return e.w("No source layers defined in indoor specification"),i;if(0===t.size)return i;const n=t.difference(i);for(const t of n)e.w(`Missing source layer required in indoor specification: ${t}`);return i.intersection(i)}(i.sourceLayers,new Set(Object.keys(t.layers))),o=i.indoorState,s=function(t,i,n,r){const o=new Set,s=new Set,h=new Set,f=new Map,m={},g=e=>{const t=f.get(e)||new Set;for(const i of o)if((f.get(i)||new Set).has(e)||t.has(i))return!0;return!1};for(const n of i){const i=t.layers[n];if(i)for(let e=0;e=i.maxzoom)continue;if("none"===i.visibility)continue;m(t,this.zoom,y.brightness,n,this.worldview);const o=_[i.id]=i.createBucket({index:g.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:c,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:r,worldview:this.worldview});g.bucketLayerIDs.push(t.map(t=>e.B(t.id,t.scope)));let s=o.prepare?o.prepare():null;null!=s?(s=s.then(()=>o.populate(u,y,this.tileID.canonical,this.tileTransform)),v.push(s)):o.populate(u,y,this.tileID.canonical,this.tileTransform)}}const b=()=>{let i,r,a,l,c,u;A.trim();const d={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},p=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster)this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:y.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(r&&a&&l){const t=new s(r),i=new Map;for(const[t,n]of a.entries()){const{imagePosition:r}=e.ft(t,n,e.fu);i.set(t,r)}const h={};for(const o in _){const s=_[o];s instanceof e.b3&&(m(s.layers,this.zoom,y.brightness,n,this.worldview),h[o]=e.fv(s,r,t.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,c,this.worldview))}const d={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(o,a,c,()=>{d.iconsPending=!1,v(h,t,d)}),this.rasterizeIfNeeded(o,l,u,()=>{d.patternsPending=!1,v(h,t,d)})}},v=(t,i,r,o)=>{if(r.iconsPending||r.patternsPending)return;const s=new e.fw(a,l,this.lut);for(const i in _){const r=_[i];if(i in t)e.fx(r,t[i],this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,s);else if(r.hasPattern&&(r instanceof e.b9||r instanceof e.ba||r instanceof e.e9)){m(r.layers,this.zoom,y.brightness,n,this.worldview);const e=Object.fromEntries(s.patternPositions);r.addFeatures(y,this.tileID.canonical,e,n,this.tileTransform,this.brightness)}}this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:A,imageAtlas:s,brightness:y.brightness})};if(!this.extraShadowCaster){const t=e.fr(y.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{i||(i=e,r=t,p())},void 0,!1,d):r={};const n=Array.from(y.iconDependencies.keys()).map(t=>e.I.parse(t));n.length?o.send("getImages",{images:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{i||(i=e,a=new Map,c=this.updateImageMapAndGetImageTaskQueue(a,t,y.iconDependencies),p())},void 0,!1,d):(a=new Map,c=new Map);const s=Array.from(y.patternDependencies.keys()).map(t=>e.I.parse(t));s.length?o.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{i||(i=e,l=new Map,u=this.updateImageMapAndGetImageTaskQueue(l,t,y.patternDependencies),p())},void 0,!1,d):(l=new Map,u=new Map)}if(y.elevationFeatures&&y.elevationFeatures.length>0){const i=[];for(const t of Object.values(_))if(t instanceof e.ba){const e=t.getUnevaluatedPortalGraph();e&&i.push(e)}const n=e.fs.evaluate(i);for(const i of Object.values(_))if(i instanceof e.ba){const e=t.layers[f.decode(i.sourceLayerIndex)];i.setEvaluatedPortalGraph(n,e,this.tileID.canonical,y.availableImages,y.brightness)}}p()};v.length>0?Promise.allSettled(v).then(b).catch(h):b()}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor}rasterizeIfNeeded(e,t,i,n){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,i,n):n()}updateImageMapAndGetImageTaskQueue(e,t,i){const n=new Map;for(const r of t.keys()){const o=i.get(r)||[];for(const i of o){const r=i.toString(),o=t.get(i.id.toString());o.usvg?n.has(r)||(n.set(r,i),e.set(r,Object.assign({},o))):e.set(r,o)}}return n}rasterize(e,t,i,n){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:i},(e,i)=>{if(!e)for(const[e,n]of i.entries()){const i=Object.assign(t.get(e),{data:n});t.set(e,i)}n()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function m(t,i,n,r,o){const s=new e.ac(i,{brightness:n,worldview:o});for(const e of t)e.recalculate(s,r)}class g extends e.E{constructor(t,i,n,r,o,s,a){super(),this.actor=t,this.layerIndex=i,this.availableImages=n,this.availableModels=r,this.loadVectorData=s||e.aL,this.loading={},this.loaded={},this.deduped=new e.aK(t.scheduler),this.isSpriteLoaded=o,this.scheduler=t.scheduler,this.brightness=a}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[r]=new f(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[r];if(delete this.loading[r],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[r]=a),n(l);const h=c.rawData,d={},p=e.aM(c.responseHeaders);p&&p.expires&&(d.expires=p.expires),p&&p.cacheControl&&(d.cacheControl=p.cacheControl),a.vectorTile=c.vectorTile||new e.fy(new e.bs(h));const f=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,i)=>{if(e||!i)return n(e);const r={};if(s){const e=t(o);e.length>0&&(r.resourceTiming=JSON.parse(JSON.stringify(e)))}n(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},i,d,r))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):f()}),this.loaded=this.loaded||{},this.loaded[r]=a})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.updateParameters(e);const o=(e,i)=>{const n=r.reloadCallback;n&&(delete r.reloadCallback,r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n)),t(e,i)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&(r.vectorTile?r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o):o())}else t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class _{loadTile(t,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.fz(n,a,r,s<1))}reloadTile(e,t){t(null,null)}abortTile(e,t){t()}removeTile(e,t){t()}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 i=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),i}}e.br.setPbf(e.bs);class A{constructor(t){this._mrt=new e.br(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source}parse(t,i){const n=this._mrt;this.status="parsing",this._entireBuffer=t;try{n.parseHeader(t),this._isHeaderLoaded=!0;const r=[];for(const i in n.layers){const o=n.getLayer(i),s=o.getDataRange(o.getBandList()),a=n.createDecodingTask(s),l=t.slice(s.firstByte,s.lastByte+1),c=e.br.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));r.push(c)}Promise.allSettled(r).then(()=>i(null,n)).catch(e=>i(e))}catch(e){i(e)}}}class y{constructor(e){this.actor=e,this.loading={},this.loaded={}}loadTile(t,i){const n=t.uid,r=t.request,o=this.loading[n]=new A(t),{cancel:s}=e.bt(r,(e,t,r)=>{const s=!this.loading[n];if(delete this.loading[n],s||e||!t)return o.status="done",s||(this.loaded[n]=o),i(e);o.parse(t,(e,t)=>{if(e||!t)return i(e);i(null,t,r)}),this.loaded[n]=o});o.abort=s}reloadTile(e,t){t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=e.uid;this.loaded[i]&&delete this.loaded[i],t()}decodeRasterArray(t,i){e.br.performDecoding(t.buffer,t.task).then(e=>i(null,e)).catch(e=>i(e))}}const v=e.fA.prototype.toGeoJSON;class x{constructor(t){this._feature=t,this.extent=e.al,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 i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const n=[];for(const t of i)n.push(new e.P(t[0],t[1]));t.push(n)}return t}}toGeoJSON(e,t,i){return v.call(this,e,t,i)}}class b{constructor(t,i){this.name=t,this.extent=e.al,this.length=i.length,this._jsonFeatures=i}feature(e){return new x(this._jsonFeatures[e])}}class w{constructor(t){this.layers={},this.extent=e.al;for(const e of Object.keys(t))this.layers[e]=new b(e,t[e])}}const T=64/4096,E=128;class C{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let n=this.features.get(e);n&&this.updateCache(n,t),i.geometry?(n=B(i),this.updateCache(n,t),this.features.set(e,n)):this.features.delete(e),this.updateCache(n,t)}}updateCache(e,t){for(const{canonical:i,uid:n}of Object.values(t)){const{z:r,x:o,y:s}=i;S(e,Math.pow(2,r),o,s)&&delete t[n]}}getTile(e,t,i){const n=Math.pow(2,e),r=[];for(const e of this.features.values())S(e,n,t,i)&&r.push(R(e,n,t,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function S({minX:e,minY:t,maxX:i,maxY:n},r,o,s){return e<(o+1+T)/r&&t<(s+1+T)/r&&i>(o-T)/r&&n>(s-T)/r}function B(e){const{id:t,geometry:i,properties:n}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)I(o,a,s);else if("MultiPoint"===r)for(const e of o)I(e,a,s);else if("LineString"===r)s.type=2,M(o,a,s);else if("MultiLineString"===r)s.type=2,P(o,a,s);else if("Polygon"===r)s.type=3,P(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)P(e,a,s,!0)}return s}function I([t,i],n,r){const o=e.aF(t);let s=e.aJ(i);s=s<0?0:s>1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function M(e,t,i,n=!1,r=!1){const o=[];for(const t of e)I(t,o,i);t.push(o),n&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(m*((a-u)/f)),u=a):d>=a&&(p=h+Math.round(m*((a-u)/f)),d=a),h>=a&&p>=a||(h>=a?(u+=Math.round(f*((a-h)/m)),h=a):p>=a&&(d=u+Math.round(f*((a-h)/m)),p=a),l&&u===l[l.length-1][0]&&h===l[l.length-1][1]||(l=[[u,h]],o.push(l)),l.push([d,p])))))}}function F({name:t,features:i},n){n.writeStringField(1,t),n.writeVarintField(5,e.al);const r=new Map,o=new Map,s={keys:r,values:o,feature:null};for(const e of i)s.feature=e,n.writeMessage(2,k,s);for(const e of r.keys())n.writeStringField(3,e);for(const e of o.keys())n.writeMessage(4,N,e)}function k(e,t){const i=e.feature;void 0!==i.id&&Number.isSafeInteger(+i.id)&&t.writeVarintField(1,+i.id),i.tags&&t.writeMessage(2,D,e),t.writeVarintField(3,i.type),t.writeMessage(4,U,i)}function D({keys:e,values:t,feature:i},n){for(const r of Object.keys(i.tags)){let o=i.tags[r];if(null===o)continue;let s=e.get(r);void 0===s&&(s=e.size,e.set(r,s)),n.writeVarint(s);const a=typeof o;"string"!==a&&"boolean"!==a&&"number"!==a&&(o=JSON.stringify(o));let l=t.get(o);void 0===l&&(l=t.size,t.set(o,l)),n.writeVarint(l)}}function O(e,t){return(t<<3)+(7&e)}function z(e){return e<<1^e>>31}function U(e,t){const{geometry:i,type:n}=e;let r=0,o=0;if(1===n){t.writeVarint(O(1,i.length));for(const e of i){const i=e[0]-r,n=e[1]-o;t.writeVarint(z(i)),t.writeVarint(z(n)),r+=i,o+=n}}else for(const e of i){t.writeVarint(O(1,1));const i=e.length-(3===n?1:0);for(let n=0;ne},j=Math.fround||(G=new Float32Array(1),e=>(G[0]=+e,G[0]));var G;const H=3,Q=5,$=6;class Z{constructor(e){this.options=Object.assign(Object.create(V),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(K(i),X(o),K(r),X(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+Q]>1?W(l,t,this.clusterProps):this.points[l[t+H]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+Q]>1?W(o,i,this.clusterProps):this.points[o[i+H]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=q(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+H]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),u=X(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+H]:this.points[t[e+H]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+Q])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+Q];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+Q]>1){const n=this.clusterProps[e[t+$]];return i?Object.assign({},n):n}const n=this.points[e[t+H]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function W(e,t,i){return{type:"Feature",id:e[t+H],properties:q(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),J(e[t+1])]}};var n}function q(e,t,i){const n=e[t+Q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+$],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+H],point_count:n,point_count_abbreviated:r})}function K(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Y(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&Y(e,t,s,n),e[s+2]=r,i-s>3&&Y(e,s,i,n))}function ee(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function te(e,t,i,n){const r={id:e??null,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ie(r,i);else if("Polygon"===t)ie(r,i[0]);else if("MultiLineString"===t)for(const e of i)ie(r,e);else if("MultiPolygon"===t)for(const e of i)ie(r,e[0]);return r}function ie(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,Y(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function se(e,t,i,n){for(let r=0;r1?1:i}function ce(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)ue(e,u,i,n,r);else if("LineString"===o)he(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)pe(e,u,i,n,r,!1);else if("Polygon"===o)pe(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];pe(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(te(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(te(t.id,o,u,t.tags))}}return l.length?l:null}function ue(e,t,i,n,r){for(let o=0;o=i&&s<=n&&fe(t,e[o],e[o+1],e[o+2])}}function he(e,t,i,n,r,o,s){let a=de(e);const l=0===r?me:ge;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=de(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&fe(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&fe(a,a[0],a[1],a[2]),a.length&&t.push(a)}function de(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pe(e,t,i,n,r,o){for(const s of e)he(s,t,i,n,r,o,!1)}function fe(e,t,i,n){e.push(t,i,n)}function me(e,t,i,n,r,o){const s=(o-t)/(n-t);return fe(e,o,i+(r-i)*s,1),s}function ge(e,t,i,n,r,o){const s=(o-i)/(r-i);return fe(e,t+(n-t)*s,o,1),s}function _e(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=xe(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=ce(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=ce(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=ce(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=ce(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=ce(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=ce(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Ce(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ye(this.tiles[a],r):null):null}}function Ce(e,t,i){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,s=r.features.filter(e=>o(e));let a={_geojsonTileLayer:r.features};s.length>0&&(a={_geojsonTileLayer:r.features.filter(e=>!o(e)),hd_road_elevation:s});const l=new w(a),c=function(t){const i=new e.bs;for(const e of Object.keys(t))i.writeMessage(3,F,{name:e,features:t[e]});return i.finish()}(a).buffer;i(null,{vectorTile:l,rawData:c})}class Be extends g{constructor(e,t,i,n,r,o,s){super(e,t,i,n,r,Se,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new C}loadData(i,n){const r=i&&i.request,o=r&&r.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(i,(s,a)=>{if(s||!a)return n(s);if("object"!=typeof a)return n(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>t.value.evaluate({zoom:0},e))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new Z(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.U(s),l=e.U("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(a.features):i.dynamic?this._dynamicIndex:function(e,t){return new Ee(e,t)}(a,i.geojsonVtOptions)}catch(e){return n(e)}const s={};if(o){const e=t(r);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}n(null,s)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.m(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}},0)}}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 Ie{constructor(t,i,n){this.tileID=new e.aP(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=i,this.worldview=n}parse(t,i,n,r){this.status="parsing";const o=new e.aP(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),s=[],a=i.familiesBySource[n.source],l=new e.fm(o,n.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,e.fB(t).then(t=>{if(!t)return r(new Error("Could not parse tile"));const i=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const r in a)for(const h of a[r]){const r=h[0];l.bucketLayerIDs.push(h.map(t=>e.B(t.id,t.scope))),r.recalculate(u,[]);const a=e.fC(t,1/e.d6(n.tileID.canonical)),d=new e.fD(h,a,o,i,c,this.brightness,l,this.worldview);i||(d.needsUpload=!0),s.push(d),d.evaluate(r)}this.status="done",r(null,{buckets:s,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>r(new Error(e.message)))}}class Me{constructor(e,t,i,n,r,o,s,a){this.actor=e,this.layerIndex=t,this.availableImages=i,this.availableModels=n,this.brightness=s,this.loading={},this.loaded={},this.worldview=a}loadTile(t,i){const n=t.uid,r=this.loading[n]=new Ie(t,this.brightness,this.worldview);e.bt(t.request,(e,o)=>{const s=!this.loading[n];return delete this.loading[n],s||e?(r.status="done",s||(this.loaded[n]=r),i(e)):o&&0!==o.byteLength?void r.parse(o,this.layerIndex,t,(e,t)=>{r.status="done",this.loaded=this.loaded||{},this.loaded[n]=r,e||!t?i(e):i(null,t)}):(r.status="done",this.loaded[n]=r,i())})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.projection=e.projection,r.brightness=e.brightness;const o=(i,n)=>{r.reloadCallback&&(delete r.reloadCallback,this.loadTile(e,t)),t(i,n)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class Pe{constructor(t){this.self=t,this.actor=new e.fF(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cl({name:"mercator"}),this.workerSourceTypes={vector:g,geojson:Be,"raster-dem":_,"raster-array":y,"batched-model":Me},this.workerSources={},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.fG.isParsed())throw new Error("RTL text plugin already registered.");e.fG.setState({pluginStatus:e.fH.parsed,pluginURL:e.fG.getPluginURL()}),e.fG.applyArabicShaping=t.applyArabicShaping,e.fG.processBidirectionalText=t.processBidirectionalText,e.fG.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:n,isLoaded:r}=i;if(this.isSpriteLoaded[t][n]=r,this.workerSources[t]&&this.workerSources[t][n])for(const i in this.workerSources[t][n]){const o=this.workerSources[t][n][i];for(const t in o){const i=o[t];i instanceof g&&(i.isSpriteLoaded=r,i.fire(new e.z("isSpriteLoaded")))}}}setImages(e,t,i){this.availableImages[e]||(this.availableImages[e]={});const{scope:n,images:r}=t;if(this.availableImages[e][n]=r,this.workerSources[e]&&this.workerSources[e][n]){for(const t in this.workerSources[e][n]){const i=this.workerSources[e][n][t];for(const e in i)i[e].availableImages=r}i()}else i()}setModels(e,{scope:t,models:i},n){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const n in this.workerSources[e][t]){const r=this.workerSources[e][t][n];for(const e in r)r[e].availableModels=i}n()}else n()}setProjection(t,i){this.projections[t]=e.cl(i)}setBrightness(e,t,i){this.brightness=t,i()}setWorldview(e,t,i){this.worldview=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){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 n=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,n){if(e.fG.isParsed())n(null,!0);else if(e.fG.isParsing())this.rtlPluginParsingListeners.push(n);else try{e.fG.setState(i);const t=e.fG.getPluginURL();!e.fG.isLoaded()||e.fG.isParsed()||e.fG.isParsing()||null==t||(e.fG.setState({pluginStatus:e.fH.parsing,pluginURL:e.fG.getPluginURL()}),this.self.importScripts(t),e.fG.isParsed()?n(null,!0):this.rtlPluginParsingListeners.push(n))}catch(e){n(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let i=this.availableModels[e][t];return i||(i={}),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new r,i.scope=t),i}getWorkerSource(e,t,i,n){const r=this.workerSources;return r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][t]||(r[e][n][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),r[e][n][t][i]||(r[e][n][t][i]=new this.workerSourceTypes[t]({send:(t,i,n,r,o,s)=>this.actor.send(t,i,n,e,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(e,n),this.getAvailableImages(e,n),this.getAvailableModels(e,n),this.isSpriteLoaded[e][n],void 0,this.brightness,this.worldview)),r[e][n][t][i]}rasterizeImagesWorker(e,t,i){const n=new Map;for(const[i,{image:r,imageVariant:o}]of t.tasks.entries()){const s=this.imageRasterizer.rasterize(o,r,t.scope,e);n.set(i,s)}i(void 0,n)}removeRasterizedImages(e,t,i){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),i()}enforceCacheSizeLimit(t,i){e.fI(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return e.fE(self)&&(self.worker=new Pe(self)),Pe}),n(["./shared"],function(e){var t="3.16.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},n={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function r(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var o,s={},a=function(){if(o)return s;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(i);try{t=new Worker(n),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(n),e}()?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===i[n=t&&t.failIfMajorPerformanceCaveat]&&(i[n]=function(t){var i,n=function(t){var i=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",n)}(t);if(!n)return!1;try{i=n.createShader(n.VERTEX_SHADER)}catch(e){return!1}return!(!i||n.isContextLost())&&(n.shaderSource(i,"void main() {}"),n.compileShader(i),!0===n.getShaderParameter(i,n.COMPILE_STATUS))}(n)),i[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var n}o=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const n=document.createElement(e);return null!=t&&(n.className=t),i&&i.appendChild(n),n}function c(e,t,i){const n=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))n.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(n),n}const u="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,h=u&&void 0!==u.userSelect?"userSelect":"WebkitUserSelect";let d;function p(){u&&h&&(d=u[h],u[h]="none")}function f(){u&&h&&(u[h]=d)}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0)}function g(){window.addEventListener("click",m,!0),window.setTimeout(()=>{window.removeEventListener("click",m,!0)},0)}function _(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function A(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;rthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,n){if(!e.h(i))return i;const r=E(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||n)}normalizeGlyphsURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/models/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeSourceURL(t,i,n,r){if(!e.h(t))return t;const o=E(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),n&&o.params.push(`language=${n}`),r&&o.params.push(`worldview=${r}`),this._makeAPIURL(o,this._customAccessToken||i)}normalizeIconsetURL(t,i){const n=E(t);return e.h(t)?(n.path=`/styles/v1${n.path}/iconset.pbf`,this._makeAPIURL(n,this._customAccessToken||i)):C(n)}normalizeSpriteURL(t,i,n,r){const o=E(t);return e.h(t)?(o.path=`/styles/v1${o.path}/sprite${i}${n}`,this._makeAPIURL(o,this._customAccessToken||r)):(o.path+=`${i}${n}`,C(o))}normalizeTileURL(t,i,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.h(t))return t;const r=E(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||n&&"raster"!==r.authority&&512===n?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.e.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.e.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${e.e.TILE_URL_VERSION}${r.path}`);const o=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,o)}canonicalizeTileURL(t,i){const n=E(t);if(!n.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!n.path.match(/\.[\w]+$/))return t;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+=`raster/${n.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:n.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${n.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${n.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=n.params;return i&&(o=o.filter(e=>!e.match(/^access_token=/))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,i){const n=!!i&&e.h(i),r=[];for(const i of t.tiles||[])e.j(i)?r.push(this.canonicalizeTileURL(i,n)):r.push(i);return r}_makeAPIURL(t,i){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=E(e.e.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return C(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),C(t)}}const T=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function E(e){const t=e.match(T);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 C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const S="mapbox.eventData";function B(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}class I{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=B(e.e.ACCESS_TOKEN);let n="";return n=i&&i.u?e.f(i.u):e.e.ACCESS_TOKEN||"",t?`${S}.${t}:${n}`:`${S}:${n}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(n);t&&(this.anonId=t);const o=localStorage.getItem(r);o&&(this.anonIdTimestamp=Number(o));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString())}catch(t){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(t,i,n,r){if(!e.e.EVENTS_URL)return;const o=E(e.e.EVENTS_URL);o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:C(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const M=new class extends I{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(t,i){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(t=>e.h(t)||e.j(t))&&this.queueRequest(Date.now(),i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=B(e.e.ACCESS_TOKEN),r=n?n.u:e.e.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),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:t,skuId:x,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)},i):this.processRequests()}},P=M.postTurnstileEvent.bind(M),R=new class extends I{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.EVENTS_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:n,timestamp:r}=this.queue.shift();n&&this.success[n]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):n&&(this.success[n]=!0)},i))}remove(){this.errorCb=null}},L=R.postMapLoadEvent.bind(R),F=new class extends I{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:n,style:r,importedStyles:o}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const s=this.getMapInstanceId(n),a={mapInstanceId:s,eventId:this.getEventId(s),style:r};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},k=F.postStyleLoadEvent.bind(F),D=new class extends I{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(t){if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),O=D.postMetricsEvent.bind(D),z=new class extends I{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(n){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:o,performanceData:s}=this.queue.shift(),a=function(n){const o=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const n of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,n.startTime),t[r]=Math.max(t[r]||-1/0,n.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(o)}return t}(function(e,t){const i={};if(e)for(const n of e){const e=t(n);void 0===i[e]&&(i[e]=[]),i[e].push(n)}return i}(o,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,u=c?c.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in a)d(h.counters,e,a[e]);if(n.interactionRange[0]!==1/0&&n.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",n.interactionRange[0]),d(h.counters,"interactionRangeMax",n.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&d(h.counters,e,t.startTime)}return d(h.counters,"visibilityHidden",n.visibilityHidden),d(h.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(o)),d(h.attributes,"terrainEnabled",n.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",n.fogEnabled?"true":"false"),d(h.attributes,"projection",n.projection),d(h.attributes,"zoom",n.zoom),d(h.metadata,"devicePixelRatio",l),d(h.metadata,"connectionEffectiveType",u),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",n.width/l),d(h.metadata,"mapHeight",n.height/l),d(h.metadata,"webglRenderer",n.renderer),d(h.metadata,"webglVendor",n.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(o,a,()=>{},n)}},U=z.postPerformanceEvent.bind(z),N=new class extends I{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,n,r){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const o=E(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${i||""}`),o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={url:C(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.SESSION_PATH&&e.e.API_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}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)}remove(){this.errorCb=null}},V=N.getSessionAPI.bind(N),j=new Set;function G(e,t){t?j.add(e):j.delete(e)}class H{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}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(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty()}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Q(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class $ extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.r()&&(this.imageRasterizerDispatcher=new e.D(e.t(),this,"Image Rasterizer Worker",1))}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({width:1,height:1}))}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e))}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e)}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e)}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.x),this._imageRasterizer}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return!1;return!0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(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.get(t).get(e.toString())}addImage(e,t,i){this._validate(e,i)&&this.images.get(t).set(e.toString(),i)}_validate(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]e.I.from(t))}getImages(e,t,i){const n=[],r=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){n.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i))}if(0===n.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of n)l.has(e.toString())||(s=!1);a||s?this._notify(n,t,i):this.requestors.push({ids:n,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:n,scope:r}=e;for(const[e,t]of n.entries()){const n=this.getImage(t.id,r);n&&i.set(e,{image:n,imageVariant:t})}this._rasterizeImages(r,i,t)}_rasterizeImages(t,i,n){if(e.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},n);else{const e=new Map;for(const[n,{image:r,imageVariant:o}]of i.entries())e.set(n,this.imageRasterizer.rasterize(o,r,t,0));n(void 0,e)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,n){const r=this.images.get(i),o=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.z("styleimagemissing",{id:i.name}))}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" 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.`);continue}const n={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(n,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),o.set(e.I.toString(i),n)}n(null,o)}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(t,i,n){const r=t.toString(),o=this.patterns.get(i),s=o.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version}else{if(a.usvg&&!a.data){const o=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(o))return null;this.patternsInFlight.add(o);const s=new e.A(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(s,i,a,n,t)),null}this.storePattern(t,i,a)}return this._updatePatternAtlas(i,n),o.get(r).position}getPatternInFlightId(t,i){return e.B(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,n,r){const o=e.toString(),s=r?r.get(o):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,n),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(t,i,n){const r={w:n.data.width+2*e.C,h:n.data.height+2*e.C,x:0,y:0},o=new e.F(r,n,e.C);this.patterns.get(i).set(t.toString(),{bin:r,position:o})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(t,i){const n=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),n.RGBA8),this.atlasTexture.set(i,r)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const n=this.patterns.get(t),r=Array.from(n.values()).map(({bin:e})=>e),{w:o,h:s}=e.G(r),a=this.atlasImage.get(t);a.resize({width:o||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:o}]of n.entries()){let n=o.padding;const s=r.x+n,c=r.y+n,u=l.get(t).data,h=u.width,d=u.height;n=n>1?n-1:n,e.q.copy(u,a,{x:0,y:0},{x:s,y:c},{width:h,height:d},i),e.q.copy(u,a,{x:0,y:d-n},{x:s,y:c-n},{width:h,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s,y:c+d},{width:h,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:h-n,y:d-n},{x:s-n,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:d-n},{x:s+h,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c+d},{width:n,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c+d},{width:n,height:n},i)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const n of e){if(this.callbackDispatchedThisFrame.get(t).has(n.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(n.toString());const e=i.get(n.toString());Q(e)&&this.updateImage(n,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Z(t){const i=t.value,n=t.valueSpec,r=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||me;if(!Array.isArray(i))return[new e.V(s,i,`array expected, ${e.K(i)} found`)];if(n.length&&i.length!==n.length)return[new e.V(s,i,`array length ${n.length} expected, length ${i.length} found`)];if(n["min-length"]&&i.lengtho)return[new e.V(i,n,`${n} is greater than the maximum value ${o}`)]}return[]}function q(t){const i=t.key,n=t.value;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];const r=t.valueSpec,o=e.J(n.type);let s,a,l,c={};const u="categorical"!==o&&void 0===n.property,h=!u,d=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.H(i[0][0])}(n),p=ge({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat(Z({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),Array.isArray(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return me({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&u&&p.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||n.stops||p.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&r.expression&&!e.M(r)&&p.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!e.N(r)?p.push(new e.V(t.key,t.value,"property functions not supported")):u&&!e.O(r)&&p.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!d||void 0!==n.property||p.push(new e.V(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const n=t.value,o=t.key;if(!Array.isArray(n))return[new e.V(o,n,`array expected, ${e.K(n)} found`)];if(2!==n.length)return[new e.V(o,n,`array length 2 expected, length ${n.length} found`)];if(d){if(!e.H(n[0]))return[new e.V(o,n,`object expected, ${e.K(n[0])} found`)];const r=n[0];if(void 0===r.zoom)return[new e.V(o,n,"object stop key must have zoom")];if(void 0===r.value)return[new e.V(o,n,"object stop key must have value")];const s=e.J(r.zoom);if("number"!=typeof s)return[new e.V(o,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return[new e.V(o,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(ge({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:m}}))}else i=i.concat(m({key:`${o}[0]`,value:n[0],style:t.style,styleSpec:t.styleSpec},n));return e.Q(e.S(n[1]))?i.concat([new e.V(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(me({key:`${o}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const n=e.K(t.value),l=e.J(t.value),u=null!==t.value?t.value:i;if(s){if(n!==s)return[new e.V(t.key,u,`${n} stop domain type must match previous stop domain type ${s}`)]}else s=n;if("number"!==n&&"string"!==n&&"boolean"!==n&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==n&&"categorical"!==o){let i=`number expected, ${n} found`;return e.N(r)&&void 0===o&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,i)]}return"categorical"!==o||"number"!==n||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===n&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew e.V(`${t.key}${i.key}`,t.value,i.message));const n=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.Z(n))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return X(n,t);if("appearance"===t.expressionContext)return J(n,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(n,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(n))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function X(t,i){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.delete(e);if(0===n.size)return[];const r=[];return t instanceof e._&&n.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...X(e,i))}),r)}function J(t,i){const n=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.add(e);if(0===n.size)return[];const r=[];return t instanceof e._&&!n.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{r.push(...J(e,i))}),r)}function Y(t){const i=t.key,n=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),o}function ee(t){return e.a2(e.S(t.value))?K(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):te(t)}function te(t){const i=t.value,n=t.key;if(!Array.isArray(i))return[new e.V(n,i,`array expected, ${e.K(i)} found`)];if(i.length<1)return[new e.V(n,i,"filter array must have at least 1 element")];const r=t.styleSpec;let o=Y({key:`${n}[0]`,value:i[0],valueSpec:r.filter_operator});switch(e.J(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.J(i[1])&&o.push(new e.V(n,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&o.push(new e.V(n,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(e.a0(i[1])||o.push(new e.V(`${n}[1]`,i[1],`string expected, ${e.K(i[1])} found`)));for(let t=2;t{t in n&&i.push(new e.V(r,n[t],`"${t}" is prohibited for ref layers`))}),o.layers.forEach(i=>{e.J(i.id)===l&&(t=i)}),t?t.ref?i.push(new e.V(r,n.ref,"ref cannot reference another ref layer")):a=e.J(t.type):"string"==typeof l&&i.push(new e.V(r,n.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(n.source)if(e.a0(n.source)){const t=o.sources&&o.sources[n.source],s=t&&e.J(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==s||n["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&n.paint&&(n.paint["line-gradient"]||n.paint["line-trim-offset"])&&"geojson"===s&&!t.lineMetrics?i.push(new e.V(r,n,`layer "${n.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(r,n.source,`layer "${n.id}" requires a 'raster-array' source.`)):i.push(new e.V(r,n.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(r,n,`layer "${n.id}" must specify a "source-layer"`)):i.push(new e.V(r,n.source,`source "${n.source}" not found`))}else i.push(new e.V(`${r}.source`,n.source,'"source" must be a string'));else i.push(new e.V(r,n,'missing required property "source"'));return i=i.concat(ge({key:r,value:n,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>me({key:`${r}.type`,value:n.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"}),filter:e=>ee(Object.assign({layerType:a},e)),layout:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>re(Object.assign({layerType:a},e))}}),paint:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ne(Object.assign({layerType:a,layer:n},e))}}),appearances(t){const i=Z({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:n,layerType:r}=t,o=e.J(t.value),s=e.J(o.name),a=e.J(o.condition),l=ge({key:i,value:o,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...K({key:t.key,value:t.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:n,layerType:r},t)),properties:t=>function(t){const i=[],{styleSpec:n,layer:r,layerType:o}=t,s=n[`paint_${o}`],a=n[`layout_${o}`],l=t.object[t.objectKey];for(const n in l){const c=n in s?"paint":n in a?"layout":void 0;if(!c){i.push(new e.V(t.key,n,`unknown property "${n}" for layer type "${o}"`));continue}const u=Object.assign({},t,{key:`${t.key}.${n}`,object:l,objectKey:n,layer:r,layerType:o,value:l[n],valueSpec:"paint"===c?s[n]:a[n]});i.push(...ie(u,c))}return i}(Object.assign({layer:n,layerType:r},t))}});return"hidden"!==s&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:n},t))}),r=Array.isArray(t.value)?t.value:[],o=new Set;return r.forEach((r,s)=>{const a=e.J(r.name);if(a)if(o.has(a)){const r=e.J(n.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`))}else o.add(a)}),i}}})),i}function se({key:t,value:i}){return e.a0(i)?[]:[new e.V(t,i,`string expected, ${e.K(i)} found`)]}const ae={promoteId:function t({key:i,value:n}){if(e.a0(n))return se({key:i,value:n});if(Array.isArray(n)){const t=[],r=e.S(n),o=e.U(r);return"error"===o.result&&o.value.forEach(n=>{t.push(new e.V(`${i}${n.key}`,null,`${n.message}`))}),e.X(o.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!e.H(n))return[new e.V(i,n,`string, expression or object expected, "${e.K(n)}" found`)];const r=[];for(const e in n)r.push(...t({key:`${i}.${e}`,value:n[e]}));return r}};function le(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];if(!("type"in i))return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new e.a3(n,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(ge({key:n,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ae})),a;case"geojson":if(a=ge({key:n,value:i,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:ae}),"cluster"in i&&"clusterProperties"in i){if(!e.H(i.clusterProperties))return[new e.V(`${n}.clusterProperties`,i,`object expected, ${e.K(i)} found`)];for(const t in i.clusterProperties){const r=i.clusterProperties[t];if(!Array.isArray(r))return[new e.V(`${n}.clusterProperties.${t}`,r,"array expected")];const[o,s]=r,l="string"==typeof o?[o,["accumulated"],["get",t]]:o;a.push(...K({key:`${n}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...K({key:`${n}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}))}}return a;case"video":return ge({key:n,value:i,valueSpec:r.source_video,style:o,styleSpec:r});case"image":return ge({key:n,value:i,valueSpec:r.source_image,style:o,styleSpec:r});case"canvas":return[new e.V(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Y({key:`${n}.type`,value:i.type,valueSpec:{values:ce(r)}})}}function ce(e){return e.source.reduce((t,i)=>{const n=e[i];return"enum"===n.type.type&&(t=t.concat(Object.keys(n.type.values||{}))),t},[])}function ue(t){const i=t.value,n=t.styleSpec,r=n.light,o=t.style;if(void 0===i)return[];if(!e.H(i))return[new e.V("light",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&r[l[1]]?me({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:n}):a&&r[a[1]]&&r[a[1]].transition?me({key:t,value:i[t],valueSpec:n.transition,style:o,styleSpec:n}):r[t]?me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function he(t){const i=t.value;if(!i)return[];const n=t.key;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];let r=[];const o=t.styleSpec,s=o["light-3d"],a=t.style,l=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V(n,i,`missing property "${t}"`)]),r;if(!e.a0(i.type))return r=r.concat([new e.V(`${n}.type`,i.type,"string expected")]),r;if(l)for(let o=0;o[],array:Z,boolean:function(t){const i=t.value,n=t.key;return e.$(i)?[]:[new e.V(n,i,`boolean expected, ${e.K(i)} found`)]},number:W,color:function({key:t,value:i}){return e.a0(i)?null===e.a1.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.K(i)} found`)]},enum:Y,filter:ee,function:q,layer:oe,object:ge,source:le,model:e.a7,light:ue,"light-3d":he,terrain:de,fog:pe,string:se,formatted:function(e){return 0===se(e).length?[]:K(e)},resolvedImage:function(e){return 0===se(e).length?[]:K(e)},projection:function(t){const i=t.value,n=t.styleSpec,r=n.projection,o=t.style;if(e.H(i)){let e=[];for(const t in i)e=e.concat(me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}));return e}return e.a0(i)?[]:[new e.V("projection",i,`object or string expected, ${e.K(i)} found`)]},import:function(t){const i=t.key,{value:n,styleSpec:r}=t;if(!e.H(n))return[new e.V(i,n,"import must be an object")];const{data:o,...s}=n;Object.defineProperty(s,"__line__",{value:n.__line__,enumerable:!1});let a=ge(Object.assign({},t,{value:s,valueSpec:r.import}));return""===e.J(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),o&&(a=a.concat(Ae(o,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,"object expected")];if(!i.type)return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];if(a=a.concat(ge({key:n,value:i,valueSpec:r[`iconset_${s}`],style:o,styleSpec:r})),function(e,t){return!("source"!==e||!t.source)}(s,i)){const t=o.sources&&o.sources[i.source],r=t&&e.J(t.type);t?"raster-array"!==r&&a.push(new e.V(n,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new e.V(n,i.source,`source "${i.source}" not found`))}return a}};function me(t,i=!1){const n=t.value,r=t.valueSpec,o=t.styleSpec;if(r.expression){if(e.a4(e.J(n)))return q(t);if(e.Q(e.S(n)))return K(t)}if(r.type&&fe[r.type]){const e=fe[r.type](t);return!0===i&&e.length>0&&Array.isArray(t.value)?K(t):e}return ge(Object.assign({},t,{valueSpec:r.type?o[r.type]:r}))}function ge(t){const i=t.key,n=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];let l=[];for(const t in n){const c=t.split(".")[0];let u;o[c]?u=o[c]:r[c]?u=me:o["*"]?u=o["*"]:r["*"]&&(u=me),u?l=l.concat(u({key:(i?`${i}.`:i)+t,value:n[t],valueSpec:r[c]||r["*"],style:s,styleSpec:a,object:n,objectKey:t},n)):l.push(new e.a3(i,n[t],`unknown property "${t}"`))}for(const t in r){if(o[t])continue;const s=r[t];s.required&&void 0===s.default&&void 0===n[t]&&l.push(new e.V(i,n,`missing required property "${t}"`))}return l}function _e({key:t,value:i}){const n=se({key:t,value:i});if(n.length)return n;const r=i;return-1===r.indexOf("{fontstack}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),n}function Ae(t,i=e.a6,n={}){return ge({key:n.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:_e}})}function ye(t,i=e.a6){return Re(Ae(t,i))}const ve=e=>Re(le(e)),xe=e=>Re(ue(e)),be=e=>Re(he(e)),we=e=>Re(de(e)),Te=e=>Re(pe(e)),Ee=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.snow;if(void 0===i)return[];if(!e.H(i))return[new e.V("snow",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Ce=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.rain;if(void 0===i)return[];if(!e.H(i))return[new e.V("rain",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Se=e=>Re(oe(e)),Be=e=>Re(ee(e)),Ie=e=>Re(ne(e)),Me=e=>Re(re(e)),Pe=t=>Re(e.a7(t));function Re(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Le(t,i){let n=!1;if(i&&i.length)for(const r of i)r instanceof e.a3?e.w(r.message):(t.fire(new e.y(new Error(r.message))),n=!0);return n}const Fe=e.a6.light;let ke;class De extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a8(ke||(ke=new e.a9({anchor:new e.aa(Fe.anchor),position:new e.ab(Fe.position),color:new e.aa(Fe.color),intensity:new e.aa(Fe.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(xe,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(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}const Oe=e.a6.terrain;let ze=class extends e.E{constructor(t,i,n,r,o){super(),this.scope=n,this._transitionable=new e.a8(new e.a9({source:new e.aa(Oe.source),exaggeration:new e.aa(Oe.exaggeration)}),n,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=o}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(t){return this._transitioning.possiblyEvaluate(new e.ac(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let n=-1,r=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.ac(t,{worldview:this.worldview})),o>.01?(n=t,r=-1):r=t;return o<.01&&n>0&&r>n?[n,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ad}};const Ue=45,Ne=65,Ve=.05;function je(t,i,n,r){const o=e.ah(Ue,Ne,n),[s,a]=Ge(t,r);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function Ge(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function He(t,i,n,r,o){const s=e.af([],[i,n,r],o.mercatorFogMatrix);return je(t,e.ag(s),o.pitch,o._fov)}function Qe(t,i,n,r,o,s,a){const l=[[n,r,0],[o,r,0],[o,s,0],[n,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const n=e.af([],t,i),r=e.ag(n);c=Math.min(c,r),u=Math.max(u,r)}return[je(t,c,a.pitch,a._fov),je(t,u,a.pitch,a._fov)]}const $e=e.a6.fog;class Ze extends e.E{constructor(t,i,n,r){super();const o=new e.a9({range:new e.aa($e.range),color:new e.aa($e.color),"color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.aa($e["high-color"]),"high-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.aa($e["space-color"]),"space-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.aa($e["horizon-blend"]),"star-intensity":new e.aa($e["star-intensity"]),"vertical-range":new e.aa($e["vertical-range"])});this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ai(o),this.scope=n}get state(){const t=this._transform,i="globe"===t.projection.name,n=e.aj(t.zoom),r=this.properties.get("range"),o=[.5,3];return{range:i?[e.ak(o[0],r[0],n),e.ak(o[1],r[1],n)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Te,e,i))return;const n=Object.assign({},e);for(const e of Object.keys($e))void 0===n[e]&&(n[e]=$e[e].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,t)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.ah(Ue,Ne,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,n){const r=e.ae.fromLngLat(i),o=n.elevation?n.elevation.getAtPointOrZero(r):0;return He(t,r.x,r.y,o,n)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Qe(this.state,i,0,0,e.al,e.al,this._transform)}getOpacityForBounds(e,t,i,n,r){return this._transform.projection.supportsFog?Qe(this.state,e,t,i,n,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Ge(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const n of i){const i=t.points[n];let r;if(i[2]>=0)r=i;else{const o=t.points[n-4];r=e.am(o,i,o[2]/(o[2]-i[2]))}if(He(this.state,r[0],r[1],0,this._transform)>=Ve)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let We,qe,Ke,Xe,Je=class extends e.E{constructor(t,i,n,r){super();const o=We||(We=new e.a9({density:new e.aa(e.a6.snow.density),intensity:new e.aa(e.a6.snow.intensity),color:new e.aa(e.a6.snow.color),opacity:new e.aa(e.a6.snow.opacity),vignette:new e.aa(e.a6.snow.vignette),"vignette-color":new e.aa(e.a6.snow["vignette-color"]),"center-thinning":new e.aa(e.a6.snow["center-thinning"]),direction:new e.aa(e.a6.snow.direction),"flake-size":new e.aa(e.a6.snow["flake-size"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ee,t,n))return;const r=Object.assign({},t),o=e.a6.snow;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},Ye=class extends e.E{constructor(t,i,n,r){super();const o=qe||(qe=new e.a9({density:new e.aa(e.a6.rain.density),intensity:new e.aa(e.a6.rain.intensity),color:new e.aa(e.a6.rain.color),opacity:new e.aa(e.a6.rain.opacity),vignette:new e.aa(e.a6.rain.vignette),"vignette-color":new e.aa(e.a6.rain["vignette-color"]),"center-thinning":new e.aa(e.a6.rain["center-thinning"]),direction:new e.aa(e.a6.rain.direction),"droplet-size":new e.aa(e.a6.rain["droplet-size"]),"distortion-strength":new e.aa(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ce,t,n))return;const r=Object.assign({},t),o=e.a6.rain;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};class et extends e.E{constructor(t,i,n,r){super(),this.scope=n,this._options=t,this.properties=new e.ai(i),this._transitionable=new e.a8(i,n,new Map(r)),this._transitionable.setTransitionOrValue(t.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")}}class tt{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,i){let n,r;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);n=[o],r=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]),a=o.add(s)._div(2);n=[o,s],r=e.aq(o,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a)}return new tt(n,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.aq(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.ar(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.x))){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o}return r}containsTile(t,i,n,r=0){const o=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map(i=>e.as(t.tileTransform,i,a));if(!e.at(l,0,0,e.al,e.al))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.au(t.tileTransform,i,a)),u=c.map(t=>new e.P(t[0],t[1])),h=i.getFreeCameraOptions().position||new e.ae(0,0,0),d=e.au(t.tileTransform,h,a),p=c.map(t=>{const i=e.av(t,t,d);return e.aw(i,i),new e.ax(d,i)}),f=e.ay(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.az(l),m.min.x=e.aA(m.min.x,0,e.al),m.min.y=e.aA(m.min.y,0,e.al),m.max.x=e.aA(m.max.x,0,e.al),m.max.y=e.aA(m.max.y,0,e.al),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=rt(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=rt(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.aB([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aD,0,1],o=[0,e.aD,0,1],s=[0,0,0,1];e.aC(r,r,n),e.aC(o,o,n),e.aC(s,s,n);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.aE(t,a)&&r[3]1?it(t.slice(0,d),i):[],m=dnew e.P(nt(t.x),t.y)),m=m.map(t=>new e.P(nt(t.x),t.y));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.ak(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,p);let A;return A=c?[new e.P(0,_),new e.P(0,0),new e.P(1,0),new e.P(1,_)]:[new e.P(1,_),new e.P(1,1),new e.P(0,1),new e.P(0,_)],g.push(...A),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map(t=>new e.ae(t.x,t.y)),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,o=0;for(let e=0;er&&(r=t[e].x,o=e);for(let e=0;e.5&&(r.x{e.x-=1}),{polygon:t,unwrapped:n}}(it(t,i).map(t=>new e.P(nt(t.x),t.y)),i);return{polygon:r.polygon.map(t=>new e.ae(t.x,t.y)),unwrapped:r.unwrapped}}}function it(t,i){return e.aG(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function nt(e){return e<0?1+e%1:e%1}function rt(e){return 100*e|0}function ot(t,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){if(t.url&&r.tiles&&t.tiles&&delete t.tiles,r.variants){if(!Array.isArray(r.variants))return o(new Error("variants must be an array"));for(const e of r.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return o(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){r=Object.assign(r,e);break}}}const n=e.aH(Object.assign({},r,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);n.tiles=i.canonicalizeTileset(n,t.url),o(null,n)}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const o=n.every(e=>e===t),s=r.every(e=>e===i);return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,n,r);return a?e.o.frame(()=>s(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,n,r),e.R.Source),s):e.o.frame(()=>{const{data:e,...i}=t;s(null,i)})}function st(t,i){const n=Math.pow(2,i.z),r=Math.floor(e.aF(t.getWest())*n),o=Math.floor(e.aJ(t.getNorth())*n),s=Math.ceil(e.aF(t.getEast())*n),a=Math.ceil(e.aJ(t.getSouth())*n);return i.x>=r&&i.x=o&&i.ythis.maxzoom||e.z{if(this._tileJSONRequest=null,this._loaded=!0,r)i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r));else if(o){if(Object.assign(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers){this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of o.vector_layers)this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id)}this.tileBounds=at.fromTileJSON(o),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}t&&t(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 t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(t,i){const n=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(n),o=this.map._requestManager.transformRequest(r,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:o,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&e.h(n)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aL.call({deduped:this._deduped},l,(i,n)=>{if(i||!n)c.call(this,i);else{const i=e.aM(n.responseHeaders);l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0)}},!0);t.request={cancel:i}}function c(n,r){return delete t.request,t.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.aN(this.dispatcher),i(null,r),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.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,t){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 ct extends e.E{constructor(t,i,n,r){super(),this.id=t,this.dispatcher=n,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=Object.assign({type:"raster"},i),Object.assign(this,e.aH(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,null,i,(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(Object.assign(this,n),n.raster_layers&&(this.rasterLayers=n.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=at.fromTileJSON(n),P(n.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.o.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(r,e.R.Tile),(n,r,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n)return t.state="errored",i(n);if(!r)return i(null);const s=e.aM(o);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(r,this.map.painter),t.state="loaded",e.aN(this.dispatcher),i(null)})}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ut([t,i],n,r,{scaled:o=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:u}=n;if(!isFinite(l)||!isFinite(c)||!isFinite(u))throw new Error("Invalid MRT header");const h=2**u,d=h*e.aF(t),p=h*e.aJ(i);return function([e,t],i,{scaled:n=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:o,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>o+s||t<-s||t>o+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${s}`);const u=(t+s)*(o+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[u])return null;let h=[];h=n?[]:new i.data.constructor(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n){if("AbortError"===n.name)return;return t.state="errored",i(n)}if(this.map._refreshExpiredTiles&&r){const i=e.aM(o);t.setExpiryData(i)}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r}i(null)};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",o,s.bind(this),void 0,!0)}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,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!0);for(const e of i.values())this.map.painter.saveTileTexture(e)}else e.destroy()}prepareTile(t,i,n,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,n,r,(i,r)=>{if(i)return t.state="errored",this.fire(new e.y(i)),void this.triggerRepaint(t);r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(n,r,this.map.painter),t.state="loaded",this.triggerRepaint(t))}))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,n=i&&i.bands&&i.bands;return n?n[0]:0}getTextureDescriptor(t,i,n){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let o=null;i instanceof e.aQ?o=i.paint.get("raster-array-band"):i instanceof e.aR&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(r);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,s);if(t.updateNeeded(i.id,s)&&!n)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const n=new Map;for(const r of t)for(const t of i){const[i,o]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(o)||!s.hasDataForBand(o))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(o),u=l+2*c,h={data:new e.q({width:u,height:u},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};n.set(t,h)}return n}queryRasterArrayValueByBandId(t,i,n){const r=i._mrt;return new Promise(o=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(n.layerName&&l!==n.layerName)continue;const u={};s[l]=u;for(const{bands:h}of c.dataIndex)for(const d of h)n.bands&&!n.bands.includes(d)||(a.add(e.B(l,d)),i.fetchBand(l,null,d,i=>{e.o.frame(()=>{u[d]=i?null:ut([t.lng,t.lat],r,c.getBandView(d)),a.delete(e.B(l,d)),0===a.size&&o(s)})},!1))}0===a.size&&o(s)})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,n,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!n)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&n){const i=e.aM(r);t.setExpiryData(i)}t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,n)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise((n,r)=>{this._loadTileForQuery(t,(o,s)=>{o?r(o):n(s?this.queryRasterArrayValueByBandId(e,t,i):null)})})}queryRasterArrayValue(t,i){const n=e.aS.convert(t),r=this.findLoadedParent(n);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(n,r,i):this.queryRasterArrayValueByAllBands(n,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ae.fromLngLat(t,this.map.transform.tileSize),n=this.maxzoom+1,r=1<0&&(l[new e.aP(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(i.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const t=e.B(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){const n=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,o=r?{image:r.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:o,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};t.request=this.actor.send(n,a,(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aT{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aU(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,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(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.y(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}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 t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aT,model:e.aW,"batched-model":class extends e.E{constructor(e,t,i,n){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(n)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,i,n,(r,o)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r))):o&&(Object.assign(this,o),o.bounds&&(this.tileBounds=new at(o.bounds,this.minzoom,this.maxzoom)),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,o.bind(this),void 0,!0);function o(e,n){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadModelData(n,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aT{constructor(t,i,n,r){super(t,i,n,r),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 e.y(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.y(new e.V(`sources.${t}`,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 e.y(new e.V(`sources.${t}`,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 HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.y(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(e){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.aV||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}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 e.E{constructor(t,i,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,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 e.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new at(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aH(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:n,z:r}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:r},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i))}),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:n}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:n})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&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 t=e.B(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},pt=function(t,i,n,r){const o=new dt[i.type](t,i,n,r);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.aX(["load","abort","unload","serialize","prepare"],o),o};function ft(e,t,i=""){return`${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return`layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return`featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function mt(e,t,i,n=""){if(e.uniqueFeatureID){const r=ft(e,t,n);if(i.has(r))return!0;i.add(r)}return!1}function gt(e,t,i,n,r=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,r);s.sort(yt);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,n,o,r);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,n);Object.keys(i).length&&a.push({wrappedTileID:0,queryResults:i})}}return 0===a.length?{}:function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(a)}function _t(e,t,i,n,r,o){const s={},a=n.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(yt);for(const e of l){const n=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in n){const i=s[t]=s[t]||[],r=n[t];r.sort((t,i)=>{const n=e.featureSortOrder;if(n){const e=n.indexOf(t.featureIndex);return n.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e)}}return s}function At(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;et.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.fqid]=n}}return i}const xt=32,bt=33,wt=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,n=0,r=0,o=0,s=0,a=0;for(1&t?r=o=s=xt:i=n=a=xt;(t>>=1)>1;){const e=i+r>>1,l=n+o>>1;1&t?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=e,a=l}const l=4*e;wt[l+0]=i,wt[l+1]=n,wt[l+2]=r,wt[l+3]=o}const Tt=new Uint16Array(2178),Et=new Uint8Array(1089),Ct=new Uint16Array(1089);function St(e){return 0===e?-.03125:32===e?.03125:0}const Bt={type:2,extent:e.al,loadGeometry:()=>[[new e.P(0,0),new e.P(e.al+1,0),new e.P(e.al+1,e.al+1),new e.P(0,e.al+1),new e.P(0,0)]]};class It{constructor(t,i,n,r,o,s){this.tileID=t,this.uid=e.b1(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=s,this._hasAppearances=null}registerFadeDuration(t){const i=t+this.timeAdded;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return!0;return!1}updateBuckets(t,i){if(!this.latestFeatureIndex)return;if(!t.style)return;const n=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages(),o=t.style.getBrightness();for(const s in this.buckets){if(!t.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",u=n[c],h=t.style.getLayerSourceCache(l);let d={};h&&(d=h._state.getState(c,void 0));const p=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},f=Object.keys(d).length>0&&!i;if(a.hasAppearances=a.layers.some(e=>e.appearances&&e.appearances.length>0),(f&&0!==a.stateDependentLayers.length||i)&&a.update(d,u,r,p,f?a.stateDependentLayers:a.layers,i,o),f&&0!==a.stateDependentLayers.length||i||a.hasAppearances){const e={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview};a.updateAppearances(this.tileID.canonical,d,r,e)}(a instanceof e.b9||a instanceof e.ba)&&t._terrain&&t._terrain.enabled&&h&&a.uploadPending()&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const m=t&&t.style&&t.style.getOwnLayer(s);m&&(this.queryPadding=Math.max(this.queryPadding,m.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=wt[t+0],n=wt[t+1],r=wt[t+2],o=wt[t+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*bt+i,h=o*bt+r,d=a*bt+s,p=Math.hypot((Tt[2*u+0]+Tt[2*h+0])/2-Tt[2*d+0],(Tt[2*u+1]+Tt[2*h+1])/2-Tt[2*d+1])>=16;Et[d]=Et[d]||(p?1:0),e<1022&&(Et[d]=Et[d]||Et[(n+c>>1)*bt+(i+l>>1)]||Et[(o+c>>1)*bt+(r+l>>1)])}const o=new e.a$,s=new e.b0;let a=0;function l(t,i){const n=i*bt+t;return 0===Ct[n]&&(o.emplaceBack(Tt[2*n+0],Tt[2*n+1],t*e.al/xt,i*e.al/xt),Ct[n]=++a),Ct[n]-1}function c(e,t,i,n,r,o){const a=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-o)>1&&Et[u*bt+a])c(r,o,e,t,a,u),c(i,n,r,o,a,u);else{const a=l(e,t),c=l(i,n),u=l(r,o);s.emplaceBack(a,c,u)}}return c(0,0,xt,xt,xt,0),c(xt,xt,0,0,0,xt),{vertices:o,indices:s}}(this.tileID.canonical,i);r=t.vertices,o=t.indices}else{r=new e.a$,o=new e.b0;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const t=e.bg(r.int16.subarray(0,4*r.length),void 0,4);for(let e=0;e0&&(l=e.bk(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,s,l,a)}_globePoint(t,i,n,r,o,s,a){let l=e.bl(t,i,n);if(s){const o=1<.5?d=-1:h<-.5&&(d=1);let p=(t/e.al+n.x)/o+d,f=(i/e.al+n.y)/o;p=(p-c)*r._pixelsPerMercatorPixel+c,f=(f-u)*r._pixelsPerMercatorPixel+u;const m=[p*r.worldSize,f*r.worldSize,0];e.af(m,m,s),l=e.bm(l,m,a)}return e.af(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,n,r,o,s){const a=new e.bc,l=new e.bd,c=new e.bn,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;uh*e+t;for(let e=0;e{if(e)i(e);else try{const e=n.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));n.parseHeader(r),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(n.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);r.byteLength>=s&&(this.entireBuffer=r),i(null,this.entireBuffer||r,o)}catch(e){i(e)}}),this.request}fetchBandForRender(e,t,i,n){this.fetchBand(e,t,i,r=>{if(r)return void n(r);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);n(null,o?o.img:null)})}fetchBand(t,i,n,r,o=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.B(String(n),e.B(this.tileID.key,t));let u=this._taskQueue.get(c);u?u.add(r):(u=new Set,u.add(r),this._taskQueue.set(c,u));const h=(e,t)=>{l.complete(e,t),e?r(e):(u.values().forEach(e=>e(null,t)),this._taskQueue.delete(c))},d=(e,t)=>{if(e)return r(e);const n=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},h,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{n&&n.cancel(),l.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e)}};let p;try{p=s.getLayer(t)}catch(e){if("reloading"===this.state)return;throw e}if(!p)return void r(new Error(`Unknown sourceLayer "${t}"`));if(p.hasDataForBand(n))return u.values().forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=p.getDataRange([n]);if(l=s.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),n=e.bt(t,d);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{n.cancel(),l.cancel()}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e)}}}updateNeeded(e,t){return(!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,n){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(n)||!r.hasDataForBand(n))return;const{bytes:o,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(n),u=s+2*a,h=new e.q({width:u,height:u},o),d=this.texturePerLayer.get(i);d&&d instanceof e.T&&d.update(h,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:n,img:h,buffer:a,offset:l,tileSize:s,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class Pt{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Rt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const n=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},Object.assign(this.stateChanges[e][n],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])i[t]||(this.deletedStates[e][n][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},n=this.stateChanges[e]||{},r=this.deletedStates[e];if(null===r)return{};if(void 0!==t){const e=String(t),o=Object.assign({},i[e],n[e]);if(r){const e=r[t];if(null===e)return{};for(const t in e)delete o[t]}return o}const o=Object.assign({},i,n);if(r)for(const e in r)delete o[e];return o}initializeTileState(e,t){e.refreshFeatureState(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]={}),Object.assign(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]||{},Object.assign(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const i in e)e[i].refreshFeatureState(t)}}class Lt extends e.E{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 Pt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Rt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===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)if(!this._tiles[e].loaded())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,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Ft).map(e=>e.key)}getRenderableIds(t,i){const n=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&n.push(this._tiles[e]);return t?n.sort((t,i)=>{const n=t.tileID,r=i.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),s=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(Ft).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(t,i,n,r,o){if(r){if(t.state="errored",404!==r.status)this._source.fire(new e.y(r,{tile:t}));else{if(this._source.fire(new e.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;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)}return}t.timeAdded=e.o.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let s=new Map;o&&o.responseHeaders&&(s=o.responseHeaders),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!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]){n[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),n=this._getLoadedTile(t);if(n)return n}}_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,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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(t,i,n,r,o){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t)}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aP(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aP(1,0,1,0,0)),a.push(new e.aP(1,0,1,1,0)),a.push(new e.aP(1,0,1,0,1)),a.push(new e.aP(1,0,1,1,1)))}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t))}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!kt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),l=Math.min(e,this._source.maxzoom);if(s){const e=t.extendTileCover(a,l);for(const t of e)a.push(t)}else if(o){const e=t.extendTileCoverToNearPlane(a,this.transform.getFrustum(l),l);for(const t of e)a.push(t)}else if(this.castsShadows&&r){const e=t.extendTileCover(a,l,r);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t)}}const u=this._updateRetainedTiles(a);if(kt(this._source.type)&&0!==a.length){const t={},i={},n=Object.keys(u);for(const r of n){const n=u[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.o.now())continue;const s=this.findLoadedParent(n,Math.max(n.overscaledZ-Lt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[r]=n}const r=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(u[e]||!t.hasData())continue;let n=t.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&i[n.key]){u[e]=t.tileID;break}}}for(const e in t)u[e]||(this._coveredTiles[e]=!0,u[e]=t[e])}for(const e in u)this._tiles[e].clearFadeHold();const h=e.bu(this._tiles,u);for(const e of h){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={},n=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,o=Math.max(r-Lt.maxOverzooming,this._source.minzoom),s=Math.max(r+Lt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const n=Boolean(i);if(!n){const e=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Mt(t,n,this.transform.tileZoom,e,this._isRaster):new It(t,n,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state))}return i.uses++,this._tiles[t.key]=i,n||this._source.fire(new e.z("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_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||"empty"===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(t,i,n){const r=[],o=this.transform;if(!o)return r;const s="globe"===o.projection.name,a=e.aF(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(n&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,0))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(const e of u){const n=t.containsTile(c,o,i,e);n&&r.push(n)}}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),n="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=n?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(kt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.o.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 n=this._tiles[e];n&&n.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(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i))};return void this._source.on("data",e)}const n=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,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)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(n.values());e.bv(a,(e,t)=>{const i=new It(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)})},i)}}function Ft(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function kt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Dt(e,t){const i=1<0:"building"===i.type?n=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(n=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!n&&t.visible,t.visible=n}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,n=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let o=n?n.getTile(t):null;if(!o&&n)for(const e in n._tiles){const i=n._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){o=i;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:r})}e.hasAnyZOffset=!1;let i=!1;for(let n=0;n{e in i&&(n[e]=i[e])}),n}function Ut(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Jt{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return!r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,n,r){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!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(e,t,i,n,r){return this._query(e,t,i,n,!1,r)}hitTest(e,t,i,n,r){return this._query(e,t,i,n,!0,r)}hitTestCircle(e,t,i,n){return this._queryCircle(e,t,i,!0,n)}_queryCell(e,t,i,n,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&n>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],e,t,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=r[u],t=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const e=this.bboxes;for(const t of u)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 h=this.circleCells[r];if(null!==h){const e=this.circles;for(const t of h)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,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const Yt={unknown:0,flipRequired:1,flipNotRequired:2},ei=Math.tan(85*Math.PI/180);function ti(t,i,n,r,o,s,a){const l=e.bB();if(n)if("globe"===s.name){const t=e.bC(o,i);e.aB(l,l,t)}else{const t=e.bD([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.bA(l,l,o.angle)}else e.aB(l,o.labelPlaneMatrix,t);return l}function ii(e,t,i,n,r,o,s){const a=ti(e,t,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ni(t,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=ti(t,i,n,r,o,s,a);return e.bk(l,l),e.aB(l,t,l),l}{const i=e.by(t),n=e.bz([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],e.aB(i,i,n),r||e.bA(i,i,-o.angle),i}}return o.glCoordMatrix}function ri(t,i,n,r){const o=[t,i,n,1];n?e.aC(o,o,r):mi(o,o,r);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function oi(e,t){return Math.min(.5+e/t*.5,1.5)}function si(e,t){const i=e[0]/e[3],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function ai(t,i,n,r,o,s,a,l,c,u,h=1){const d=n.transform,p=r?t.textSizeData:t.iconSizeData,f=e.bJ(p,n.transform.zoom,h),m="globe"===d.projection.name,g=[256/n.width*2+1,256/n.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let A=null;m&&(A=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;rMath.abs(n)?{useVertical:!0}:t===e.bK.vertical?r>0?{needsFlipping:!0}:null:i!==Yt.unknown&&function(e,t){return 0===e||Math.abs(t/e)>ei}(n,r)?i===Yt.flipRequired?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function ui(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:S,writingMode:B,flipState:I}=t,M=T+t.lineLength,P=t=>{if(h){const[i,n,r]=t.up,o=u.length;e.bM(h,o+0,i,n,r),e.bM(h,o+1,i,n,r),e.bM(h,o+2,i,n,r),e.bM(h,o+3,i,n,r)}const[i,n,r]=t.point;e.bN(u,i,n,r,t.angle)};if(C>1){const e=li(x,l,b,w,n,d,p,t,c,s,f,g,!1,_,A,y,v);if(!e)return{notEnoughRoom:!0};if(r&&!n){let[i,n,r]=e.first.point,[o,s,l]=e.last.point;[i,n]=ri(i,n,r,a),[o,s]=ri(o,s,l,a);const c=ci(B,I,(o-i)*m,s-n);if(t.flipState=c&&c.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:di(p,r,i,1,o,void 0,_,A.canonical),l=ci(B,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,l)return l}const i=pi(x*l.getoffsetX(E),b,w,n,d,p,S,T,M,c,s,f,g,!1,!1,_,A,y,v);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function hi(e,t,i,n,r){const{x:o,y:s,z:a}=n.projectTilePoint(e.x,e.y,t);if(!r)return ri(o,s,a,i);const[l,c,u]=r.getElevation(e,r.elevation,r.elevationFeature);return ri(o+l,s+c,a+u,i)}function di(t,i,n,r,o,s,a,l){const c=hi(t.sub(i)._unit()._add(t),l,o,a,s);return e.av(c,n,c),e.aw(c,c),e.bG(c,n,c,r)}function pi(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y){const v=r?t-i:t+i;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+a+(x>0?0:1)|0,T=o,E=o,C=0,S=0;const B=Math.abs(v),I=[],M=[];let P=s,R=P,L=e.bE([]);const F=()=>di(R,P,E,B-C+1,h,p,g,_.canonical);for(;C+S<=B;){if(w+=x,w=c)return null;if(E=T,R=P,I.push(E),f&&M.push(R),P=new e.P(u.getx(w),u.gety(w)),T=d[w],!T){const e=hi(P,_.canonical,h,g,p);T=e[3]>0?d[w]=e:F()}C+=S;const t=e.av([],T,E),i=e.bF(E,T);if(n&&i>0&&S>0&&e.bI(L,t)/(S*i)0,y),w=c*b.perspectiveRatio,T=(n.x1*i+a.x-n.padding)*w+b.point.x,E=(n.y1*i+a.y-n.padding)*w+b.point.y,C=(n.x2*i+a.x+n.padding)*w+b.point.x,S=(n.y2*i+a.y+n.padding)*w+b.point.y,B=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(T,E,C,S)||!l&&this.grid.hitTest(T,E,C,S,h)||B?{box:[],offscreen:!1,occluded:b.occluded}:{box:[T,E,C,S],offscreen:this.isOffscreen(T,E,C,S),occluded:!1}}placeCollisionCircles(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=[],A=this.transform.elevation,y=t.getProjection(),v="road"===t.elevationType,x=!!A||v,b=e.bU.getAtTileOffsetFunc(g,this.transform.center.lat,this.transform.worldSize,y),w=new e.P(n.tileAnchorX,n.tileAnchorY),T=new e.P(n.tileAnchorX,n.tileAnchorY);let{x:E,y:C,z:S}=y.projectTilePoint(T.x,T.y,g.canonical),B=null;if(x){const e=v?t.getElevationFeatureForText(r):null;B={getElevation:b,elevation:A,elevationFeature:e};const[i,n,o]=b(w,A,e);E+=i,C+=n,S+=o}const I="globe"===y.name,M=this.projectAndGetPerspectiveRatio(l,E,C,S,g,I||!!A||this.transform.pitch>0,y),{perspectiveRatio:P}=M,R=(d?a/P:a*P)/e.bX,L=ri(E,C,S,c),F=n.lineOffsetX*R,k=n.lineOffsetY*R,D=e.an(t.layers[0].layout.get("text-max-angle")),O=Math.cos(D),z=M.signedDistanceFromCamera>0?li(R,s,F,k,v&&1===n.flipState,L,T,n,o,c,{},x&&!d?B:null,d&&x,y,g,d,O):null;let U=!1,N=!1,V=!0;if(z&&!M.occluded){const t=.5*f*P+m,n=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Xt,{first:s,last:a}=z,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(x&&!I&&(i=b(ne[3]<=0)&&(c=[]));let g=[];if(c.length>0){let t=1/0,i=-1/0,o=1/0,s=-1/0;for(const e of c)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=n.x&&t<=r.x&&s>=n.y&&o<=r.y&&(g=[c.map(t=>new e.P(t[0],t[1]))],(tr.x||or.y)&&(g=e.bV(g,n.x,n.y,r.x,r.y)))}for(const e of g){o.reset(e,.25*t);let n=0;n=o.length<=.5*t?1:Math.ceil(o.paddedLength/d)+1;for(let e=0;e0){if(e.aC(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return e.af(l,l,a),je(t,e.ag(l),s.pitch,s._fov)}(this.fogState,i,n,r,o.toUnwrapped(),this.transform);c=t>.9}}else mi(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+gi,(-l[1]/u+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,i,n){return i=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ti(t,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=e.c0(t),l=-(s-.5)*i,c=-(a-.5)*n,u=e.c1(t,r);return new e.P(l+u[0]*o,c+u[1]*o)}function Ei(t,i,n,r,o){const s=new e.P(t,i);return n&&s._rotate(r?o:-o),s}class Ci{constructor(e,t,i,n,r,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new _i(this.transform,r),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new wi(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,n,r,o=1){const s=n.getBucket(i),a=n.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,u=n.collisionBoxArray,h=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),d=n.tileSize/e.al,p=n.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(m=n.tileID,g=s.getProjection(),_=this.transform,g.name===this.projection?_.calculateProjMatrix(m.toUnwrapped()):Wt(_,g,m));var m,g,_;const A="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(n),w=ii(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);let T=null;const E=s.getProjection().createInversionMatrix(this.transform,n.tileID.canonical);if(A){const t=ni(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);T=e.aB([],this.transform.labelPlaneMatrix,t)}let C=null;v&&n.latestFeatureIndex&&(C={unwrappedTileID:p,dynamicFilter:v,dynamicFilterNeedsFeature:x}),this.retainedQueryData[s.bucketInstanceId]=new bi(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,n.tileID);const[S,B]=s.layers[0].layout.get("text-size-scale-range"),I=e.aA(o,S,B),[M,P]=l.get("icon-size-scale-range"),R=e.aA(o,M,P),L={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:E,mercatorCenter:[e.aF(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:C,scale:h,textPixelRatio:d,holdingForFade:n.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bJ(s.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bJ(s.iconSizeData,this.transform.zoom,R),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:n.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:L})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const{textOffset0:x,textOffset1:b,crossTileID:w}=f,T=[x,b],E=Ti(e,o,s,T,a),C=this.collisionIndex.placeCollisionBox(g,a,t,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate);if(A){const e=g.getSymbolInstanceIconSize(v,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,A,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(C.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[w]&&this.prevPlacement.placements[w]&&this.prevPlacement.placements[w].text&&(t=this.prevPlacement.variableOffsets[w].anchor),this.variableOffsets[w]={textOffset:T,width:o,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(g,e,f,_),g.allowVerticalPlacement&&(this.markUsedOrientation(g,_,f),this.placedOrientations[w]=_),{shift:E,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,n,r,o=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:g,collisionBoxArray:_,partiallyEvaluatedTextSize:A,partiallyEvaluatedIconSize:y,collisionGroup:v,latestFeatureIndex:x}=t.parameters,b=a.get("text-optional"),w=a.get("icon-optional"),T=a.get("text-allow-overlap"),E=a.get("icon-allow-overlap"),C="map"===a.get("text-rotation-alignment"),S="map"===a.get("icon-rotation-alignment"),B="map"===a.get("text-pitch-alignment"),I=l.get("symbol-z-offset"),M="sea"===a.get("symbol-elevation-reference"),P=a.get("symbol-placement"),[R,L]=a.get("text-size-scale-range"),[F,k]=a.get("icon-size-scale-range"),D=e.aA(o,R,L),O=e.aA(o,F,k),z=a.get("text-variable-anchor"),U=C&&"point"!==P,N=S&&"point"!==P,V=z&&s.hasTextData(),j=s.hasIconTextFit()&&V&&s.hasIconData();this.transform.setProjection(s.projection);const G=V||U,H=N||j;let Q=T&&(E||!s.hasIconData()||w),$=E&&(T||!s.hasTextData()||b);const Z=!I.isConstant();!s.collisionArrays&&_&&s.deserializeCollisionBoxes(_),n&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,_,D,O);const W=(t,r,o)=>{const{crossTileID:l,numVerticalGlyphVertices:_}=t;let S=null;if(d&&d.dynamicFilterNeedsFeature||Z){const e=this.retainedQueryData[s.bucketInstanceId];S=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:s.worldview},S,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[l]=new vi(!1,!1,!1,!0),void i.add(l);const P=I.evaluate(S,{});if(i.has(l))return;if(g)return void(this.placements[l]=new vi(!1,!1,!1));let R=!1,L=!1,F=!0,k=!1,D=!1,O=null,U={box:null,offscreen:null,occluded:null},N={box:null},V=null,j=null,W=null,q=0,K=0,X=0;o.textFeatureIndex?q=o.textFeatureIndex:t.useRuntimeCollisionCircles&&(q=t.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);const J=s.elevationFeatures?s.elevationFeatures[t.elevationFeatureIndex]:void 0,Y=i=>{i.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const n=this.transform.elevation;i.elevation=M?P:P+e.bU.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),n,J),i.elevation+=t.zOffset},ee=o.textBox;if(ee){Y(ee);const i=i=>{let n=e.bK.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,n=e,this.markUsedOrientation(s,n,t))}return n},n=(t,i)=>{if(s.allowVerticalPlacement&&_>0&&o.verticalTextBox){for(const n of s.writingModes)if(n===e.bK.vertical?(U=i(),N=U):U=t(),U&&U.box&&U.box.length)break}else U=t()};if(z){let a=z;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor))}const u=(e,i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),l=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,h=t.hasIconTextFit&&!E?i:null;h&&Y(h);let d={box:[],offscreen:!1,occluded:!1};const g=T?2*a.length:a.length;for(let i=0;i=a.length,t,r,s,n,h,A,y);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){R=!0,O=g.shift;break}}return d};n(()=>u(ee,o.iconBox,e.bK.horizontal),()=>{const t=o.verticalTextBox;return t&&Y(t),s.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&_>0&&t?u(t,o.verticalIconBox,e.bK.vertical):{box:null,offscreen:null,occluded:null}}),U&&(R=U.box,F=U.offscreen,k=U.occluded);const h=i(!(!U||!U.box));if(!R&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(s,e.anchor,t,h))}}else{const a=(i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(s,o,i,f,m,G,new e.P(0,0),T,p,c,v.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(s,n,t),this.placedOrientations[l]=n),a};n(()=>a(ee,e.bK.horizontal),()=>{const t=o.verticalTextBox;return s.allowVerticalPlacement&&_>0&&t?(Y(t),a(t,e.bK.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(U&&U.box&&U.box.length))}}if(V=U,R=V&&V.box&&V.box.length>0,F=V&&V.offscreen,k=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,r=s.text.placedSymbolArray.get(i),o=e.bL(s.textSizeData,A,r),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,T,r,i,s.lineVertexArray,s.glyphOffsetArray,o,c,u,h,n,B,v.predicate,t.collisionCircleDiameter*o/e.bX,l,this.retainedQueryData[s.bucketInstanceId].tileID),R=T||j.circles.length>0&&!j.collisionDetected,F=F&&j.offscreen,k=j.occluded}if(o.iconFeatureIndex&&(X=o.iconFeatureIndex),o.iconBox){const i=i=>{Y(i);const n=t.hasIconTextFit&&O?Ei(O.x,O.y,C,B,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,f,m,H,n,E,p,c,v.predicate)};N&&N.box&&N.box.length&&o.verticalIconBox?(W=i(o.verticalIconBox),L=W.box.length>0):(W=i(o.iconBox),L=W.box.length>0),F=F&&W.offscreen,D=W.occluded}const te=b||0===t.numHorizontalGlyphVertices&&0===_,ie=w||0===t.numIconVertices;if(te||ie?ie?te||(L=L&&R):R=L&&R:L=R=L&&R,R&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),s.bucketInstanceId,N&&N.box&&K?K:q,v.ID),L&&W&&this.collisionIndex.insertCollisionBox(W.box,a.get("icon-ignore-placement"),s.bucketInstanceId,X,v.ID),j&&(R&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,q,v.ID),n)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new xi);for(let e=0;e=0;--e){const i=t[e];W(s.symbolInstances.get(i),i,s.collisionArrays[i])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,n){const r=i===e.bK.horizontal||i===e.bK.horizontalOnly?i:0,o=i===e.bK.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new yi(o,n,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new yi(null,n,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new yi(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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,i,n){const r=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,o,o.collisionBoxArray,i,n,o.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,o.tileID),"road"===t.elevationType&&t.updateRoadElevation(o.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(t,i,n,r,o,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,u=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),d=new yi(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),g="map"===c.get("text-rotation-alignment"),_="map"===c.get("text-pitch-alignment"),A=u.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),v=!A.isConstant(),x=new yi(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const b=(e,t,i)=>{for(let n=0;n0||p>0,L=T>0,F=this.placedOrientations[f],k=F===e.bK.vertical,D=F===e.bK.horizontal||F===e.bK.horizontalOnly;!R&&!L||P.isHidden()||w++;let O=!1;if((R||L)&&s)for(const i of t.activeReplacements){if(e.bY(i,o,e.bZ.Symbol,l))continue;if(i.min.x>E||E>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.b_(E,C,a.canonical,i.footprintTileId.canonical);if(O=e.b$(t,i.footprint),O)break}if(R){const e=O?Di:ki(P.text);b(t.text,u,k?Di:e),b(t.text,p,D?Di:e);const i=P.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||k?1:0;n>=0&&(a.get(n).hidden=l),r>=0&&(a.get(r).hidden=l),o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=i||D?1:0);const h=this.variableOffsets[f];h&&this.markUsedJustification(t,h.anchor,c,F);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(L){const e=O?Di:ki(P.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=c,r=t.icon.placedSymbolArray,o=P.icon.isHidden()?1:0;i>=0&&(b(t.icon,T,k?Di:e),r.get(i).hidden=o),n>=0&&(b(t.icon,c.numVerticalIconVertices,D?Di:e),r.get(n).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let n=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(n=Ti(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&n._rotate(_?this.transform.angle:-this.transform.angle)):r=!1}h&&(r=!P.clipped),i.textBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||k,I,y,n.x,n.y),i.verticalTextBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||D,I,y,n.x,n.y)}const o=r&&Boolean(!D&&i.verticalIconBox);i.iconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0),i.verticalIconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,!o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0)}}}if(t.fullyClipped=0===w,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Si(e,t,i,n,r,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0)}const Bi=Math.pow(2,25),Ii=Math.pow(2,24),Mi=Math.pow(2,17),Pi=Math.pow(2,16),Ri=Math.pow(2,9),Li=Math.pow(2,8),Fi=Math.pow(2,1);function ki(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*Bi+t*Ii+i*Mi+t*Pi+i*Ri+t*Li+i*Fi+t}const Di=0;class Oi{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,n,r,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.o.now()-s;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),u="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),h=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=u&&h,p=this._inProgressLayer=this._inProgressLayer||new Oi(t),f=e.B(s.source,s.scope);if(p.continuePlacement(i||d?r[f]:n[f],this.placement,this._showCollisionBoxes,s,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.al/2;class Ni{constructor(t,i,n){this.tileID=t,this.bucketInstanceId=n,this.index=new e.c3(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.al,o=t.canonical.y*e.al;for(let e=0;ee-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!n.has(t)){n.add(t),i.crossTileID=t;break}}}}}class Vi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ji{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hi=771;class Qi{constructor(e,t,i,n){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=n}}Qi.Replace=[1,0,1,0],Qi.disabled=new Qi(Qi.Replace,e.ao.transparent,[!1,!1,!1,!1]),Qi.unblended=new Qi(Qi.Replace,e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlended=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlendedNonPremultiplied=new Qi([770,Hi,770,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.multiply=new Qi([774,0,774,0],e.ao.transparent,[!0,!0,!0,!0]),Qi.additive=new Qi([1,1,1,1],e.ao.transparent,[!0,!0,!0,!0]);class $i{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}$i.ReadOnly=!1,$i.ReadWrite=!0,$i.disabled=new $i(519,$i.ReadOnly,[0,1]);const Zi=7680;class Wi{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Wi.disabled=new Wi({func:519,mask:0},0,0,Zi,Zi,Zi);const qi=1029,Ki=2305;class Xi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function Ji(t,i){const n=e.c9(t,3);e.cb(t,i),e.cf(t,3,n)}function Yi(t,i){const n=e.c6([]);return e.c7(n,n,-i),e.c8(n,n,-t),n}function en(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.ag(n)>=1e-15){const t=e.aw([],n);e.c4(r,t,e.bI(r,t)),i[0]=r[0],i[1]=r[1]}const o=e.bH([],i,t);if(e.c5(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Yi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Xi.disabled=new Xi(!1,qi,Ki),Xi.backCCW=new Xi(!0,qi,Ki),Xi.backCW=new Xi(!0,qi,2304),Xi.frontCW=new Xi(!0,1028,2304),Xi.frontCCW=new Xi(!0,1028,Ki);class tn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ae?t:new e.ae(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bS(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,n){if(this.orientation=null,!this.position)return;const r=this.position,o=n||(this._elevation?this._elevation.getAtPointOrZero(e.ae.fromLngLat(t)):0),s=e.ae.fromLngLat(t,o),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=en(a,i)}setPitchBearing(t,i){this.orientation=Yi(e.an(t),e.an(-i))}}class nn{constructor(t,i){this._transform=e.bz([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.ae(t[0],t[1],t[2])}get position(){const t=e.c9(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.cf(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.c6([]),t&&Ji(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=Yi(e,t),Ji(this._transform,this._orientation)}forward(){const t=e.c9(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.c9(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.c9(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.bk(n,this.getWorldToCamera(t,i)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,n){const r=this.position;e.c4(r,r,-t);const o=new Float64Array(16);return e.bp(o,[n,n,n]),e.bq(o,o,r),o[10]*=i,o}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return e.ca(r,this._orientation),e.c4(o,o,-t),e.cb(n,r),e.bq(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const o=new Float64Array(16);return e.cc(o,t,i,n,r),o}getCameraToClipOrthographic(t,i,n,r,o,s){const a=new Float64Array(16);return e.cd(a,t,i,n,r,o,s),a}getDistanceToElevation(t,i=!1){const n=0===t?0:e.ce(t,i?e.a_(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new nn([...this.position],[...this.orientation])}}const rn={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class on{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.ak(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.ak(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.ak(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.ak(t.right,i.right,n)),this}getCenter(t,i){const n=e.aA((this.left+t-this.right)/2,0,t),r=e.aA((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new on(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const sn=15;class an{constructor(t,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=n??0,this._maxPitch=r??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aS(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 on,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new nn,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const e=new an(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);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._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch0&&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(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e)}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;s{const l=e.cX(i,t,n,o,s);a.has(l)||(r.push(new e.aP(t,i,n,o,s)),a.add(l))};for(let e=0;e0,f=a.y+10,g=r.wrap-(p?0:1),_=r.wrap+(d?0:1),A=p?a.x-1:h-1,y=d?a.x+1:0;if(o)n[0]<0?(l(c,_,a.z,y,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))):n[0]>0?(l(c,g,a.z,A,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))):n[1]<0&&f?l(c,u,a.z,a.x,a.y+1):m&&l(c,u,a.z,a.x,a.y-1);else{const e=r.visibleQuadrants;1&e&&(l(c,g,a.z,A,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))),2&e&&(l(c,_,a.z,y,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))),4&e&&(l(c,g,a.z,A,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1))),8&e&&(l(c,_,a.z,y,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)))}}const c=[];for(const e of r)r.some(t=>e.isChildOf(t))||c.push(e);if(r=c.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-n[0],i=e.canonical.y+.5-n[1];return t*t+i*i{const l=e.cX(i,t,n,s,a);o.has(l)||(r.push(new e.aP(t,i,n,s,a)),o.add(l))},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),n),l=1<{const r=Math.floor(t[0]),o=Math.floor(t[1]),d=(t[0]-r)*e.al,p=(t[1]-o)*e.al,f=Math.floor(i[0]),m=Math.floor(i[1]),g=(i[0]-f)*e.al,_=(i[1]-m)*e.al;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){u.x=d-t*e.al,h.x=g-(i-f)*e.al;for(let t=-1;t<=1;t++){const r=o+t;u.y=p-t*e.al,h.y=_-(r-m)*e.al,e.cY(u,h,c)&&s(a,0,n,i,r)}}}},p=i.points,f=p[e.cu],m=p[e.cv],g=this._projectToGround(f,p[e.cw]),_=this._projectToGround(m,p[e.cx]);return d(f,g),d(m,_),r}_projectToGround(t,i){return e.cy(e.cz(),t,i,t[2]/(t[2]-i[2]))}coveringTiles(t){let i=this.coveringZoomLevel(t);const n=i,r=this.elevation&&this.elevation.exaggeration(),o=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,n=new e.ae(t.x+i,t.y,t.z),r=new e.ae(t.x,t.y+i,t.z),o=t.toLngLat(),s=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/i},E=t=>{const i=x,n=b;return{aabb:e.cE(this,c,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let S=[];const B=i,I=t.reparseOverscaled?n:i,M=(g-this._centerAltitude)*m,P=e=>{if(!this._elevation||!e.tileID||!s)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=L(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=(e,t)=>{if(.707*t{if(t.zoom=.9)return!0}else if(o&&(a=t.aabb.distanceZ(_)*m),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=T(new e.ae((t.x+.5)/i,(t.y+.5)/i));c=n>.85?1:n}if(!s&&!h){const e=Math.sqrt(i*i+r*r+a*a);let n=(1<0;){const n=C.pop(),r=n.x,a=n.y;let l=n.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<>1),d={aabb:s?n.aabb.quadrant(t):e.cE(this,c,n.zoom+1,i,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:u,wrap:n.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};o&&!h&&(d.tileID=new e.aP(n.zoom+1===B?I:n.zoom+1,n.wrap,n.zoom+1,i,u),P(d)),C.push(d)}else{const o=n.zoom===B?I:n.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let i=A?n.aabb.intersectsPrecise(p):n.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.cC(n.zoom,r,a);i=e.cD(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(n.aabb.center))s=15;else for(let e=0;e<4;e++)0!==n.aabb.quadrant(e).intersects(p)&&(s|=1<{const o=[0,0,0,1],s=[e.al,e.al,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aC(o,o,a),e.aC(s,s,a);const l=e.cF([],o,s),c=e.cG([],o,s),u=e.c_(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(r.tileID)),o||(o={min:b,max:x});const s=e.cH(this.rotation),a=[s[0]*e.al,s[1]*e.al,o.max];e.af(a,a,i),h=(1-a[1])*this.height*.5e.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.log2(e)}project(t){const i=e.aA(t.lat,-e.cI,e.cI),n=this.projection.project(t.lng,i);return new e.P(n.x*this.worldSize,n.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/e.ce(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-o.x)/e,r=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);n=e.x-t.x,r=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.ae(s.x-n,s.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const n=i?e.ce(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ae(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aC(r,r,this.pixelMatrixInverse),e.aC(o,o,this.pixelMatrixInverse);const s=o[3];e.cJ(r,r,1/r[3]),e.cJ(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.aC(i,i,this.pixelMatrixInverse),e.aC(n,n,this.pixelMatrixInverse),e.cJ(i,i,1/i[3]),e.cJ(n,n,1/n[3]),i[2]=e.ce(i[2],this._center.lat)*this.worldSize,n[2]=e.ce(n[2],this._center.lat)*this.worldSize,e.cJ(i,i,1/this.worldSize),e.cJ(n,n,1/this.worldSize),new e.ax([i[0],i[1],i[2]],e.aw([],e.av([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,o=e.ce(i[2],this._center.lat),s=e.ce(n[2],this._center.lat);return new e.ae(e.ak(i[0],n[0],r)/this.worldSize,e.ak(i[1],n[1],r)/this.worldSize,e.ak(o,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.ae(n[0],n[1],n[2]);let r=0,o=this.horizonLineFromTop();if(t.y>o)return this.pointCoordinate(t,i);const s=.02*o,a=t.clone();for(let t=0;t<10&&o-r>s;t++){a.y=e.ak(r,o,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(o=a.y,n=t):r=a.y}return n?new e.ae(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.cK)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.aC(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,n)),l=this.pointLocation3D(new e.P(i,n));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,n,r,o)=>{const s=(t+n)/2,a=(i+r)/2,l=new e.P(s,a),{lng:g,lat:_}=this.pointLocation3D(l),A=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(op)&&(m(t,i,s,a,o+1),m(s,a,n,r,o+1))};if(m(i,t,r,t,1),m(r,t,r,n,1),m(r,n,i,n,1),m(i,n,i,t,1),"globe"===this.projection.name){const[t,i]=e.cL(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.aI(new e.aS(c,h),new e.aS(u,d))}_getBoundsRectangular(t,i){const{top:n,left:r}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(r,n),l=new e.P(s,n),c=new e.P(s,o),u=new e.P(r,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.ae((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.ae(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.ae((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.ae(-p.y/m(p,d)+p.x,0)),(new e.aI).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_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(t){this.maxBounds=t,this.minLat=-e.cI,this.maxLat=e.cI,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(a=h-c),h-ut&&(s=t-l),t-e{for(let o=0;o<16;o++)t[o]=e.ak(i[o],n[o],r)})(a,a,l,e.c$(this.pitch>=sn?1:this.pitch/sn))}else a=l;const c=e.cO([],l,s);let u=e.cO([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.bz([]);e.bq(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aB(i,i,e.cP(this)),e.bq(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aB(u,u,i),e.aB(c,c,i),this.inverseAdjustmentMatrix=e.cQ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cR([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.bk(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cO([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.bk([],a);this.frustumCorners=e.cS.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.bz(d),e.cR(d,d,[1,-1,1]),e.cT(d,d,this._pitch),e.bA(d,d,this.angle);const p=e.cc(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.by(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.aB(d,p,d);const m=this.point,g=m.x,_=m.y,A=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=g-Math.round(g)+v*A+x*y,w=_-Math.round(_)+v*y+x*A,T=new Float64Array(u);if(e.bq(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=e.bB(),e.cR(u,u,[this.width/2,-this.height/2,1]),e.bq(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.bB(),e.cR(u,u,[1,-1,1]),e.bq(u,u,[-1,-1,0]),e.cR(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.aB(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.bk(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cU(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.af(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.c4(o,o,r),e.c4(n,n,-1),e.cV(n,n,o);const s=e.bB();e.bq(s,s,n),e.cR(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(o=Math.min((i-n)/r,1)),this._camera.position=e.bG([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=e.ce(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.an(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);e.bG(t,t,i,a),this._pitch=e.aA(n,e.an(this.minPitch),e.an(this.maxPitch)),this.angle=e.bS(r,-Math.PI,Math.PI),this._setZoom(e.aA(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ae(t[0],t[1],t[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,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,n=e.cK,r=0,o=1/0;for(;n-i>1e-6&&n>i;){const e=i+.5*(n-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cW(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.ag(e.av([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,n],r){const o=[t,i,n,1];e.aC(o,o,r);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,n=this.worldSize){const r=e.cN(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,n,r);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=e.ak(1,s,e.c$(this.pitch>=sn?1:this.pitch/sn))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aB(t,t,this.globeMatrix),t}getFrustum(t){return e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const ln=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const n=t.transform,r=Math.max(Math.abs(n._zoom-(t.minCutoffZoom-1)),1),o=n.isLODDisabled(!1)?e.ah(60,45,n.pitch):e.ah(30,15,n.pitch),s=n._farZ-n._nearZ,a=i*n.height,l=((1-(c=o))*n.cameraToCenterDistance+c*(n._farZ+a))*r;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(l-n._nearZ)/s,(l-a-n._nearZ)/s]}}},cn={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class un{constructor(e,t){this.aabb=e,this.lastCascade=t}}class hn{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 un(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,n){const r=e.d8.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),r)break}}return o+1}}class dn{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new hn,this._depthMode=new $i(e.context.gl.LEQUAL,$i.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._forceDisable=!1,this.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),e.tp.registerParameter(cn,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(cn,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(cn,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const n=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=n.style.order.reduce((e,i)=>{const r=n.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=n.context,s=cn.shadowMapResolution,a=cn.shadowMapResolution;if(0===this._cascades.length||cn.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.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]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let i=0;i=0)return{};const o=function(t,i,n){const r=n/(1<0&&(e.d7(o[1],o[1],[r[0]*s,0,0]),e.d7(o[2],o[2],[r[0]*s,0,0])),r[1]<0?(e.d7(o[0],o[0],[0,r[1]*s,0]),e.d7(o[1],o[1],[0,r[1]*s,0])):r[1]>0&&(e.d7(o[2],o[2],[0,r[1]*s,0]),e.d7(o[3],o[3],[0,r[1]*s,0]));const a={};return a.vertices=o,a.planes=[pn(o[1],o[0],o[4]),pn(o[2],o[1],o[5]),pn(o[3],o[2],o[6]),pn(o[0],o[3],o[7])],a}addShadowReceiver(t,i,n){this._receivers.add(t,e.d8.fromTileIdAndHeight(t,i,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function pn(t,i,n){const r=e.av([],n,i),o=e.av([],t,i),s=e.bH([],r,o),a=e.ag(s);return 0===a?[0,0,1,0]:(e.c4(s,s,1/a),[s[0],s[1],s[2],-e.bI(s,i)])}function fn(t){const i=t.properties.get("direction"),n=e.d3(i.x,i.y,i.z);n[2]=e.aA(n[2],0,75);const r=e.d5([n[0],n[1],n[2]]);return e.d4(r.x,r.y,r.z)}function mn(t,i,n){const r="none"===i.properties.get("color-use-theme"),o=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===n.properties.get("color-use-theme"),u=n.properties.get("color"),h=n.properties.get("intensity"),d=Math.max(e.bI([0,0,1],l),0),p=[0,0,0];e.c4(p,u.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),h);const f=[0,0,0];return e.c4(f,o.toPremultipliedRenderColor(r?null:t.getLut(n.scope)).toArray01Linear().slice(0,3),d*s),e.da([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function gn(t,i,n,r,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=r-n,m=r+n;let g,_;p>f/m?(g=r,_=r*d):(g=.5*m*(1+p),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*p+m*m*p*p));const A=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),v=[0,0,-g*u];e.af(v,v,y);let x=_*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?A:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,n,r);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.cO(s,o,i);const u=new Float64Array(16);e.bk(u,s);const h=e.cA.fromInvProjectionMatrix(u,c,a,!0);for(const i of h.points){const n=((w=i)[0]/=l,w[1]/=l,w[2]=e.ce(w[2],t._center.lat),w);x=Math.max(x,e.c5(e.d9([],v,n)))}}var w;x*=o/(o-1);const T=Math.acos(i[2]),E=Math.atan2(-i[0],-i[1]),C=new nn;C.position=v,C.setPitchBearing(T,E);const S=C.getWorldToCamera(c,A),B=x*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*B),M=C.getCameraToClipOrthographic(-B,B,-B,B,I,(B+s*A)/i[2]),P=new Float64Array(16);e.aB(P,M,S);const R=e.d4(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),L=.5*o,F=[0,0,0];e.af(F,R,P),e.c4(F,F,L);const k=[Math.floor(F[0]),Math.floor(F[1]),Math.floor(F[2])],D=[0,0,0];e.av(D,F,k),e.c4(D,D,-1/L);const O=new Float64Array(16);return e.bz(O),e.bq(O,O,D),e.aB(P,O,P),[P,B]}class _n extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,i){return e.db(this.requestManager.transformRequest(i,e.R.Model).url).then(n=>{if(!n)return;const r=e.dc(n),o=new e.dd(t,i,void 0,void 0,r);return o.computeBoundsAndApplyParent(),o}).catch(n=>{if(n&&404===n.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${n.message}`)))})}load(t,i,n={forceReload:!1}){this.models[i]||(this.models[i]={});const r=Object.keys(t),o=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!n.forceReload||(this.modelByURL[r]={modelId:e,scope:i},o.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(o).then(t=>{for(let e=0;e{this.fire(new e.y(new Error(`Could not load models: ${t.message}`)))})}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t,i={exactIdMatch:!1}){return!!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===n)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(n)){const{scope:e,modelId:t}=this.modelByURL[n];this.models[e][t].numReferences++}else this.modelUris[i][e]=n,this.load({[e]:this.modelUris[i][e]},i)}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n={};for(const r of t)this.hasModel(r,i,{exactIdMatch:!0})||this.hasURLBeenRequested(r)?this.models[i][r].numReferences++:this.modelUris[i][r]&&!this.hasURLBeenRequested(r)?n[r]=this.modelUris[i][r]:!this.hasURLBeenRequested(r)&&e.de(r,!1)&&(this.modelUris[i][r]=this.requestManager.normalizeModelURL(r),n[r]=this.modelUris[i][r]);this.load(n,i)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,n=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||n)){const n=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[n];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy()}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}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].model&&this.models[t][i].model.upload(e.context)}}const An=e.a6.colorTheme,yn=new e.a9({data:new e.aa(An.data)});function vn(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:n,top:r,width:o,height:s}=t.metadata.content_area,a=n*i,l=r*i;return[a,l,a+o*i,l+s*i]}function xn(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class bn{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const n=this.sourceCache.getSource();if(!(n instanceof ht))return t;const r=i.map(e=>this.sourceCache.getTile(e)),o=n.getImages(r,Array.from(this.pendingRequests));for(const[i,n]of o)t.set(e.I.from({name:i,iconsetId:this.id}),n),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const wn=(e,t)=>Le(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Tn=e.aH(Nt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),En=e.aH(Nt,["setCenter","setZoom","setBearing","setPitch"]),Cn=new Set(["background","sky","slot","custom"]),Sn={version:8,layers:[],sources:{}},Bn={duration:300,delay:0};class In extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},Bn),this._buildingIndex=new Ot(this),this.crossTileSymbolIndex=new Gi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new H,this.dispatcher=i.dispatcher?i.dispatcher:new e.D(e.dg(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new $(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.dh(t._requestManager,i.localFontFamily?e.di.all:i.localIdeographFontFamily?e.di.ideographs:e.di.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new _n(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.dj());const n=this;this._rtlTextPluginCallback=In.registerForPluginStateChange(t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.dk(t),i&&i.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||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)}})}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.h(t))return t;const i=e.dl(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.dm(JSON.stringify(t))}`}_diffStyle(t,i,n){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,n))}catch(e){t(e,!1)}};if("string"==typeof t){const n=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(n,e.R.Style);e.m(o,(t,n)=>{t?this.fire(new e.y(t)):n&&r(n,i)})}else"object"==typeof t&&r(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.h(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,n);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(o,(i,r)=>{if(this._request=null,i)this.fire(new e.y(i));else if(r)return this.importsCache.set(t,r),this._load(r,n)})}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Sn,!1)}_loadImports(t,i,n){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise(e=>{t.once("style.import.load",e),t.once("error",e)}).then(()=>this.mergeAll());if(r.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(n){const e=this.fragments.findIndex(({id:e})=>e===n);this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.B(t.id,this.scope):t.id;let n;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(n=Object.assign({},t.config,r));const o=new In(this.map,{scope:i,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:n,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Sn,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&wn(this,ye(t)))return;this._loaded=!0,this.stylesheet=e.dn(t);const n=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const n=Ut(this.stylesheet.layers);if(this._order=n.map(e=>e.id),this.stylesheet.light&&e.w("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 De(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new De(this.stylesheet.light)),this._layers={};for(const t of n){const i=e.dt(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const n=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&i.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(r,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.z("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))}).catch(t=>{this.fire(new e.y(new Error("Failed to load imports",t))),this.fire(new e.z(o?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{n()}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()})}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances}mergeAll(){let e,t,i,n,r,o,s,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(h=>{if(h.stylesheet){if(null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);n=this._prioritizeTerrain(n,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(r=h.fog),h.stylesheet.snow&&null!=h.snow&&(o=h.snow),h.stylesheet.rain&&null!=h.rain&&(s=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=o,this.rain=s,this._styleColorThemeForScope=u,null===n?delete this.terrain:this.terrain=n,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Bn,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const n=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:n?e:null:null!=t&&(!e||n||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 t={},i={},n={};this.forEachFragmentStyle(r=>{for(const i in r._sourceCaches){const n=e.B(i,r.scope);t[n]=r._sourceCaches[i]}for(const t in r._otherSourceCaches){const n=e.B(t,r.scope);i[n]=r._otherSourceCaches[t]}for(const t in r._symbolSourceCaches){const i=e.B(t,r.scope);n[i]=r._symbolSourceCaches[t]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=n}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const n=i,r=e.B(n.sourceId,t.scope);this._mergedIndoor[r]=new Set(n.sourceLayers||[])}})}mergeLayers(){const t={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const o=n._layers[r];if("slot"===o.type){const i=e.dp(r);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}}),this._mergedOrder=[];let r=-1;const o=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.dp(s.id);t[i]&&o(t[i]),this._mergedSlots.push(i)}else{const t=e.B(s.id,s.scope);this._mergedOrder.push(t),n[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0)}};if(o(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i])}this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,n){const r=Object.assign({},i);for(const e of Object.keys(An))void 0===r[e]&&(r[e]=An[e].default);const o=new e.a8(yn,t,new Map(n));return o.setTransitionOrValue(r,n),o.untransitioned().possiblyEvaluate(new e.ac(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((n,r)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void n();let s=t;s.startsWith(o)||(s=o+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void n();this._styleColorTheme.lutLoading=!1;const{width:o,height:s,data:c}=e.o.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.q({width:o,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const u=this.imageManager.getImage(a,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},n()):r(new Error("Missing LUT image."))}})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}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.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,n){let r,o,s;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,s||(s=e,r=t,u())}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,s||(s=e,o=t,u())});function u(){if(s)n(s);else if(r&&o){const t=e.o.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=r[n],f=new e.q({width:o,height:s});e.q.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[n]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==c&&c,stretchX:h,stretchY:d,content:p,usvg:!1,version:0}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i){const t=new Map;for(const n in i)t.set(e.I.from(n),i[n]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const n=this.getOwnSourceCache(i.source);if(!n)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=n.getSource();if("raster-array"!==r.type)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const o=new bn(t,this.scope,n);this.imageManager.addImageProvider(o,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(t){if(!e.h(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var n,r;this._spriteRequest=(r=(n,r)=>{if(this._spriteRequest=null,n)i?this._loadSprite(t):this.fire(new e.y(n));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.bt((n=this.map._requestManager).transformRequest(n.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void r(t);const n={},o=e.df(new e.bs(i));for(const t of o.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:vn(t),stretchX:t.metadata?xn(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?xn(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};n[t.name]=i}r(null,n)}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.y(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.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.imageManager.hasPatternsInFlight())return!1;if(!this.modelManager.isLoaded())return!1;if(this._styleColorTheme.lutLoading)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()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;if(this.hasSnowTransition())return!0;if(this.hasRainTransition())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}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.y(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let n=e.minzoom||0;n<(e.maxzoom||25.5);n++){const n=e.getProgramIds();if(n)for(const r of n){const n=e.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);n&&(i.style=this,this.fog&&(i._fogVisible=!0,n.overrideFog=!0,i.getOrCreateProgram(r,n)),i._fogVisible=!1,n.overrideFog=!1,i.getOrCreateProgram(r,n),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(n.overrideRtt=!0,i.getOrCreateProgram(r,n)))}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const n=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:n}=e[t];(i||n)&&(this._updateWorkerLayers(t,i,n),r=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}const o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(i,t)}):this.precompilePrograms(i,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&r&&this.mergeLayers();const s=this.imageManager.getPendingImageProviders();for(const e of s)e.sourceCache.used=!0;for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),n&&this.fire(new e.z("data",{dataType:"style"}))}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e)}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i])}for(const t in e)this._changes.resetUpdatedImages(t)}_updateWorkerLayers(e,t,i){const n=this.getFragmentStyle(e);n&&this.dispatcher.broadcast("updateLayers",{layers:t?n._serializeLayers(t):[],scope:e,removedIds:i||[],options:n.options})}setState(t,i){if(this._checkLoaded(),wn(this,ye(t)))return!1;(t=e.dn(t)).layers=Ut(t.layers);const n=function(t,i){if(!t)return[{command:Nt.setStyle,args:[i]}];let n=[];try{if(!e.bx(t.version,i.version))return[{command:Nt.setStyle,args:[i]}];if(e.bx(t.center,i.center)||n.push({command:Nt.setCenter,args:[i.center]}),e.bx(t.zoom,i.zoom)||n.push({command:Nt.setZoom,args:[i.zoom]}),e.bx(t.bearing,i.bearing)||n.push({command:Nt.setBearing,args:[i.bearing]}),e.bx(t.pitch,i.pitch)||n.push({command:Nt.setPitch,args:[i.pitch]}),e.bx(t.sprite,i.sprite)||n.push({command:Nt.setSprite,args:[i.sprite]}),e.bx(t.glyphs,i.glyphs)||n.push({command:Nt.setGlyphs,args:[i.glyphs]}),e.bx(t.imports,i.imports)||function(t=[],i=[],n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&r[e.source]?n.push({command:Nt.removeLayer,args:[e.id]}):s.push(e)});let a=t.terrain;a&&r[a.source]&&(n.push({command:Nt.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),e.bx(a,i.terrain)||n.push({command:Nt.setTerrain,args:[i.terrain]}),function(t,i,n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice(),c=Object.create(null);let u,h,d,p,f,m,g;for(u=0,h=0;u!(e.command in En));if(0===n.length)return!1;const r=n.filter(e=>!(e.command in Tn));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const o=[];return n.forEach(e=>{o.push(this[e.command](...e.args))}),i&&Promise.all(o).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(0===t.size)return this;for(const[i,n]of t.entries()){if(this.getImage(i))return this.fire(new e.y(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,n),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.y(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this)}updateImage(t,i,n=!1){this.imageManager.updateImage(t,this.scope,i),n&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})))}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModelURLs(t){return this.modelManager.addModelURLs(t,this.scope),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(t,i,n={}){return this._checkLoaded(),this._validate(Pe,`models.${t}`,i,null,n)||(this.modelManager.addModel(t,i,this.scope),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope,!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,n={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(ve,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=pt(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const o=t=>{const i=(t?"symbol:":"other:")+r.id,n=e.B(i,this.scope),o=this._sourceCaches[i]=new Lt(n,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const n=this.getOwnSourceCaches(t);for(const t of n){const i=e.dp(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.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}areTilesLoaded(){const e=this._mergedSourceCaches;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}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const n of t){if(this._validate(be,"lights",n))return;switch(n.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(n),e.updateTransitions(i)}else this.ambientLight=new et(n,Ke||(Ke=new e.a9({color:new e.aa(e.a6.properties_light_ambient.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(n),e.updateTransitions(i)}else this.directionalLight=new et(n,Xe||(Xe=new e.a9({direction:new e.ap(e.a6.properties_light_directional.direction),color:new e.aa(e.a6.properties_light_directional.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_directional.intensity),"cast-shadows":new e.aa(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.aa(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.aa(e.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const n=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ac(this.z||0,n);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const n=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=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.d3(s.x,s.y,s.z)[2]/90,l=n(r)*o*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity"),h=n(c)*u;return Number(((l+h)/2).toFixed(6))}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(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.dq(t)){const i=e.dr(t),n=this.fragments.find(({id:e})=>e===i);if(!n)return;const r=e.dp(t);return n.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i={},n=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const r in t){const o=this._featuresetSelectors[r]=[];for(const s of t[r].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const o=n(t.source,t.sourceLayer);if(o in i&&i[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${r}'s selector is not associated to the same source, skip this selector`);continue}i[o]=s.featureNamespace}let t;if(s.properties)for(const i in s.properties){const n=e.U(s.properties[i]);"success"===n.result&&(t=t||{},t[i]=n.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._uniqueFeatureID})}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return[];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const n=this.getFragmentStyle(i),r=n.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const o=[];for(const e of r[t].selectors){const t=n.getOwnLayer(e.layer);t&&o.push(t)}return o}getConfigProperty(t,i){const n=this.getFragmentStyle(t);if(!n)return null;const r=e.B(i,n.scope),o=n.options.get(r),s=o?o.value||o.default:null;return s?s.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const n=e.B(t,i);return this._mergedIndoor[n]}setIndoorData(e,t){this.map.indoor.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,n){const r=this.getFragmentStyle(t);if(!r)return;const o=r.stylesheet.schema;if(!o||!o[i])return;const s=e.U(n);if("success"!==s.result)return void wn(this,s.value);const a=s.value.expression,l=e.B(i,r.scope),c=r.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[i],g=e.U(o[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,Object.assign({},c,{value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m})),this.updateConfigDependencies(i)):this.fire(new e.y(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const n=i.stylesheet.schema;if(!n)return null;const r={};for(const t in n){const n=e.B(t,i.scope),o=i.options.get(n),s=o?o.value||o.default:null;r[t]=s?s.serialize():null}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const n in i){let r,o;const s=e.U(i[n].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[n]){const i=e.U(t[n]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[n];if(r){const t=e.B(n,this.scope);this.options.set(t,{default:r,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.y(new Error(`No schema defined for config option "${n}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty())}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t)}}),this._changes.setDirty()}addLayer(t,i,n={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.y(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(wn(this,e.ds(t)))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.dn(t),t=Object.assign(t,{source:r})),this._validate(Se,`layers.${r}`,t,{arrayIndex:-1},n))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=e.B(o.source,o.scope);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?a=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const l=this.getOwnLayerSourceCache(o),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&o.canCastShadows()&&c&&(l.castsShadows=!0);const u=this._changes.getRemovedLayer(o);if(u&&o.source&&l&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.B(o.source,o.scope);u.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),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],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const n=this.getOwnLayerSourceCache(t);if(n&&n.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}n.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 n=this._checkLayer(e);n&&(n.minzoom===t&&n.maxzoom===i||(null!=t&&(n.minzoom=t),null!=i&&(n.maxzoom=i),this._updateLayer(n)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(t,i,n={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bx(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Be,`layers.${r.id}.filter`,i,{layerType:r.type},n)||(r.filter=e.dn(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.dn(i.filter)}setLayoutProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.bx(o.getLayoutProperty(i),n)){if(null!=n&&(!r||!1!==r.validate)&&wn(o,Me.call(ye,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,n),0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),this._updateLayer(o)}}setLayerProperty(e,t,i,n={}){this._checkLoaded();const r=this._checkLayer(e);r&&("appearances"===t?(r.setAppearances(i),this._changes.setDirty()):r.isPaintProperty(t)?this.setPaintProperty(e,t,i,n):this.setLayoutProperty(e,t,i,n))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(e.bx(o.getPaintProperty(i),n))return;if(null!=n&&(!r||!1!==r.validate)&&wn(o,Ie.call(ye,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6})))return;const s=o.setPaintProperty(i,n);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),s&&this._updateLayer(o),this._changes.updatePaintProperties(o)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.setFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.setFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=t.sourceLayer,o=this._checkSource(n);if(!o)return;const s=o.type;if("geojson"===s&&r)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.setFeatureState(r,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.removeFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.removeFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=this._checkSource(n);if(!r)return;const o=r.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:n,importId:r}=t.target,o=this.getFragmentStyle(r),s=o.getFeaturesetLayers(n);for(const{source:n,sourceLayer:r}of s){const s=o.getFeatureState({id:t.id,source:n,sourceLayer:r});if(s&&!i)i=s;else if(!e.bx(i,s))return void this.fire(new e.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);i=this.getFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer})}return i}const i=t.source,n=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.du({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t)}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),n=e.B(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[n]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(n,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,n={},r=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){n[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t)}}}r.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=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&n[t.layer.id]{if(Cn.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=o[t.id]=o[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.y(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i)}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,o,n),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dv(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,n){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Be,"queryRenderedFeatures.filter",i.filter,null,i),r=e.b5(i.filter));const o="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:o,filter:r}));else{const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:o,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:o,filter:r,target:e})}}const a=this.queryRenderedTargets(t,s,n),l=[],c=new Set;for(const t of a)for(const i of t.variants[o])mt(i,t,c)||l.push(new e.dw(t,i));return l}queryRenderedTargets(t,i,n){const r={},o=(e,t,i,n)=>{const o=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(o.has3DLayers=!0),!n)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push(Object.assign({},i,{namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID}))};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:n}=t.target,r=this.getFragmentStyle(n);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!Cn.has(i.type)&&o(i,r.getOwnLayerSourceCache(i),t,e)}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Cn.has(i.type))continue;o(i,this.getLayerSourceCache(i),t)}const s=this._queryRenderedFeatures(t,r,n);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,t,i){const n=[],r=!!this.map._showQueryGeometry,o=tt.createFromScreenPoints(e,i);for(const e in t){const s=gt(o,t[e],this._availableImages,i,r);Object.keys(s).length&&n.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=_t(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&n.push(i)}return n}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Be,"querySourceFeatures.filter",i,null,t);let n=[];const r=this.getOwnSourceCaches(e);for(const e of r)n=n.concat(At(e,t));return n}addSourceType(e,t,i){return In.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(In.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(t,i,n={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e.bx(t[i],r[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(t,i,n),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let n=t;const r=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.dn(n),n=Object.assign(n,{source:t})}const t=Object.assign({},n),i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(we,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,r=i.get();for(const t of Object.keys(e.a6.terrain))!n.hasOwnProperty(t)&&e.a6.terrain[t].default&&(n[t]=e.a6.terrain[t].default);for(const n in t)if(!e.bx(t[n],r[n])){i.set(t,this.options),this.stylesheet.terrain=t;const n=this._getTransitionParameters({duration:0});i.updateTransitions(n),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Ze(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createSnow(e){const t=this.snow=new Je(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createRain(e){const t=this.rain=new Ye(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=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(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createFog(t);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const n=this._evaluateColorThemeData(i);this._loadColorTheme(n).then(()=>{this.fire(new e.z("colorthemeset")),t()}).catch(t=>{e.w(`Couldn't set color theme: ${t}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme())}_getTransitionParameters(t){return{now:e.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)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 ze(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const n=this._getTransitionParameters({duration:0});i.updateTransitions(n)}_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(t,i,n,r,o={}){if(o&&!1===o.validate)return!1;const s=Object.assign({},this.serialize());return wn(this,t.call(ye,Object.assign({key:i,style:s,value:n,styleSpec:e.a6},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dx.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.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),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()}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear()}}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()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope)})}updateSources(e){let t;this.directionalLight&&(t=fn(this.directionalLight));const i=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];t.hasElevation()&&!i.has(t.source)&&i.add(t.source)}for(const n in this._mergedSourceCaches){const r=this._mergedSourceCaches[n],o=i.has(r._source.id);r.update(e,void 0,void 0,t,o)}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,n,r,o,s,a=!1){let l=!1,c=!1;const u={},h={};for(const t of this._mergedOrder){const n=this._mergedLayers[t];if("symbol"!==n.type)continue;const r=e.B(n.source,n.scope);let o=u[r];if(!o){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),o=u[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const s=this.crossTileSymbolIndex.addLayer(n,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.z("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),i.zoom))&&(this.pauseablePlacement=new zi(i,this._mergedOrder,a,n,r,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,u,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;te===t.id))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return n.push(t),this._loadImports([t],!0);const r=n.findIndex(({id:e})=>e===i);return-1===r&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=n.slice(0,r).concat(t).concat(n.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(t);return-1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==n[r].url&&this.setImportUrl(t,i.url),e.bx(i.config,n[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.bx(i.data,n[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const n=this.getImportIndex(e);if(-1===n)return this;const r=this.getImportIndex(t);if(-1===r)return this;const o=i[n],s=this.fragments[n];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(o).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);if(-1===n)return this;i[n].url=t;const r=this.fragments[n];return r.style=this._createFragmentStyle(i[n]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),n=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete n[i].data,this.setImportUrl(e,n[i].url))}setImportConfig(e,t,i){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const o=this.fragments[n];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.style.updateConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return-1===i&&this.fire(new e.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}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(t,i){const n=e.B(t,i);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(t){const i=e.B(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);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)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e)}getImages(t,i,n){this.imageManager.getImages(i.images,i.scope,n),this._updateTilesForChangedImages();const r=t=>{if(t){const n=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,n)}},o=e.B(i.source,i.scope);r(this._mergedOtherSourceCaches[o]),r(this._mergedSymbolSourceCaches[o]),i.images.some(e=>e.iconsetId)&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,n){return e.dy(i,n)}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(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return!1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),n="building"===e.type;if(e.is3D(!!this.terrain)){if(i||n||t&&"batched-model"===t.type)return!0;if("model"===e.type)return!0}else if("symbol"===e.type)return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(e=>{e.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}In.getSourceType=function(e){return dt[e]},In.setSourceType=function(e,t){dt[e]=t},In.registerForPluginStateChange=e.dz;class Mn extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},e.aX(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=e,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(e){this._activeFloorsVisible=e,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(e){for(const[t,i]of Object.entries(e.buildings))if(this._buildings[t])for(const e of i.floorIds)this._buildings[t].floors[e]||(this._buildings[t].floors[e]=i.floors[e]);else this._buildings[t]=i;for(const t of e.activeFloors)this._activeFloors.add(t);this._updateIndoorSelector()}getIndoorTileOptions(e,t){const i=this._style.getIndoorSourceLayers(e,t);return i&&this._indoorState?{sourceLayers:i,indoorState:this._indoorState}:null}_updateUI(t,i,n){const r=function(t,i,n,r){let o=null,s=Number.MAX_SAFE_INTEGER;if(r<16)return null;for(const[r,a]of Object.entries(t)){const t=a.center;if(t){const a=i.distanceTo(e.aS.convert(t));a({id:e,name:n.floors[e].name,zIndex:n.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex);this.fire(new e.z("selector-update",{selectedFloorId:r,activeFloorsVisible:this._activeFloorsVisible,floors:o}))}_updateActiveFloors(){const e=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:e,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var Pn="\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;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Rn="\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 vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));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\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Ln="\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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}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);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Fn="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;}",kn="\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;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\nvec4 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; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(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;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif//DEPTH_OCCLUSION",Dn="#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",On="#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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",zn="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp 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(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Un="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",Nn="#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) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,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",Vn="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform 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;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\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_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {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)*shadow_opacity;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));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}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 jn=[];Wn(Pn,jn),Wn(Ln,jn),Wn(Rn,jn);const Gn={"_prelude_fog.vertex.glsl":Dn,"_prelude_terrain.vertex.glsl":kn,"_prelude_shadow.vertex.glsl":Nn,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":On,"_prelude_shadow.fragment.glsl":Vn,"_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":zn,"_prelude_raster_particle.glsl":Un},Hn={};qn("",kn),qn(On,Dn),qn(Vn,Nn),qn(zn,""),qn(Un,"");const Qn=qn(Rn,Ln),$n=Pn;var Zn={background:qn('#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:qn('#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 highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_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 vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp 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_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nfloat hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in 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 color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nshadowed_lighting_factor=dot(normal,u_lighting_directional_dir);\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\n#endif\nglFragColor=color; \n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\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;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\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_shadows;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);v_depth_shadows=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);}'),buildingBloom:qn("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),buildingDepth:qn("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;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:qn('#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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\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() {\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\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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:qn("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:qn('#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() {\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:qn("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:qn("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 vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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:qn("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:qn("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}'),elevatedStructuresDepth:qn("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:qn("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}"),elevatedStructures:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\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\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\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#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fill:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid 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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);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);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:qn('#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;\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\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\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,1.0/gl_FragCoord.w);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;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.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,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 INDICATOR_CUTOUT\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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#include "_prelude_material_table.vertex.glsl"\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;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\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;\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;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\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\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\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\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\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);float attr_height=height;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=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_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 cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_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);\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);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),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}'),fillExtrusionDepth:qn("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\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 is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\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\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp 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#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\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#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\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,height);\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"\n#include "_prelude_material_table.vertex.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 float u_width_scale;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 RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp 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 highp vec4 color\n#pragma mapbox: define mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\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 mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\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 is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_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\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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:qn('#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;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);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,1.0/gl_FragCoord.w));\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),0.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;\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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:qn("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;\n#endif\nHANDLE_WIREFRAME_DEBUG;\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 float u_dynamic_offset;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;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float 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=direction*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(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*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:qn("precision highp float;uniform highp 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:qn('#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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\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\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\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=(u_width_scale*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).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_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 trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\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*u_width_scale)+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) {float 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=mix(border_color*trim_alpha,out_color,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\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,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec3 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;uniform float u_width_scale;uniform highp float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\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#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\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 highp float v_depth;\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 a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\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;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);halfwidth=(u_width_scale*(left==1.0 ? a_z_offset_width.y : a_z_offset_width.z))/2.0;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-1.0*offset*u_width_scale;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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2];\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=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\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*u_floor_width_scale),(-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#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\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);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=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#endif\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=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:qn('#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;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform 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 highp 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;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\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 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#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid 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\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\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);vec3 globe_pos=latLngToECEF(latLng.xy);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);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;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);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\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\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}'),rasterParticle:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=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);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).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 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 float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);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) {vec2 merc_pos=vec2(mercatorX,mercatorY);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)*w,w);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\nuv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:qn("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:qn("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:qn('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:qn('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.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_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\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\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;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;}\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_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) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\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);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define APPEARANCE_ICON 1.0\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_auto_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\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\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_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;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 vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\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 highp float v_depth;\n#endif\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\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\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\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\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 a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;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 (a_apperance_icon==APPEARANCE_ICON) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,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;vec2 a;\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);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 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\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); \n#endif\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\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\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);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:qn('#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;\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,1.0/gl_FragCoord.w);\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,1.0/gl_FragCoord.w,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,1.0/gl_FragCoord.w);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;\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.);\n#endif\n}'),terrainDepth:qn("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:qn('#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+=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}',Fn),skyboxGradient:qn('#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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Fn),skyboxCapture:qn("\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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;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\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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 norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp 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(clamp(raster.rgb,vec3(0),vec3(1))*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\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=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:qn('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_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_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_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;glFragColor=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:qn('#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 highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\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 APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(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;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn 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\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}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;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp 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#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\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 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,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(mix(diffuse,baseColor,u_emissive_strength),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)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).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\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\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);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,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,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord);\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_node_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 highp vec4 v_pos_light_view_0;out highp 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 hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);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#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\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\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\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.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:qn("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 hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:qn("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);}"),snowParticle:qn("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:qn("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:qn("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:qn("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function Wn(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 qn(e,t){const i=/#include\s+"([^"]+)"/g,n=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,r={},o=[],s=[];if(e=e.replace(i,(e,t)=>(s.push(t),"")),(t=t.replace(i,(e,t)=>(o.push(t),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let a=[...jn];Wn(e,a),Wn(t,a);for(const e of[...o,...s])Gn[e]||console.error(`Undefined include: ${e}`),Hn[e]||(Hn[e]=[],Wn(Gn[e],Hn[e])),a=[...a,...Hn[e]];return{fragmentSource:e=e.replace(n,(e,t,i,n,o)=>(r[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(n,(e,t,i,n,o)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,a="float"===n?"vec2":n,l=`GET_ATTRIBUTE_${a}(a_${o}, materialInfo, ${s})`,c=o.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${i} ${n} a_${o};\n#endif\n`:r[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif\nout ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o}) \n #ifdef ${s}\n ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} a_${o};\n out ${i} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${o} = a_${o};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif \n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${o}0;\nin vec4 a_${o}1;\nin vec4 a_${o}2;\nin vec4 a_${o}3;\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${i} ${n} ${o} = a_${o};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = ${l};\n #else\n ${i} ${n} ${o} = a_${o};\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${i} ${n} ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`}),usedDefines:a,vertexIncludes:o,fragmentIncludes:s}}class Kn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,n,r,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!l&&e{const o=n.paint.get("hillshade-shadow-color"),s="none"===n.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=n.paint.get("hillshade-highlight-color"),l="none"===n.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=n.paint.get("hillshade-accent-color"),u="none"===n.paint.get("hillshade-accent-color-use-theme").constantOr("default"),h=n.paint.get("hillshade-emissive-strength");let d=e.an(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),n=e.d3(i.x,i.y,i.z);d=e.an(n[1])}const p=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:Xn(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),d],u_shadow:o.toPremultipliedRenderColor(s?null:n.lut),u_highlight:a.toPremultipliedRenderColor(l?null:n.lut),u_emissive_strength:h,u_accent:c.toPremultipliedRenderColor(u?null:n.lut)}})(t,n,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(n);d.draw(t,c.TRIANGLES,o,s,a,Xi.disabled,p,r.id,f,m,g)}function Yn(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(r,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function er(t,i,n){const r=t.context,o=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(o.TEXTURE1),Yn(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;r.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},o.RGBA8);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.disabled,((t,i)=>{const n=i.stride,r=e.bB();return e.cd(r,0,e.al,-e.al,0,0,1),e.bq(r,r,[0,-e.al,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ}})(i.tileID,s),n.id,c,u,h),i.needsHillshadePrepare=!1}class tr{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 ir extends tr{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}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 nr extends tr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class rr extends tr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class or extends tr{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 sr extends tr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class ar extends tr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class lr extends tr{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 cr extends tr{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 ur extends tr{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 hr extends tr{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 dr extends tr{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 pr extends tr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class fr extends tr{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 mr extends tr{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 gr extends tr{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}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 _r extends tr{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 Ar extends tr{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 yr extends tr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class vr extends tr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let xr=class extends tr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class br extends tr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class wr extends tr{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 Tr extends tr{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 Er extends tr{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 Cr extends tr{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 Sr extends tr{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 Br extends tr{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ir extends tr{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Mr extends tr{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 Pr extends tr{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 Rr extends tr{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 Lr extends tr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Fr extends Lr{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 kr extends Lr{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 Dr extends Lr{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 Or extends kr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const zr=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Ur=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,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:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function Nr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Vr=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,r){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:n,phase:0,duration:r,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()}},jr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Gr(e,t,i){if(0===t)return 0;const n=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*n}function Hr(e,t){const i=1<({u_matrix:e});function $r(t,i,n,r,o){if(o>0){const s=e.o.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.aA(h?a:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:a<1}:{opacity:d,mix:0,isFading:a<1}}return{opacity:1,mix:0,isFading:!1}}class Zr extends Lt{constructor(e){const t=pt("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",t,!1),t.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Wr extends Lt{constructor(e){const t=pt("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,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 n=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 It(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t}return t},{});for(const e in this._tiles)e in n||(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 qr extends e.aP{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 Kr extends e.bU{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(){const t=new e.bc,i=new e.b0,n=131;t.reserve(17161),i.reserve(33800);const r=e.al/128,o=e.al+r/2,s=o+r;for(let i=-r;io||i<0||i>o?24575:0,s=e.aA(Math.round(n),0,e.al),a=e.aA(Math.round(i),0,e.al);t.emplaceBack(s+r,a)}const a=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+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]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(n,e.be.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.bf.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.bf.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Wr(i.map),this.orthoMatrix=e.bB(),e.cd(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.al,0,e.al,0,1);const a=s.gl;this._overlapStencilMode=new Wi({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Zr(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.w(`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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),i.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,n=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=n;const r=null!=i?n-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.ak(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?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._emptyDEMTextureDirty=!0,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.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.ae.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(n.x,n.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const n=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map(e=>new qr(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[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 n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Yn(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const n=i.dem.tree.minimums[0];return n>0&&e++,t+n},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.dK({width:1,height:1},new Float32Array([n]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),o}setupElevationDraw(t,i,n){const r=this.painter.context,o=r.gl,s={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;c=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,r.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,r.activeTexture.set(o.TEXTURE2),h&&(s.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(n&&n.useDepthForOcclusion,i,s),n&&n.useMeterToDem&&a){const t=(1<{if(c===i)return;const n=[jr[i],"PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:n,overrideFog:r}),c=i},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=e.dE(u),g=[e.aF(u.center.lng),e.aJ(u.center.lat)],_=t.globeSharedBuffers,A=[u.width*e.o.devicePixelRatio,u.height*e.o.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=Gr(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const x=a.TRIANGLES;for(const c of r){const r=n.getTile(c),b=Wi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Nr(w,T)&&Vr.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Vr.getMorphValuesForProxy(c.key),C=E?1:0;E&&Object.assign(v,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dC(E.phase)}});const S=e.dF(c.canonical),B=e.dG(S.getCenter().lat),I=e.dH(c.canonical,S,B,u.worldSize/u._pixelsPerMercatorPixel),M=e.bj(e.dI(c.canonical)),P=Ur(u.expandedFarZProjMatrix,y,m,M,e.aj(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,h,u._farZ,I);if(d(c,C),l&&(i.setupElevationDraw(r,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),_)){const[e,i,n]=_.getGridBuffers(B,0!==h);l.draw(t,x,f,b,p,Xi.backCCW,P,"globe_raster",e,i,n)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of r){const{x:r,y:c,z:h}=o.canonical,d=0===c,m=c===(1<e.draw(t,a.TRIANGLES,f,Wi.disabled,p,Xi.disabled,Ur(u.expandedFarZProjMatrix,_,_,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,0,u._farZ),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&E(l,y),m&&t.renderDefaultSouthPole&&(_=e.cR(e.bB(),_,[1,-1,1]),E(l,x))}}}}(t,i,n,r,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=ln(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(jr[e]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),u&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),u.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=t.transform,g=Gr(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(_=mn(t.style,e,i))}{c=-1;const A=a.TRIANGLES,[y,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),x=Wi.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];Nr(b,w)&&Vr.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=Vr.getMorphValuesForProxy(c.key),E=T?1:0;let C;T&&(C={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.dC(T.phase)}});const S=zr(c.projMatrix,Hr(c.canonical,m.renderWorldCopies)?g/10:g,_);if(d(E),!l)continue;i.setupElevationDraw(r,l,C);const B=c.toUnwrapped();u&&u.setupShadows(B,l),t.uploadCommonUniforms(s,l,B,null,h),l.draw(t,A,f,x,p,Xi.backCCW,S,"terrain_raster",i.gridBuffer,y,v)}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?r.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;n.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(n.clear({color:e.ao.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,n=t;for(let r=0;ri}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 n=this._visibleDemTiles.filter(e=>e.dem).map(n=>{const r=n.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:n[0],height:n[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(n[0],n[1],!0,null);return o.colorAttachment.set(r.texture),o.depthAttachment=new Or(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof lt){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=n}_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=0;r--){const o=i[r];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],r=this.proxyToSource[o.key];let s=0;for(const e in r){const t=r[e],o=i[e];if(!o||o.length!==t.length||t.some((t,i)=>t!==o[i]||n[e]&&n[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 r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const n of i){if(t.proxyCachedFBO[n.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[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.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&&(r.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):Wi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,n=this.painter.context,r=n.gl;i._tileClippingMaskIDs={},n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=i.getOrCreateProgram("clippingMask");for(const n of e){const e=i._tileClippingMaskIDs[n.key]=--t;o.draw(i,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(n.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const n=[t.x,t.y,1,1];e.aC(n,n,i.pixelMatrixInverse),e.cJ(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=e.ce(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=e.d9([],n.slice(0,3),s);e.aw(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.bG(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(t,i,n){if(t.getSource()instanceof e.aT)return this._setupProxiedCoordsForImageSource(t,i,n);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,n){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,i)=>{const n=t.wrap+t.canonical.x/(1<s+c.max.x||r+oa+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let o,s,a;r=e.bB();const l=i.tileID.wrap-t.wrap<0?(o=e.al>>n,s=o*((i.tileID.canonical.x<=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}s.key!==t.key&&(c.push(s.key),n=i.getTile(s))}const u=e=>{c.forEach(t=>{r[t]=e}),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=s.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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 Xr(t,i,n){const r=function(t,i,n){const r=e.bI(i,t),o=e.bI(n,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(r+1,1));return s(.92,1,Math.asin(e.aA(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.c4(o,n.slice(0,3),r);const s=[0,0,0];e.c4(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.d7(a,o,s),e.da(a)}const Jr=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Yr=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","elevatedStructures","model","symbol"];class eo{static cacheKey(e,t,i,n){let r=`${t}${n?n.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,n,r,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...s];let l=r?r.defines():[];l=l.concat(s.map(e=>`#define ${e}`));const c="#version 300 es\n";let u=c+l.concat("precision mediump float;",$n,Qn.fragmentSource).join("\n");for(const e of n.fragmentIncludes)u+=`\n${Gn[e]}`;u+=`\n${n.fragmentSource}`;let h=c+l.concat("precision highp float;",$n,Qn.vertexSource).join("\n");for(const e of n.vertexIncludes)h+=`\n${Gn[e]}`;this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&-1!==n.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(h+="\nuniform int u_instanceID;\n"),h+=`\n${n.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(h=h.replaceAll("gl_InstanceID","u_instanceID"));const d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,u),a.compileShader(d),a.attachShader(this.program,d);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,h),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(d),this.fixedUniforms=o(t),this.binderUniforms=r?r.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.cg(t)}))(t)),(s.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.cg(t),u_dem_prev:new e.cg(t),u_dem_tl:new e.cj(t),u_dem_scale:new e.ci(t),u_dem_tl_prev:new e.cj(t),u_dem_scale_prev:new e.ci(t),u_dem_size:new e.ci(t),u_dem_lerp:new e.ci(t),u_exaggeration:new e.ci(t),u_depth:new e.cg(t),u_depth_size_inv:new e.cj(t),u_depth_range_unpack:new e.cj(t),u_occluder_half_size:new e.ci(t),u_occlusion_depth_offset:new e.ci(t),u_meter_to_dem:new e.ci(t),u_label_plane_matrix_inv:new e.ck(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.ch(t),u_tile_tr_up:new e.ch(t),u_tile_br_up:new e.ch(t),u_tile_bl_up:new e.ch(t),u_tile_up_scale:new e.ci(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.ck(t),u_fog_range:new e.cj(t),u_fog_color:new e.d2(t),u_fog_horizon_blend:new e.ci(t),u_fog_vertical_limit:new e.cj(t),u_fog_temporal_offset:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_globe_transition:new e.ci(t),u_is_globe:new e.cg(t),u_viewport:new e.cj(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.d2(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.ch(t),u_lighting_directional_dir:new e.ch(t),u_lighting_directional_color:new e.ch(t),u_ground_radiance:new e.ch(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.ck(t),u_light_matrix_1:new e.ck(t),u_fade_range:new e.cj(t),u_shadow_normal_offset:new e.ch(t),u_shadow_intensity:new e.ci(t),u_shadow_texel_size:new e.ci(t),u_shadow_map_resolution:new e.ci(t),u_shadow_direction:new e.ch(t),u_shadow_bias:new e.ch(t),u_shadowmap_0:new e.cg(t),u_shadowmap_1:new e.cg(t)}))(t)))}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}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(t,i,n,r,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!Jr.includes(this.name))||!(!h.layers3D||!Yr.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(g.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const n in t[e])i[e][n]&&i[e][n].set(i.program,n,t[e][n].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,a,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),f.bind(),d.setColorMode(new Qi([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.ao.transparent,[!0,!0,!0,!1])),d.setDepthMode(new $i(i.func===p.LESS?p.LEQUAL:i.func,$i.ReadOnly,i.range)),d.setStencilMode(Wi.disabled);const A=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=u||1;for(let t=0;t1?p.drawElementsInstanced(p.LINES,A,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,A,p.UNSIGNED_SHORT,y);o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(n),d.setColorMode(r)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const n of Object.keys(i))if(!i[n].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${n} not set but required by ${t} being defined`)}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=e.context,_=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(n),g.setColorMode(r),g.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const A={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new Kn)).bind(g,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i1?_.drawElementsInstanced(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2,m):c?_.drawElements(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2):_.drawArrays(t,o.vertexOffset,o.vertexLength);t===_.TRIANGLES&&c&&this._drawDebugWireframe(e,i,n,r,c,o,h,d,p,m)}}}function to(t,i,n=0){const r=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=o*(i.tileID.canonical.x+i.tileID.wrap*r),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ay(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:n}}const io={terrain:0,flat:1},no=e.bB(),ro=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A)=>{const y=i.style.light,v=y.properties.get("position"),x=[v.x,v.y,v.z],b=e.dN();"viewport"===y.properties.get("anchor")&&(e.dO(b,-i.transform.angle),e.dP(x,x,b));const w=y.properties.get("color").toPremultipliedRenderColor(null),T=i.transform,E={u_matrix:t,u_lightpos:x,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:no,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:io[u],u_base_type:io[h],u_ao:o,u_edge_radius:s,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:_,u_ground_shadow_factor:A};return"globe"===T.projection.name&&(E.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:n,u_height_type:io[r],u_base_type:io[o]}),so=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_)=>{const A=ro(e,t,i,n,r,o,s,a,c,u,h,d,p,f,m,g,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(A,to(t,l,_),y)},ao=(e,t,i,n,r,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:n?1:0,u_meter_to_tile:r,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:u,u_dynamic_offset:1}),lo=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),co=(e,t,i,n,r,o=0)=>Object.assign(lo(e,t,r),to(i,n,o)),uo=(e,t,i,n)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:n}),ho=(e,t,i,n,r,o,s=0)=>Object.assign(co(e,t,i,n,o,s),{u_world:r}),po=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),fo=(e,t,i,n,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:n,u_reset_depth:r}),mo=(e,t,i,n,r,o,s,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:n,u_camera_pos:r,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l}),go=e=>({u_matrix:e}),_o=e=>({u_matrix:e}),Ao=(t,i,n,r,o,s,a,l)=>{const c=e.al/s.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:n.getCameraToCenterDistance(l),u_extrude_scale:[n.pixelsToGLUnits[0]/c,n.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:o}},yo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),vo=e.bB(),xo=(t,i,n,r,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.dQ(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ay(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:vo,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=r,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.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:e.dS(d.paint.get("raster-saturation")),u_contrast_factor:e.dR(d.paint.get("raster-contrast")),u_spin_weights:Eo(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:bo(e.dT,g,A),u_colorization_offset:wo(e.dT,_,A),u_color_ramp:m,u_texture_offset:[v/(y+2*v),y/(y+2*v)],u_texture_res:[y+2*v,y+2*v],u_emissive_strength:x});function Eo(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]}const Co=.05,So=(e,t,i,n,r,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:r,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Bo=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:n,u_color_ramp:o,u_velocity_res:r,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Co,Co]}),Io=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:n,u_max_speed:r,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Co,Co]}),Mo=e.bB(),Po=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T)=>{const E=o.transform,C={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:E.getCameraToCenterDistance(y),u_rotate_symbol:+n,u_aspect_ratio:E.width/E.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:h,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Mo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Mo,u_up_vector:[0,-1,0],u_color_adj_mat:b,u_icon_transition:w||0,u_gamma_scale:r?o.transform.getCameraToCenterDistance(y)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:T||1,u_ground_shadow_factor:v,u_inv_matrix:e.bk(e.bB(),a),u_normal_scale:x,u_lutTexture:rn.LUT};return"globe"===y.name&&(C.u_tile_id=[f.canonical.x,f.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:n}),Lo=(t,i,n,r,o,s,a,l,c)=>Object.assign(function(t,i,n,r,o,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),u=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(s.tileID.canonical.x+s.tileID.wrap*c),d=u*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[a,l],u_pattern_size:n.displaySize,u_pattern_units_to_pixels:o?[r.transform.width,-1*r.transform.height]:[1/e.ay(s,1,r.transform.tileZoom),1/e.ay(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:n}),Fo=new Float32Array(e.bz([])),ko=(t,i,n,r,o,s,a,l,c,u,h,d,p,f=[0,0,0],m,g,_)=>{const A=o.style.light,y=A.properties.get("position"),v=[-y.x,-y.y,y.z],x=e.dN();"viewport"===A.properties.get("anchor")&&(e.dO(x,-o.transform.angle),e.dP(v,v,x));const b="MASK"===h.alphaMode,w=A.properties.get("color").toNonPremultipliedRenderColor(null),T=p.paint.get("model-ambient-occlusion-intensity"),E=p.paint.get("model-color").constantOr(e.ao.white).toNonPremultipliedRenderColor(null);return E.a=p.paint.get("model-color-mix-intensity").constantOr(0),_&&(E.r=_[0],E.g=_[1],E.b=_[2],E.a=_[3]),g&&(E.r=g.color.r,E.g=g.color.g,E.b=g.color.b,E.a=g.colorMix,d=g.emissionStrength,s=g.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:n,u_node_matrix:r||Fo,u_lightpos:v,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+b,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:rn.BaseColor,u_metallicRoughnessTexture:rn.MetallicRoughness,u_normalTexture:rn.Normal,u_occlusionTexture:rn.Occlusion,u_emissionTexture:rn.Emission,u_lutTexture:rn.LUT,u_color_mix:E.toArray01(),u_aoIntensity:T,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Do=(e,t=Fo,i=Fo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Oo={fillExtrusion:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_opacity:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_flood_light_color:new e.ch(t),u_vertical_scale:new e.ci(t),u_flood_light_intensity:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillExtrusionDepth:t=>({u_matrix:new e.ck(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_vertical_scale:new e.ci(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t)}),fillExtrusionPattern:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_height_factor:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_opacity:new e.ci(t),u_pattern_transition:new e.ci(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.ck(t),u_opacity:new e.ci(t),u_ao_pass:new e.ci(t),u_meter_to_tile:new e.ci(t),u_ao:new e.cj(t),u_flood_light_intensity:new e.ci(t),u_flood_light_color:new e.ch(t),u_attenuation:new e.ci(t),u_edge_radius:new e.ci(t),u_fb:new e.cg(t),u_fb_size:new e.ci(t),u_dynamic_offset:new e.ci(t)}),fill:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),fillOutline:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_ground_shadow_factor:new e.ch(t)}),fillOutlinePattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),building:t=>({u_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_opacity:new e.ci(t),u_faux_facade_ao_intensity:new e.ci(t),u_camera_pos:new e.ch(t),u_tile_to_meter:new e.ci(t),u_facade_emissive_chance:new e.ci(t),u_flood_light_color:new e.ch(t),u_flood_light_intensity:new e.ci(t)}),buildingBloom:t=>({u_matrix:new e.ck(t)}),buildingDepth:t=>({u_matrix:new e.ck(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.ck(t),u_depth_bias:new e.ci(t)}),elevatedStructures:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.ck(t),u_camera_pos:new e.ch(t),u_depth_bias:new e.ci(t),u_height_scale:new e.ci(t),u_reset_depth:new e.ci(t)}),circle:e.dX,collisionBox:t=>({u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_extrude_scale:new e.cj(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t)}),collisionCircle:t=>({u_matrix:new e.ck(t),u_inv_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_viewport_size:new e.cj(t)}),debug:t=>({u_color:new e.dA(t),u_matrix:new e.ck(t),u_overlay:new e.cg(t),u_overlay_scale:new e.ci(t)}),clippingMask:t=>({u_matrix:new e.ck(t)}),heatmap:t=>({u_extrude_scale:new e.ci(t),u_intensity:new e.ci(t),u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_up_dir:new e.ch(t)}),heatmapTexture:t=>({u_image:new e.cg(t),u_color_ramp:new e.cg(t),u_opacity:new e.ci(t)}),hillshade:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_latrange:new e.cj(t),u_light:new e.cj(t),u_shadow:new e.dA(t),u_highlight:new e.dA(t),u_emissive_strength:new e.ci(t),u_accent:new e.dA(t)}),hillshadePrepare:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_dimension:new e.cj(t),u_zoom:new e.ci(t)}),line:e.dW,linePattern:e.dV,raster:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_brightness_low:new e.ci(t),u_brightness_high:new e.ci(t),u_saturation_factor:new e.ci(t),u_contrast_factor:new e.ci(t),u_spin_weights:new e.ch(t),u_perspective_transform:new e.cj(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t),u_colorization_mix:new e.d2(t),u_colorization_offset:new e.ci(t),u_color_ramp:new e.cg(t),u_texture_offset:new e.cj(t),u_texture_res:new e.cj(t),u_emissive_strength:new e.ci(t)}),rasterParticle:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t)}),rasterParticleTexture:t=>({u_texture:new e.cg(t),u_opacity:new e.ci(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_tile_offset:new e.cj(t),u_velocity:new e.cg(t),u_color_ramp:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_velocity:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_speed_factor:new e.ci(t),u_reset_rate:new e.ci(t),u_rand_seed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),symbol:t=>({u_is_size_zoom_constant:new e.cg(t),u_is_size_feature_constant:new e.cg(t),u_size_t:new e.ci(t),u_size:new e.ci(t),u_camera_to_center_distance:new e.ci(t),u_rotate_symbol:new e.cg(t),u_aspect_ratio:new e.ci(t),u_fade_change:new e.ci(t),u_matrix:new e.ck(t),u_label_plane_matrix:new e.ck(t),u_coord_matrix:new e.ck(t),u_is_text:new e.cg(t),u_elevation_from_sea:new e.cg(t),u_pitch_with_map:new e.cg(t),u_texsize:new e.cj(t),u_texsize_icon:new e.cj(t),u_texture:new e.cg(t),u_texture_icon:new e.cg(t),u_gamma_scale:new e.ci(t),u_device_pixel_ratio:new e.ci(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_camera_forward:new e.ch(t),u_tile_matrix:new e.ck(t),u_up_vector:new e.ch(t),u_ecef_origin:new e.ch(t),u_is_halo:new e.cg(t),u_icon_transition:new e.ci(t),u_color_adj_mat:new e.ck(t),u_scale_factor:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_inv_matrix:new e.ck(t),u_normal_scale:new e.ci(t),u_lutTexture:new e.cg(t)}),background:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_color:new e.dA(t)}),backgroundPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_image:new e.cg(t),u_pattern_tl:new e.cj(t),u_pattern_br:new e.cj(t),u_texsize:new e.cj(t),u_pattern_size:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_pattern_units_to_pixels:new e.cj(t)}),terrainRaster:t=>({u_matrix:new e.ck(t),u_image0:new e.cg(t),u_skirt_height:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),skybox:t=>({u_matrix:new e.ck(t),u_sun_direction:new e.ch(t),u_cubemap:new e.cg(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxGradient:t=>({u_matrix:new e.ck(t),u_color_ramp:new e.cg(t),u_center_direction:new e.ch(t),u_radius:new e.ci(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dB(t),u_sun_direction:new e.ch(t),u_sun_intensity:new e.ci(t),u_color_tint_r:new e.d2(t),u_color_tint_m:new e.d2(t),u_luminance:new e.ci(t)}),globeRaster:t=>({u_proj_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_image0:new e.cg(t),u_grid_matrix:new e.dB(t),u_skirt_height:new e.ci(t),u_far_z_cutoff:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_viewport:new e.cj(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_horizon:new e.ci(t),u_transition:new e.ci(t),u_fadeout_range:new e.ci(t),u_atmosphere_fog_color:new e.d2(t),u_high_color:new e.d2(t),u_space_color:new e.d2(t),u_temporal_offset:new e.ci(t),u_horizon_angle:new e.ci(t)}),model:t=>({u_matrix:new e.ck(t),u_lighting_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_node_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_camera_pos:new e.ch(t),u_opacity:new e.ci(t),u_baseColorFactor:new e.d2(t),u_emissiveFactor:new e.d2(t),u_metallicFactor:new e.ci(t),u_roughnessFactor:new e.ci(t),u_baseTextureIsAlpha:new e.cg(t),u_alphaMask:new e.cg(t),u_alphaCutoff:new e.ci(t),u_baseColorTexture:new e.cg(t),u_metallicRoughnessTexture:new e.cg(t),u_normalTexture:new e.cg(t),u_occlusionTexture:new e.cg(t),u_emissionTexture:new e.cg(t),u_lutTexture:new e.cg(t),u_color_mix:new e.d2(t),u_aoIntensity:new e.ci(t),u_emissive_strength:new e.ci(t),u_occlusionTextureTransform:new e.d2(t)}),modelDepth:t=>({u_matrix:new e.ck(t),u_instance:new e.ck(t),u_node_matrix:new e.ck(t)}),groundShadow:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),stars:t=>({u_matrix:new e.ck(t),u_up:new e.ch(t),u_right:new e.ch(t),u_intensity_multiplier:new e.ci(t)}),snowParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_horizontalOscillationRadius:new e.ci(t),u_horizontalOscillationRate:new e.ci(t),u_boxSize:new e.ci(t),u_billboardSize:new e.ci(t),u_simpleShapeParameters:new e.cj(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_particleColor:new e.d2(t),u_direction:new e.ch(t)}),rainParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_texScreen:new e.cg(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_boxSize:new e.ci(t),u_rainDropletSize:new e.cj(t),u_distortionStrength:new e.ci(t),u_rainDirection:new e.ch(t),u_color:new e.d2(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_shapeDirectionalPower:new e.ci(t),u_shapeNormalPower:new e.ci(t),u_mode:new e.ci(t)}),vignette:t=>({u_vignetteShape:new e.ch(t),u_vignetteColor:new e.d2(t)}),occlusion:t=>({u_matrix:new e.ck(t),u_anchorPos:new e.ch(t),u_screenSizePx:new e.cj(t),u_occluderSizePx:new e.cj(t),u_color:new e.d2(t)})};class zo{constructor(e,t,i,n){this.id=zo.uniqueIdxCounter,zo.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=zo.uniqueIdxCounter,zo.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)}}zo.uniqueIdxCounter=0;const Uo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class No{constructor(e,t,i,n,r,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,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||r||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;i0&&e.vertexAttribDivisor(r,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Vo{constructor(e,t,i,n,r){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();n&&(this.colorAttachment=new Fr(e,o)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new kr(e,o):new Dr(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 jo{constructor(e,t){this.gl=e,this.clearColor=new ir(this),this.clearDepth=new nr(this),this.clearStencil=new rr(this),this.colorMask=new or(this),this.depthMask=new sr(this),this.stencilMask=new ar(this),this.stencilFunc=new lr(this),this.stencilOp=new cr(this),this.stencilTest=new ur(this),this.depthRange=new hr(this),this.depthTest=new dr(this),this.depthFunc=new pr(this),this.blend=new fr(this),this.blendFunc=new mr(this),this.blendColor=new gr(this),this.blendEquation=new _r(this),this.cullFace=new Ar(this),this.cullFaceSide=new yr(this),this.frontFace=new vr(this),this.program=new xr(this),this.activeTexture=new br(this),this.viewport=new wr(this),this.bindFramebuffer=new Tr(this),this.bindRenderbuffer=new Er(this),this.bindTexture=new Cr(this),this.bindVertexBuffer=new Sr(this),this.bindElementBuffer=new Br(this),this.bindVertexArrayOES=new Ir(this),this.pixelStoreUnpack=new Mr(this),this.pixelStoreUnpackPremultiplyAlpha=new Pr(this),this.pixelStoreUnpackFlipY=new Rr(this),this.options=t?Object.assign({},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.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&-1!==this.renderer.indexOf("PowerVR"),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),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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 zo(this,e,t,i)}createVertexBuffer(e,t,i,n,r){return new No(this,e,t,i,n,r)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,n){return new Vo(this,e,t,i,n)}clear({color:e,depth:t,stencil:i,colorMask:n}){const r=this.gl;let o=0;e&&(o|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(n||[!0,!0,!0,!0])),void 0!==t&&(o|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.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(t){e.bx(t.blendFunction,Qi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Go;function Ho(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=[e.aF(u.center.lng),e.aJ(u.center.lat)],d=n.layout.get("symbol-placement"),p=n.layout.get("text-variable-anchor"),f="map"===n.layout.get("icon-rotation-alignment"),m="map"===n.layout.get("text-rotation-alignment"),g="point"!==d,_=[];let A=0,y=0;for(let l=0;l0){const t=e.bB(),i=L;e.cO(t,x.placementInvProjMatrix,u.glCoordMatrix),e.cO(t,t,x.placementViewportMatrix),_.push({circleArray:k,circleOffset:y,transform:i,invTransform:t,projection:x.getProjection()}),A+=k.length/4,y=A}if(!F)continue;t.terrain&&t.terrain.setupElevationDraw(v,R);const D=M?[d.canonical.x,d.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:C,y:S,z:B,angle:L})}else fi(b,d)}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(i=mn(t.style,e,n))}return i},Q=e=>{C.depthOcclusionForSymbolsAndCircles&&(n.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},$=i=>{n.lut&&!w&&(n.lut.texture||(n.lut.texture=new e.d_(t.context,n.lut.image,[n.lut.image.height,n.lut.image.height,n.lut.image.height],T.gl.RGBA8)),T.activeTexture.set(T.gl.TEXTURE0+rn.LUT),n.lut.texture&&n.lut.texture.bind(T.gl.LINEAR,T.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},Z=()=>{const i=S&&"point"!==n.layout.get("symbol-placement"),a=[];Q(a),$(a);const c=i||V,h="road"===s.elevationType,_=t.shadowRenderer,w=h&&I&&!!_&&_.enabled,T=H(w),B=h&&I&&!t.terrain?F:L,M=n.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),M>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),0===A&&0===y&&0===v&&1===x||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),w&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&I&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS");const P=s.icon.programConfigurations.get(n.id),R=t.getOrCreateProgram("symbol",{config:P,defines:a}),D=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],z=s.iconSizeData,N=e.bJ(z,C.zoom),Z=I||!C.isOrthographic,W=ti(f,r.tileID.canonical,I,S,C,s.getProjection(),m),q=ni(f,r.tileID.canonical,I,S,C,s.getProjection(),m),K=t.translatePosMatrix(q,r,l,u,!0),X=t.translatePosMatrix(f,r,l,u),J=c?Qo:W,Y=S&&!I&&!i;let ee=U;!O&&!C.mercatorFromTransition||S||(ee=$o(C));const te=d?ee:U,ie=n.getColorAdjustmentMatrix(A,y,v,x),ne=Po(z.kind,N,Y,I,t,X,J,K,b,!1,D,[0,0],0,o,p,k,j,te,s.getProjection(),T,G,ie,M,null),re=r.imageAtlasTexture?r.imageAtlasTexture:null,oe=1!==n.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,se=s.sdfIcons||t.options.rotating||t.options.zooming||oe||Z?E.LINEAR:E.NEAREST,ae=s.sdfIcons&&0!==n.paint.get("icon-halo-width").constantOr(1),le=t.terrain&&I&&i?e.bk(e.bB(),W):Qo;if(i&&s.icon){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),a=ii(f,r.tileID.canonical,I,S,C,s.getProjection(),m),l=n.layout.get("icon-size-scale-range"),c=e.aA(t.scaleFactor,l[0],l[1]);ai(s,f,t,!1,a,q,I,g,i,o,c)}return{program:R,buffers:s.icon,uniformValues:ne,atlasTexture:re,atlasTextureIcon:null,atlasInterpolation:se,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:ae,depthMode:B,tile:r,renderWithShadows:w,labelPlaneMatrixInv:le}},W=()=>{const i=B&&"point"!==n.layout.get("symbol-placement"),a=[],l=i||D||V,u="road"===s.elevationType,g=t.shadowRenderer,A=u&&M&&!!g&&g.enabled,y=H(A),v=u&&M&&!t.terrain?F:L;t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||u&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),A&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),u&&M&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Q(a);const x=s.text.programConfigurations.get(n.id),w=t.getOrCreateProgram("symbol",{config:x,defines:a});let T,S=[0,0],I=null;const P=s.textSizeData;s.iconsInText&&(S=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],I=r.imageAtlasTexture?r.imageAtlasTexture:null,T=M||!C.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?E.LINEAR:E.NEAREST);const R=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],z=n.layout.get("text-size-scale-range"),N=e.aA(t.scaleFactor,z[0],z[1]),$=e.bJ(P,C.zoom,N),Z=ti(f,r.tileID.canonical,M,B,C,s.getProjection(),m),W=ni(f,r.tileID.canonical,M,B,C,s.getProjection(),m),q=t.translatePosMatrix(W,r,c,h,!0),K=t.translatePosMatrix(f,r,c,h),X=l?Qo:Z,J=B&&!M&&!i;let Y=U;!O&&!C.mercatorFromTransition||B||(Y=$o(C));const ee=Po(P.kind,$,J,M,t,K,X,q,b,!0,R,S,0,o,p,k,j,d?Y:U,s.getProjection(),y,G,null,null,N),te=r.glyphAtlasTexture?r.glyphAtlasTexture:null,ie=E.LINEAR,ne=0!==n.paint.get("text-halo-width").constantOr(1),re=t.terrain&&M&&i?e.bk(e.bB(),Z):Qo;if(i&&s.text){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),n=ii(f,r.tileID.canonical,M,B,C,s.getProjection(),m);ai(s,f,t,!0,n,W,M,_,i,o,N)}return{program:w,buffers:s.text,uniformValues:ee,atlasTexture:te,atlasTextureIcon:I,atlasInterpolation:ie,atlasInterpolationIcon:T,isSDF:!0,hasHalo:ne,depthMode:v,tile:r,renderWithShadows:A,labelPlaneMatrixInv:re}},q=s.icon.segments.get().length,K=s.text.segments.get().length,X=q&&!a.onlyText?Z():null,J=K&&!a.onlyIcons?W():null,Y=n.paint.get("icon-opacity").constantOr(1),ee=n.paint.get("text-opacity").constantOr(1);if(P&&s.canOverlap){R=!0;const t=Y&&!a.onlyText?s.icon.segments.get():[],i=ee&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)z.push({segments:new e.bf([i]),sortKey:i.sortKey,state:X});for(const t of i)z.push({segments:new e.bf([t]),sortKey:t.sortKey,state:J})}else a.onlyText||z.push({segments:Y?s.icon.segments:new e.bf([]),sortKey:0,state:X}),a.onlyIcons||z.push({segments:ee?s.text.segments:new e.bf([]),sortKey:0,state:J})}R&&z.sort((e,t)=>e.sortKey-t.sortKey);for(const e of z){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(C.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,2),r.u_is_halo=0}else{if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,1)),r.u_is_halo=0}Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,i.uniformValues,1)}}}function Ko(e,t,i,n,r,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];r.draw(n,n.context.gl.TRIANGLES,o,s,a,Xi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),u,c)}function Xo(t,i){const n=1<=sn?1:t.pitch/sn))),2*i}(t.transform),u=t.transform.getFreeCameraOptions().position,h="elevatedStructuresDepthReconstruct",d=t.getOrCreateProgram(h,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(h);for(const e of r){const r=i.getTile(e),h=r.getBucket(n);if(!h)continue;const f=h.elevatedStructures;if(!f)continue;const m=h.elevationBufferData.heightRange,g=Xo(e.toUnwrapped(),u),_=t.translatePosMatrix(e.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));let A,y,v,x;if("initialize"===o){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=d}else if("reset"===o){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;A=fo(_,g,0,0,1),y=l,v=f.maskSegments,x=d}else if("geometry"===o){if(0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=p}x.draw(t,s.TRIANGLES,y,Wi.disabled,Qi.disabled,Xi.disabled,A,n.id,f.vertexBuffer,f.indexBuffer,v,n.paint,t.transform.zoom)}}function Yo(t,i,n){const{painter:r,sourceCache:o,layer:s,coords:a,colorMode:l,elevationType:c,terrainEnabled:u,pass:h}=t,d=r.context.gl,p=s.paint.get("fill-pattern"),f=s.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=c;"road"!==c||i&&!u||(g="none");const _="road"===g,A=t.painter.shadowRenderer,y=_&&!!A&&A.enabled,v=new $i(r.context.gl.LEQUAL,$i.ReadOnly,r.depthRangeFor3D);let x=[0,0,0];if(y){const e=r.style.directionalLight,t=r.style.ambientLight;e&&t&&(x=mn(r.style,e,t))}const b=p&&p.constantOr(1),w=(t,h)=>{let p,g,w,T,E;h?(p=b&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",w=d.LINES):(p=b?"fillPattern":"fill",w=d.TRIANGLES);for(const C of a){const a=o.getTile(C);if(b&&!a.patternsLoaded())continue;const S=a.getBucket(s);if(!S)continue;const B=i?S.elevationBufferData:S.bufferData;if(B.isEmpty())continue;r.prepareDrawTile();const I=B.programConfigurations.get(s.id),M=r.isTileAffectedByFog(C),P=[],R=[];_&&(P.push("ELEVATED_ROADS"),R.push(B.elevatedLayoutVertexBuffer)),y&&P.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),b&&(r.context.activeTexture.set(d.TEXTURE0),a.imageAtlasTexture&&a.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),I.updatePaintBuffers());let L=!1;if(m&&a.imageAtlas){const t=a.imageAtlas,i=e.e2.from(m),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),o=t.patternPositions.get(n),s=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;L=!!o&&!!s,o&&I.setConstantPatternPositions(o,s)}f>0&&(L||I.getPatternTransitionVertexBuffer("fill-pattern"))&&P.push("FILL_PATTERN_TRANSITION");const F=r.getOrCreateProgram(p,{config:I,overrideFog:M,defines:P}),k=r.translatePosMatrix(C.projMatrix,a,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));y&&A.setupShadows(a.tileID.toUnwrapped(),F,"vector-tile");const D=s.paint.get("fill-emissive-strength");if(h){T=B.lineIndexBuffer,E=B.lineSegments;const e=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[d.drawingBufferWidth,d.drawingBufferHeight];g="fillOutlinePattern"===p&&b?ho(k,D,r,a,e,x,f):uo(k,D,e,x)}else T=B.indexBuffer,E=B.triangleSegments,g=b?co(k,D,r,a,x,f):lo(k,D,x);r.uploadCommonUniforms(r.context,F,C.toUnwrapped());let O=t;("road"===c&&!u||"offset"===c)&&(O=v),F.draw(r,w,O,n||r.stencilModeForClipping(C),l,Xi.disabled,g,s.id,B.layoutVertexBuffer,T,E,s.paint,r.transform.zoom,I,R)}};r.renderPass===h&&w(r.depthModeForSublayer(1,"opaque"===r.renderPass?$i.ReadWrite:$i.ReadOnly),!1),"none"===g&&"translucent"===r.renderPass&&s.paint.get("fill-antialias")&&w(r.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,$i.ReadOnly),!0)}function es(t,i,n,r,o,s,a,l){n.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=n.paint.get("fill-extrusion-pattern"),p=n.paint.get("fill-extrusion-pattern-cross-fade"),f=d.constantOr(null),m=d.constantOr(1),g=n.paint.get("fill-extrusion-opacity"),_=t.style.enable3dLights(),A=n.paint.get(_&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],v=n.layout.get("fill-extrusion-edge-radius"),x=v>0&&!n.paint.get("fill-extrusion-rounded-roof"),b=x?0:v,w="globe"===h.projection.name?e.ea():0,T="globe"===h.projection.name,E=T?e.aj(h.zoom):0,C=[e.aF(h.center.lng),e.aJ(h.center.lat)],S="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),B=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(S?null:n.lut).toArray01().slice(0,3),I=n.paint.get("fill-extrusion-flood-light-intensity"),M=n.paint.get("fill-extrusion-vertical-scale"),P=0!==n.paint.get("fill-extrusion-line-width").constantOr(1),R=n.paint.get("fill-extrusion-height-alignment"),L=n.paint.get("fill-extrusion-base-alignment"),F=ln(t,n.paint.get("fill-extrusion-cutoff-fade-range")),k=[];let D;T&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),x&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),I>0&&k.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),P&&k.push("RENDER_WALL_MODE");const O="shadow"===t.renderPass,z=t.shadowRenderer,U=O&&!!z,N=O?Xi.disabled:Xi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let V=[0,0,0];if(z){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(V=mn(t.style,e,i)),O||(k.push("RENDER_SHADOWS","DEPTH_TEXTURE"),z.useNormalOffset&&k.push("NORMAL_OFFSET")),D=k.concat(["SHADOWS_SINGLE_CASCADE"])}const j=U?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",G=n.getLayerRenderingStats();for(const d of r){const r=i.getTile(d),_=r.getBucket(n);if(!_||_.projection.name!==h.projection.name)continue;let A=!1;z&&(A=0===z.getMaxCascadeForTile(d.toUnwrapped()));const v=t.isTileAffectedByFog(d),x=_.programConfigurations.get(n.id);let S=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.e2.from(f),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),o=i.getSecondary(),s=t.patternPositions.get(n),a=o?t.patternPositions.get(o.scaleSelf(e.o.devicePixelRatio).toString()):null;S=!!s&&!!a,s&&x.setConstantPatternPositions(s,a)}p>0&&(S||x.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const U=t.getOrCreateProgram(j,{config:x,defines:A?D:k,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(r,U,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=U.getAttributeLocation(u,"a_centroid_pos");-1!==e&&u.vertexAttrib2f(e,0,0)}!O&&z&&z.setupShadows(r.tileID.toUnwrapped(),U,"vector-tile"),m&&(t.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),x.updatePaintBuffers());const H=n.paint.get("fill-extrusion-vertical-gradient"),Q=1/_.tileToMeter;let $;if(O&&z){if(as(r.tileID,_.maxHeight,t))continue;const e=z.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());$=oo(e,b,Q,M,R,L)}else{const e=t.translatePosMatrix(d.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,d.canonical);$=m?so(e,t,H,g,y,b,Q,d,r,w,R,L,E,C,i,B,M,p):ro(e,t,H,g,y,b,Q,d,w,R,L,E,C,i,B,M,I,V)}t.uploadCommonUniforms(c,U,d.toUnwrapped(),null,F);let Z=_.segments;if("mercator"===h.projection.name&&!O&&(Z=_.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!Z.get().length))continue;if(G)if(O)for(const e of Z.get())G.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of Z.get())G.numRenderedVerticesInTransparentPass+=e.primitiveLength;const W=[];(t.terrain||l)&&W.push(_.centroidVertexBuffer),T&&W.push(_.layoutVertexExtBuffer),P&&W.push(_.wallVertexBuffer),U.draw(t,c.gl.TRIANGLES,o,s,a,N,$,n.id,_.layoutVertexBuffer,_.indexBuffer,Z,n.paint,t.transform.zoom,x,W)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class ts{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function is(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i.context,b=x.gl,w=i.transform,T=i.transform.zoom,E=[],C=t.translate,S=t.translateAnchor,B=t.edgeRadius,I=ln(i,t.cutoffFadeRange);"clear"===h?(E.push("CLEAR_SUBPASS"),v&&(E.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),v.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),A&&E.push("HAS_CENTROID"),I.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=(e,t,n,o,h)=>{let y=E;null!=t.groundRadiusBuffer&&(y=E.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),w=i.isTileAffectedByFog(e),C=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:w}),S=ao(i,o,d,u,h,[p,f*h],m,g,_,T>=17?0:B*h,v?v.size[0]:0),M=[];A&&M.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&M.push(t.groundRadiusBuffer),i.uploadCommonUniforms(x,C,e.toUnwrapped(),null,I),C.draw(i,x.gl.TRIANGLES,s,a,l,c,S,r.id,t.vertexBuffer,t.indexBuffer,n,r.paint,T,b,M)};for(const t of o){const o=n.getTile(t),s=o.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,o,C,S),n=a.getDefaultSegment();M(t,a,n,e,l)}if(y)for(let s=0;s<4;s++){const a=e.e8[s](t),c=n.getTile(a);if(!c)continue;const u=c.getBucket(r);if(!u||u.projection.name!==w.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.al,0,0],p=1):1===s?(d=[e.al,0,0],p=0):2===s?(d=[0,-e.al,0],p=3):(d=[0,e.al,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.bq(m,t.projMatrix,d),M(t,h,f,i.translatePosMatrix(m,o,C,S),l)}}}function ns(t,i,n,r,o,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(n):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=t=>new e.P(Math.ceil((t+e.ec)*e.ed),0),u=e=>{const t=i.getSource().minzoom,n=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(h[0]=Math.min(t.min.y,i.min.y),h[1]=Math.max(t.max.y,i.max.y),h[2]=e.al-i.min.x>t.max.x?i.min.x-e.al:t.max.x,h),p=(t,i)=>(h[0]=Math.min(t.min.x,i.min.x),h[1]=Math.max(t.max.x,i.max.x),h[2]=e.al-i.min.y>t.max.y?i.min.y-e.al:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,r,o,a,c,u)=>{if(!s)return 0;const h=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=u<0?e.al+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&u<0||0!==r&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(n,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const o=e.e8[t](n),l=u(o);if(!(l&&l instanceof e.e9))continue;const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;if(s&&h&&h.dem&&r.borderDEMTileTimestamp[t]!==h.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=h.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==r.canonical.z,A=l.borderFeatureIndices[d];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(p)for(const e of A)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}for(const n of i){const i=r.featuresOnBorder[n],s=r.centroidData[i.centroidDataIndex],u=i.borders[t];let p;for(;yu[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&yu[1]-3)&&(v++,++y!==A.length);)p=l.featuresOnBorder[A[y]];p=l.featuresOnBorder[A[n]];let x=!1;if(v>=1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(v=1,x=!0,y=n+1)}else if(0===v){r.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&x&&(((g=s).flags|(_=b).flags)&e.eb?(g.flags|=e.eb,_.flags|=e.eb):(g.flags&=~e.eb,_.flags&=~e.eb));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)y=n,s.centroidXY=b.centroidXY=new e.P(0,0);else if(h&&h.dem&&!w){const i=f[t](s,b),n=t%2?e.al-1:0,r=m(i[0],Math.min(e.al-1,i[1]),n,h,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(r)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else r.showCentroid(i)}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}var g,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const rs=[1,0,0],os=[0,1,0],ss=[0,0,1];function as(t,i,n){const r=n.transform,o=n.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=r.tileSize*o._cascades[n.currentShadowCascade].scale;let l=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[rs,os,ss,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===r.projection.name,p=r.scaleZoom(a),f=e.cA.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ls(t){const{painter:i,source:n,layer:r,coords:o}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,u=i.shadowRenderer,h=e.ee(i.transform.center.lat,i.transform.zoom),d=ln(i,r.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF")),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const p of o){const o=n.getTile(p),f=o.getBucket(r);if(!f)continue;u&&0===u.getMaxCascadeForTile(p.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(r.id);let g,_,A,y=i.translatePosMatrix(p.expandedProjMatrix,o,[0,0],"map");if(y=e.cR(e.bB(),y,[1,1,t.verticalScale]),l&&u){if(as(o.tileID,f.maxHeight*h,i))continue;let n=u.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());n=e.cR(e.bB(),n,[1,1,t.verticalScale]),A=_o(n),g=_=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1})}else if(c)g=_=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),A=go(y);else{const n=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.cR(n,n,[1,1,t.verticalScale]);const r=e.bB();e.cR(r,n,[1,-1,1/h]),e.bk(r,r),e.ef(r,r);const o=i.transform.getFreeCameraOptions().position,a=1<{if(c){const o=e.entranceBloom;n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,Xi.disabled,A,r.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,r.paint,i.transform.zoom,m,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{const o=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,l?Xi.disabled:Xi.backCW,A,r.id,e.layoutVertexBuffer,e.indexBuffer,o,r.paint,i.transform.zoom,m,s)}};i.uploadCommonUniforms(a,_,p.toUnwrapped(),null,d),f.buildingWithoutFacade&&v(f.buildingWithoutFacade,_),f.buildingWithFacade&&(g!==_&&i.uploadCommonUniforms(a,g,p.toUnwrapped(),null,d),v(f.buildingWithFacade,g))}}function cs(t,i,n,r,o,s,a,l,c,u,h,d,p){const f=t.context.gl,m=t.depthModeForSublayer(1,$i.ReadOnly,f.LEQUAL,!0),g=.1*(1-(_=h))+3*_;var _;const A=t._showOverdrawInspector,y=d,v=new ts;A||is(v,t,i,n,r,m,new Wi({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),new Qi([f.ONE,f.ONE,f.ONE,f.ONE],e.ao.transparent,[!1,!1,!1,!0],f.MIN),Xi.disabled,o,"sdf",s,a,l,c,u,g,y,!1);{const h=A?Wi.disabled:new Wi({func:f.EQUAL,mask:255},255,255,f.KEEP,f.DECR,f.DECR),d=A?t.colorModeForRenderPass():new Qi([f.ONE_MINUS_DST_ALPHA,f.DST_ALPHA,f.ONE,f.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(v,t,i,n,r,m,h,d,Xi.disabled,o,"color",s,a,l,c,u,g,y,!1)}}function us(t){return[t[0]*e.eg,t[1]*e.eg,t[2]*e.eg,0]}function hs(t,i,n,r,o,s,a,l,c){const u=r.getSource(),h=n.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=r.getTile(i)),u instanceof e.aT?(p=u.texture,f=e.dJ(0,0,n.transform)):d&&i&&(p=d.texture,f=e.dJ(i.canonical.z,i.canonical.x,n.transform)),!p||!f)return;t||(f=e.cR(e.bB(),f,[1,-1,1]));const m=n.context,g=m.gl,_="nearest"===o.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,A=n.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const v=new $i(g.LEQUAL,$i.ReadWrite,n.depthRangeFor3D),x=Float32Array.from(n.transform.expandedFarZProjMatrix),b=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0))));n.terrain&&n.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),p.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),p.bind(_,g.CLAMP_TO_EDGE),"useMipmap"in p&&m.extTextureFilterAnisotropic&&n.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,T,E,C]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),S=o.paint.get("raster-elevation");let B;t?(B=w,n.renderDefaultNorthPole=0!==S):(B=T,n.renderDefaultSouthPole=0!==S);const I=us(a.mix),M=((e,t,i,n,r,o,s,a,l,c,u,h,d)=>To(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],n,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(x,b,f,e.aj(n.transform.zoom),0,o,0,S,0,I,a.offset,a.range,s),P=n.getOrCreateProgram("raster",{defines:y});n.uploadCommonUniforms(m,P,null),P.draw(n,g.TRIANGLES,v,c,A,l,M,o.id,B,E,C)}function ds(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),n=i-t,r=.2*e.height,o=t+r;return[t,i,(o-r-t)/n,(o-t)/n]}function ps(e,t,i,n){if(e)return t instanceof ht&&e instanceof Mt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:us(n.mix),offset:n.offset,buffer:0,tileSize:1}}var fs=e.eh([{name:"a_index",type:"Int16",components:1}]);class ms{constructor(t,i,n,r){const o={width:n[0],height:n[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const n=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.ei;o.reserve(r);for(let e=0;e0){const t=e.bi(n.canonical,c),i=e.ek(t);p=e.aB(new Float32Array(16),c.globeMatrix,i),e.aB(p,c.projMatrix,p)}const f=e.bB();f[12]+=2*o/(e.o.devicePixelRatio*c.width),f[13]+=2*s/(e.o.devicePixelRatio*c.height),e.aB(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),g=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=$i.disabled,A=Wi.disabled,y=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const x=g._tileDebugBuffer||t.debugBuffer,b=g._tileDebugIndexBuffer||t.debugIndexBuffer,w=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,A,y,Xi.disabled,yo(p,r.toPremultipliedRenderColor(null)),v,x,b,w,null,null,null,[g._globeTileDebugBorderBuffer]),a){const e=g.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(r+=` => ${n.overscaledZ}`),r+=` ${g.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,r)}const T=i.getTile(n).tileSize,E=512/Math.min(T,512)*(n.overscaledZ/c.zoom)*.5,C=g._tileDebugTextBuffer||t.debugBuffer,S=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,B=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,A,Qi.alphaBlended,Xi.disabled,yo(p,e.ao.transparent.toPremultipliedRenderColor(null),E),v,C,S,B,null,null,null,[g._globeTileDebugTextBuffer])}function Es(e,t,i,n){Ss(e,0,t+i/2,e.transform.width,i,n)}function Cs(e,t,i,n){Ss(e,t-i/2,0,i,e.transform.height,n)}function Ss(t,i,n,r,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,n*e.o.devicePixelRatio,r*e.o.devicePixelRatio,o*e.o.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Bs=e.eh([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Is}=Bs;function Ms(e,t,i,n){e.emplaceBack(t,i,n)}class Ps{constructor(t){this.vertexArray=new e.el,this.indices=new e.b0,Ms(this.vertexArray,-1,-1,1),Ms(this.vertexArray,1,-1,1),Ms(this.vertexArray,-1,1,1),Ms(this.vertexArray,1,1,1),Ms(this.vertexArray,-1,-1,-1),Ms(this.vertexArray,1,-1,-1),Ms(this.vertexArray,-1,1,-1),Ms(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=t.createVertexBuffer(this.vertexArray,Is),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.bf.simpleSegment(0,0,36,12)}}function Rs(t,i,n,r,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.en(e.dN(),r),o,u,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Ls=e.eh([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Fs{constructor(t){const i=new e.eo;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new e.b0;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Ls.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.bf.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const ks=e.eh([{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 Ds{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Os{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Qi([1,0,1,0],e.ao.transparent,[!1,!1,!1,!0]),this.params=new Ds,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Fs(i);const t=this.params.sizeRange,n=this.params.intensityRange,r=function(t){const i=e.eq(30),n=[];for(let r=0;r{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,n,r,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:n,u_horizon:r,u_transition:o,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,g,u,d,f,A,x);t.uploadCommonUniforms(n,l);const h=this.atmosphereBuffer;h&&l.draw(t,r.TRIANGLES,s,Wi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",h.vertexBuffer,h.indexBuffer,h.segments)};b(!1),b(!0)}drawStars(t,i){const n=e.aA(i.properties.get("star-intensity"),0,1);if(0===n)return;const r=t.context,o=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.c6([]);e.c8(l,l,-s._pitch),e.c7(l,l,-s.angle),e.c8(l,l,e.an(s._center.lat)),e.es(l,l,-e.an(s._center.lng));const c=e.cb(new Float32Array(16),l),u=e.aB([],s.starsProjMatrix,c),h=e.en([],c),d=e.et([],h),p=[0,1,0];e.dP(p,p,d),e.c4(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.dP(f,f,d),e.c4(f,f,this.params.sizeMultiplier);const m=(g=p,_=f,A=n,{u_matrix:Float32Array.from(u),u_up:g,u_right:_,u_intensity_multiplier:A});var g,_,A;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,this.colorModeAlphaBlendedWriteRGB,Xi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class zs{constructor(){this.visibleTiles=[]}updateBorders(t,i){const n=[],r=[],o=t._getRenderableCoordinates(!1,!0);for(const e of o){const o=t.getTile(e);if(!o.hasData())continue;const s=o.getBucket(i);s&&(s.isEmpty()||(n.push(e.key),r.push({bucket:s,tileID:e.canonical})))}let s=n.length!==this.visibleTiles.length;if(!s){n.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,n=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?n.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.eu,!1),r.updateFootprintHiddenFlags(n,e.eu,!0)}}}function Us(t,i){const n=[...t],r=i.cameraWorldSizeForFog/i.worldSize,o=e.bz([]);return e.cR(o,o,[r,r,1]),e.aB(n,o,n),e.aB(n,i.worldToFogMatrix,n),n}function Ns(t,i,n,r,o){const s=n.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=s;function p(e,i,n){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+n),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:n,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,n,r)}}p(l,"HAS_TEXTURE_u_baseColorTexture",rn.BaseColor),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",rn.MetallicRoughness),p(u,"HAS_TEXTURE_u_normalTexture",rn.Normal),p(h,"HAS_TEXTURE_u_occlusionTexture",rn.Occlusion),p(d,"HAS_TEXTURE_u_emissionTexture",rn.Emission),o&&(o.texture||(o.texture=new e.d_(r.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+rn.LUT),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),n.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(n.texcoordBuffer)),n.colorBuffer&&(t.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(n.colorBuffer)),n.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(n.normalBuffer)),n.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(n.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Vs(t,i,n,r,o,s){const a=n.paint.get("model-opacity").constantOr(1),l=i.context,c=new $i(i.context.gl.LEQUAL,t.isLightMesh?$i.ReadOnly:$i.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aB([],r.zScaleMatrix,t.nodeModelMatrix),e.aB(m,r.negCameraPosMatrix,m);const g=e.bk([],m);e.ef(g,g);const _="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=n.paint.get("model-emissive-strength").constantOr(0),y=ko(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(g),null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,A,n,void 0,void 0,t.materialOverride,t.modelColor),v={defines:[]},x=[],b=i.shadowRenderer;b&&(b.useNormalOffset=!1),Ns(v.defines,x,h,i,_?null:n.lut);let w=null;if(f){const e=Us(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,i=h.aabb.max,[n,r]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);v.overrideFog=n>=Ve||r>=Ve}}const T=ln(i,n.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Xi.disabled:Xi.backCCW,y,n.id,h.vertexBuffer,h.indexBuffer,h.segments,n.paint,i.transform.zoom,void 0,x)}function js(e,t,i){return"vector"===e.type?t.scope:i?"basemap":""}function Gs(t,i,n,r,o,s,a,l,c){const u=t.transform,h=!!i.isGeometryBloom&&i.isGeometryBloom;if(h&&"shadow"===t.renderPass)return;const d="globe"===u.projection.name?e.eC(n,u):[...n];e.aB(d,d,i.globalMatrix);const p=e.aB([],r,d);if(i.meshes)for(const t of i.meshes){const i=l.get(t.material.name);if(i&&i.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c});continue}const n=e.af([],t.centroid,p);!u.isOrthographic&&n[2]<=0||s.push({mesh:t,depth:n[2],modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c})}if(i.children)for(const e of i.children)Gs(t,e,n,r,o,s,a,l,c)}function Hs(e,t,i,n){const r=i.shadowRenderer;if(!r)return;const o=r.getShadowPassDepthMode(),s=r.getShadowPassColorMode(),a=r.calculateShadowPassMatrixFromMatrix(t),l=Do(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Wi.disabled,s,Xi.disabled,l,n.id,e.vertexBuffer,e.indexBuffer,e.segments,n.paint,i.transform.zoom,void 0,void 0)}function Qs(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};o.set(s,l)}}function $s(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};o.set(s,l)}}function Zs(e,t,i,n,r,o){if(1===i)for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,e.colorModeForRenderPass());else{for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,Qi.disabled);for(const i of r)Vs(i,e,t,o[i.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}const s=Qi.additive;for(const i of n)Vs(i,e,t,o[i.modelIndex],Wi.disabled,i.isLightMesh?s:e.colorModeForRenderPass())}function Ws(t,i,n){const r=i.updateZoomBasedPaintProperties(),o=function(t,i,n){let r,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(n);o&&o.dem?r=e.eE.create(i,n,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.aA(r.x,s,a)-r.x,d=e.aA(r.y,l,c)-r.y,p=e.ce(u,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Xs(e,t,i,n,r,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new $i(a.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let g,_,A;const y=!d&&n.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const v=ln(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)g=e.getOrCreateProgram("modelDepth",{defines:f}),_=Do(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),A=c.getShadowPassColorMode();else{Ns(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),g=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const n=p.material,l=n.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);_=ko(o.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,u,l.baseColorFactor,n.emissiveFactor,l.metallicFactor,l.roughnessFactor,n,d,t,r),c&&(s.shadowUniformsInitialized?g.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),g,"model-tile"),s.shadowUniformsInitialized=!0)),A=v.shouldRenderCutoff||u<1||"OPAQUE"!==n.alphaMode?Qi.alphaBlended:Qi.unblended}e.uploadCommonUniforms(a,g,o.toUnwrapped(),null,v);const x=p.material.doubleSided?Xi.disabled:Xi.backCCW;if(y)m.push(n.instancedDataBuffer),g.draw(e,a.gl.TRIANGLES,u,Wi.disabled,A,x,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,n.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let r=0;rc[1]?a:c,s[0]=n.max[0],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c,s[1]=n.min[1],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c;const u=e.aA(r[0],0,1),h=100*i.pixelsPerMeter*e.aA(r[1],0,1),d=e.aA(r[2],0,1),p=e.eG(e.eF(),l,c,u),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===h)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/h,_=(e,t,i)=>(1-i)*e+i*t,A=e.aA(_(1,d,g),d,1);return _(1,A,e.aA((i.pitch-20)/20,0,1))}class ia{}class na{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,n){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=n.gl,o=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.eI;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class ra{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}const oa=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class sa{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class aa{constructor(e,t){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...t,"Reveal"],"revealStart",{min:0,max:17,step:.05}),e.registerParameter(this,[...t,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}const la=e.eh([{type:"Float32",name:"a_pos_2f",components:2}]);class ca{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const n=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eJ,n=new e.b0;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,la.members),this.vignetteIdx=t.context.createIndexBuffer(n)}const r=e.bf.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,n);const e={u_vignetteShape:(o={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:o.vignetteColor};n.draw(t,t.context.gl.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r)}var o}}class ua{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const n=t.getFreeCameraOptions().position,r=n.toAltitude(),o=n.toLngLat(),s=e.an(o.lng),a=e.an(o.lat),l=t.pixelsPerMeter/i,c=s*e.eL,u=e.eL*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const e=-this._offsetYPrev+u,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=u,this._elevationPrev=r}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ha(e,t){return[-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function da(t){const i=e.eq(1323123451230),n=[];for(let r=0;rn)return;const r=pa(0,1,i.revealStart,i.revealStart+i.revealRange,n);if(!this.particlesVx||!this.particlesIdx)return;const o=structuredClone(this._params);let s=[-o.direction.x,o.direction.y,-100];e.aw(s,s);const a=structuredClone(this._vignetteParams);a.strength*=r,o.overrideStyleParameters||(o.intensity=t.style.rain.state.density,o.timeFactor=t.style.rain.state.intensity,o.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),o.screenThinning.intensity=t.style.rain.state.centerThinning,o.dropletSizeX=t.style.rain.state.dropletSize[0],o.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],o.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,o.timeFactor),c=t.context,u=c.gl,h=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},u.RGBA8)),o.distortionStrength>0&&(c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),u.copyTexSubImage2D(u.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const d=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,d),c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE);const p=[o.color.r,o.color.g,o.color.b,o.color.a],f=(i,n)=>{const r=ha(this._movement.getPosition(),i),a=o.dropletSizeX,c=o.dropletSizeX*o.dropletSizeYScale,f=t.width/2,m=t.height/2,g=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),A=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(v={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:r,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:o.distortionStrength,rainDirection:s,color:p,screenSize:[h.width,h.height],thinningCenterPos:[f,m],thinningShape:[g,_,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:A,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:n?0:1},{u_modelview:Float32Array.from(v.modelview),u_projection:Float32Array.from(v.projection),u_time:v.time,u_cam_pos:v.camPos,u_texScreen:0,u_velocityConeAperture:v.velocityConeAperture,u_velocity:v.velocity,u_boxSize:v.boxSize,u_rainDropletSize:v.rainDropletSize,u_distortionStrength:v.distortionStrength,u_rainDirection:v.rainDirection,u_color:v.color,u_screenSize:v.screenSize,u_thinningCenterPos:v.thinningCenterPos,u_thinningShape:v.thinningShape,u_thinningAffectedRatio:v.thinningAffectedRatio,u_thinningParticleOffset:v.thinningParticleOffset,u_shapeDirectionalPower:v.shapeDirectionalPower,u_shapeNormalPower:v.shapeNormalPower,u_mode:v.mode});var v;const x=Math.round(o.intensity*this.particlesCount),b=e.bf.simpleSegment(0,0,4*x,2*x);d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,b)};o.distortionStrength>0&&f(o.boxSize,!0),f(o.boxSize,!1),this._vignette.draw(t,a)}}const ga=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class _a extends fa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new aa(e.tp,["Precipitation","Snow"]),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=da(this.particlesCount),n=new e.eN,r=new e.b0;let o=0;const s=e.eq(1323123451230);for(let e=0;es)return;const a=pa(0,1,o.revealStart,o.revealStart+o.revealRange,s);r.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),n=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,r.strength=1,r.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,u=c.gl,h=t.transform,d=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,d),((i,r,o)=>{const s=ha(this._movement.getPosition(),i),a=h.width/2,c=h.height/2,p=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),f=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),m=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),g=(_={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:i,billboardSize:1*o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[h.width,h.height],thinningCenterPos:[a,c],thinningShape:[p,f,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:m,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:n},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const A=Math.round(o.intensity*this.particlesCount),y=e.bf.simpleSegment(0,0,4*A,2*A);this.particlesVx&&this.particlesIdx&&d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,y)})(i.boxSize,0,i),this._vignette.draw(t,r)}}const Aa={symbol:function(t,i,n,r,o){if("translucent"!==t.renderPass)return;const s=Wi.disabled,a=t.colorModeForRenderPass(),l=n.layout.get("text-variable-anchor"),c=n.layout.get("text-size-scale-range"),u=e.aA(t.scaleFactor,c[0],c[1]);l&&function(t,i,n,r,o,s,a,l){const c=i.transform,u="map"===o,h="map"===s;for(const i of t){const t=r.getTile(i),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.bJ(o.textSizeData,c.zoom,l),d=Kt(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=ti(d,t.tileID.canonical,h,u,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();s&&Wo(o,u,h,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,m)}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o,u);const h=0!==n.paint.get("icon-opacity").constantOr(1),d=0!==n.paint.get("text-opacity").constantOr(1);void 0!==n.layout.get("symbol-sort-key").constantOr(1)&&(h||d)?qo(t,i,n,r,s,a):(h&&qo(t,i,n,r,s,a,{onlyIcons:!0}),d&&qo(t,i,n,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Ho(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Ho(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1),c=n.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=n.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,$i.ReadOnly),g=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D),_="none"===f||p?m:g,A=Wi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),v="globe"===d.projection.name,x=[e.aF(d.center.lng),e.aJ(d.center.lat)],b=[];for(let o=0;oe.sortKey-t.sortKey);const w={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of b){const{programConfiguration:i,program:r,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,p=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,w),t.uploadCommonUniforms(u,r,c.tileID.toUnwrapped()),r.draw(t,h.TRIANGLES,_,A,y,Xi.disabled,l,n.id,o,a,p,n.paint,d.zoom,i,s)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=Wi.disabled,l=new Qi([s.ONE,s.ONE,s.ONE,s.ONE],e.ao.transparent,[!0,!0,!0,!0]);!function(e,t,i,n){const r=e.gl,o=t.width*n,s=t.height*n;e.activeTexture.set(r.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=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,n,r,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,r,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(e,0,t,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,n,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.ao.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Xi.frontCCW:Xi.disabled,p=[e.aF(c.center.lng),e.aJ(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))},line:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=n.paint.get("line-emissive-strength"),l=n.paint.get("line-occlusion-opacity"),c=n.layout.get("line-elevation-reference"),u="meters"===n.layout.get("line-width-unit"),h="sea"===c,d=!(!t.terrain||!t.terrain.enabled),p=t.context,f=p.gl;if(n.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const m=n.layout.get("line-cross-slope"),g=void 0!==m,_=m<1,A=t.colorModeForDrapableLayerRenderPass(a),y=t.terrain&&t.terrain.renderingToTexture,v=y?1:e.o.devicePixelRatio,x=n.paint.get("line-dasharray"),b=x.constantOr(1),w=n.layout.get("line-cap"),T=x.constantOr(null),E=w.constantOr(null),C=n.paint.get("line-pattern"),S=C.constantOr(1),B=n.paint.get("line-pattern-cross-fade"),I=C.constantOr(null),M=n.paint.get("line-opacity").constantOr(1);let P=!S&&1!==M||t.depthOcclusion&&l>0&&l<1;const R=n.paint.get("line-gradient"),L=S?"linePattern":"line",F=e.e1(n);let k;if(y&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&t.depthOcclusion){const t=n.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?k=t.value:e.w(`Occlusion opacity for layer ${n.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==s.value.kind&&!1===s.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH");const D=(r,o,s,a,c,d)=>{for(const m of r){const r=i.getTile(m);if(S&&!r.patternsLoaded())continue;const g=r.getBucket(n);if(!g)continue;if("none"!==g.elevationType&&!c||"none"===g.elevationType&&c)continue;t.prepareDrawTile();const _=[...o],x=t.shadowRenderer,w="road"===g.elevationType&&!!x&&x.enabled;let C=[0,0,0];if(w){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(C=mn(t.style,e,i)),_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const F=g.programConfigurations.get(n.id);let D=!1;if(I&&r.imageAtlas){const t=e.e2.from(I),i=t.getPrimary().scaleSelf(v).toString(),n=r.imageAtlas.patternPositions.get(i),o=t.getSecondary(),s=o?r.imageAtlas.patternPositions.get(o.scaleSelf(v).toString()):null;D=!!n&&!!s,n&&F.setConstantPatternPositions(n,s)}B>0&&(D||F.getPatternTransitionVertexBuffer("line-pattern"))&&_.push("LINE_PATTERN_TRANSITION");const O=t.isTileAffectedByFog(m),z=t.getOrCreateProgram(L,{config:F,defines:_,overrideFog:O});if(!S&&T&&E&&r.lineAtlas){const e=r.lineAtlas.getDash(T,E);e&&F.setConstantPatternPositions(e)}w&&x.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile");let[U,N]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;U!==N&&(0===U&&(U-=e),1===N&&(N+=e))}const V=y?m.projMatrix:null,j=u?1/g.tileToMeter/e.ay(r,1,t.transform.zoom):1,G=u?1/g.tileToMeter/e.ay(r,1,Math.floor(t.transform.zoom)):1,H=S?e.e3(t,r,n,V,v,j,G,[U,N],C,B):e.e4(t,r,n,V,g.lineClipsArray.length,v,j,G,[U,N],C);if(R){const r=g.gradients[n.id];let o=r.texture;if(n.gradientVersion!==r.version){let s=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=m.canonical.z===n?Math.ceil(1<{null!=k&&(k.value=M*l),z.draw(t,f.TRIANGLES,s,e,A,Xi.disabled,H,n.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,n.paint,t.transform.zoom,F,[g.layoutVertexBuffer2,g.patternVertexBuffer,g.zOffsetVertexBuffer]),null!=k&&(k.value=M)};if(P&&!c){const e=t.stencilModeForClipping(m).ref;0===e&&y&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};H.u_alpha_discard_threshold=.8,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.INVERT)),H.u_alpha_discard_threshold=0,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.KEEP))}else H.u_alpha_discard_threshold=P&&c&&d?.8:0,Q(c?a:t.stencilModeForClipping(m))}};let O=t.depthModeForSublayer(0,$i.ReadOnly);const z=new $i(t.depthOcclusion?f.GREATER:f.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);if(n.hasNonElevatedBuckets){const i=!y&&t.terrain;0!==l&&i?e.w(`Occlusion opacity for layer ${n.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${n.id}.`):D(r,F,O,Wi.disabled,!1,!0)}if(n.hasElevatedBuckets){"hd-road-markup"===c?d||(O=z,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),O=z,g&&F.push(_?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),h&&F.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Wi.disabled;t.forceTerrainMode=!0,D(r,F,O,e,!0,!0),P&&D(r,F,O,e,!0,!1),t.forceTerrainMode=!1}P&&(t.resetStencilClippingMasks(),y&&p.clear({stencil:0})),0===l||t.depthOcclusion||y||t.layersWithOcclusionOpacity.push(t.currentLayer)},fill:function(t,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=n.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.ao.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let h="none";"none"!==n.layout.get("fill-elevation-reference")?h="road":0!==n.paint.get("fill-z-offset").constantOr(1)&&(h="offset");const d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:n,coords:r,colorMode:l,elevationType:h,terrainEnabled:d,pass:u};if("shadow"!==t.renderPass)if("offset"!==h){if(Yo(p,!1),"road"===h){const e=!d&&"translucent"===t.renderPass;e&&Jo(t,i,n,r,"geometry"),Yo(p,!0,Wi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r,colorMode:o}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=mn(t.style,e,i))}const h=e=>{for(const h of r){const r=i.getTile(h),d=r.getBucket(n);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(n.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(n.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const g=t.isTileAffectedByFog(h),_=[];l&&_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const A=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:g,defines:_}),y=t.translatePosMatrix(h.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),A,"vector-tile");const v=po(y,u);t.uploadCommonUniforms(t.context,A,h.toUnwrapped()),A.draw(t,s.TRIANGLES,c,Wi.disabled,o,Xi.backCCW,v,n.id,p.vertexBuffer,p.indexBuffer,f,n.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(p)}}else Yo(p,!1,t.stencilModeFor3D());else t.shadowRenderer&&"road"===h&&!d&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r}=e,o=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(n);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(n.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p={u_matrix:d,u_depth_bias:0};h.draw(t,o.TRIANGLES,s.getShadowPassDepthMode(),Wi.disabled,s.getShadowPassColorMode(),Xi.disabled,p,n.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,n.paint,t.transform.zoom,c)}}(p)},"fill-extrusion":function(t,i,n,r){const o=n.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.style.isLayerClipped(n,i.getSource()),h=t.style.order.indexOf(n.fqid);if(u&&function(e,t,i,n,r){for(const o of n){const n=t.getTile(o).getBucket(i);n&&(n.updateReplacement(o,e.replacementSource,r),n.uploadCentroid(e.context))}}(t,i,n,r,h),l||u)for(const e of r){const r=i.getTile(e).getBucket(n);r&&ns(t.context,i,e,r,n,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ad)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();es(t,i,n,r,a,Wi.disabled,c,u)}else if("translucent"===t.renderPass){const h=!n.paint.get("fill-extrusion-pattern").constantOr(1),d=n.paint.get("fill-extrusion-color").constantOr(e.ao.white);if(!c&&0!==d.a){const e=new $i(t.context.gl.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);1===o&&h?es(t,i,n,r,e,Wi.disabled,Qi.unblended,u):(es(t,i,n,r,e,Wi.disabled,Qi.disabled,u),es(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=n.paint.get("fill-extrusion-opacity"),h=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=n.paint.get("fill-extrusion-flood-light-intensity"),f="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:n.lut).toArray01().slice(0,3),g=h>0&&d>0,_=p>0,A=(e,t,i)=>(1-i)*e+i*t,y=new ts;y.translate=n.paint.get("fill-extrusion-translate"),y.translateAnchor=n.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=n.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=n.paint.get("fill-extrusion-cutoff-fade-range");const v=s=>{const l=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!0),c=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=A(.1,3,c),g=t._showOverdrawInspector;if(!g){const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,l,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,f,u,!1)}{const c=g?Wi.disabled:new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=g?t.colorModeForRenderPass():new Qi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,l,c,_,Xi.disabled,s,"color",o,h,d,p,m,f,u,!1)}};if(c){const c=(s,l,c)=>{const f=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!1),g=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=A(.1,3,g);{const c=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0]);is(y,t,i,n,r,f,Wi.disabled,c,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l)}{const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,f,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,g=new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),A=new Qi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,f,g,A,Xi.disabled,s,"color",o,h,d,p,m,_,u,l)}{const g=new Qi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.ao.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);is(y,t,i,n,r,f,Wi.disabled,g,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l,c)}};if(g||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],n=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===n)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.q({width:t,height:n}),a.RGBA8)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,n)}g&&c(!0,!1,i),_&&c(!1,!0,i)}}else g&&v(!0),_&&v(!1),(g||_)&&t.resetStencilClippingMasks()}}},building:function(e,t,i,n){e.currentLayer0&&o>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;(!e.shadowRenderer||u<1)&&(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,n,r,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(r&&o.updateReplacement(s,e.replacementSource,n),o.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,n),function(e,t,i,n){for(const r of n){const n=t.getTile(r).getBucket(i);n&&n.needsEvaluation()&&n.uploadUpdatedColorBuffer(e.context)}}(e,t,i,n),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=e.shadowRenderer,o=[],s=r.getShadowPassDepthMode();ls({painter:e,source:t,layer:i,coords:n,defines:o,blendMode:r.getShadowPassColorMode(),depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),g="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),_=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:i.lut).toArray01().slice(0,3),A=i.paint.get("building-flood-light-ground-attenuation"),y=m>0,v=new $i(e.context.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D);a<1&&ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:Qi.disabled,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_,depthOnly:!0});const x=e.colorModeForRenderPass();ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:x,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_}),l&&cs(e,t,i,n,!0,a,r,o,m,_,s,h),y&&cs(e,t,i,n,!1,a,r,o,m,_,A,h)}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],o=new $i(e.context.gl.LEQUAL,$i.ReadOnly,e.depthRangeFor3D);ls({painter:e,source:t,layer:i,coords:n,defines:r,blendMode:Qi.alphaBlended,depthMode:o,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},hillshade:function(e,t,i,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},n]:e.stencilConfigForOverlap(n);for(const n of a){const r=t.getTile(n);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)er(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,$i.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):s[n.overscaledZ];Jn(e,n,r,i,t,c,l)}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,n,r,o,s){if("translucent"!==t.renderPass)return;if(0===n.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==n.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=i.getSource(),p=function(t,i,n,r){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let u=i.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?r.NEAREST:r.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=r.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),n.activeTexture.set(r.TEXTURE2),i.updateColorRamp(u);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(n,i.colorRamp,r.RGBA8)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,n,u,h);if(d instanceof e.aT&&!r.length&&!a)return;const f=n.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),g=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,A="nearest"===n.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.aT&&!r.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Wi.disabled;return void hs(!!d.onNorthPole,null,t,i,n,f,p,Xi.disabled,e)}if(!r.length)return;const[y,v]=d instanceof e.aT||g?[{},r]:t.stencilConfigForOverlap(r),x=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(r,o,v)=>{for(const b of r){const r=b.toUnwrapped(),w=i.getTile(b);if(g&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const T=ps(w,d,n,p);if(!T||!T.texture)continue;const{texture:E,mix:C,offset:S,tileSize:B,buffer:I}=T;let M,P;g?(M=$i.disabled,P=b.projMatrix):l?(M=new $i(h.LEQUAL,$i.ReadWrite,t.depthRangeFor3D),P=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,_)):(M=t.depthModeForSublayer(b.overscaledZ-x,1===n.paint.get("raster-opacity")?$i.ReadWrite:$i.ReadOnly,h.LESS),P=t.transform.calculateProjMatrix(r,_));const R=t.terrain&&g?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:n.paint.get("raster-fade-duration");w.registerFadeDuration(L);const F=i.findLoadedParent(b,0),k=$r(w,F,i,t.transform,L);let D,O;!k.isFading&&w.refreshedUponExpiration&&(w.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),E.bind(A,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),F?(F.texture&&F.texture.bind(A,h.CLAMP_TO_EDGE),D=Math.pow(2,F.tileID.overscaledZ-w.tileID.overscaledZ),O=[w.tileID.canonical.x*D%1,w.tileID.canonical.y*D%1]):E.bind(A,h.CLAMP_TO_EDGE),"useMipmap"in E&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const z=t.transform;let U;const N=l?ds(z):[0,0,0,0];let V,j,G,H,Q,$=0;if(c&&d instanceof e.aT&&d.coordinates.length>3)V=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0)))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=d.elevatedGlobePerspectiveTransform,Q=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.dF(b.canonical);$=e.dG(t.getCenter().lat),V=Float32Array.from(e.bj(e.dI(b.canonical))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=[0,0],Q=Float32Array.from(e.dH(b.canonical,t,$,z.worldSize/z._pixelsPerMercatorPixel))}else U=d instanceof e.aT?d.perspectiveTransform:[0,0],V=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),H=[0,0],Q=new Float32Array(9);const Z=To(P,V,j,G,Q,O||[0,0],e.aj(t.transform.zoom),H,N,D||1,k,n,U,l?n.paint.get("raster-elevation"):0,2,C,S,p.range,B,I,f),W=t.isTileAffectedByFog(b),q=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:W});if(t.uploadCommonUniforms(u,q,r),d instanceof e.aT){const i=d.elevatedGlobeVertexBuffer,r=d.elevatedGlobeIndexBuffer;if(g||!a)d.boundsBuffer&&d.boundsSegments&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,Xi.disabled,Z,n.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&r){const s=z.zoom<=e.cZ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(z.center.lng);s&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,o,Z,n.id,i,r,s)}}else if(c){M=new $i(h.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,r,s]=e.getGridBuffers($,!1);q.draw(t,h.TRIANGLES,M,v||R,t.colorModeForRenderPass(),o,Z,n.id,i,r,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(w);q.draw(t,h.TRIANGLES,M,R,m,Xi.disabled,Z,n.id,e,i,r)}}if(!(d instanceof e.aT)&&c)for(const e of r){const r=e.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},r=1/1.1;for(let e=0;ee.e8[t](r));f.push(r);const m=r.canonical.x,g=r.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<e.tileID)),f&&(u.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,n.scope)),c){const i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0}),r=new Float32Array(e.bz([])),u=new e.aP(0,0,0,0,0),d=f?Lo(r,l,a,t,0,n.scope,m,c,{tileID:u,tileSize:p}):Ro(r,l,a,o.toPremultipliedRenderColor(s?null:n.lut));i.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,d,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}else for(const e of b){const g=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(v,{overrideFog:g}),w=e.toUnwrapped(),T=r?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):x?x[e.key]:new It(e,p,d.zoom,t),C=f?Lo(T,l,a,t,0,n.scope,m,c,{tileID:e,tileSize:p}):Ro(T,l,a,o.toPremultipliedRenderColor(s?null:n.lut));t.uploadCommonUniforms(u,b,w);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:B,tileBoundsSegments:I}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,C,n.id,S,B,I)}},sky:function(t,i,n){const r=t._atmosphere?e.aj(t.transform.zoom):1,o=n.paint.get("sky-opacity")*r;if(0===o)return;const s=t.context,a=n.paint.get("sky-type"),l=new $i(s.gl.LEQUAL,$i.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i){const n=t.context,r=n.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=n.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ps(n),i.skyboxTexture=n.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.bz(l),e.em(l,l,.5*-Math.PI),Rs(t,i,a,l,s,0),e.bz(l),e.em(l,l,.5*Math.PI),Rs(t,i,a,l,s,1),e.bz(l),e.cT(l,l,.5*-Math.PI),Rs(t,i,a,l,s,2),e.bz(l),e.cT(l,l,.5*Math.PI),Rs(t,i,a,l,s,3),e.bz(l),Rs(t,i,a,l,s,4),e.bz(l),e.em(l,l,Math.PI),Rs(t,i,a,l,s,5),n.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,n,r){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,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,n,r);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Wi.disabled,e.colorModeForRenderPass(),Xi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,n,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ps(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.an(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,n,Wi.disabled,t.colorModeForRenderPass(),Xi.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,l,o,c)},custom:function(t,i,n,r){const o=t.context,s=n.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&n.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const n=t.transform.pointMerc;i.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.aj(t.transform.zoom),[n.x,n.y],t.transform.pixelsPerMeterRatio)}else i.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,n={x:i.x+r[0].wrap*(s.wrapTileId?0:1<{u&&(u.useNormalOffset=!0,h||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,n,r,o){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;n.modelManager=c;const u=t.shadowRenderer;if(!n._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=n._unevaluatedLayout._values["model-id"],d=Object.assign({},n.layout.get("model-id").parameters),p=t.style.order.indexOf(n.fqid);for(const f of r){const r=i.getTile(f).getBucket(n);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,o),r.modelsRequested=!0),a)d.zoom=f.overscaledZ;else{const e=Ks(f,s);d.zoom=e}const g=h.possiblyEvaluate(d);if(Ws(t,r,f),qs.shadowUniformsInitialized=!1,qs.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(qs.tileMatrix.set(i),qs.shadowTileMatrix=Float32Array.from(u.calculateShadowPassMatrixFromMatrix(i)),qs.aabb.min=[0,0,0],qs.aabb.max[0]=qs.aabb.max[1]=e.al,qs.aabb.max[2]=0,Ys(r,qs,t,n.scope))continue}const _=1<0&&t.style.isLayerClipped(n,i.getSource())&&r.updateReplacement(f,t.replacementSource,p,o)&&(r.uploaded=!1,r.upload(t.context));let y=0;const v=new Array,x=new Array,b=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const u=c.getModel(i,o);if(u||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),u&&u.uploaded)if(a){const i=e.c4([],[l.x,l.y,l.z],t.transform.worldSize);e.ev(i,i);for(let n=0;n0&&n.elevationUpdate(e.terrain,r,s,i.source),n.needsReEvaluation(e,o,i)&&n.evaluate(i))}})(t,i,n,r),function(){let c,h,E;b?(c=r.length-1,h=-1,E=-1):(c=0,h=r.length,E=1);const C=new Float64Array(16),S=e.cz(),B=new e.P(0,0);for(let I=c;I!==h;I+=E){const c=r[I],h=i.getTile(c).getBucket(n);if(!h||!h.uploaded)continue;let E=!1;l&&(E=0===l.getMaxCascadeForTile(c.toUnwrapped()));const M=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),P=h.modelTraits;!y&&b&&(e.bk(C,M),e.af(S,u,C),B.x=S[0],B.y=S[1]);const R=[];h.setFilter(n.filter);for(const i of h.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const n=i.node;let r=0;t.terrain&&n.elevation&&(r=n.elevation*t.terrain.exaggeration());const o=(()=>{const t=i.aabb;return A.min=[...t.min],A.max=[...t.max],A.min[2]+=r,A.max[2]+=r,e.af(A.min,A.min,M),e.af(A.max,A.max,M),A})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===o.intersects(v))continue;if(!y&&b){const t=1/6;i.cameraCollisionOpacity=u[0]>o.min[0]&&u[0]o.min[1]&&u[1]!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of R){const r=i.nodeInfo,c=r.node;let u=e.aB([],f,i.tileModelMatrix);e.aB(u,d,u);const h=e.bk([],u);e.ef(h,h),e.cR(h,h,Js),u=e.aB(u,u,c.globalMatrix);const p="light-beam"===t.renderPass,m="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=P&e.eH.HasMapboxMeshFeatures,v=A?0:r.evaluatedRMEA[0][2];for(let e=0;e=Ve||r>=Ve}}const S=d.material;let B;S.occlusionTexture&&S.occlusionTexture.offsetScale&&(B=S.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const I=t.getOrCreateProgram("model",b);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,I,l.useNormalOffset),t.uploadCommonUniforms(o,I,null,C);const M=S.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const P=ko(new Float32Array(x),new Float32Array(u),new Float32Array(h),new Float32Array(c.globalMatrix),t,i.opacity,M.baseColorFactor,S.emissiveFactor,M.metallicFactor,M.roughnessFactor,S,v,n,[0,0,0],B);!f&&(r.hasTranslucentParts||i.opacity<1)&&I.draw(t,o.gl.TRIANGLES,g,Wi.disabled,Qi.disabled,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w),I.draw(t,o.gl.TRIANGLES,f?_:g,Wi.disabled,f||i.opacity<1||r.hasTranslucentParts?Qi.alphaBlended:Qi.unblended,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w)}}}}()}(t,i,n,r),void d();if("model"!==p.type)return;const f=p.getModels(),m=[],g=t.transform.getFreeCameraOptions().position,_=e.c4([],[g.x,g.y,g.z],t.transform.worldSize);e.ev(_,_);const A=[],y=[];let v=0;for(const r of f){const o=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=n.paint.get("model-rotation").evaluate(s,o),u=n.paint.get("model-scale").evaluate(s,o),h=n.paint.get("model-translation").evaluate(s,o);Qs(n,r.id,o,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),$s(n,r.id,o,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,u,h,l,a,!1);const d=e.bz([]),p=e.ee(r.position.lat,t.transform.zoom),f=e.bp([],[1,1,1/p]);e.bq(d,d,_),m.push({zScaleMatrix:f,negCameraPosMatrix:d});for(const e of r.nodes)Gs(t,e,r.matrix,t.transform.expandedFarZProjMatrix,v,A,y,r.materialOverrides);v++}if(A.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass)Zs(t,n,o,A,y,m),d();else{for(const e of y)Hs(e.mesh,e.nodeModelMatrix,t,n);for(const e of A)Hs(e.mesh,e.nodeModelMatrix,t,n);d()}}},ya={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const n of i){const i=t.getTile(n).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0},model:function(e,t,i){const n=t.getSource();if(!n.loaded())return;if("vector"===n.type||"geojson"===n.type){const t=js(n,e,i.style._importedAsBasemap);return void(i.modelManager&&i.modelManager.upload(i,t))}if("batched-model"===n.type)return;if("model"!==n.type)return;const r=n.getModels();for(const e of r)e.upload(i.context)},raster:function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)},"raster-particle":function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-particle-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)}},va={fill:Jo},xa={fill:function(e,t,i,n){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,o=new $i(r.LEQUAL,$i.ReadOnly,e.depthRangeFor3D),s=new Wi({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of n){const n=t.getTile(c),u=n.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||0===h.depthSegments.segments[0].primitiveLength)continue;const d=Xo(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=fo(p,d,0,1,0);l.draw(e,r.TRIANGLES,o,s,Qi.disabled,Xi.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class ba{constructor(t,i,n,r,o,s){this.context=new jo(t,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of a)this._debugParams.enabledLayers[e]=!0;o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of a)o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new ra(o),this.setup(),this.numSublayers=Lt.maxUnderzooming+Lt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eO,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new dn(this),this._wireframeDebugCache=new na,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const l=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,l,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.worldview=s}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 Kr(this,e));const n=this._terrain;this.transform.elevation=i?n:null,n.update(e,this.transform,t),this.transform.elevation&&!n.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,n]=t.getFovAdjustedRange(this.transform._fov);if(i>n)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new Kr(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.o.devicePixelRatio,this.height=i*e.o.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 t=this.context,i=new e.bc;i.emplaceBack(0,0),i.emplaceBack(e.al,0),i.emplaceBack(0,e.al),i.emplaceBack(e.al,e.al),this.tileExtentBuffer=t.createVertexBuffer(i,e.be.members),this.tileExtentSegments=e.bf.simpleSegment(0,0,4,2);const n=new e.bc;n.emplaceBack(0,0),n.emplaceBack(e.al,0),n.emplaceBack(0,e.al),n.emplaceBack(e.al,e.al),this.debugBuffer=t.createVertexBuffer(n,e.be.members),this.debugSegments=e.bf.simpleSegment(0,0,4,5);const r=new e.bc;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.be.members),this.viewportSegments=e.bf.simpleSegment(0,0,4,2);const o=new e.a$;o.emplaceBack(0,0,0,0),o.emplaceBack(e.al,0,e.al,0),o.emplaceBack(0,e.al,0,e.al),o.emplaceBack(e.al,e.al,e.al,e.al),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.bh.members),this.mercatorBoundsSegments=e.bf.simpleSegment(0,0,4,2);const s=new e.b0;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.bd;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bB();const l=this.context.gl;this.stencilClearMode=new Wi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(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,$i.disabled,this.stencilClearMode,Qi.disabled,Xi.disabled,Qr(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 n=this.context,r=n.gl;this.nextStencilID+i.length>256&&this.clearStencil(),n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),n=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},n,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(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 Wi({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 Wi({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),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Qi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ao(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,n=!1){if(this.depthOcclusion)return new $i(this.context.gl.GREATER,$i.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!n)return $i.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new $i(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((e,t)=>e+t/this._fpsHistory.length,0))}render(t,i){const n=e.o.now();this._dt=n-this._timeStamp,this._timeStamp=n,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,o=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(o).filter(e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=s(),l=!1,c=!1,u=null;for(const e of a){const t=r[e];"circle"===t.type?l=!0:"building"===t.type?u=t:"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0)}let h=a.map(e=>r[e]);const d=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();let p=0,f=!1;for(const e in d){const t=d[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++p)}let m=!1;for(const e of h)e.isHidden(this.transform.zoom)||("clip"===e.type&&(m=!0),this.prepareLayer(e));const g={},_={},A={},y={},v={};for(const e in d){const t=d[e];g[e]=t.getVisibleCoordinates(),_[e]=g[e].slice().reverse(),A[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(g[e])}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(p||m||this._clippingActiveLastFrame){const t=[],i=[];let n=0;for(const e of h)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(n)),n++;if(t&&(m||t.length>1)||this._clippingActiveLastFrame){m=!1;const n=[];for(let r=0;r0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D(o)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(A),this.opaquePassCutoff=0,a=s(),h=a.map(e=>r[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in d)for(const t of g[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eQ(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Os(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const T=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(T&&!this._snow&&(this._snow=new _a(this)),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&(this._rain=new ma(this)),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),u){this.buildingTileBorderManager||(this.buildingTileBorderManager=new zs);const e=this.style.getLayerSourceCache(u);this.buildingTileBorderManager.updateBorders(e,u)}if(!j.has(this.context.gl))return;this.renderPass="offscreen";for(const e of h){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const n=i?_[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||n&&n.length)&&this.renderLayer(this,i,e,n)}this.depthRangeFor3D=[0,1-(h.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const C="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),S=(()=>{if(i.showOverdrawInspector)return e.ao.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const n="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}if(C){const n="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}}return e.ao.transparent})();if(this.context.clear({color:S,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=h[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const n=i?(e.is3D(o)?v:_)[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.aj(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--I){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=h[this.currentLayer],n=t.getLayerSourceCache(i),r=n?_[n.id]:void 0;this.terrain||this._renderTileClippingMasks(i,n,n?g[n.id]:void 0),this.renderLayer(this,n,i,r)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;h.forEach(e=>{const n=t.getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&n.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const n=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,r=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(r.push("LIGHTING_3D_MODE"),r.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):n||r.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||r.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(r.push("TERRAIN"),this.linearFloatFilteringSupported()&&r.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&r.push("GLOBE"),!this._fogVisible||n||void 0!==t&&!t||r.push("FOG","FOG_DITHERING"),n&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],n=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=eo.cacheKey(Zn[e],e,r,n);return this.cache[o]||(this.cache[o]=new eo(this.context,e,Zn[e],n,Oo[e],r)),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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}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(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const o=((t,i,n)=>{const r=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:n.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:n.getLut(i.scope)).toArray01(),u=i.properties.get("intensity"),h=[r.x,r.y,r.z],d=e.dM(c,u),p=e.dM(s,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:h,u_lighting_directional_color:p,u_ground_radiance:Xr(h,p,d)}})(n,r,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,n,r,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=t.transform,f="none"===i.properties.get("color-use-theme"),m=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();m[3]=r;const g=t.frameCounter/1e3%1,[_,A]=i.properties.get("vertical-range");return{u_fog_matrix:n?p.calculateFogTileMatrix(n):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,A),A],u_fog_temporal_offset:g,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.aj(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,n,o,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*e.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],r);i.setFogUniformValues(t,a)}o&&i.setCutoffUniformValues(t,o.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 n of i)t[n.key]=e[n.key]||new It(n,512,this.transform.tileZoom,this,void 0,this.worldview);return t}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(e,t){return!(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==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]>=Ve||t[1]>=Ve}setupDepthForOcclusion(e,t,i){const n=this.context,r=n.gl,o=!!i;var s;i||(i={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),n.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),n.activeTexture.set(r.TEXTURE0),o||t.setTerrainUniformValues(n,i)}}function wa(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}class Ta{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aX(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=wa(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=Ea(e);if(this._hashName){const e=this._hashName;let i=!1;const n=location.hash.slice(1).split("&").map(n=>{const r=n.split("=")[0];return r===e?(i=!0,`${r}=${t}`):n}).filter(e=>e);return i||n.push(`${e}=${t}`),`#${n.join("&")}`}return`#${t}`}_getCurrentHash(){const e=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(Number(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(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Ea(e,t){const i=e.getCenter(),n=Math.round(100*e.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${n}`:`${n}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Ca={linearity:.3,easing:e.eS(0,0,.3,1)},Sa=Object.assign({deceleration:2500,maxSpeed:1400},Ca),Ba=Object.assign({deceleration:20,maxSpeed:1400},Ca),Ia=Object.assign({deceleration:1e3,maxSpeed:360},Ca),Ma=Object.assign({deceleration:1e3,maxSpeed:90},Ca);class Pa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=La(i.pan.mag(),n,Object.assign({},Sa,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Ra(r,e)}if(i.zoom){const e=La(i.zoom,n,Ba);r.zoom=this._map.transform.zoom+e.amount,Ra(r,e)}if(i.bearing){const t=La(i.bearing,n,Ia);r.bearing=this._map.transform.bearing+e.aA(t.amount,-179,179),Ra(r,t)}if(i.pitch){const e=La(i.pitch,n,Ma);r.pitch=this._map.transform.pitch+e.amount,Ra(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function Ra(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class Da extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class Oa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new Da(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Fa(e.type,this._map,e))}mouseup(e){this._map.fire(new Fa(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Fa(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Fa(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new Fa(e.type,this._map,e))}mouseover(e){this._map.fire(new Fa(e.type,this._map,e))}mouseout(e){this._map.fire(new Fa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ka(e.type,this._map,e))}touchmove(e){this._map.fire(new ka(e.type,this._map,e))}touchend(e){this._map.fire(new ka(e.type,this._map,e))}touchcancel(e){this._map.fire(new ka(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class za{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new Fa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Fa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Fa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ua{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&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,n=this._startPos,r=this._lastPos;if(!n||!r||r.equals(i)||!this._box&&i.dist(n){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=c-a+"px")})}mouseupWindow(t,i){if(!this._active)return;const n=this._startPos,r=i;if(n&&0===t.button){if(this.reset(),g(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}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),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function Na(e,t){const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Na(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=Na(i,t);for(const e in this.touches){const t=n[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 ja{constructor(e){this.singleTap=new Va(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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class Ga{constructor(){this._zoomIn=new ja({numTouches:1,numTaps:2}),this._zoomOut=new ja({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return 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})}):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})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ha={0:1,2:2},Qa={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class $a{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=y(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=Ha[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=Na(n,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Xa{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 n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,o]=n,s=Ja(i,t,r),a=Ja(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[n,r]=this._firstTwoTouches,o=Ja(i,t,n),s=Ja(i,t,r);o&&s||(this._active&&g(),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 Ja(e,t,i){for(let n=0;nMath.abs(e.x)}class rl extends Xa{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,nl(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,n){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.eT()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return nl(e)&&nl(t)&&o}}const ol={panStep:100,bearingStep:15,pitchStep:10};class sl{constructor(){const e=ol;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,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*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 al(e){return e*(2-e)}const ll=4.000244140625,cl=1/450;class ul{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=cl,e.aX(["_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(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.eT()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=e.o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%ll==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.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=_(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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>ll?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.ak(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=n,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.eU;if(this._prevEase){const t=this._prevEase,n=(e.o.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.eS(o,s,.25,1)}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(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=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class hl{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 dl{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 pl{constructor(){this._tap=new ja({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 n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/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 fl{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 ml{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 gl{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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 _l=e=>e.zoom||e.drag||e.pitch||e.rotate;class Al extends e.z{}class yl{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.av([],i,t);this.radius=e.ag(n[2]<0?e.eW([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.eW(t,t,this.constants),e.aw(t,t),e.eX(t,t,this.constants);const i=e.c4([],t,this.radius);if(i[2]>0){const t=e.c4([],[0,0,1],e.bI(i,[0,0,1])),n=e.c4([],e.aw([],[i[0],i[1],0]),this.radius),r=e.d7([],i,e.c4([],e.av([],e.d7([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function vl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class xl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new yl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aX(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,n,i)}}destroy(){for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,n,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Oa(t,e));const n=t.boxZoom=new Ua(t,e);this._add("boxZoom",n);const r=new Ga,o=new dl;t.doubleClickZoom=new hl(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new pl;this._add("tapDragZoom",s);const a=t.touchPitch=new rl(t);this._add("touchPitch",a);const l=new Wa(e),c=new qa(e);t.dragRotate=new ml(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new Za(e),h=new Ka(t,e);t.dragPan=new fl(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new il,p=new el;t.touchZoomRotate=new gl(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new za(t));const f=t.scrollZoom=new ul(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new sl;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!!_l(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<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,n=i?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?A(this._el,a):i?void 0:_(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=n);this._previousActiveHandlers=s,(Object.keys(c).length||vl(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||vl(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,n,r){if(!i)return;Object.assign(e,i);const o={handlerName:n,originalEvent:i.originalEvent||r};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 t={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,o),Object.assign(n,s);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,o=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!vl(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&r._stop(!0),!vl(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.eV(e.a_(t.y))*i,f[1]=-a.y*e.eV(o.center.lat)*i}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),i={dir:e.aw([],e.av([],t,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(t,l);e.c4(g,i.dir,n)}}const _=e.d7(f,f,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,n,!0)}_fireEvents(t,i,n){const r=_l(this._eventsInProgress),o=_l(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=_l(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Al("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const bl="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class wl extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aX(["_renderFrameCallback"],this)}getCenter(){return new e.aS(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),n)}panTo(e,t,i){return this.easeTo(Object.assign({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(Object.assign({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(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):n/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,n,r,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.eY(h,d),f=e.aw([],p),m=e.aw([],e.bH([],f,[0,1,0])),g=e.bH([],m,f),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],A=[p,e.eY(c.lat,c.lng),e.eY(u.lat,c.lng),e.eY(u.lat,u.lng),e.eY(c.lat,u.lng),e.eY(h,c.lng),e.eY(h,u.lng),e.eY(c.lat,d),e.eY(u.lat,d)];let y=e.d8.fromPoints(A.map(t=>[e.bI(m,t),e.bI(g,t),e.bI(f,t)]));const v=e.af([],y.center,_);0===e.eZ(v)&&e.e_(v,0,0,1),e.aw(v,v),e.c4(v,v,e.aD),a.center=e.e$(v);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);y=e.d8.applyTransform(y,e.aB([],x,_));const w=this._extendAABB(y,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.af(v,v,x);const T=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(a,y),C=e.c4([],[0,0,1],T),S=e.d7(C,v,C),B=E+(0===a.pitch?0:e.bF(v,S)),I=a.globeCenterInViewSpace,M=e.av([],v,[I[0],I[1],I[2]]);e.aw(M,M),e.c4(M,M,B);const P=e.d7([],v,M);e.af(P,P,b);const R=e.eL/e.aD,L=e.ag(P),F=e.ce(Math.max(L*R-e.eL,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(F),l.maxZoom);return k>.5*(e.cZ+e.cK)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,n,r,o,s)):{center:a.center,zoom:k,bearing:r,pitch:o}}_extendAABB(t,i,n,r){const o=.5*((n.padding.left||0)+(n.padding.right||0)),s=.5*((n.padding.top||0)+(n.padding.bottom||0)),a=s,l=o,c=o,u=s,h=i.width-(l+c),d=i.height-(a+u),p=e.av([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),n.maxZoom);if(isNaN(m))return null;const g=i.scale/i.zoomScale(m),_=new e.d8([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+a*g,t.max[2]]),A=("number"==typeof n.offset.x&&"number"==typeof n.offset.y?new e.P(n.offset.x,n.offset.y):e.P.convert(n.offset)).rotate(-e.an(r));return _.center[0]-=A.x*g,_.center[1]+=A.y*g,_}queryTerrainElevation(t,i){const n=this.transform.elevation;return n?(i=Object.assign({},{exaggerated:!0},i),n.getAtPoint(e.ae.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,n,r,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,n,r,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=new e.aS(c.lng,u.lat),d=new e.aS(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),A=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,g||0,_||0,A||0)],[f.x,f.y,Math.max(m||0,g||0,_||0,A||0)]];let v=e.d8.fromPoints(y);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);v=e.d8.applyTransform(v,x);const w=this._extendAABB(v,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=w;const T=.5*e.av([],v.max,v.min)[2],E=this._minimumAABBFrustumDistance(a,v),C=[0,0,1,0];e.aC(C,C,x),e.f0(C,C);const S=e.c4([],C,E+T),B=e.d7([],v.center,S);e.af(v.center,v.center,b),e.af(B,B,b);const I=a.unproject(new e.P(v.center[0],v.center[1])),M=e.f1(a.projection,I),P=Math.pow(2,M),R=Math.min(a._zoomFromMercatorZ(B[2]*a.pixelsPerMeter*P/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&R<.5*(e.cZ+e.cK)?(a.setProjection({name:"globe"}),a.zoom=R,this._cameraForBounds(a,i,n,r,o,s)):{center:I,zoom:R,bearing:r,pitch:o}}fitBounds(e,t,i){const n=this.cameraForBounds(e,t);return this._fitInternal(n,t,i)}fitScreenCoordinates(t,i,n,r,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],g=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,m,n,g,r);return this._fitInternal(_,r,o)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const n=t.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.aS.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(o=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(s=!0,n.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!n.isPaddingEqual(a))if(!1===t.retainPadding){const e=n.clone();e.padding=a,n.setLocationAtPoint(n.center,e.centerPoint)}else n.padding=a;return t.preloadOnly?(this._preloadTiles(n),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),r&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),o&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),s&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(bl),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return e.w(bl),this;this.stop();const r=n.zoom,o=n.pitch,s=n.bearing;n.setFreeCameraOptions(t);const a=r!==n.zoom,l=o!==n.pitch,c=s!==n.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eU},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===n.projection.name){const i=e.ae.fromLngLat(n.center),r=d.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const o=i.toLngLat(),s=e.aS.convert(t.center||o);this._normalizeCenter(s),p=n.centerPoint.add(r),f=new e.P(i.x,i.y).mult(n.worldSize),m=new e.P(e.aF(s.lng),e.aJ(s.lat)).mult(n.worldSize).sub(f)}else{p=n.centerPoint.add(d);const i=n.pointLocation(p),r=e.aS.convert(t.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let _,A;t.around&&(_=e.aS.convert(t.around),A=n.locationPoint(_));const y=this._zooming||l!==r,v=this._rotating||o!==c,x=this._pitching||u!==s,b=!n.isPaddingEqual(h),w=!1===t.retainPadding?n.clone():n,T=n=>T=>{if(y&&(n.zoom=e.ak(r,l,T)),v&&(n.bearing=e.ak(o,c,T)),x&&(n.pitch=e.ak(s,u,T)),b&&(w.interpolatePadding(a,h,T),p=w.centerPoint.add(d)),_)n.setLocationAtPoint(_,A);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-T),o=n.unproject(f.add(m.mult(T*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(T,t.duration,n);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=v,this._pitching=x,this._padding=b,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||n.moving||this.fire(new e.z("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.z("zoomend",t)),r&&this.fire(new e.z("rotateend",t)),o&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const n=e.aH(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eU},t);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aA(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=n.zoomScale(l-r),p=e.P.convert(t.offset);let f=n.centerPoint.add(p);const m=n.pointLocation(f),g=e.aS.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),A=n.project(g).sub(_);let y=t.curve;const v=Math.max(n.width,n.height),x=v/d,b=A.mag();if("minZoom"in t){const i=e.aA(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),o=v/n.zoomScale(i-r);y=Math.sqrt(o/b*2)}const w=y*y;function T(e){const t=(x*x-v*v+(e?-1:1)*w*w*b*b)/(2*(e?x:v)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}const S=T(0);let B=function(e){return C(S)/C(S+y*e)},I=function(e){return v*((C(S)*(E(t=S+y*e)/C(t))-E(S))/w)/b;var t},M=(T(1)-S)/y;if(Math.abs(b)<1e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(t,i);const e=xt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,L=!n.isPaddingEqual(h),F=!1===t.retainPadding?n.clone():n,k=n=>d=>{const m=d*M,y=1/B(m);n.zoom=1===d?l:r+n.scaleZoom(y),P&&(n.bearing=e.ak(o,c,d)),R&&(n.pitch=e.ak(s,u,d)),L&&(F.interpolatePadding(a,h,d),f=F.centerPoint.add(p));const v=1===d?g:n.unproject(_.add(A.mult(I(m))).mult(y));return n.setLocationAtPoint(n.renderWorldCopies?v.wrap():v,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(k,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=L,this._prepareEase(i,!1),this._ease(k(n),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_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(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.bS(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const n=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=n;e++){const t=o(e/n);r.push(t.clone())}return r}_preloadTiles(e,t){}}class Tl{constructor(t={}){this.options=t,e.aX(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const n=l("span","mapboxgl-ctrl-icon",this._compactButton);return n.setAttribute("aria-hidden","true"),n.setAttribute("title",i),this._innerContainer=l("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}_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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){const n=i.reduce((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${ne.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=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 El{constructor(){e.aX(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("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 Cl{constructor(){e.aX(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",e=>this._onIndoorUpdate(e)),this._container}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_createSeparator(){return l("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,t){this._map&&(e.setAttribute("aria-label",t),e.textContent=t)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px",t&&Array.from(this._container.children).forEach(e=>e.remove()),e.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(e.floors,e.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const e=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const e=this._map;this._model&&e&&e._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(e),this._createSeparator()}_updateBuildingsButtonState(){const e=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");e&&this._model&&(this._model.activeFloorsVisible?e.classList.remove("mapboxgl-ctrl-level-button-selected"):e.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(e,t){for(let i=0;i{this._map._selectIndoorFloor(n.id)});this._setButtonTitle(r,n.zIndex.toString()),this._model&&n.id===this._model.selectedFloorId&&t&&r.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(r),i=this._endTime)return this._end;const i=e.dC((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}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 Il={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","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"};class Ml extends e.z{constructor(e,t,i,n){const{point:r,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=n}}class Pl{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const n=i.filter;let r=i.type;n&&this.filters.set(t,e.b5(n)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const o=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===o.size&&this.map.on(r,this.handleType),0===o.size&&this.interactionsByType.set(r,o),o.set(t,i),this.typeById.set(t,r)}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType))}queryTargets(e,t){const i=[];for(const[e,n]of t)n.target&&i.push({targetId:e,target:n.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())))}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear()}handleType(t,i){const n="mouseenter"===t.type;if(n&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),o=!!i;i=i||this.queryTargets(t.point,r);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const u of r){if(mt(u,l,a,i))continue;const r=new e.dw(l,u),h=ft(u,l,i);o&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const d=n?this.prevHoveredFeatures.get(h):null,p=new Ml(t,i,c,r),f=d?d.stop:c.handler(p);if(n&&this.hoveredFeatures.set(h,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:n,target:r}=i;if(!r&&!1!==n(new Ml(t,e,i,null)))break}}}function Rl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),n=new Set(i);return e.size===n.size&&t.every(e=>n.has(e))}return e.bx(t,i)}const Ll={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,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},Fl={showCompass:!0,showZoom:!0,visualizePitch:!1};class kl{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Wa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new qa({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aX(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),p()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),_(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,_(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=A(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=A(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)n.width||i.y>n.height;n.locationPoint3D(r).distSqr(i)180;){const e=n.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Ol={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%)"},zl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ul extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aX(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:n="center",color:r="#3FB1CE",scale:o=1,draggable:s=!1,clickTolerance:a=0,rotation:l=zl.rotation,rotationAlignment:c=zl.rotationAlignment,pitchAlignment:u=zl.pitchAlignment,occludedOpacity:h=zl.occludedOpacity,altitude:d=zl.altitude}=t||{};this._anchor=n,this._color=r,this._scale=o,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=u,this._occludedOpacity=h,this._altitude=d,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.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 p=this._element.classList;for(const e in Ol)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`);const f=t&&t.className?t.className.trim().split(/\s+/):[];p.add(...f),this._popup=null}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return c("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"},t),c("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"},t),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}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(t){return this._lngLat=e.aS.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||zl.altitude,this._update()),this}getAltitude(){return this._altitude}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,n=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":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,e._altitude=this._altitude,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,this._altitude),n=e.getFreeCameraOptions();if(!n.position)return!1;const r=n.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const n=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.f4(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.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 ${Ol[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,n=this.getPitchAlignment();if(!i||!t||"map"!==n)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.cW(e.f5(i.transform,this._lngLat)),o=t.sub(e.f6(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=r/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);n=e.cW(Math.atan2(r.y,r.x))-90}else n=-i.getBearing();else if("horizon"===r){const r=e.ah(4,6,i.getZoom()),o=e.f6(i.transform);o.y+=r*i.transform.height;const s=t.sub(o),a=e.cW(Math.atan2(s.y,s.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Dl(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),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(t){const i=this._map;if(!i)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(n)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.f2(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new an(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Sl,this._domRenderTaskQueue=new Sl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b1(),this._locale=Object.assign({},Il,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Bl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new w(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat=t.spriteFormat,e.aX(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new sa),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},()=>{this.setScaleFactor(this._scaleFactor)}),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)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new xl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ta("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Tl({customAttribution:t.customAttribution})),this._logoControl=new El,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.z(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))}),this._interactions=new Pl(this)}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 i=!this._moving;return i&&this.fire(new e.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aI.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this._tp.refreshUI(),this._scaleFactorChanged=!0,this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}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?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?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._styleDirty=!0,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 t=this.transform,i=t.projection.name;let n;"globe"===i&&t.zoom>=e.cK?(t.setMercatorFromTransition(),n=!0):"mercator"===i&&t.zoom=e.cK?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&n!==this.transform.mercatorFromTransition;return(i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aS.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}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){const n=e=>{let i=[];if(Array.isArray(t)){const n=t.filter(e=>this.getLayer(e));i=n.length?this.queryRenderedFeatures(e,{layers:n}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const o=t=>{const o=n(t.point);o.length?r||(r=!0,i.call(this,new Fa(e,this,t.originalEvent,{features:o}))):r=!1};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=t=>{n(t.point).length?r=!0:r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))},s=t=>{r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const r=e=>{const t=n(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n{if(n){const r="string"==typeof n?n:n instanceof Error?n.message:n.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}else r&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new In(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new In(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.y(new Error("IDs can't be empty."))),!1):!e.dq(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return"featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(e)}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(){return this.style.areTilesLoaded()}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(t,i,{pixelRatio:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:u}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(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:c,height:u}=i,h=i;this.style.addImage(l,{data:new e.q({width:c,height:u},new Uint8Array(h.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const n=e.I.from(t),r=this.style.getImage(n);if(!r)return void this.fire(new e.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.o.getImageData(i):i,{width:s,height:a,data:l}=o;if(void 0===s||void 0===a)return void this.fire(new e.y(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`")));if(s!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.y(new Error(`The width and height of the updated image (${s}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let u=!1;r.usvg?(r.data=new e.q({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,u=!0):r.data.replace(l,c),this.style.updateImage(n,r,u)}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.y(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t))}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(t,n)=>{i(t,n instanceof HTMLImageElement?e.o.getImageData(n):n)})}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.y(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}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.y(new Error("Failed to add import",t)))),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}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){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}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,n={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,n),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,n),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayerProperty(e,t,i,n),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}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}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}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(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aS.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.indoor.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.indoor.setActiveFloorsVisibility(e)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Cl),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,n,r,o=this._container;for(;o&&(!n||!r);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(n=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),o=o.parentElement}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=r?Math.abs(t/r):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("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/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new Mn(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("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=l("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{n[e]=l("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.o.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}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 t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(G(i,!0),this.painter=new ba(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp,this._worldview),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.k.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.z("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_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(t){let r;this.fire(new e.z("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,s=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.o.now(),r=new e.ac(t,{now:n,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s);const u=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),u&&(this._placementDirty=u.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,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:l,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 e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,n.mark(i.load),this.fire(new e.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.o.now()-s;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("gpu-timing-layer",{layerTimes:i}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.z("gpu-timing-deferred-render",{gpuTime:i}))},50)}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,n.mark(i.fullLoad),this._performanceMetricsCollection&&U(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 n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){V(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===b||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof El&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(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/")))}}),L(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&k(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&O(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,n=i.createFramebuffer();function r(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,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bv(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),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,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.f3(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Fl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aX(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),l("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})}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aX(["_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=l("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(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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 kl(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=l("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 e.E{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},Nl,t),e.aX(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=wa(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("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 t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitudet.getEast()||i.latitudet.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish()}}_updateCamera(t){const i=new e.aS(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),o=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aS(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.ce(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}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=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ul({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ul({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",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("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 e.w("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 e.z("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 e.z("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 e.z("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=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.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:Tl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Vl,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aX(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,n=t._containerWidth/2-e/2,r=t.unproject([n,i]),o=t.unproject([n+e,i]),s=r.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 n=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),r=n/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(n):`${n} ${jl[i]}`,this._container.style.width=e*r+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("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(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aX(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),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(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:Cl,Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Gl),t),this._altitude=this.options.altitude,e.aX(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aS.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),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(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}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=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',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,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.xt.transform.width-r/2;if(n.y+et.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(t){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Dl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const n=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=Ql(this.options.offset),o=this._anchor=this._getAnchor(r.y),s=Ql(this.options.offset,o),a=n.add(s).round();i._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${Ol[o]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&i._showingGlobe()){const t=e.f4(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Hl);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:Ul,Style:In,LngLat:e.aS,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ae,FreeCameraOptions:tn,Evented:e.E,config:e.e,prewarm:e.f8,clearPrewarmedResources:e.f7,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t},get workerCount(){return e.fh.workerCount},set workerCount(t){e.fh.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.fg(t)},get workerUrl(){return e.ff.workerUrl},set workerUrl(t){e.ff.workerUrl=t},get workerClass(){return e.ff.workerClass},set workerClass(t){e.ff.workerClass=t},get workerParams(){return e.ff.workerParams},set workerParams(t){e.ff.workerParams=t},get dracoUrl(){return e.fe()},set dracoUrl(t){e.fd(t)},get meshoptUrl(){return e.fc()},set meshoptUrl(t){e.fb(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return $l});var r=i;return r}();var Ze=He($e.exports),We=e({__proto__:null,default:Ze},[$e.exports]),qe={exports:{}};qe.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,n*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),u=Math.sin(n),h=Math.cos(n);switch(r){case"xyz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"xzy":e[0]=s*c*h-a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h+s*l*u;break;case"yxz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;case"yzx":e[0]=s*c*h+a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h-s*l*u;break;case"zxy":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"zyx":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;default:throw new Error("Unknown angle order "+r)}return e}function S(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function B(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),b=new p(4),p!=Float32Array&&(b[0]=0,b[1]=0,b[2]=0,b[3]=0),g(),A(1,0,0),A(0,1,0),E(),E(),f(),S();const I=8192;function M(e,t,i){return t*(I/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function P(e,t){return(e%t+t)%t}function R(e,t,i){return e*(1-i)+t*i}function L(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 F(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";function oe(){return new Error(re)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(n=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new ce(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;if(i.signal.aborted)throw oe();return{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var n;return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(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 n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)fe(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof ge&&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 Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},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:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},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,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},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,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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)}function tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,nt=.82521,rt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,n]){let r,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?r=o=s:(r=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+rt}function ft([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*gt(r),o=it*gt(o),s=nt*gt(s),[mt(3.1338561*o-1.6168667*r-.4906146*s),mt(-.9787684*o+1.9161415*r+.033454*s),mt(.0719453*o-.2289914*r+1.4052427*s),n]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-rt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,n)=>Tt(e,t[n],i))}class Ct{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+r,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=ut(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=ht(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?ut(Math.atan2(n,i)*ct):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Et(e.rgb,t.rgb,i);return new Ct(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:Tt(r,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(n,r,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class St{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}}const Bt=["bottom","center","top"];class It{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof St||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof St)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let n=Vt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Gt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Ht[i],n++}else r=Ve;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],n++}i=qe(r,o)}else{if(!Ht[r])throw new Error(`Types doesn't contain name = ${r}`);i=Ht[r]}const o=[];for(;ne.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{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];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=$t[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Pt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Lt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new qt;try{n=new Gt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}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 n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{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 n=1;n=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,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,Ve),n=t.parse(e[2],2,Ve);return i&&n?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,Ve);if(!i||!n)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ti(i,n,r):null}return new ti(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,Vt(e)))return null}else i=Vt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(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()}}class ni{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class ri{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,ke);if(!i||!n)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ri(i.type,i,n,r):null}return new ri(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,n).join("");if(et(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new si(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[oi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ci=1,li=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=pi(t,e.base,i,n);else if("linear"===e.name)r=pi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new hi(o[0],o[1],o[2],o[3]).solve(pi(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,ke),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,n,r,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=oi(t,n),s=di.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>Je(n,e.type));return new mi(o?Ve:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,n){return 0===n.compare(t,i)}function Ai(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(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,je),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!_i(0,t,i,n)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(n,r,o)}evaluate(e){return new St(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}}class Ci{constructor(e,t,i,n,r){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,De),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,De),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,ke),!a)?null:new Ci(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ge,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Bt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Si(n)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Bi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,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 ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Mi),Math.round(n*r*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Mi+t.x)/i,360*r-180),(n=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Di(e,t,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!ji(e,t,i,n)||!ji(i,n,e,t));var r,o}function Oi(e,t,i){for(const n of i)for(let i=0;i(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Li(t,e)}function $i(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Qi(n,t,i,r),s.push(n)}return s}function Zi(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Qi(n,t,i,r)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=Ji){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Xi(e,i,t),r(e[n],o)>0&&Xi(e,i,n);s0;)a--}0===r(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Xi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=tn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function an(e,t){return t[0]-e[0]}function ln(e){return e[1]-e[0]+1}function cn(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ln(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function hn(e,t){if(!cn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Li(i,e[n]);return i}function dn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function pn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fn(e,t,i){if(!pn(e)||!pn(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(Fi(r,o)){if(xn(e,t))return 0}else if(xn(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(ln(l)<=c){if(!cn(l,e.length))return NaN;if(t){const t=vn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=yn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=un(l,t);wn(s,o,n,e,a,i[0]),wn(s,o,n,e,a,i[1])}}return o}function Cn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],an);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(ln(l)<=u&&ln(c)<=h){if(!cn(l,e.length)&&cn(c,i.length))return NaN;let o;if(t&&n)o=_n(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=mn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=mn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=An(e,l,i,c,r),s=Math.min(s,o)}else{const o=un(l,t),u=un(c,n);Tn(a,s,r,e,i,o[0],u[0]),Tn(a,s,r,e,i,o[0],u[1]),Tn(a,s,r,e,i,o[1],u[0]),Tn(a,s,r,e,i,o[1],u[1])}}return s}function Sn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Bn{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Bn(t,t.features.map(e=>Sn(e.geometry)).flat());if("Feature"===t.type)return new Bn(t,Sn(t.geometry));if("type"in t&&"coordinates"in t)return new Bn(t,Sn(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new sn(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,En([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,En(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,bn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class In{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new In(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Mn={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ni,coalesce:mi,collator:Ei,format:Si,image:Bi,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ri,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Bn,"global-state":In};class Pn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Pn.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Dn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i{i=t?i&&Dn(e):i&&e instanceof Gt}),!!i&&On(e)&&Un(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function On(e){if(e instanceof Pn){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 Wi)return!1;if(e instanceof Bn)return!1;let t=!0;return e.eachChild(e=>{t&&!On(e)&&(t=!1)}),t}function zn(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!zn(e)&&(t=!1)}),t}function Un(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Un(e,t)&&(i=!1)}),i}function Nn(e){return{result:"success",value:e}}function Vn(e){return{result:"error",value:e}}function jn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hn(e){return!!e.expression&&e.expression.interpolated}function Qn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function $n(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function Zn(e){return e}function Wn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||(Hn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Jn;case"interval":return Xn;case"categorical":return Kn;case"identity":return Yn;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Jn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?qn(e.default,t.default):a(e,t,r,l,c)}}}function qn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return qn(typeof i===r?n[i]:void 0,e.default,t.default)}function Xn(e,t,i){if("number"!==Qn(i))return qn(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 r=oi(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Jn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Qn(i))return qn(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 o=oi(e.stops.map(e=>e[0]),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||Zn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Yn(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return qn(i,e.default,t.default)}Pn.register(Mn,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[ze,[ke,ke,ke],Rn],rgba:[ze,[ke,ke,ke,ke],Rn],has:{type:Oe,overloads:[[[De],(e,[t])=>Ln(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Ln(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,kn(ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[ke,kn(ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,kn(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,kn(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,kn(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class er{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&$n(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 Ft(`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 tr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mn}function ir(e,t,i){const n=new Kt(Mn,Dn,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Nn(new er(r,t,i)):Vn(n.errors)}class nr{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}}class rr{constructor(e,t,i,n,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this.interpolationType=n,this._globalState=r}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function or(e,t,i){const n=ir(e,t,i);if("error"===n.result)return n;const r=n.value.expression,o=On(r);if(!o&&!jn(t))return Vn([new Re("","data expressions not supported")]);const s=Un(r,["zoom"]);if(!s&&!Gn(t))return Vn([new Re("","zoom expressions not supported")]);const a=ar(r);return a||s?a instanceof Re?Vn([a]):a instanceof di&&!Hn(t)?Vn([new Re("",'"interpolate" expressions cannot be used with this property')]):Nn(a?new rr(o?"camera":"composite",n.value,a.labels,a instanceof di?a.interpolation:void 0,i):new nr(o?"constant":"source",n.value,i)):Vn([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sr{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Wn(this._parameters,this._specification))}static deserialize(e){return new sr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ar(e){let t=null;if(e instanceof Xt)t=ar(e.result);else if(e instanceof mi){for(const i of e.args)if(t=ar(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=ar(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function lr(e,t=new Set){return e instanceof In&&t.add(e.key),e.eachChild(e=>{lr(e,t)}),t}function cr(e,t){const{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function ur(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(!ur(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const hr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function dr(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};ur(e)||(e=mr(e));const i=ir(e,hr,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,n)=>i.value.evaluate(e,t,{},n),needGeometry:fr(e),getGlobalStateRefs:()=>lr(i.value.expression)}}function pr(e,t){return et?1:0}function fr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?gr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(mr))):"all"===t?["all"].concat(e.slice(1).map(mr)):"none"===t?["all"].concat(e.slice(1).map(mr).map(yr)):"in"===t?_r(e[1],e.slice(2)):"!in"===t?yr(_r(e[1],e.slice(2))):"has"===t?Ar(e[1]):"!has"!==t||yr(Ar(e[1]));var i}function gr(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 _r(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(pr)]]:["filter-in-small",e,["literal",t]]}}function Ar(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function yr(e){return["!",e]}function vr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${vr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new Me(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Br(e){const t=e.valueSpec,i=wr(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Qn(e.value.stops)&&"array"===Qn(e.value.stops[0])&&"object"===Qn(e.value.stops[0][0]),u=Er({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Cr({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Qn(n)&&0===n.length&&t.push(new Me(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Hn(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jn(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!Gn(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Qn(n))return[new Me(a,n,`array expected, ${Qn(n)} found`)];if(2!==n.length)return[new Me(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Qn(n[0]))return[new Me(a,n,`object expected, ${Qn(n[0])} found`)];if(void 0===n[0].zoom)return[new Me(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Me(a,n,"object stop key must have value")];if(o&&o>wr(n[0].zoom))return[new Me(a,n[0].zoom,"stop zoom values must appear in ascending order")];wr(n[0].zoom)!==o&&(o=wr(n[0].zoom),r=void 0,s={}),i=i.concat(Er({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Sr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return tr(Tr(n[1]))?i.concat([new Me(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Qn(e.value),l=wr(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return jn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew Me(`${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 Me(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&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Un(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!On(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Mr(e){const t=e.key,i=e.value,n=Qn(i);return"string"!==n?[new Me(t,i,`color expected, ${n} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Pr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Rr(e){return ur(Tr(e.value))?Ir(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Lr(e)}function Lr(e){const t=e.value,i=e.key;if("array"!==Qn(t))return[new Me(i,t,`array expected, ${Qn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Pr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),wr(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===wr(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Qn(t[1]),"string"!==r&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new Me(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{wr(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(n,i.ref,"ref cannot reference another ref layer")):s=wr(e.type):t.push(new Me(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&wr(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(n,i.source,`source "${i.source}" not found`))}else t.push(new Me(n,i,'missing required property "source"'));return t=t.concat(Er({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Rr,layout:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Dr(Pe({layerType:s},e))}}),paint:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kr(Pe({layerType:s},e))}})}})),t}function zr(e){const t=e.value,i=e.key,n=Qn(t);return"string"!==n?[new Me(i,t,`string expected, ${n} found`)]:[]}const Ur={promoteId:function({key:e,value:t}){if("string"===Qn(t))return zr({key:e,value:t});{const i=[];for(const n in t)i.push(...zr({key:`${e}.${n}`,value:t[n]}));return i}}};function Nr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=wr(t.type);let a;switch(s){case"vector":case"raster":return a=Er({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:Ur,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Qn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Me("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===wr(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Me(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Me(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=Er({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:Ur}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Ir({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Ir({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Er({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return Er({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Vr(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function jr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function Gr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Hr(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Me(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(Er({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zr({key:n,value:i})}function Qr(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Qn(e.value)} found`)];var t}const $r={"*":()=>[],array:Cr,boolean:function(e){const t=e.value,i=e.key,n=Qn(t);return"boolean"!==n?[new Me(i,t,`boolean expected, ${n} found`)]:[]},number:Sr,color:Mr,constants:br,enum:Pr,filter:Rr,function:Br,layer:Or,object:Er,source:Nr,light:Vr,sky:jr,terrain:Gr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Qn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Me(t,i,`projection expected, invalid type "${n}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:zr,formatted:function(e){return 0===zr(e).length?[]:Ir(e)},resolvedImage:function(e){return 0===zr(e).length?[]:Ir(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Qn(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(br({key:"constants",value:e.constants}))),Xr(i)}function Kr(e){return function(t){return e(Object.assign({},t,{validateSpec:Zr}))}}function Xr(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Jr(e){return function(...t){return Xr(e.apply(this,t))}}qr.source=Jr(Kr(Nr)),qr.sprite=Jr(Kr(Hr)),qr.glyphs=Jr(Kr(Wr)),qr.light=Jr(Kr(Vr)),qr.sky=Jr(Kr(jr)),qr.terrain=Jr(Kr(Gr)),qr.state=Jr(Kr(Qr)),qr.layer=Jr(Kr(Or)),qr.filter=Jr(Kr(Rr)),qr.paintProperty=Jr(Kr(kr)),qr.layoutProperty=Jr(Kr(Dr));const Yr=Ae,eo=qr,to=eo.light,io=eo.sky,no=eo.paintProperty,ro=eo.layoutProperty;function oo(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new ge(new Error(n.message))),i=!0;return i}class so{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e=c[l+0]&&n>=c[l+1])?(s[h]=!0,o.push(r[h])):s[h]=!1}}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[n];r[n]=ao[i].shallow.indexOf(n)>=0?o:po(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function fo(e){if(ho(e))return e;if(Array.isArray(e))return e.map(fo);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=uo(e)||"Object";if(!ao[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=ao[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=ao[t].shallow.indexOf(i)>=0?r:fo(r)}return n}class mo{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const bo=xo(["Arab","Dupl","Mong","Ougr","Syrc"]);function wo(e){return!bo.test(String.fromCodePoint(e))}function To(e){return!(_o(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Eo=xo(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Co(e){return Eo.test(String.fromCodePoint(e))}function So(e,t){return!(!t&&Co(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Bo(e){for(const t of e)if(Co(t.codePointAt(0)))return!0;return!1}const Io=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Io.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Mo{constructor(e,t){this.isSupportedScript=Po,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new mo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Po(e){return function(e,t){for(const i of e)if(!So(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===Io.getRTLTextPluginStatus())}const Ro="-transition";class Lo{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if($n(e))return new sr(e,t);if(tr(e)){const n=or(e,t,i);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Fo{constructor(e,t){this.property=e,this.value=new Lo(e,void 0,t)}transitioned(e,t){return new Do(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class ko{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].value=new Lo(this._values[e].property,null===t?void 0:j(t),this._globalState)}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].transition=j(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 n=this.getTransition(t);void 0!==n&&(e[`${t}${Ro}`]=n)}return e}transitioned(e,t){const i=new Oo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Oo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nn.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Mo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Qo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class $o{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Lo(i,void 0,void 0),r=this.defaultTransitionablePropertyValues[t]=new Fo(i,void 0);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}lo("DataDrivenProperty",jo),lo("DataConstantProperty",Vo),lo("CrossFadedDataDrivenProperty",Go),lo("CrossFadedProperty",Ho),lo("ColorRampProperty",Qo);class Zo extends _e{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=dr(e.filter,i)),t.layout&&(this._unevaluatedLayout=new zo(t.layout,i)),t.paint)){this._transitionablePaint=new ko(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._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=dr(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const n=this._transitionablePaint._values[i].value;for(const r of n.getGlobalStateRefs()){const o=null!==(e=t.get(r))&&void 0!==e?e:[];o.push({name:i,value:n.value}),t.set(r,o)}}return t}setLayoutProperty(e,t,i={}){null!=t&&this._validate(ro,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Ro)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(no,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Ro))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):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){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&oo(this,e.call(eo,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Uo&&jn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Wo;var qo={get paint(){return Wo=Wo||new $o({"raster-opacity":new Vo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Vo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Vo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Vo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Vo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Vo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Vo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Vo(Ae.paint_raster["raster-fade-duration"])})}};class Ko extends Zo{constructor(e,t){super(e,qo,t)}}const Xo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Jo{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 Yo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(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")}}function es(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=Xo[e.type].BYTES_PER_ELEMENT,o=i=ts(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:ts(i,Math.max(n,t)),alignment:t}}function ts(e,t){return Math.ceil(e/t)*t}class is extends Yo{_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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}is.prototype.bytesPerElement=4,lo("StructArrayLayout2i4",is);class ns extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}ns.prototype.bytesPerElement=6,lo("StructArrayLayout3i6",ns);class rs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}rs.prototype.bytesPerElement=8,lo("StructArrayLayout4i8",rs);class os extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,lo("StructArrayLayout2i4i12",os);class ss extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ss.prototype.bytesPerElement=8,lo("StructArrayLayout2i4ub8",ss);class as extends Yo{_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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}as.prototype.bytesPerElement=8,lo("StructArrayLayout2f8",as);class ls extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ls.prototype.bytesPerElement=20,lo("StructArrayLayout10ui20",ls);class cs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}cs.prototype.bytesPerElement=16,lo("StructArrayLayout8ui16",cs);class us extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,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]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}us.prototype.bytesPerElement=24,lo("StructArrayLayout4i4ui4i24",us);class hs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}hs.prototype.bytesPerElement=12,lo("StructArrayLayout3f12",hs);class ds extends Yo{_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}}ds.prototype.bytesPerElement=4,lo("StructArrayLayout1ul4",ds);class ps extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ps.prototype.bytesPerElement=20,lo("StructArrayLayout6i1ul2ui20",ps);class fs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}fs.prototype.bytesPerElement=12,lo("StructArrayLayout2i2i2i12",fs);class ms extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ms.prototype.bytesPerElement=16,lo("StructArrayLayout2f1f2i16",ms);class gs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}gs.prototype.bytesPerElement=16,lo("StructArrayLayout2ub2f2i16",gs);class _s extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}_s.prototype.bytesPerElement=6,lo("StructArrayLayout3ui6",_s);class As extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=n,this.uint16[A+3]=r,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}As.prototype.bytesPerElement=48,lo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",As);class ys extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=n,this.int16[I+3]=r,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=S,this.uint16[I+31]=B,e}}ys.prototype.bytesPerElement=64,lo("StructArrayLayout8i15ui1ul2f2ui64",ys);class vs extends Yo{_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}}vs.prototype.bytesPerElement=4,lo("StructArrayLayout1f4",vs);class xs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}xs.prototype.bytesPerElement=12,lo("StructArrayLayout1ui2f12",xs);class bs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}bs.prototype.bytesPerElement=8,lo("StructArrayLayout1ul2ui8",bs);class ws extends Yo{_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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}ws.prototype.bytesPerElement=4,lo("StructArrayLayout2ui4",ws);class Ts extends Yo{_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}}Ts.prototype.bytesPerElement=2,lo("StructArrayLayout1ui2",Ts);class Es extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}Es.prototype.bytesPerElement=16,lo("StructArrayLayout4f16",Es);class Cs extends Jo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Cs.prototype.size=20;class Ss extends ps{get(e){return new Cs(this,e)}}lo("CollisionBoxArray",Ss);class Bs extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Bs.prototype.size=48;class Is extends As{get(e){return new Bs(this,e)}}lo("PlacedSymbolArray",Is);class Ms extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ms.prototype.size=64;class Ps extends ys{get(e){return new Ms(this,e)}}lo("SymbolInstanceArray",Ps);class Rs extends vs{getoffsetX(e){return this.float32[1*e+0]}}lo("GlyphOffsetArray",Rs);class Ls extends ns{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}lo("SymbolLineVertexArray",Ls);class Fs extends Jo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Fs.prototype.size=12;class ks extends xs{get(e){return new Fs(this,e)}}lo("TextAnchorOffsetArray",ks);class Ds extends Jo{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]}}Ds.prototype.size=8;class Os extends bs{get(e){return new Ds(this,e)}}lo("FeatureIndexArray",Os);class zs extends is{}class Us extends is{}class Ns extends is{}class Vs extends os{}class js extends ss{}class Gs extends as{}class Hs extends ls{}class Qs extends cs{}class $s extends us{}class Zs extends hs{}class Ws extends ds{}class qs extends fs{}class Ks extends gs{}class Xs extends _s{}class Js extends ws{}const Ys=es([{name:"a_pos",components:2,type:"Int16"}],4),{members:ea}=Ys;class ta{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return e>ta.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${ta.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ta.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>ta.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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,n){return new ta([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function ia(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}ta.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,lo("SegmentVector",ta);const na=es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ra=es([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var oa,sa,aa,la={exports:{}},ca={exports:{}},ua={exports:{}},ha=function(){if(aa)return la.exports;aa=1;var e=(oa||(oa=1,ca.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>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:r^=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 r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ca.exports),t=(sa||(sa=1,ua.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=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),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ua.exports);return la.exports=e,la.exports.murmur3=e,la.exports.murmur2=t,la.exports}(),da=n(ha);class pa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(fa(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=fa(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return ma(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new pa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function fa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:da(String(e))}function ma(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;ga(e,o,s),ga(t,3*o,3*s),ga(t,3*o+1,3*s+1),ga(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new va(e,t):new Aa(e,t)}}class Ta{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,n){let r=null;"u_pattern_to"===n?r=this.patternTo:"u_pattern_from"===n?r=this.patternFrom:"u_dasharray_to"===n?r=this.dashTo:"u_dasharray_from"===n?r=this.dashFrom:"u_pixel_ratio_to"===n?r=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(r=this.pixelRatioFrom),null!==r&&e.set(r)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)||"u_dasharray_"===i.substr(0,12)?new ya(e,t):new Aa(e,t)}}class Ea{constructor(e,t,i,n){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 n}populatePaintArray(e,t,i){const n=this.paintVertexArray.length,r=this.expression.evaluate(new Mo(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(n,e,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(0,r),i,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=ba(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=r,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){const n=this.expression.evaluate(new Mo(this.zoom,i),t,{},i.canonical,[],i.formattedSection),r=this.expression.evaluate(new Mo(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,n,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(this.zoom,r),i,n),s=this.expression.evaluate(new Mo(this.zoom+1,r),i,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=ba(i),o=ba(n);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ea||i instanceof Ca)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ma(n,t,i);this.needsUpload=!1,this._featureMap=new pa,this._bufferOffset=0}populatePaintArrays(e,t,i,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||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()}}function Ra(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function La(e,t,i){const n={color:{source:as,composite:Es},number:{source:vs,composite:as}},r=function(e){return{"line-pattern":{source:Hs,composite:Hs},"fill-pattern":{source:Hs,composite:Hs},"fill-extrusion-pattern":{source:Hs,composite:Hs},"line-dasharray":{source:Qs,composite:Qs}}[e]}(e);return r&&r[i]||n[t][i]}lo("ConstantBinder",wa),lo("CrossFadedConstantBinder",Ta),lo("SourceExpressionBinder",Ea),lo("CrossFadedPatternBinder",Ba),lo("CrossFadedDasharrayBinder",Ia),lo("CompositeExpressionBinder",Ca),lo("ProgramConfiguration",Ma,{omit:["_buffers"]}),lo("ProgramConfigurationSet",Pa);const Fa=Math.pow(2,14)-1,ka=-Fa-1;function Da(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Oa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Da(e):[]}}const za=-32768;function Ua(e,t,i,n,r){e.emplaceBack(za+8*t+n,za+8*i+r)}class Na{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Us,this.indexArray=new Xs,this.segments=new ta,this.programConfigurations=new Pa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ea),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())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=I||n<0||n>=I)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e1){if(Qa(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function qa(e,t){let i,n,r,o=!1;for(let s=0;st.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function Ka(e,t){let i=!1;for(let n=0,r=e.length-1;nt.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 Xa(e,t,i){const n=i[0],r=i[2];if(e.xr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Ja(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ya(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function el(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(let t=0;tsl(e,t,i,n))}(l,r,s,a),p=c),ol({queryGeometry:d,size:p,transform:r,unwrappedTileID:s,getElevation:a,pitchAlignment:h,pitchScale:u},n)}}class hl extends Na{}let dl;lo("HeatmapBucket",hl,{omit:["layers"]});var pl={get paint(){return dl=dl||new $o({"heatmap-radius":new jo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Vo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Qo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Vo(Ae.paint_heatmap["heatmap-opacity"])})}};function fl(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError(`mismatched image size. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function ml(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=fl({},{width:t,height:i},n);gl(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function gl(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Il(e,this.getUnpackVector())}getPixels(){return new Al({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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;t0)for(let r=t;r=t;r-=n)o=nc(r/n|0,e[r],e[r+1],o);return o&&Xl(o,o.next)&&(rc(o),o=o.next),o}function Dl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Xl(n,n.next)&&0!==Kl(n.prev,n,n.next))n=n.next;else{if(rc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ol(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Ql(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Ul(e,n,r,o):zl(e))t.push(l.i,e.i,c.i),rc(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Ol(e=Nl(Dl(e),t),t,i,n,r,o,2):2===s&&Vl(e,t,i,n,r,o):Ol(Dl(e),t,i,n,r,o,1);break}}}function zl(e){const t=e.prev,i=e,n=e.next;if(Kl(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Wl(r,a,o,l,s,c,f.x,f.y)&&Kl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ul(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Kl(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Ql(p,f,t,i,n),A=Ql(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Nl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!Xl(n,r)&&Jl(n,i,i.next,r)&&tc(n,r)&&tc(r,n)&&(t.push(n.i,i.i,r.i),rc(i),rc(i.next),i=e=r),i=i.next}while(i!==e);return Dl(i)}function Vl(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&ql(s,e)){let a=ic(s,e);return s=Dl(s,s.next),a=Dl(a,a.next),Ol(s,t,i,n,r,o,0),void Ol(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function jl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Gl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(Xl(e,i))return i;do{if(Xl(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Zl(ro.x||i.x===o.x&&Hl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=ic(i,e);return Dl(n,n.next),Dl(i,i.next)}function Hl(e,t){return Kl(e.prev,e,t.prev)<0&&Kl(t.next,e,e.next)<0}function Ql(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $l(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Wl(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Zl(e,t,i,n,r,o,s,a)}function ql(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(tc(e,t)&&tc(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Kl(e.prev,e,t.prev)||Kl(e,t.prev,t))||Xl(e,t)&&Kl(e.prev,e,e.next)>0&&Kl(t.prev,t,t.next)>0)}function Kl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Xl(e,t){return e.x===t.x&&e.y===t.y}function Jl(e,t,i,n){const r=ec(Kl(e,t,i)),o=ec(Kl(e,t,n)),s=ec(Kl(i,n,e)),a=ec(Kl(i,n,t));return r!==o&&s!==a||!(0!==r||!Yl(e,i,t))||!(0!==o||!Yl(e,n,t))||!(0!==s||!Yl(i,e,n))||!(0!==a||!Yl(i,t,n))}function Yl(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 ec(e){return e>0?1:e<0?-1:0}function tc(e,t){return Kl(e.prev,e,e.next)<0?Kl(e,t,e.next)>=0&&Kl(e,e.prev,t)>=0:Kl(e,t,e.prev)<0||Kl(e,e.next,t)<0}function ic(e,t){const i=oc(e.i,e.x,e.y),n=oc(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function nc(e,t,i,n){const r=oc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function rc(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 oc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class sc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n=1||y<=0)||m&&(ar)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),_=n+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=dc(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;er!=(o===lc)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return Ol(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let n=0;n0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(A-e),r=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?n/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function fc(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(cta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=mc(s,n,o,a,d,m,c),y=mc(s,n,o,a,p,g,c),v=mc(s,n,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;eta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=mc(s,n,o,a,r,f,c),_=mc(s,n,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function mc(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class gc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Ns,this.indexArray=new Xs,this.indexArray2=new Js,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.segments2=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Oa(s,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Da(s),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasDependencies){const e=Fl("fill",this.layers,n,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rl),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,n,r,o){for(const e of Yi(t,500)){const t=hc(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;fc((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,canonical:n})}}let _c,Ac;lo("FillBucket",gc,{omit:["layers","patternFeatures"]});var yc={get paint(){return Ac=Ac||new $o({"fill-antialias":new Vo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new jo(Ae.paint_fill["fill-opacity"]),"fill-color":new jo(Ae.paint_fill["fill-color"]),"fill-outline-color":new jo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Vo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Vo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Go(Ae.paint_fill["fill-pattern"])})},get layout(){return _c=_c||new $o({"fill-sort-key":new jo(Ae.layout_fill["fill-sort-key"])})}};class vc extends Zo{constructor(e,t){super(e,yc,t)}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 gc(e)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ga(el(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const xc=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),bc=es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:wc}=xc;class Tc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(Ec,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Tc(this._pbf,t,this.extent,this._keys,this._values)}}function Bc(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){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Ic{constructor(e,t){this.layers=e.readFields(Mc,{},t)}}function Mc(e,t,i){if(3===e){const e=new Sc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Pc=Math.pow(2,13);function Rc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*Pc)+s,r*Pc*2,o*Pc*2,Math.round(a))}class Lc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Vs,this.centroidVertexArray=new zs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Ll("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Oa(n,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Da(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push(Fl("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wc),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,bc.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{Rc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;nta.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Fc(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function Dc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let Oc;lo("FillExtrusionBucket",Lc,{omit:["layers","features"]});var zc={get paint(){return Oc=Oc||new $o({"fill-extrusion-opacity":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Go(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Uc extends Zo{constructor(e,t){super(e,zc,t)}createBucket(e){return new Lc(e)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=el(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,n.push(C)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ga(i,t)&&(n=Vc(i,t[0]));for(let r=0;re.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new js,this.layoutVertexArray2=new Gs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("line",this.layers,t)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},dashes:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.hasDependencies?(Ll("line",this.layers,t)?Fl("line",this.layers,n,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,t),this.patternFeatures.push(n)):this.addFeature(n,r,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:n})}addFeatures(e,t,i,n){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,e.subdivisionGranularity)}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,Qc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gc),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&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap"),u=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,u,h,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,dashPositions:o,canonical:n})}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=dc(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":n;if(w&&"round"===T&&(yr&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>Zc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Zc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,n){for(const r of e){const e=r.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===r.layout.get("line-cap"),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,u=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;n.dashDependencies[c]=s,n.dashDependencies[u]=a,n.dashDependencies[h]=l,t.dashes[r.id]={min:c,mid:u,max:h}}}}let qc,Kc;lo("LineBucket",Wc,{omit:["layers","patternFeatures"]});var Xc={get paint(){return Kc=Kc||new $o({"line-opacity":new jo(Ae.paint_line["line-opacity"]),"line-color":new jo(Ae.paint_line["line-color"]),"line-translate":new Vo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Vo(Ae.paint_line["line-translate-anchor"]),"line-width":new jo(Ae.paint_line["line-width"]),"line-gap-width":new jo(Ae.paint_line["line-gap-width"]),"line-offset":new jo(Ae.paint_line["line-offset"]),"line-blur":new jo(Ae.paint_line["line-blur"]),"line-dasharray":new Go(Ae.paint_line["line-dasharray"]),"line-pattern":new Go(Ae.paint_line["line-pattern"]),"line-gradient":new Qo(Ae.paint_line["line-gradient"])})},get layout(){return qc=qc||new $o({"line-cap":new Vo(Ae.layout_line["line-cap"]),"line-join":new jo(Ae.layout_line["line-join"]),"line-miter-limit":new Vo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Vo(Ae.layout_line["line-round-limit"]),"line-sort-key":new jo(Ae.layout_line["line-sort-key"])})}};class Jc extends jo{possiblyEvaluate(e,t){return t=new Mo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let Yc;class eu extends Zo{constructor(e,t){super(e,Xc,t),this.gradientVersion=0,Yc||(Yc=new Jc(Xc.paint.properties["line-width"].specification),Yc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Yc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Wc(e)}queryRadius(e){const t=e,i=tu(Ja("line-width",this,t),Ja("line-gap-width",this,t)),n=Ja("line-offset",this,t);return i/2+Math.abs(n)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=el(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*tu(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(let r=0;r=3)for(let t=0;t0?t+2*e:e}const iu=es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),nu=es([{name:"a_projected_pos",components:3,type:"Float32"}],4);es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ru=es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ou=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),su=es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function au(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)}),e}es([{name:"triangle",components:3,type:"Uint16"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),es([{type:"Float32",name:"offsetX"}]),es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var lu=24;const cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},uu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hu={40:!0};function du(e,t,i,n,r,o){if("fontStack"in t){const n=i[t.fontStack],o=n&&n[e];return o?o.metrics.advance*t.scale+r:0}{const e=n[t.imageName];return e?e.displaySize[0]*t.scale*lu/o+r:0}}function pu(e,t,i,n){const r=Math.pow(e-t,2);return n?eMath.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let n=0;ni))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void H("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName: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)}determineLineBreaks(e,t,i,n,r){const o=[],s=this.determineAverageLineWidth(e,t,i,n,r),a=this.hasZeroWidthSpaces();let l=0,c=0;const u=this.text[Symbol.iterator]();let h=u.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!h.done;){const t=this.getSection(c),g=h.value.codePointAt(0);if(Ao(g)||(l+=du(g,t,i,n,e,r)),!p.done){const e=go(g),i=p.value.codePointAt(0);(uu[g]||e||"imageName"in t||!m.done&&hu[i])&&o.push(mu(c+1,l,s,o,fu(g,i,e&&a),!1))}c++,h=u.next(),p=d.next(),m=f.next()}return gu(mu(this.length(),l,s,o,0,!0))}determineAverageLineWidth(e,t,i,n,r){let o=0,s=0;for(const t of this.text){const a=this.getSection(s);o+=du(t.codePointAt(0),a,i,n,e,r),s++}return o/Math.max(1,Math.ceil(o/t))}}const Au=4294967296,yu=1/Au,vu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class xu{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return bu(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&vu?vu.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&wu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&wu(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Tu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Eu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Cu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Su,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Iu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Mu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Pu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ru,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function bu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function wu(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Tu(e,t){for(let i=0;it.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&eg.toCodeUnitIndex(e));const e=y(g.toString(),A);for(const t of e){const e=[...t].map(()=>0);_.push(new _u(t,g.sections,e))}}else if(v){_=[],A=A.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const i of g.text)t.push(...Array(i.length).fill(g.sectionIndex[e])),e++;const i=v(g.text,t,A);for(const e of i){const t=[];let i="";for(const n of e[0])t.push(e[1][i.length]),i+=n;_.push(new _u(e[0],g.sections,t))}}else _=function(e,t){const i=[];let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return nc){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function Ku(e,t,i,n,r,o){const s=e.image;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 u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}lo("ImagePosition",Ou),lo("ImageAtlas",zu),e.ay=void 0,(Uu=e.ay||(e.ay={}))[Uu.none=0]="none",Uu[Uu.horizontal=1]="horizontal",Uu[Uu.vertical=2]="vertical",Uu[Uu.horizontalOnly=3]="horizontalOnly";const Xu=128,Ju=32640;function Yu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Mo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;re.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Yu(this.zoom,i["text-size"]),this.iconSizeData=Yu(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==eh(n,"text-overlap","text-allow-overlap")||"never"!==eh(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ay[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new oh(new Pa(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new oh(new Pa(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new Ls,this.symbolInstances=new Ps,this.textAnchorOffsets=new ks}calculateGlyphDependencies(e,t,i,n,r){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||n)&&r){const e=cu[o];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,n){const r=this.layers[0],o=r.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Mt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Mo(this.zoom);for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,_=Oa(i,t);if(!r._featureFilter.filter(m,_,n))continue;let A,y;if(t||(_.geometry=Da(i)),c){const e=r.getValueAndResolveTokens("text-field",_,n,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||rh(t);(!i||"unavailable"===Io.getRTLTextPluginStatus()||i&&Io.isParsed())&&(A=au(t,r,_))}if(u){const e=r.getValueAndResolveTokens("icon-image",_,n,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},n):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:Tc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ay.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const n=yo(A.toString()),r=e.fontStack||t,o=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,o,i,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}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.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let lh,ch;lo("SymbolBucket",ah,{omit:["layers","collisionBoxArray","features","compareText"]}),ah.MAX_GLYPHS=65535,ah.addDynamicAttributes=nh;var uh={get paint(){return ch=ch||new $o({"icon-opacity":new jo(Ae.paint_symbol["icon-opacity"]),"icon-color":new jo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new jo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Vo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Vo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(Ae.paint_symbol["text-opacity"]),"text-color":new jo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Vo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Vo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return lh=lh||new $o({"symbol-placement":new Vo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Vo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Vo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Vo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Vo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Vo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Vo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Vo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Vo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Vo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Ae.layout_symbol["icon-image"]),"icon-rotate":new jo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Vo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new jo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Vo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Vo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Vo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Ae.layout_symbol["text-field"]),"text-font":new jo(Ae.layout_symbol["text-font"]),"text-size":new jo(Ae.layout_symbol["text-size"]),"text-max-width":new jo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Vo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new jo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Vo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new jo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new jo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Vo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Vo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Ae.layout_symbol["text-rotate"]),"text-padding":new Vo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Vo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new jo(Ae.layout_symbol["text-transform"]),"text-offset":new jo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Vo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Vo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Vo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Vo(Ae.layout_symbol["text-optional"])})}};class hh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}lo("FormatSectionOverride",hh,{omit:["defaultValue"]});class dh extends Zo{constructor(e,t){super(e,uh,t)}recalculate(e,t){if(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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||tr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new ah(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of uh.paint.overridableProperties){if(!dh.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new hh(t),n=new er(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new nr("source",n):new rr("composite",n,t.value.zoomStops),this.paint._values[e]=new Uo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&dh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=uh.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Mt)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{r||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let ph;var fh={get paint(){return ph=ph||new $o({"background-color":new Vo(Ae.paint_background["background-color"]),"background-pattern":new Ho(Ae.paint_background["background-pattern"]),"background-opacity":new Vo(Ae.paint_background["background-opacity"])})}};class mh extends Zo{constructor(e,t){super(e,fh,t)}}class gh extends Zo{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class _h{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ah={once:!0},yh=6371008.8;class vh{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 vh(O(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return yh*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof vh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new vh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new vh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const xh=2*Math.PI*yh;function bh(e){return xh*Math.cos(e*Math.PI/180)}function wh(e){return(180+e)/360}function Th(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Eh(e,t){return e/bh(t)}function Ch(e){return 360*e-180}function Sh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Bh(e,t){return e*bh(Sh(t))}class Ih{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=vh.convert(e);return new Ih(wh(i.lng),Th(i.lat),Eh(t,i.lat))}toLngLat(){return new vh(Ch(this.x),Sh(this.y))}toAltitude(){return Bh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xh*(e=Sh(this.y),1/Math.cos(e*Math.PI/180));var e}}function Mh(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Ph{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Fh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=Mh(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=Mh(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Rh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Fh(e,t.z,t.z,t.x,t.y)}}class Lh{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Ph(i,+n,+r),this.key=Fh(t,e,i,n,r)}clone(){return new Lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Lh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Fh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Fh(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Lh(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,n=2*this.canonical.y;return[new Lh(t,this.wrap,t,i,n),new Lh(t,this.wrap,t,i+1,n),new Lh(t,this.wrap,t,i,n+1),new Lh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===i);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function Oh(e){var t,i;if(!e)return{};const n={};return n.removeAll=e.removeAll,n.remove=new Set(e.remove||[]),n.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),n.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),n}lo("CanonicalTileID",Ph),lo("OverscaledTileID",Lh,{omit:["terrainRttPosMatrix32f"]});class zh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Uh{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=n,this.properties=e.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Nh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Vh extends Nh{}class jh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Hh extends Nh{delta;constructor(e,t,i,n){super(e,t,n),this.delta=i}}class Qh extends Hh{constructor(e,t,i,n){super(e,Int32Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class $h extends Nh{constructor(e,t,i){super(e,Int32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Zh{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,t,i,n,r=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=n,this._extent=r}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let t=0;for(;t>4,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<3,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<10,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<17,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<24,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(1&r)<<31,r<128)return 4294967296*n+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function cd(e,t,i,n){throw new Error("FastPFor is not implemented yet.")}function ud(e){return e>>>1^-(1&e)}function hd(e){return e>>1n^-(1n&e)}function dd(e,t){let i=0n,n=0,r=t.get();for(;r=64)throw new Error("Varint too long")}return t.set(r),i}function pd(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i=4)for(let n=e[0];i>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const t=e.length/4*4;let i=2;if(t>=4)for(;i>>1^-(1&t))+e[i-2],e[i+1]=(n>>>1^-(1&n))+e[i-1],e[i+2]=(r>>>1^-(1&r))+e[i],e[i+3]=(o>>>1^-(1&o))+e[i+1]}for(;i!=e.length;i+=2)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-2],e[i+1]=(e[i+1]>>>1^-(1&e[i+1]))+e[i-1]}function Ad(e,t,i){return Math.min(i,Math.max(t,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Kh||(Kh={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(Xh||(Xh={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Jh||(Jh={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Yh||(Yh={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(ed||(ed={}));class yd{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,t,i,n,r,o,s){this._physicalStreamType=e,this._logicalStreamType=t,this._logicalLevelTechnique1=i,this._logicalLevelTechnique2=n,this._physicalLevelTechnique=r,this._numValues=o,this._byteLength=s}static decode(e,t){const i=e[t.get()],n=Object.values(qh)[i>>4];let r=null;switch(n){case qh.DATA:r=new od(Object.values(Jh)[15&i]);break;case qh.OFFSET:r=new od(null,Object.values(Yh)[15&i]);break;case qh.LENGTH:r=new od(null,null,Object.values(ed)[15&i])}t.increment();const o=e[t.get()],s=Object.values(Kh)[o>>5],a=Object.values(Kh)[o>>2&7],l=Object.values(Xh)[3&o];t.increment();const c=sd(e,t,2);return new yd(n,r,s,a,l,c[0],c[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class vd extends yd{num_bits;coordinate_shift;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this.num_bits=a,this.coordinate_shift=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new vd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new vd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class xd extends yd{_runs;_numRleValues;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this._runs=a,this._numRleValues=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new xd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new xd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class bd{static decode(e,t){const i=yd.decode(e,t);return i.logicalLevelTechnique1===Kh.MORTON?vd.decodePartial(i,e,t):Kh.RLE!==i.logicalLevelTechnique1&&Kh.RLE!==i.logicalLevelTechnique2||Xh.NONE===i.physicalLevelTechnique?i:xd.decodePartial(i,e,t)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(td||(td={}));class wd{values;_size;constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}class Td{constructor(){}static decodeIntStream(e,t,i,n,r){const o=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeIntBuffer(o,i,n,r)}static decodeLengthStreamToOffsetBuffer(e,t,i){const n=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeLengthToOffsetBuffer(n,i)}static decodePhysicalLevelTechnique(e,t,i){const n=i.physicalLevelTechnique;if(n===Xh.FAST_PFOR)return cd();if(n===Xh.VARINT)return sd(e,t,i.numValues);if(n===Xh.NONE){const n=t.get();t.add(i.byteLength);const r=e.subarray(n,t.get());return new Int32Array(r)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,t,i,n){const r=Td.decodePhysicalLevelTechnique(e,t,i);if(1===r.length){const e=r[0];return n?ud(e):e}return n?function(e){return ud(e[1])}(r):function(e){return e[1]}(r)}static decodeSequenceIntStream(e,t,i){return function(e){if(2==e.length){const t=ud(e[1]);return[t,t]}return[ud(e[2]),ud(e[3])]}(Td.decodePhysicalLevelTechnique(e,t,i))}static decodeSequenceLongStream(e,t,i){return function(e){if(2==e.length){const t=hd(e[1]);return[t,t]}return[hd(e[2]),hd(e[3])]}(ad(e,t,i.numValues))}static decodeLongStream(e,t,i,n){const r=ad(e,t,i.numValues);return this.decodeLongBuffer(r,i,n)}static decodeLongFloat64Stream(e,t,i,n){const r=function(e,t,i){const n=new Float64Array(t);for(let r=0;r>>1^-(1&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&t))+e[i-1],e[i+1]=(n>>>1^-(1&n))+e[i],e[i+2]=(r>>>1^-(1&r))+e[i+1],e[i+3]=(o>>>1^-(1&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i>>1^-(1&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):pd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.MORTON:return gd(e),e;case Kh.COMPONENTWISE_DELTA:return n?(function(e,t,i,n){let r=e[0]>>>1^-(1&e[0]),o=e[1]>>>1^-(1&e[1]);e[0]=Ad(Math.round(r*t),i,n),e[1]=Ad(Math.round(o*t),i,n);const s=e.length/16;let a=2;if(s>=4)for(;a>>1^-(1&s))+r,u=(l>>>1^-(1&l))+o;e[a]=Ad(Math.round(c*t),i,n),e[a+1]=Ad(Math.round(u*t),i,n);const h=e[a+2],d=e[a+3];r=(h>>>1^-(1&h))+c,o=(d>>>1^-(1&d))+u,e[a+2]=Ad(Math.round(r*t),i,n),e[a+3]=Ad(Math.round(o*t),i,n)}for(;a!=e.length;a+=2)r+=e[a]>>>1^-(1&e[a]),o+=e[a+1]>>>1^-(1&e[a+1]),e[a]=Ad(Math.round(r*t),i,n),e[a+1]=Ad(Math.round(o*t),i,n)}(e,n.scale,n.min,n.max),e):(_d(e),e);case Kh.NONE:return i&&function(e){for(let t=0;t>>1^-(1&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE?function(e,t,i){const n=new BigInt64Array(i);let r=0,o=0n;for(let i=0;i>1n^-(1n&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>1n^-(1n&t))+e[i-1],e[i+1]=(n>>1n^-(1n&n))+e[i],e[i+2]=(r>>1n^-(1n&r))+e[i+1],e[i+3]=(o>>1n^-(1n&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>1n^-(1n&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new BigInt64Array(i);let r=0;for(let i=0;i>1n^-(1n&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):fd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.NONE:return i&&function(e){for(let t=0;t>1n^-(1n&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=md(e,t.runs,t.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&r),t[n]=t[n-1]+i}return t}(e);if(t.logicalLevelTechnique1===Kh.RLE&&t.logicalLevelTechnique2===Kh.NONE)return function(e,t,i){const n=new Int32Array(i+1);n[0]=0;let r=1,o=n[0];for(let i=0;i>>1^-(1&a);for(let e=r;e>>1^-(1&t[0]):0,n=1):i[0]=0;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>>1^-(1&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new Int32Array(e.size());let r=0;for(let o=0;o>>1^-(1&a);for(let t=r;t>>1^-(1&e)}else i[r]=0;return i}(n,e):function(e,t){const i=new Int32Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,t,i,n){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=fd(e,t.runs,t.numRleValues)),function(e,t){const i=new BigInt64Array(e.size());let n=0;e.get(0)?(i[0]=e.get(0)?t[0]>>1n^-(1n&t[0]):0n,n=1):i[0]=0n;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>1n^-(1n&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new BigInt64Array(e.size());let r=0;for(let o=0;o>1n^-(1n&a);for(let t=r;t>1n^-(1n&e)}else i[r]=0n;return i}(n,e):function(e,t){const i=new BigInt64Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0n;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,t,i,n){const r=e.logicalLevelTechnique1;if(r===Kh.RLE)return 1===e.runs?td.CONST:td.FLAT;const o=t instanceof wd?t.size():t;if(r===Kh.DELTA&&e.logicalLevelTechnique2===Kh.RLE){const t=e.runs,r=2;if(e.numRleValues!==o)return td.FLAT;if(1===t)return td.SEQUENCE;if(2===t){const t=n.get();let o;if(e.physicalLevelTechnique===Xh.VARINT)o=sd(i,n,4);else{const e=n.get();o=new Int32Array(i.buffer,i.byteOffset+e,4)}if(n.set(t),o[2]===r&&o[3]===r)return td.SEQUENCE}}return 1===e.numValues?td.CONST:td.FLAT}}class Ed extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Cd extends Hh{constructor(e,t,i,n){super(e,BigInt64Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Sd{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,t,i){this._geometryOffsets=e,this._partOffsets=t,this._ringOffsets=i}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class Bd{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,t){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=t+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=t}validateCoordinates(e){if(e.xthis.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Id extends Bd{encode(e){this.validateCoordinates(e);const t=e.x+this._coordinateShift,i=e.y+this._coordinateShift;let n=0;for(let e=0;e>1)-this._coordinateShift}}decodeMorton(e){let t=0;for(let i=0;i>i;return t}static decode(e,t,i){return{x:Id.decodeMorton(e,t)-i,y:Id.decodeMorton(e>>1,t)-i}}static decodeMorton(e,t){let i=0;for(let n=0;n>n;return i}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(id||(id={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(nd||(nd={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(rd||(rd={}));class Md{createPoint(e){return[[e]]}createMultiPoint(e){return e.map(e=>[e])}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,t){return[e,...t]}createMultiPolygon(e){return e.flat()}}function Pd(e){const t=new Array(e.numGeometries);let n=1,r=1,o=1,s=0;const a=new Md;let l=0,c=0;const u=e.mortonSettings,h=e.topologyVector,d=h.geometryOffsets,p=h.partOffsets,f=h.ringOffsets,m=e.vertexOffsets,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let h=0;h0&&t.push(t[0]),h.push(t)}e[t]=h,o&&c++}break;case id.MULTIPOLYGON:{const u=o[c]-o[c-1];c++;const h=[];for(let e=0;e0&&t.push(t[0]),h.push(t)}}e[t]=h}}return e}[Symbol.iterator](){return null}}class jd extends Vd{_numGeometries;_geometryType;constructor(e,t,i,n,r,o){super(i,n,r,o),this._numGeometries=e,this._geometryType=t}static create(e,t,i,n,r,o){return new jd(e,t,i,n,r,o)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class Gd extends Vd{_geometryTypes;constructor(e,t,i,n,r){super(t,i,n,r),this._geometryTypes=e}static create(e,t,i,n,r){return new Gd(e,t,i,n,r)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Hd(e,t,i,n,r){const o=bd.decode(e,i);let s=null,a=null,l=null,c=null,u=null,h=null,d=null,p=null;if(Td.getVectorType(o,n,e,i)===td.CONST){const f=Td.decodeConstIntStream(e,i,o,!1);for(let n=0;ni?t[o++]:1);return n}function $d(e,t,i,n){const r=new Int32Array(t[t.length-1]+1);let o=0;r[0]=o;let s=1,a=0;for(let l=0;l=12?Yd.decode(e.subarray(t,i)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(e,t,i)}class tp extends Nh{offsetBuffer;constructor(e,t,i,n){super(e,i,n),this.offsetBuffer=t}}class ip extends tp{textEncoder;constructor(e,t,i,n){super(e,t,i,n??t.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return ep(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class np extends tp{indexBuffer;textEncoder;constructor(e,t,i,n,r){super(e,i,n,r??t.length),this.indexBuffer=t,this.indexBuffer=t,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const t=this.indexBuffer[e];return ep(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class rp extends tp{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,t,i,n,r,o,s){super(e,i,n,s),this.indexBuffer=t,this.symbolOffsetBuffer=r,this.symbolTableBuffer=o,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,t,i){const n=[],r=new Array(t.length).fill(0);for(let e=1;e1?6:4,i.type="physicalType",t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let t=null;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const n={type:"physicalType"};return n.physicalType=t,i.type="scalarType",i.scalarType=n,i}}const cp=new TextDecoder;function up(e,t){const i=sd(e,t,1)[0];if(0===i)return"";const n=t.get(),r=e.subarray(n,n+i);return t.add(i),cp.decode(r)}function hp(e,t){const i=sd(e,t,1)[0]>>>0,n=!!(4&i),r=!!(2&i),o=sd(e,t,1)[0]>>>0,s={};if(1&i&&(s.nullable=!0),r){const r={};if(n?(r.type="logicalType",r.logicalType=o):(r.type="physicalType",r.physicalType=o),8&i){const i=sd(e,t,1)[0]>>>0;r.children=new Array(i);for(let n=0;n>>0,n=lp.decodeColumnType(i);if(!n)throw new Error(`Unsupported column type code: ${i}`);if(lp.columnTypeHasName(i)?n.name=up(e,t):i>=0&&i<=3?n.name="id":4===i&&(n.name="geometry"),lp.columnTypeHasChildren(i)){const i=sd(e,t,1)[0]>>>0,r=n.complexType;r.children=new Array(i);for(let n=0;n>>0,o=sd(e,t,1)[0]>>>0;n.columns=new Array(o);for(let i=0;ithis.projectPoint(e,t,i,n))}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();let a;switch(this.type){case 1:{const e=[];for(const t of s)e.push(t[0]);const t=this.projectLine(e,r,o,n);a=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{const e=s.map(e=>this.projectLine(e,r,o,n));a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Yi(s),t=[];for(const i of e)t.push(i.map(e=>this.projectLine(e,r,o,n)));a=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw new Error(`unknown feature type: ${this.type}`)}const l={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(l.id=this.id),l}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const n=[];for(const e of t)n.push(new i(e.x,e.y));e.push(n)}return e}bbox(){return[0,0,0,0]}}class gp{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new mp(this.features[e],this.extent)}}class _p{constructor(e){this.layers={};const t=function(e,t,i=!0){const n=new Wh(0),r=[];for(;n.get()>>0,s=n.get()+o;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=sd(e,n,1)[0]>>>0){n.set(s);continue}const a=pp(e,n),l=a[1],c=a[0].featureTables[0];let u=null,h=null;const d=[];let p=0;for(const r of c.columns){const o=r.name;if("id"===o){let t=null;if(r.nullable){const i=bd.decode(e,n),r=n.get(),o=Xd(e,i.numValues,n);n.set(r+i.byteLength),t=new wd(o,i.numValues)}const s=bd.decode(e,n);p=s.getDecompressedCount(),u=fp(e,r,n,o,s,t??p,i)}else if("geometry"===o){const i=sd(e,n,1)[0];if(0===p){const t=n.get();p=bd.decode(e,n).getDecompressedCount(),n.set(t)}h=Hd(e,i,n,p,t)}else{const t=lp.hasStreamCount(r)?sd(e,n,1)[0]:1;if(0===t&&"scalarType"===r.type)continue;const i=sp(e,n,r,t,p,void 0);i&&(Array.isArray(i)?d.push(...i):d.push(i))}}const f=new Zh(c.name,h,u,d,l);r.push(f),n.set(s)}return r}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new gp(t)}),{})}}class Ap{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Ap;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Ap;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}const yp="_geojsonTileLayer";class vp{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new so(I,16,0),this.grid3D=new so(I,16,0),this.featureIndexArray=new Os,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Ic(new xu(this.rawTileData)).layers:new _p(this.rawTileData).layers,this.sourceLayerCoder=new zh(this.vtLayers?Object.keys(this.vtLayers).sort():[yp])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=dr(o.filter,o.globalState),l=e.queryGeometry,c=e.queryPadding*s,u=Ap.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Ap.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(Ka(e,t))return!0;for(let t=0;t(d||(d=Da(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=Oa(p,!0);if(!r.filter(new Mo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new Mo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s})}function bp(e,t){return t-e}function wp(e,t,n,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}function Tp(e,t,i,n,r){switch(t){case 1:return function(e,t,i,n){const r=[];for(const o of e)for(const e of o){const o=0===n?e.x:e.y;o>=t&&o<=i&&r.push([e])}return r}(e,i,n,r);case 2:return Cp(e,i,n,r,!1);case 3:return Cp(e,i,n,r,!0)}return[]}function Ep(e,t,n,r,o){const s=0===r?Sp:Bp;let a=[];const l=[];for(let i=0;it&&a.push(s(c,u,t)):h>n?d=t&&(a.push(s(c,u,t)),p=!0),d>n&&h<=n&&(a.push(s(c,u,n)),p=!0),!o&&p&&(l.push(a),a=[])}const c=e.length-1,u=0===r?e[c].x:e[c].y;return u>=t&&u<=n&&a.push(e[c]),o&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function Cp(e,t,i,n,r){const o=[];for(const s of e){const e=Ep(s,t,i,n,r);e.length>0&&o.push(...e)}return o}function Sp(e,t,n){return new i(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))}function Bp(e,t,n){return new i(e.x+(n-e.y)/(t.y-e.y)*(t.x-e.x),n)}lo("FeatureIndex",vp,{omit:["rawTileData","sourceLayerCoder"]});class Ip extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new Ip(this.x,this.y,this.angle,this.segment)}}function Mp(e,t,i,n,r){if(void 0===t.segment||0===i)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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Pp(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(n.x,r.x,u),d=fi.number(n.y,r.y,u),p=new Ip(h,d,r.angleTo(n),i);return p._round(),!s||Mp(e,p,a,s,t)?p:void 0}l+=o}}function kp(e,t,i,n,r,o,s,a,l){const c=Rp(n,o,s),u=Lp(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Ip(_,A,m,t);i._round(),n&&!Mp(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=Dp(e,h/2,i,n,r,o,s,!0,l)),p}function Op(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=qu(e)),A=zp(h,0,t[0]),v=zp(d,0,t[1]),y=zp(h,t[0],t[2]),x=zp(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=n-x}const C=u.x1,S=u.y1,B=u.x2-C,I=u.y2-S,M=(e,r,o,l)=>{const c=Np(e.stretch-A,y,B,C),u=Vp(e.fixed-b,w,e.stretch,f),h=Np(r.stretch-v,x,I,S),d=Vp(r.fixed-T,E,r.stretch,m),p=Np(o.stretch-A,y,B,C),g=Vp(o.fixed-b,w,o.stretch,f),_=Np(l.stretch-v,x,I,S),M=Vp(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=r.stretch+r.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/B,minFontScaleY:E/a/I,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=Up(h,g,f),t=Up(d,_,m);for(let i=0;i0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?qu(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class Gp{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function Hp(e,t=1,n=!1){const r=Ap.fromPoints(e[0]),o=Math.min(r.width(),r.height());let s=o/2;const a=new Gp([],Qp),{minX:l,minY:c,maxX:u,maxY:h}=r;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,n&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new $p(i.p.x-s,i.p.y-s,s,e)),a.push(new $p(i.p.x+s,i.p.y-s,s,e)),a.push(new $p(i.p.x-s,i.p.y+s,s,e)),a.push(new $p(i.p.x+s,i.p.y+s,s,e)),p+=4)}return n&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Qp(e,t){return t.max-e.max}function $p(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Wa(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Zp;e.aO=void 0,(Zp=e.aO||(e.aO={}))[Zp.center=1]="center",Zp[Zp.left=2]="left",Zp[Zp.right=3]="right",Zp[Zp.top=4]="top",Zp[Zp.bottom=5]="bottom",Zp[Zp["top-left"]=6]="top-left",Zp[Zp["top-right"]=7]="top-right",Zp[Zp["bottom-left"]=8]="bottom-left",Zp[Zp["bottom-right"]=9]="bottom-right";const Wp=Number.POSITIVE_INFINITY;function qp(e,t){return t[1]!==Wp?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Kp(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*lu);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Dt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*lu,Wp]:r.get("text-offset").evaluate(t,{},i).map(e=>e*lu);const o=[];for(const e of s)o.push(e,qp(e,n));return new Dt(o)}return null}function Xp(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 Jp(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=ef(n.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=r&&r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),S=f.get("symbol-placement"),B=x/2,M=f.get("icon-text-fit");let P;r&&"none"!==M&&(t.allowVerticalPlacement&&n.vertical&&(P=Ku(r,n.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(r=Ku(r,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,n);let S,B,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=da("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new jp(c,i,u,h,d,r.vertical,p,f,m,e),a&&(M=new jp(c,i,u,h,d,a,_,A,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{}),r="none"!==l.layout.get("icon-text-fit"),s=Op(o,n,w,r),p=a?Op(a,n,w,r):void 0;B=new jp(c,i,u,h,d,o,_,A,!1,n),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Xu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Ju&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Xu*b.compositeIconSizes[0].evaluate(x,{},T),Xu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ju||m[1]>Ju)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ay.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ay.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(r.horizontal);for(const n of U){const o=r.horizontal[n];if(!S){z=da(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);S=new jp(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=Yp(t,i,o,s,l,m,x,g,C,r.vertical?e.ay.horizontal:e.ay.horizontalOnly,a?U:[n],O,k,b,T),a)break}r.vertical&&(F+=Yp(t,i,r.vertical,s,l,m,x,g,C,e.ay.vertical,["vertical"],O,D,b,T));const N=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=B?B.boxStartIndex:t.collisionBoxArray.length,$=B?B.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(S,q),q=K(I,q),q=K(B,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/lu),t.glyphOffsetArray.length>=ah.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Kp(l,x,T),[Y,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,n,r,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===S)for(const e of wp(i.geometry,0,0,I,I)){const i=dc(e,R),o=kp(i,x,T,n.vertical||g,r,24,y,t.overscaling,I);for(const e of o)g&&tf(t,g.text,B,e)||L(i,e)}else if("line-center"===S){for(const e of i.geometry)if(e.length>1){const t=dc(e,R),i=Fp(t,T,n.vertical||g,r,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Hp(e,16);L(dc(e[0],R,!0),new Ip(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=dc(e,R);L(t,new Ip(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Ip(t.x,t.y,0))}function Yp(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(lu-r.metrics.width*r.scale)/2:(r.scale-1)*lu)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[r.x+g,r.y]:[0,0];let A=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=r.metrics.isDoubleResolution?2:1,x=(r.metrics.left-h)*r.scale-g+A[0],b=(-r.metrics.top-h)*r.scale+A[1],w=x+s.w/v*r.scale/p,T=b+s.h/v*r.scale/p,E=new i(x,b),C=new i(w,b),S=new i(x,T),B=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),S._matMult(i),B._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:S,br:B,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[Xu*o.layout.get("text-size").evaluate(a,{})],A[0]>Ju&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[Xu*f.compositeTextSizes[0].evaluate(a,{},m),Xu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Ju||A[1]>Ju)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function ef(e){for(const t in e)return e[t];return null}function tf(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nf[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new rf(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=nf.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 of(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)cf(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];cf(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function of(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;sf(e,t,s,n,r,o),of(e,t,i,n,s-1,1-o),of(e,t,i,s+1,r,1-o)}function sf(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);sf(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(af(e,t,n,i),t[2*r+o]>s&&af(e,t,n,r);as;)l--}t[2*n+o]===s?af(e,t,n,l):(l++,af(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function af(e,t,i,n){lf(e,i,n),lf(t,2*i,2*n),lf(t,2*i+1,2*n+1)}function lf(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function cf(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}var uf;e.cG=void 0,(uf=e.cG||(e.cG={})).create="create",uf.load="load",uf.fullLoad="fullLoad";let hf=null,df=[];const pf=1e3/60,ff="loadTime",mf="fullLoadTime",gf={mark(e){performance.mark(e)},frame(e){const t=e;null!=hf&&df.push(t-hf),hf=t},clearMetrics(){hf=null,df=[],performance.clearMeasures(ff),performance.clearMeasures(mf);for(const t in e.cG)performance.clearMarks(e.cG[t])},getPerformanceMetrics(){performance.measure(ff,e.cG.create,e.cG.load),performance.measure(mf,e.cG.create,e.cG.fullLoad);const t=performance.getEntriesByName(ff)[0].duration,i=performance.getEntriesByName(mf)[0].duration,n=df.length,r=1/(df.reduce((e,t)=>e+t,0)/n/1e3),o=df.filter(e=>e>pf).reduce((e,t)=>e+(t-pf)/pf,0);return{loadTime:t,fullLoadTime:i,fps:r,percentDroppedFrames:o/(n+o)*100,totalFrames:n}}};e.$=h,e.A=p,e.B=oo,e.C=eo,e.D=Vo,e.E=_e,e.F=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.G=fi,e.H=Mo,e.I=Ou,e.J=io,e.K=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.L=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new _h(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Ah):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:po(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(fo(i.error)):t.resolve(fo(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=fo(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?po(t):null,data:po(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.M=le,e.N=function(){var e=new p(16);return p!=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},e.O=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.P=i,e.Q=function(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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},e.R=Al,e.S=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.T=Sl,e.U=function(e,t){const i={};for(let n=0;n0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0;if((o||s)&&(t=Object.assign({},t),e.set(i.id,t),o&&(t.geometry=i.newGeometry),s)){if(t.properties=i.removeAllProperties?{}:Object.assign({},t.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete t.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:n}of i.addOrUpdateProperties)t.properties[e]=n}}},e.a9=yp,e.aA=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.aB=S,e.aC=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aD=function(e){return e[0]=0,e[1]=0,e},e.aE=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aF=nh,e.aG=T,e.aH=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.aI=wp,e.aJ=Va,e.aK=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return[t,i,n,r]},e.aL=lu,e.aM=M,e.aN=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians: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]}return[r?i[0]:M(t,i[0],e.zoom),r?i[1]:M(t,i[1],e.zoom)]},e.aP=eh,e.aQ=Xp,e.aR=Vu,e.aS=rf,e.aT=es,e.aU=ac,e.aV=zs,e.aW=ta,e.aX=Xs,e.aY=te,e.aZ=Bh,e.a_=v,e.aa=Ih,e.ab=Ap,e.ac=25,e.ad=Ph,e.ae=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.af=Me,e.ag=function(){return U++},e.ah=Ss,e.ai=ah,e.aj=dr,e.ak=Oa,e.al=Uh,e.am=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;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},e.an=D,e.ao=85.051129,e.ap=ee,e.aq=function(e){return Math.pow(2,e)},e.ar=m,e.as=Eh,e.at=function(e){return Math.log(e)/Math.LN2},e.au=function(e){var t=e[0],i=e[1];return t*t+i*i},e.av=class{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}},e.aw=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,n=-1/0,r=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,u=Math.pow(2,t-c),h=e*u,d=l*u;s.push({id:a,x:h,y:d}),hn&&(n=h),do&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==n&&e.y!==r&&e.y!==o||a.add(e.id);return a},e.ax=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?D(di.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.az=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/Xu:"composite"===e.kind?fi.number(n/Xu,r/Xu,i):t},e.b=W,e.b$=class extends _a{constructor(e,t){super(e,t),this.current=xa}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.b0=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.b1=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b2=function(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.b3=x,e.b4=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b5=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},e.b6=_,e.b7=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.b8=w,e.b9=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},e.bA=C,e.bB=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=r*c-o*l,h=o*a-n*c,d=n*l-r*a;return e[0]=a+s*(u+=u)+r*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-n*d,e[2]=c+s*d+n*h-r*u,e},e.bC=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/n),f},e.bD=yh,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bG=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bH=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bI=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.bJ=function(e,t){const i=P(e,360),n=P(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)0?s:-s},e.bM=function(e,t){const i=P(e,2*Math.PI),n=P(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bN=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const n=Ae.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bO=ue,e.bP=mo,e.bQ=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n"raster"===e.type,e.bU=j,e.bV=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!xe(e.version,t.version))return[{command:"setStyle",args:[t]}];xe(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),xe(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),xe(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),xe(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),xe(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),xe(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),xe(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),xe(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),xe(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),xe(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),xe(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),xe(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),xe(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),xe(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const n={},r=[];!function(e,t,i,n){let r;for(r in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(t,r)||Te(r,i,n));for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(Object.prototype.hasOwnProperty.call(e,r)?xe(e[r],t[r])||("geojson"===e[r].type&&"geojson"===t[r].type&&Ce(e,t,r)?be(i,{command:"setGeoJSONSourceData",args:[r,t[r].data]}):Ee(r,t,i,n)):we(r,t,i))}(e.sources,t.sources,r,n);const o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Be),r=t.map(Be),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bm=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),_=(a=n[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Ct,e.bp=Aa,e.bq=lc,e.br=cc,e.bs=sc,e.bt=R,e.bu=L,e.bv=zt,e.bw=function(e,t,i,n,r){return R(n,r,D((e-t)/(i-t),0,1))},e.bx=P,e.by=function(){return new Float64Array(3)},e.bz=function(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e},e.c=oe,e.c$=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},e.c0=ya,e.c1=class extends _a{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c2=class extends _a{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c3=f,e.c4=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c5=function(e,t,i){var n=t[0],r=t[1],o=t[2];return e[0]=n*i[0]+r*i[3]+o*i[6],e[1]=n*i[1]+r*i[4]+o*i[7],e[2]=n*i[2]+r*i[5]+o*i[8],e},e.c6=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),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]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.c7=class extends _a{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i25||n<0||n>=1||i<0||i>=1)},e.cD=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},e.cE=class extends ns{},e.cF=gf,e.cH=function(e){return e.message===re},e.cI=ce,e.cJ=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cK=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cL=function(e,t){const i={};for(let n=0;ne*lu)}let y=a?"center":n.get("text-justify").evaluate(r,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(r,{},t.canonical)*lu:1/0,x=()=>{t.bucket.allowVerticalPlacement&&yo(o)&&(f.vertical=Nu(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ay.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cZ=Ic,e.c_=_p,e.ca=su,e.cb=class extends _s{},e.cc=vl,e.cd=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.ce=yl,e.cf=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.cg=class extends rs{},e.ch=class extends Ts{},e.ci=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.cj=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],S=t[8],B=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=d*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-S)<=d*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-B)<=d*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.ck=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},e.cl=e=>"symbol"===e.type,e.cm=e=>"circle"===e.type,e.cn=e=>"heatmap"===e.type,e.co=e=>"line"===e.type,e.cp=e=>"fill"===e.type,e.cq=e=>"fill-extrusion"===e.type,e.cr=e=>"hillshade"===e.type,e.cs=e=>"color-relief"===e.type,e.ct=e=>"background"===e.type,e.cu=e=>"custom"===e.type,e.cv=F,e.cw=function(e,t,i){const n=B(t.x-i.x,t.y-i.y),r=B(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.cx=k,e.cy=function(e,t){return ne[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cz=function(e,t){return ie[t]&&"touches"in e},e.d=de,e.d0=function(e,i,n,r,o){return t(this,void 0,void 0,function*(){if(h())try{return yield K(e,i,n,r,o)}catch(e){}return function(e,t,i,n,r){const o=e.width,s=e.height;X&&J||(X=new OffscreenCanvas(o,s),J=X.getContext("2d",{willReadFrequently:!0})),X.width=o,X.height=s,J.drawImage(e,0,0,o,s);const a=J.getImageData(t,i,n,r);return J.clearRect(0,0,o,s),a.data}(e,i,n,r,o)})},e.d1=Bl,e.d2=n,e.d3=ir,e.d4=Io,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>{n.src=q})},n.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 r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new xu(e).readFields(Lu,[])},e.p=Du,e.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.r=_l,e.s=Y,e.t=$o,e.u=Ae,e.v=Yr,e.w=H,e.x=ko,e.y=to,e.z=Ro}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bS(i,n);t._featureFilter=e.aj(t.filter,n),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const i=t.map(e=>this._layers[e.id]),n=i[0];if("none"===n.visibility)continue;const r=n.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const s=n.sourceLayer||e.a9;let a=o[s];a||(a=o[s]=[]),a.push(i)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.r({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.r.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cM("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.a1(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ah;const l=new e.cN(Object.keys(t.layers).sort()),c=new e.cO(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;ee.id)))}}const p=e.bX(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const y=h.dashDependencies;let v=Promise.resolve({});if(Object.keys(y).length){const e=new AbortController;this.inFlightDependencies.push(e),v=s.sendAsync({type:"GDA",data:{dashes:y}},e)}const[x,b,w,T]=yield Promise.all([f,g,A,v]),E=new i(x),C=new e.cP(b,w);for(const t in u){const i=u[t];i instanceof e.ai?(r(i.layers,this.zoom,o),e.cQ({bucket:i,glyphMap:x,glyphPositions:E.positions,imageMap:b,imagePositions:C.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cR||i instanceof e.cS||i instanceof e.cT)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,C.patternPositions,T))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:E.image,imageAtlas:C,dashPositions:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?E.positions:null}})}}function r(t,i,n){const r=new e.H(i);for(const e of t)e.recalculate(r,n)}class o extends e.cW{constructor(t,i){super(new e.cV,0,i,[],[]),this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],i=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of i){const i=[];for(const t of n)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}class s extends e.cU{constructor(t,i){super(new e.cV),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=i?i.version:1,this.extent=i?i.extent:4096,this.length=t.length,this.features=t}feature(e){return new o(this.features[e],this.extent)}}function a(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n>31}function d(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(u(1,i));const a=3===n?s.length-1:s.length;for(let e=0;et.map(t=>new e.P(t.x,t.y)))}}class m extends e.cU{constructor(t,i,n){super(new e.cV),this.version=2,this._myFeatures=t,this.name=i,this.length=t.length,this.extent=n}feature(e){return this._myFeatures[e]}}class g{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _(t){let i=function(t){const i=new e.cV;return function(e,t){for(const i in e.layers)t.writeMessage(3,a,e.layers[i])}(t,i),i.finish()}(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function A(t,i,n){const{extent:r}=t,o=Math.pow(2,n.z-i.z),s=(n.x-i.x*o)*r,a=(n.y-i.y*o)*r,l=[];for(let i=0;i0&&l.addLayer(r)}const u=_(l);return this.overzoomedTileResultCache.set(s,u),u}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[i];if(n.showCollisionBoxes=t.showCollisionBoxes,"parsing"===n.status){const r=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:n,cacheControl:s,resourceTiming:a}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:n.slice(0),encoding:t.encoding},r,s,a)}else o=r;return o}if("done"===n.status&&n.vectorTile)return n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class v{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.d0(r,-1,-1,c,u)):r,d=new e.d1(i,h,n,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var x,b,w=function(){if(b)return x;function e(e,i){if(0!==e.length){t(e[0],i);for(var n=1;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}return b=1,x=function t(i,n){var r,o=i&&i.type;if("FeatureCollection"===o)for(r=0;re},C=Math.fround||(S=new Float32Array(1),e=>(S[0]=+e,S[0]));var S;class B{constructor(e){this.options=Object.assign(Object.create(E),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(P(i),R(o),P(r),R(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?I(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=M(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=P(n),u=R(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function I(e,t,i){return{type:"Feature",id:e[t+3],properties:M(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),L(e[t+1])]}};var n}function M(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function P(e){return e/360+.5}function R(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function F(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&F(e,t,s,n),e[s+2]=r,i-s>3&&F(e,s,i,n))}function k(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function D(e,t,i,n){const r={id:null==e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)O(r,i);else if("Polygon"===t)O(r,i[0]);else if("MultiLineString"===t)for(const e of i)O(r,e);else if("MultiPolygon"===t)for(const e of i)O(r,e[0]);return r}function O(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,F(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function V(e,t,i,n){for(let r=0;r1?1:i}function H(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)Q(e,u,i,n,r);else if("LineString"===o)$(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)W(e,u,i,n,r,!1);else if("Polygon"===o)W(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];W(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(D(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(D(t.id,o,u,t.tags))}}return l.length?l:null}function Q(e,t,i,n,r){for(let o=0;o=i&&s<=n&&q(t,e[o],e[o+1],e[o+2])}}function $(e,t,i,n,r,o,s){let a=Z(e);const l=0===r?K:X;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=Z(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&q(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Z(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function W(e,t,i,n,r,o){for(const s of e)$(s,t,i,n,r,o,!1)}function q(e,t,i,n){e.push(t,i,n)}function K(e,t,i,n,r,o){const s=(o-t)/(n-t);return q(e,o,i+(r-i)*s,1),s}function X(e,t,i,n,r,o){const s=(o-i)/(r-i);return q(e,t+(n-t)*s,o,1),s}function J(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=ie(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=H(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=H(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=H(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=H(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=H(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=H(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ae(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ee(this.tiles[a],r):null):null}}function ae(e,t,i){return 32*((1<`${e.key}: ${e.message}`).join(", "));const r=t.features.filter(e=>n.value.evaluate({zoom:0},e));return this._toFeatureCollection(r)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function ce(t,i){return i.cluster?new B(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.d3(s),l=e.d3("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(t.features):function(e,t){return new se(e,t)}(t,i.geojsonVtOptions)}class ue{constructor(t){this.self=t,this.actor=new e.L(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=t=>{e.d4.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d4.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new y(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new le(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new v),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue}),i("index",["exports","./shared"],function(e,t){var i="5.13.0";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o,s;const a={frame(e,i,n){const r=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(r),n(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)},set prefersReducedMotion(e){s=e}},l=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class u{static testProp(e){if(!u.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",u.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=u.getScale(e);return u.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=u.getScale(e);for(let r=0;r{d&&g(d),d=null,m=!0},p.onerror=()=>{f=!0,d=null},p.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{h.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:c}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?l(i,c):t.m(i,c);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},l=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(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."))},o.src=s})}(_||(_={})),_.resetRequestQueue();class A{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function y(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:n,url:r}))}}return t}function v(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function x(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,r&&r.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,r&&r.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const n of e){let e=this.getImage(n);e||(this.fire(new t.l("styleimagemissing",{id:n})),e=this.getImage(n)),e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${n}" 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.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const w=1e20;function T(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new S.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[n,r]of Object.entries(t))new RegExp(`\\b${n}\\b`,"i").test(e)&&(i=`${r}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF&&(t.tinySDF=null),t.ideographTinySDF&&(t.ideographTinySDF=null),t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}S.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},S.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(w,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}T(_,0,0,c,u,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[F]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(a.hardwareConcurrency/2);let O,z;function U(){return O||(O=new k),O}k.workerCount=t.K(globalThis)?Math.max(Math.min(D,3),1):1;class N{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function V(){return z||(z=new N(U(),t.M),z.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),z}function j(e,i){const n=t.N();return t.O(n,n,[1,1,0]),t.Q(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.S(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function G(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(H);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e.getState(),n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,j(o,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])Q(n,t);return e}(function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function H(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function Q(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function $(e,i,n){return t._(this,void 0,void 0,function*(){let r=e;if(e.url?r=(yield t.j(i.transformRequest(e.url,"Source"),n)).data:yield a.frameAsync(n),!r)return null;const o=t.U(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map(e=>e.id)),o})}class Z{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(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 t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.V)r=e,o=e;else{if(!(e instanceof Z))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Z.convert(e)):this.extend(t.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.V.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.V(r.lng,r.lat),this._ne=new t.V(o.lng,o.lat)),this}getCenter(){return new t.V((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 t.V(this.getWest(),this.getNorth())}getSouthEast(){return new t.V(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:i,lat:n}=t.V.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}intersects(e){if((e=Z.convert(e)).getNorth()this.getNorth())return!1;const i=t.W(this.getWest(),-180,180),n=t.W(this.getEast(),-180,180),r=t.W(e.getWest(),-180,180),o=t.W(e.getEast(),-180,180),s=i>n,a=r>o;return!(!s||!a)||(s?o>=i||r<=n:a?n>=r||i<=o:!(r>n||oi.lng?new t.V(i.lng+360,i.lat):i)}}class W{constructor(e,t,i){this.bounds=Z.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 i=Math.pow(2,e.z),n=Math.floor(t.Y(this.bounds.getWest())*i),r=Math.floor(t.X(this.bounds.getNorth())*i),o=Math.ceil(t.Y(this.bounds.getEast())*i),s=Math.ceil(t.X(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class K extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,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=t.e({type:"raster"},i),t.e(this,t.U(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield $(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new W(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield _.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class X extends K{constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield _.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.Z()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.$()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.a0(e,-1,-1,i,n))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.a1(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a1(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}function Y(e){const t=new Z;let i;switch(e.type){case"FeatureCollection":i=e.features.map(e=>J(e.geometry)).flat(1/0);break;case"Feature":i=J(e.geometry);break;default:i=J(e)}if(0==i.length)return t;for(let e=0;e0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(i)})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyDiff(e){const i="string"==typeof this.promoteId?this.promoteId:void 0;this._data.url||this._data.updateable||!t.a6(this._data.geojson,i)||(this._data={updateable:t.a7(this._data.geojson,i)}),e&&this._data.updateable?t.a8(this._data.updateable,e,i):t.w("Cannot apply GeoJSONSource#updateData due to internal error")}_getShouldReloadTileOptions(e){if(this._options.cluster||!e||e.removeAll)return;const{add:i=[],update:n=[],remove:r=[]}=e||{},o=new Set([...n.map(e=>e.id),...r]);for(const e of o.values())if("number"!=typeof e&&null==this.promoteId)return void t.w(`GeoJSONSource "${this.id}": updateData is slower when using string GeoJSON feature IDs (e.g. "${e}"). Consider using promoteId or numeric IDs for better performance.`);return{nextBounds:[...n.map(e=>e.newGeometry),...i.map(e=>e.geometry)].filter(Boolean).map(e=>Y(e)),prevIds:o}}shouldReloadTile(e,{nextBounds:i,prevIds:n}){if(!e.latestFeatureIndex)return"unloaded"!==e.state;const r=e.latestFeatureIndex.loadVTLayers();for(let i=0;i{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.aa.fromLngLat);var n;return this.tileID=function(e){const i=t.ab.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.ad(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.ab.fromPoints(e),s={};for(let e=0;e<=t.ac;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class ie extends te{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.ae(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.af(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.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,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ne extends te{constructor(e,i,n,r){super(e,i,n,r),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 t.k(new t.af(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.af(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.af(`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 t.k(new t.af(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(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 i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0});let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.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}}const re={},oe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return X;case"vector":return q;case"video":return ie;case"canvas":return ne}return re[e]},se="RTLPluginLoaded";class ae extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=V()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(se))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let le=null;function ce(){return le||(le=new ae),le}var ue,he;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(ue||(ue={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(he||(he={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ag(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:n}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=n}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,n){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ah}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=r[t.a9]||r[o];if(!s)return;const a=t.aj(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=ve(n,T,r);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||we)(e.zoom+t.at(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const S=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=S){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const Ce=t.ab.fromPoints([new t.P(0,0),new t.P(t.a4,t.a4)]);class Se extends t.E{constructor(e,i,n){super(),this.id=e,this.dispatcher=n,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(oe(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,i,n,this),this._tiles={},this._cache=new t.av(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}getState(){return this._state}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,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,n)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}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)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Be).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const n=e.tileID,r=i.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(Be).map(e=>e.key)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._isIdRenderable(i.tileID.key)}return!1}_isIdRenderable(e,t=!1){var i;return null===(i=this._tiles[e])||void 0===i?void 0:i.isRenderable(t)}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)t&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[i],t)||(e?this._reloadTile(i,"expired"):"errored"!==this._tiles[i].state&&this._reloadTile(i,"reloading"))}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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){const i=this._getLoadedDescendents(t),n=new Set;for(const r of t){const t=i[r.key];if(!(null==t?void 0:t.length)){n.add(r);continue}const o=r.overscaledZ+Se.maxOverzooming,s=t.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){n.add(r);continue}const a=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,r.overscaledZ)||n.add(r)}return n}_getLoadedDescendents(e){var t;const i={};for(const n in this._tiles){const r=this._tiles[n];if(r.hasData())for(const n of e)r.tileID.isChildOf(n)&&(i[t=n.key]||(i[t]=[])).push(r)}return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){const t=this._tiles[e.key];return(null==t?void 0:t.hasData())?t:null}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e,this._resetTileReloadTimers()}}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a1(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ee(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[],this.usedForTerrain&&(n=this._addTerrainIdealTiles(n));const r=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=Te(e,this._source),s=this._updateRetainedTiles(n,o),a=Ie(this._source.type);a&&this._rasterFadeDuration>0&&!i&&this._updateFadingTiles(n,s),a?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(e){for(const t in this._tiles)e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t in this._tiles){const i=this._tiles[t];e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(n)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n=new Set;for(const t of e)this._addTile(t).hasData()||n.add(t);const r=e.reduce((e,t)=>(e[t.key]=t,e),{}),o=this._retainLoadedChildren(r,n),s={},a=Math.max(t-Se.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._tiles[e.key],n=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&n&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=t.wasRequested(),e)break}}}return r}_updateFadingTiles(e,i){const n=c(),r=t.aw(e);for(const t of e){const e=this._tiles[t.key];e.fadingDirection!==he.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,i,n)||this._updateFadingDescendents(e,i,n)||this._updateFadingEdge(e,r,n)||e.resetFadeLogic()}}_updateFadingAncestor(e,t,i){if(!e.hasData())return!1;const{tileID:n,fadingRole:r,fadingDirection:o,fadingParentID:s}=e;if(r===ue.Base&&o===he.Incoming&&s)return t[s.key]=s,!0;const a=Math.max(n.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let r=n.overscaledZ-1;r>=a;r--){const o=n.scaledTo(r),s=this.getLoadedTile(o);if(s)return e.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Incoming,fadingParentID:s.tileID,fadeEndTime:i+this._rasterFadeDuration}),s.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Departing,fadeEndTime:i+this._rasterFadeDuration}),t[o.key]=o,!0}return!1}_updateFadingDescendents(e,t,i){if(!e.hasData())return!1;const n=e.tileID.children(this._source.maxzoom);let r=this._updateFadingChildren(e,n,t,i);if(r)return!0;for(const o of n){const n=o.children(this._source.maxzoom);this._updateFadingChildren(e,n,t,i)&&(r=!0)}return r}_updateFadingChildren(e,t,i,n){if(t[0].overscaledZ>=this._source.maxzoom)return!1;let r=!1;for(const o of t){const t=this.getLoadedTile(o);if(!t)continue;const{fadingRole:s,fadingDirection:a,fadingParentID:l}=t;s===ue.Base&&a===he.Departing&&l||(t.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Departing,fadingParentID:e.tileID,fadeEndTime:n+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Incoming,fadeEndTime:n+this._rasterFadeDuration})),i[o.key]=o,r=!0}return r}_updateFadingEdge(e,t,i){const n=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(n)&&(e.setSelfFadeLogic(i+this._rasterFadeDuration),!0)}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const n=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,n||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){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])}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._clearTileReloadTimer(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))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.ab.fromPoints(u);for(let e=0;ee.getTilePoint(new t.aa(i.x,i.y)));if(i.expandBy(p),i.intersects(Ce)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.ab.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.ab.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.aa(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(Ie(this._source.type)&&this._rasterFadeDuration>0){const e=c();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,n){this._state.updateState(e=e||t.a9,i,n)}removeFeatureState(e,i,n){this._state.removeFeatureState(e=e||t.a9,i,n)}getFeatureState(e,i){return this._state.getState(e=e||t.a9,i)}setDependencies(e,t,i){const n=this._tiles[e];n&&n.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))}}function Be(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ie(e){return"raster"===e||"image"===e||"video"===e}Se.maxUnderzooming=10,Se.maxOverzooming=3;class Me{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Re{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e0}hitTestCircle(e,t,i,n,r){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!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=r[h+2]&&t<=r[h+3]&&i>=r[h+0]&&n>=r[h+1]&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))&&(o.push({key:d,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const d=this.circleCells[r];if(null!==d){const r=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Le(e,i,r){const o=t.N();if(!e){const{vecSouth:e,vecEast:t}=ke(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.Q(o,o,[1/r,1/r,1]),o}function Fe(e,i,n,r){if(e){const e=t.N();if(!i){const{vecSouth:t,vecEast:i}=ke(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.Q(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function ke(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.aB();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.aC(a);l<1e-9?t.aD(a):t.aE(a,a,1/l);const c=t.aB();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.aC(c);return u<1e-9?t.aD(c):t.aE(c,c,1/u),{vecEast:c,vecSouth:a}}function De(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aG(o,o,n)):(o=[e,i,0,1],Ye(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Oe(e,t){return.5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Ue(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.ax(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let n=0;nMath.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ay.vertical?i.yn.x)?{needsFlipping:!0}:null}function je(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=Ne(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=$e(c.first.point.x,c.first.point.y,i,n),_=$e(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Ve(r.writingMode,g,_,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n0?a.point:Ge(i.tileAnchorPoint,s,e,1,i),c=$e(e.x,e.y,i,n),h=$e(l.x,l.y,i,n),d=Ve(r.writingMode,c,h,u);if(d)return d}const e=Ke(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.aF(c,e.point,e.angle);return{}}function Ge(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=Qe(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function He(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Qe(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded=r.anyProjectionOccluded||s.isOccluded,s.point;const a=e-n.direction;return Ge(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function Qe(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=De(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function $e(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aG(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function We(e,t,i){return e._unit()._perp()._mult(t*i)}function qe(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=He(e+c.direction,l,c),d=We(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.aH(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ke(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=Qe(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=He(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const n=g.sub(_);t=0===n.mag()?We(He(p+u,a,e).sub(g),i,u):We(n,i,u),m||(m=_.add(t)),f=qe(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const Xe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Je(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.xr.x||i.yr.y?[]:t.aI([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=De(e.x,e.y,n,i.getElevation),r=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height,r})}(e,i);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;oi&&(i=r,t=n));return e.slice(t,t+i)}(n)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.ab;for(const r of e){const e=new t.P(r.x+et,r.y+et);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aJ(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));I=e.some(e=>!e.isOccluded),B=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aK(B),allPointsOccluded:!I}}}class it{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class nt{constructor(e,t,i,n,r){this.text=new it(e?e.text:null,t,i,r),this.icon=new it(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class rt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class ot{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class st{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 at(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aR(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class lt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new tt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new st(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.a4,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aM(n,1,this.transform.zoom),m=t.aN(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aN(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Le(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ot(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.ax(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aO[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=at(x,n,r,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:r,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aP(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aP(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!r.hasIconData()||g),C=v&&(A||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const S=this.retainedQueryData[r.bucketInstanceId].tileID,B=this._getTerrainElevationFunc(S),I=this.transform.getFastPathSimpleProjectionMatrix(S),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new rt(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let n=t.ay.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ay.vertical?(k=n(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,u,S,l,b,x,s,f.predicate,B,void 0,I);return n&&n.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(G,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ay.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aO[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ay.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.az(r.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,b,f.predicate,e.collisionCircleDiameter,u,s,B),z.circles.length&&z.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,S,l,b,x,a,f.predicate,B,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),r.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),r.bucketInstanceId,N,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new rt((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ay.horizontal||i===t.ay.horizontalOnly?i:0,o=i===t.ay.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new nt(o,n,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new nt(null,n,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new nt(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new nt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new nt(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n0,A=this.placedOrientations[r.crossTileID],y=A===t.ay.vertical,v=A===t.ay.horizontal||A===t.ay.horizontalOnly;if(o>0||s>0){const t=_t(c.text);m(e.text,o,y?At:t),m(e.text,s,v?At:t);const i=c.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(e,n.anchor,r,A);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(e,"left",r,a),this.markUsedOrientation(e,a,r))}if(_){const t=_t(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:At),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?At:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=at(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=y),n.verticalTextBox&&(r=v),ct(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,x.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!v&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),ct(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),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.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function ct(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-et,a=n[1]-et,l=n[2]-et,c=n[3]-et;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const ut=Math.pow(2,25),ht=Math.pow(2,24),dt=Math.pow(2,17),pt=Math.pow(2,16),ft=Math.pow(2,9),mt=Math.pow(2,8),gt=Math.pow(2,1);function _t(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*ut+t*ht+i*dt+t*pt+i*ft+t*mt+i*gt+t}const At=0;class yt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&c()-n>2;for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new yt(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xt=512/t.a4/2;class bt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*xt),y:Math.floor(e.anchorY*xt)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aS(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=xt/Math.pow(2,l-o),u=(a*t.a4+e.anchorY)*c,h=r*t.a4*xt;return{x:Math.floor((s*t.a4+e.anchorX)*c-n*t.a4*xt),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.ze)}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Tt{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Ct="void main() {fragColor=vec4(1.0);}";const St={prelude:Bt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Bt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Bt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Bt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Bt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Bt("in 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\nvoid 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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out 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\nvoid 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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Bt(Ct,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Bt("uniform 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Bt("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Bt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Bt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Bt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Bt(Ct,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Bt("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Bt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Bt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Bt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Bt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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:Bt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Bt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;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 float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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\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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\nvoid main() {\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\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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.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_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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#ifdef GLOBE\nout float v_depth;\n#endif\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\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_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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 floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\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 floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\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 floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Bt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;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;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Bt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Bt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;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\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\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 inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Bt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;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\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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;if (u_is_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);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Bt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Bt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Bt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Bt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Bt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Bt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Bt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class It{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Mt=t.aT([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Rt="mercator";class Lt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Rt}get shaderDefine(){return Pt}get shaderPreludeCode(){return St.projectionMercator}get vertexShaderPreludeCode(){return St.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aU.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(t.a4,0),s.emplaceBack(0,t.a4),s.emplaceBack(t.a4,t.a4);const a=e.createVertexBuffer(s,Mt.members),l=t.aW.simpleSegment(0,0,4,2),c=new t.aX;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new It(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ft{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.G.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.G.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.G.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.G.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.an((this.left+e-this.right)/2,0,e),r=t.an((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ft(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function kt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Dt(e){return Math.max(0,Math.floor(e))}class Ot{constructor(e,i){var n;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(n=null==i?void 0:i.constrainOverride)&&void 0!==n?n:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ft,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ft(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.W(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aY(this._fovInRadians)}setFov(e){e=t.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aq(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new Z([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.ao,t.ao])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.ab.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ar(new Float64Array(16));t.Q(e,e,[this._width/2,-this._height/2,1]),t.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ar(new Float64Array(16)),t.Q(e,e,[1,-1,1]),t.O(e,e,[-1,-1,0]),t.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,a=t.aa.fromLngLat(e,i),l=-Math.cos(t.ap(s)),c=Math.sin(t.ap(s)),u=c*Math.sin(t.ap(o)),h=-c*Math.cos(t.ap(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aZ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.aa(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.at(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.as(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/i,r=t.aa.fromLngLat(this.center,this.elevation),o=ye(this.center,this.elevation,this.pitch,this.bearing,n);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aZ(o.z,r.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Ut{distanceToTile2d(e,t,i,n){const r=n.distanceX([e,t]),o=n.distanceY([e,t]);return Math.hypot(r,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Nt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),l=[[-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(n=>function(e,i,n,r){const o=t.aG([],e,i),s=1/o[3]/n*r;return t.b5(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.b1([],e[i+s],e[i+o]),r=t.b6(n);t.a_(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.b7(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.b1([],e[i[0]],e[i[1]]),r=t.b1([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.b2(o,t.b3([],n,r)),o[3]=-t.b4(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.b8(e),r=t.b9([],e,1/n),o=t.b1([],i,t.a_([],r,t.b4(i,r))),s=t.b8(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.a_([],r,-r[3]),a=t.a$([],n,t.a_([],o,e/s));return t.ba(i,a)}return null}(n,u);if(null!==h){const e=h/t.b4(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.b1([],l[e[0]],l[e[1]]),n=t.b1([],l[e[2]],l[e[1]]),r=t.b2([],t.b3([],i,n)),o=-t.b4(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Nt(l,c,new zt(u,h))}}class Vt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.an(+i,this.minZoom,this.maxZoom);const n={center:new t.V(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.aq(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.X(e[1])*o,a=t.X(e[0])*o,a-sa&&(_=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.W(f,e-o/2,e+o/2));const n=d/2;i-nc&&(g=c-n)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);n.center=ge(o,e).wrap()}return n},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ut}clone(){const e=new Vt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.bb(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.bb(n,e))}return i}getCameraFrustum(){return Nt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.as(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.aa.fromLngLat(e),a=new t.aa(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.aa.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aa.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aG(r,r,this._pixelMatrixInverse),t.aG(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.aa(t.G.number(r[0]/s,o[0]/a,d)/this.worldSize,t.G.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aG(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-_e(this));return(new Z).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-_e(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.bc(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=Ae(e,this.worldSize);t.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=Ae(e,this.worldSize);return t.S(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ap(this.fov)*(Math.abs(Math.cos(t.ap(this.roll)))*this.height+Math.abs(Math.sin(t.ap(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.an(Math.PI-a-l,.01,Math.PI-.01)),u=_e(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ap(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.an(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.as(1,this.center.lat)*this.worldSize;const o=t.ap(Math.min(this.pitch,fe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.bd(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aA(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.be(a),t.Q(a,a,[1,-1,1]),t.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.bf(a,a,-this.rollInRadians),t.bg(a,a,this.pitchInRadians),t.bf(a,a,-this.bearingInRadians),t.O(a,a,[-n,-r,0]),this._mercatorMatrix=t.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),t.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aA([],a);const l=[0,0,-1,1];t.aG(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.bd(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.bf(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bg(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.bf(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.O(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+h*c+d*u,f=r-Math.round(r)+h*u+d*c,m=new Float64Array(a);if(t.O(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aA(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aG(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.aa.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aG(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&r?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.b0(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aG(s,s,o)):(s=[e,i,0,1],Ye(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.aa.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.bi();return t.O(o,o,[n.x,n.y,n.z]),t.bf(o,o,Math.PI),t.bg(o,o,Math.PI/2),t.Q(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.a1(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=Ae(i,this.worldSize);t.S(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.a4,t.a4,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.Q(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function jt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Gt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bl(r,i,n,e.k);const o=t.bm(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ht(e,i,n,r,o){const s=o.padding,a=me(o.worldSize,n.getNorthWest()),l=me(o.worldSize,n.getNorthEast()),c=me(o.worldSize,n.getSouthEast()),u=me(o.worldSize,n.getSouthWest()),h=t.ap(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void jt();const x=Math.min(t.at(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ap(r)),T=b.add(w).mult(o.scale/t.aq(x));return{center:ge(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:r}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),n=Math.abs(_e(t));return{easingOffset:e.mult(Math.min(.75*n/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Ht(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.V.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.applyConstrain(t.V.convert(i.center||d),null!=u?u:n);kt(e,p);const m=me(e.worldSize,d),g=me(e.worldSize,p).sub(m),_=t.aq(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.G.number(n,f,a)),t.bn(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.aq(e.zoom-n),r=f>n?Math.min(2,_):Math.max(.5,_),o=Math.pow(r,1-a),s=ge(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;kt(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),u=c.mag(),h=t.aq(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.applyConstrain(s,n).zoom;d=t.aq(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.at(n));const h=1===i?s:ge(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class $t{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}$t.Replace=[1,0],$t.disabled=new $t($t.Replace,t.bo.transparent,[!1,!1,!1,!1]),$t.unblended=new $t($t.Replace,t.bo.transparent,[!0,!0,!0,!0]),$t.alphaBlended=new $t([1,771],t.bo.transparent,[!0,!0,!0,!0]);const Zt=2305;class Wt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Wt.disabled=new Wt(!1,1029,Zt),Wt.backCCW=new Wt(!0,1029,Zt),Wt.frontCCW=new Wt(!0,1028,Zt);class qt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const Kt=7680;class Xt{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Xt.disabled=new Xt({func:519,mask:0},0,0,Kt,Kt,Kt);const Jt=new WeakMap;function Yt(e){var t;if(Jt.has(e))return Jt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Jt.set(e,i),i}}class ei{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aV;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aX;o.emplaceBack(0,1,2),this._fullscreenTriangle=new It(i.createVertexBuffer(r,Mt.members),i.createIndexBuffer(o),t.aW.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),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.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Yt(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,qt.disabled,Xt.disabled,$t.unblended,Wt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Yt(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Yt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ei._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const ti=t.a4/128;function ii(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.a4;-1===r&&(o=-ti),r===n+1&&(o=t.a4+ti);let s=i/n*t.a4;-1===i&&(s=e.extendToNorthPole?t.bq:-ti),i===n+1&&(s=e.extendToSouthPole?t.br:t.a4+ti),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ai(e){const t=ui(e.worldSize,e.center.lat);return 2*Math.PI*t}function li(e,i,n,r,o){const s=1/(1<1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.V(t.W(s,-180,180),i)}return new t.V(0,i)}function di(e){return Math.cos(e*Math.PI/180)}function pi(e,i){const n=di(e),r=di(i);return t.at(r/n)}function fi(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+pi(i.center.lat,0),o=t.bt(1/di(i.center.lat),1/di(Math.min(Math.abs(i.center.lat),60)),t.bw(r,7,3,0,1)),s=360/ai({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.V(i.center.lng-n.x*s*o,t.an(i.center.lat+n.y*s,-t.ao,t.ao))}function mi(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function gi(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=mi(s+r*(a-s)),c=mi(s),u=mi(a);return new t.V(e.lng+i*((l-c)/(u-c)),o)}return new t.V(e.lng+i*r,o)}class _i{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class Ai{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new Ai(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.bA([],n[0],n[1],n[2]),o=t.bB([],[i[0],0,0],r),s=t.bB([],[0,i[1],0],r),a=t.bB([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.a$(n,n,t.a_([],o,1&~i?-1:1)),t.a$(n,n,t.a_([],s,1==(i>>1&1)?1:-1)),t.a$(n,n,t.a_([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new Ai(u,[[...o,-t.b4(o,u[0])],[...s,-t.b4(s,u[0])],[...a,-t.b4(a,u[0])],[-o[0],-o[1],-o[2],-t.b4(o,u[7])],[-s[0],-s[1],-s[2],-t.b4(s,u[7])],[-a[0],-a[1],-a[2],-t.b4(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n=0&&o++}if(0===o)return 0;o=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n=0&&i++}return i===t?2:0===i?0:1}}function yi(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function vi(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>1?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,yi(t,n,r))}class xi{constructor(){this._boundingVolumeCache=new _i(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bD,l/=t.bD,a+=1,l+=1,e.z<=0)return Ai.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Ai.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[li(0,0,e.x,e.y,e.z),li(t.a4,0,e.x,e.y,e.z),li(t.a4,t.a4,e.x,e.y,e.z),li(0,t.a4,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.a_([],e,l));if(l!==a)for(const e of i)n.push(t.a_([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<=(1<{const n=t.an(e.lat,-t.ao,t.ao),r=t.an(+i,this.minZoom+pi(0,n),this.maxZoom);return{center:new t.V(e.lng,n),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new xi}clone(){const e=new wi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.b6(u);return t.a_(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ci(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.b3(a,s,o),t.b2(s,s),t.b2(a,a);const l=[0,0,0];return t.b2(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<o&&(o=i),na&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Z(u)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=ci(this.unprojectScreenPoint(i)),r=ci(e),o=t.by();t.bK(o);const s=t.by();t.bH(s,n,o,-this.center.lng*Math.PI/180),t.bG(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(h,e)+t.bM(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bE();return t.aG(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const n=t.b4(e,i),r=t.by(),o=t.by();t.a_(o,i,n),t.b1(r,e,o);const s=1-t.b4(r,r);if(s<0)return null;const a=t.b4(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.by();t.a$(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.by();return t.b2(o,e),hi(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.ba(o,i)/s,l=t.by();if(a>0)t.a$(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.by();t.a$(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.ba(this._cachedClippingPlane,e);t.b1(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.by();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return hi(function(e,i,n){const r=t.by();t.b1(r,n,e);const o=t.by();return t.bz(o,e,r,i/t.b8(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.V.convert(e),r=1/t.bD,o=t.bi();return t.bI(o,o,n.lng/180*Math.PI),t.bg(o,o,-n.lat/180*Math.PI),t.O(o,o,[0,0,1+i/t.bD]),t.bg(o,o,.5*Math.PI),t.Q(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a1(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ti{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Vt,this._verticalPerspectiveTransform=new wi}clone(){const e=new Ti;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bt(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ei{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=fi(e,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bJ(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bJ(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.b4(h,u),p=t.by();t.a$(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.b6(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ui(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bw(g,.9,.5,1,.25),A=(1-t.aq(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.V(i.center.lng+l*A,t.an(i.center.lat+c*A,-t.ao,t.ao));i.setLocationAtPoint(r,n);const b=i.center,w=t.bw(Math.abs(a),45,85,0,1),T=t.bw(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bJ(b.lng,x.lng),S=t.bJ(b.lat,x.lat);i.setCenter(new t.V(b.lng+C*E,b.lat+S*E).wrap()),i.setZoom(v+pi(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(fi(e.panDelta,t).wrap()),t.setZoom(r+pi(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Ht(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bJ(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bJ(d,p),_=f+.5*t.bJ(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ci(n.getNorthWest()),ci(n.getNorthEast()),ci(n.getSouthWest()),ci(n.getSouthEast()),ci(new t.V(p,_)),ci(new t.V(d,_)),ci(new t.V(g,f)),ci(new t.V(g,m))],x=ci(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.at(b),s;jt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.applyConstrain(i.center?t.V.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+pi(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.V.convert(i.center):r,d=e.applyConstrain(h,n).center;kt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+pi(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+pi(r.lat,m.lat),_=n+pi(r.lat,0),A=g+pi(m.lat,0),y=t.bJ(r.lng,m.lng),v=t.bJ(r.lat,m.lat),x=t.aq(A-_);return u=g!==n,{easeFunc:n=>{if(t.bn(s,a)||Gt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-n),o=gi(r,y,v,n*i);e.setCenter(o.wrap())}if(u){const i=t.G.number(_,A,n)+pi(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+pi(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;kt(e,d);const p=function(e,i,n){const r=ci(i),o=ci(n),s=t.b4(r,o),a=Math.acos(s),l=ai(e);return a/(2*Math.PI)*l}(e,r,d),f=o+pi(r.lat,0),m=c+pi(d.lat,0),g=t.aq(m-f);let _;if("number"==typeof i.minZoom){const n=+i.minZoom+pi(d.lat,0),r=Math.min(n,f,m)+pi(0,d.lat),o=e.applyConstrain(d,r).zoom+pi(d.lat,0);_=t.aq(o-f)}const A=t.bJ(r.lng,d.lng),y=t.bJ(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=gi(r,A,y,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.at(o);e.setZoom(1===n?c:m+pi(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.B(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),Bi=t.bN();class Ii extends t.E{constructor(e,i={}){var n,r;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(U(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new b,this.imageManager.setEventedParent(this);const o=(null===(n=e._container)||void 0===n?void 0:n.lang)||"undefined"!=typeof document&&(null===(r=document.documentElement)||void 0===r?void 0:r.lang)||void 0;this.glyphManager=new S(e._requestManager,i.localIdeographFontFamily,o),this.lineAtlas=new L(256,512),this.crossTileSymbolIndex=new Et,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bQ(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const n of e){i[n]=this._globalState[n];for(const e in this._layers){const i=this._layers[e],r=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs();if(r.has(n)&&t.add(i.source),o.has(n))for(const{name:e,value:t}of o.get(n))this._updatePaintProperty(i,e,t)}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const r=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(r,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,n)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(Bi,{validate:!1})}_load(e,i,n){var r,o;let s=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!Si(this,t.C(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new R(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){var e,i,n;const r=t.bR(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",r),this._order=r.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const e of r){const r=t.bS(e,this._globalState);if(r.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=r,t.bT(r)&&this.tileManagers[r.source]){const t=null!==(n=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==n?n:r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,n=void 0){let r;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=y(e),s=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=i.transformRequest(v(n,s,".json"),"SpriteJSON");l[e]=t.j(o,r);const a=i.transformRequest(v(n,s,".png"),"SpriteImage");c[e]=_.getImage(a,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=a.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,r=e,this.fire(new t.k(r))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),n&&n(r)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(n))&&this.fire(new t.k(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bU(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bU(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.tileManagers){const t=this.tileManagers[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in n){const i=this.tileManagers[e];!!n[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&Si(this,t.C(e)))return!1;(e=t.bU(e)).layers=t.bR(e.layers);const o=t.bV(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.C.source,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=this.tileManagers[e]=new Se(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.k(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(Si(this,t.bW(e)))return;o=t.bS(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bU(e),e=t.e(e,{source:r})),this._validate(t.C.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bS(e,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.tileManagers[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bQ(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.C.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bU(i)),this._updateLayer(r)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bU(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getPaintProperty(i),n)||this._updatePaintProperty(o,i,n,r):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,n,r={}){e.setPaintProperty(i,n,r)&&this._updateLayer(e),t.bT(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.tileManagers[n];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.tileManagers[n];if(void 0===r)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.tileManagers[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bX(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bY({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(H);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:r.filter,globalState:r.globalState},r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const n in e)for(const r of e[n])Q(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.C.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.tileManagers[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((r=r||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new vt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.C.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,n]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(n.dasharray,n.round);return e})}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...y(this.stylesheet.sprite),...o];this._validate(t.C.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=y(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return y(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.C.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];if(t.setEventedParent(null),t._tiles){for(const e in t._tiles)t._tiles[e].unloadVectorData();t._tiles={}}t._cache.reset(),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Mi=t.aT([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Li={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Fi(e){const t=[];for(let i=0;i({u_depth:new t.bZ(e,i.u_depth),u_terrain:new t.bZ(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.b$(e,i.u_terrain_matrix),u_terrain_unpack:new t.c0(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.b$(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c0(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c0(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.b$(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=n?n.getUniforms(e,E):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Li[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const n=i.vaos||(i.vaos={});(n[c]||(n[c]=new Pi)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Di(e,i,n){const r=1/t.aM(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Oi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.c3();"viewport"===o.properties.get("anchor")&&t.c4(l,e.transform.bearingInRadians),t.c5(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},zi=(e,i,n,r,o,s,a)=>t.e(Oi(e,i,n,r),Di(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ui=(e,i,n,r)=>t.e(Di(i,e,n),{u_fill_translate:r}),Ni=(e,t)=>({u_world:e,u_fill_translate:t}),Vi=(e,i,n,r,o)=>t.e(Ui(e,i,n,o),{u_world:r}),ji=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aM(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.a4*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Gi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Hi=e=>({u_viewport_size:[e.width,e.height]}),Qi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),$i=(e,i,n,r)=>{const o=t.aM(e,1,i)/(t.a4*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aM(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},Zi=(e,i,n,r)=>{const o=t.N();t.c6(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},Wi=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t{const n=i.stride,r=t.N();return t.c6(r,0,t.a4,-t.a4,0,0,1),t.O(r,r,[0,-t.a4,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ki(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.aa(0,r/n).toLngLat().lat,new t.aa(0,(r+1)/n).toLngLat().lat]}const Xi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Ji=(e,i,n,r)=>{const o=e.transform;return{u_translation:on(e,i,n),u_ratio:r/t.aM(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Yi=(e,i,n,r,o)=>t.e(Ji(e,i,n,r),{u_image:0,u_image_height:o}),en=(e,i,n,r,o)=>{const s=e.transform,a=rn(i,s);return{u_translation:on(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aM(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},tn=(e,i,n,r,o)=>{const s=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},nn=(e,i,n,r,o,s)=>{const a=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_image:0,u_image_height:s,u_tileratio:a,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function rn(e,i){return 1/t.aM(e,1,i.tileZoom)}function on(e,i,n){return t.aN(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const sn=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:an(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function an(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]}const ln=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{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:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},cn=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(ln(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},un=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(cn(e,i,n,r,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),hn=(e,t)=>({u_opacity:e,u_color:t}),dn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aM(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),pn=(e,t)=>{},fn={fillExtrusion:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c2(e,i.u_world),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bZ(e,i.u_scale_with_map),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_extrude_scale:new t.c2(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c2(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c2(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c2(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b_(e,i.u_color),u_overlay:new t.bZ(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:pn,clippingMask:pn,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_color_ramp:new t.bZ(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_latrange:new t.c2(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c8(e,i.u_altitudes),u_azimuths:new t.c8(e,i.u_azimuths),u_accent:new t.b_(e,i.u_accent),u_method:new t.bZ(e,i.u_method),u_shadows:new t.c7(e,i.u_shadows),u_highlights:new t.c7(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_image:new t.bZ(e,i.u_image),u_dimension:new t.c2(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c0(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_unpack:new t.c0(e,i.u_unpack),u_dimension:new t.c2(e,i.u_dimension),u_elevation_stops:new t.bZ(e,i.u_elevation_stops),u_color_stops:new t.bZ(e,i.u_color_stops),u_color_ramp_size:new t.bZ(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_texsize:new t.c2(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.bZ(e,i.u_image),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.bZ(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c2(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.bZ(e,i.u_image0),u_image1:new t.bZ(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c1(e,i.u_spin_weights),u_coords_top:new t.c0(e,i.u_coords_top),u_coords_bottom:new t.c0(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texsize_icon:new t.c2(e,i.u_texsize_icon),u_texture:new t.bZ(e,i.u_texture),u_texture_icon:new t.bZ(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b_(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.bZ(e,i.u_image),u_pattern_tl_a:new t.c2(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c2(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c2(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c2(e,i.u_pattern_br_b),u_texsize:new t.c2(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c2(e,i.u_pattern_size_a),u_pattern_size_b:new t.c2(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.b$(e,i.u_fog_matrix),u_fog_color:new t.b_(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c1(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c1(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.b$(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b_(e,i.u_sky_color),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon:new t.c2(e,i.u_horizon),u_horizon_normal:new t.c2(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class mn{constructor(e,t,i){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||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const gn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class _n{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Gi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.c9;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:B,angle:I})}else Je(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===n.layout.get("text-rotation-alignment");Ue(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?or:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?un(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):cn(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):ln(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:B,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aW([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,hr(i.buffers,t.segments,n,e,i.program,w,h,d,r,i.projectionData,t.terrainData)),r.u_is_halo=0}hr(i.buffers,t.segments,n,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function hr(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,Wt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function dr(e,i,n,r,o){const s=e.context,a=s.gl,l=Xt.disabled,c=new $t([a.ONE,a.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=fr(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,qt.disabled,l,c,Wt.disabled,$i(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function pr(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=mr(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Zi(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function fr(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function mr(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function gr(e,i,n,r,o,s,a,l){let c=256;if(o.stepInterpolant){const r=i.getSource().maxzoom,o=a.canonical.z===r?Math.ceil(1<20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),M=f.getProjectionData({overscaledTileID:b,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),P=sn(S,C,B.fadeMix,i,a),R=m.getMeshFromTileID(h,b.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,n,r?r[b.overscaledZ]:Xt.disabled,g,l?Wt.frontCCW:Wt.backCCW,P,I,M,i.id,R.vertexBuffer,R.indexBuffer,R.segments)}}function Br(e,i,n,r){const o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===n||r)return o;if(e.fadingParentID){const r=i.getLoadedTile(e.fadingParentID);if(!r)return o;const s=Math.pow(2,r.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,n){const r=c(),o=(r-i.timeAdded)/n,s=e.fadingDirection===he.Incoming,a=t.an((r-e.timeAdded)/n,0,1),l=t.an(1-o,0,1),u=s?a:l;return{tileOpacity:u,parentTileOpacity:s?l:a,fadeMix:{opacity:1,mix:1-u}}}(e,r,n);return{parentTile:r,parentScaleBy:s,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const n=(c()-e.timeAdded)/i,r=t.an(n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}(e,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return o}const Ir=new t.bo(1,0,0,1),Mr=new t.bo(0,1,0,1),Pr=new t.bo(0,0,1,1),Rr=new t.bo(1,0,1,1),Lr=new t.bo(0,1,1,1);function Fr(e,t,i,n){Dr(e,0,t+i/2,e.transform.width,i,n)}function kr(e,t,i,n){Dr(e,t-i/2,0,i,e.transform.height,n)}function Dr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Or(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("debug"),a=qt.disabled,l=Xt.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(n).tileSize,m=512/Math.min(f,512)*(n.overscaledZ/e.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,o.TRIANGLES,a,l,$t.alphaBlended,Wt.disabled,Qi(t.bo.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(r,o.LINE_STRIP,a,l,c,Wt.disabled,Qi(t.bo.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function zr(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Ri(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Xt.disabled,l,Wt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Ur(e,i){if(!i.mesh){const n=new t.aV;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aX;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new It(e.createVertexBuffer(n,Mt.members),e.createIndexBuffer(r),t.aW.simpleSegment(0,0,n.length,r.length))}return i.mesh}class Nr{constructor(e,i){this.context=new ir(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Se.maxOverzooming+Se.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Et}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aV;i.emplaceBack(0,0),i.emplaceBack(t.a4,0),i.emplaceBack(0,t.a4),i.emplaceBack(t.a4,t.a4),this.tileExtentBuffer=e.createVertexBuffer(i,Mt.members),this.tileExtentSegments=t.aW.simpleSegment(0,0,4,2);const n=new t.aV;n.emplaceBack(0,0),n.emplaceBack(t.a4,0),n.emplaceBack(0,t.a4),n.emplaceBack(t.a4,t.a4),this.debugBuffer=e.createVertexBuffer(n,Mt.members),this.debugSegments=t.aW.simpleSegment(0,0,4,5);const r=new t.cg;r.emplaceBack(0,0,0,0),r.emplaceBack(t.a4,0,t.a4,0),r.emplaceBack(0,t.a4,0,t.a4),r.emplaceBack(t.a4,t.a4,t.a4,t.a4),this.rasterBoundsBuffer=e.createVertexBuffer(r,Mi.members),this.rasterBoundsSegments=t.aW.simpleSegment(0,0,4,2);const o=new t.aV;o.emplaceBack(0,0),o.emplaceBack(t.a4,0),o.emplaceBack(0,t.a4),o.emplaceBack(t.a4,t.a4),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,Mt.members),this.rasterBoundsSegmentsPosOnly=t.aW.simpleSegment(0,0,4,5);const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Mt.members),this.viewportSegments=t.aW.simpleSegment(0,0,4,2);const a=new t.ch;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aX;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Xt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new It(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.N();t.c6(n,0,this.width,this.height,0,0,1),t.Q(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,qt.disabled,this.stencilClearMode,$t.disabled,Wt.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode($t.disabled),n.setDepthMode(qt.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){const r=this.context,o=r.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,qt.disabled,new Xt({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),$t.disabled,i?Wt.disabled:Wt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,n=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ee(n,{tileSize:n.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=n.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,t.TRIANGLES,o,Xt.disabled,$t.disabled,Wt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Xt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i0};for(const e in s){const t=s[e];t.used&&t.prepare(this.context),a[e]=t.getVisibleCoordinates(!1),l[e]=a[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=_e(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new qt(n.LEQUAL,qt.ReadWrite,[0,1]),s=Xt.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Ur(i,t);l.draw(i,n.TRIANGLES,o,s,a,Wt.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=s[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Ur(r,i);s.draw(r,o.TRIANGLES,a,Xt.disabled,$t.alphaBlended,Wt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let n=0;nh.getElevation(o,e,t):null;lr(s,d,p,c,u,g,i,f,_,t.aN(u,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&ur(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&ur(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(rr(e,i,n,r,!0),rr(e,i,n,r,!1))}(e,i,n,r,this.style.placement.variableOffsets,o):t.cm(n)?function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,qt.ReadOnly),m=Xt.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,d.TRIANGLES,f,m,g,Wt.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}}(e,i,n,r,o):t.cn(n)?function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?dr(e,r,n,t,l):"translucent"===e.renderPass&&pr(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=Xt.disabled,c=new $t([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.cc);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=fr(e,i.width/4,i.height/4),n.heatmapFbos.set(t.cc,o))})(o,e,n),o.clear({color:t.bo.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=i?St.projectionMercator:o.shaderPreludeCode,a=i?Pt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Rt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return this.cache[l]||(this.cache[l]=new ki(this.context,St[e],t,fn[e],this._showOverdrawInspector,r,s,a,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];t&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Vr(e,t){let i,n=!1,r=null,o=null;const s=()=>{r=null,n&&(e.apply(o,i),r=setTimeout(s,t),n=!1)};return(...e)=>(n=!0,o=this,i=e,r||s(),r)}class jr{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Vr(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.V(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Gr={linearity:.3,easing:t.cv(0,0,.3,1)},Hr=t.e({deceleration:2500,maxSpeed:1400},Gr),Qr=t.e({deceleration:20,maxSpeed:1400},Gr),$r=t.e({deceleration:1e3,maxSpeed:360},Gr),Zr=t.e({deceleration:1e3,maxSpeed:90},Gr),Wr=t.e({deceleration:1e3,maxSpeed:360},Gr);class qr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=Xr(i.pan.mag(),n,t.e({},Hr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,Kr(r,o)}if(i.zoom){const e=Xr(i.zoom,n,Qr);r.zoom=this._map.transform.zoom+e.amount,Kr(r,e)}if(i.bearing){const e=Xr(i.bearing,n,$r);r.bearing=this._map.transform.bearing+t.an(e.amount,-179,179),Kr(r,e)}if(i.pitch){const e=Xr(i.pitch,n,Zr);r.pitch=this._map.transform.pitch+e.amount,Kr(r,e)}if(i.roll){const e=Xr(i.roll,n,Wr);r.roll=this._map.transform.roll+t.an(e.amount,-179,179),Kr(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(r,{noMoveStart:!0})}}function Kr(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class eo extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class to{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new eo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Jr(e.type,this._map,e))}mouseup(e){this._map.fire(new Jr(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Jr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Jr(e.type,this._map,e))}mouseover(e){this._map.fire(new Jr(e.type,this._map,e))}mouseout(e){this._map.fire(new Jr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Yr(e.type,this._map,e))}touchmove(e){this._map.fire(new Yr(e.type,this._map,e))}touchend(e){this._map.fire(new Yr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Yr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class io{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Jr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Jr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class no{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class ro{constructor(e,t){this._map=e,this._tr=new no(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&&(u.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(u.remove(this._box),this._box=null),u.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=oo(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=oo(i,t);for(const e in this.touches){const t=n[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 ao{constructor(e){this.singleTap=new so(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class lo{constructor(e){this._tr=new no(e),this._zoomIn=new ao({numTouches:1,numTaps:2}),this._zoomOut=new ao({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(r)},{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}}class co{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)!0}),t=new mo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const _o=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Ao{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=oo(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class Co extends yo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Eo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Eo(e)&&Eo(t)&&o}}const So={panStep:100,bearingStep:15,pitchStep:10};class Bo{constructor(e){this._tr=new no(e);const t=So;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:Io,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:a.center},{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 Io(e){return e*(2-e)}const Mo=4.000244140625,Po=1/450;class Ro{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new no(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Po}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)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Mo==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_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 i=u.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.V.convert(n.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Mo?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),t.at(r*n)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,s=!1;if("wheel"===this._type&&n&&r){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=r(a);o=t.G.number(n,i,l),a<1?this._frameId||(this._frameId=!0):s=!0}else o=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cx;if(this._prevEase){const e=this._prevEase,n=(c()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.cv(o,s,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Lo{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 Fo{constructor(e){this._tr=new no(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ko{constructor(){this._tap=new ao({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Do{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Oo{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class zo{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Uo{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=u.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(u.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const No=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Vo extends t.l{}function jo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Go{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(s,c,a))l.reset();else if(l[i||e.type]){if(t.cy(e,i||e.type)){const t=u.mousePos(this._map.getCanvas(),e);h=l[i||e.type](e,t)}else if(t.cz(e,i||e.type)){const t=this._getMapTouches(e.touches),n=u.touchPos(this._map.getCanvas(),t);h=l[i||e.type](e,n,t)}else t.cA(i||e.type)||(h=l[i||e.type](e));this.mergeHandlerResult(r,o,h,a,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||l.isActive())&&(s[a]=l)}const a={};for(const e in this._previousActiveHandlers)s[e]||(a[e]=n);this._previousActiveHandlers=s,(Object.keys(a).length||jo(r))&&(this._changes.push([r,o,a]),this._triggerRenderFrame()),(Object.keys(s).length||jo(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=r;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)u.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)u.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new to(i,e));const r=i.boxZoom=new ro(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Uo(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new lo(i),a=new Fo(i);i.doubleClickZoom=new Lo(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new ko;this._add("tapDragZoom",l);const c=i.touchPitch=new Co(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const a=new fo({checkCorrectEvent:e=>0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cw(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)});return new co({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:_o})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new fo({checkCorrectEvent:e=>2===u.mouseButton(e)&&e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y0===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:_o})}(e),g=new Ao(e,i);i.dragPan=new Do(n,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new To,A=new bo;i.touchZoomRotate=new zo(n,A,_,l),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new io(i));const y=i.scrollZoom=new Ro(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new Bo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable()}_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=[]}}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 Boolean(No(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(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),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(jo(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||n.transform.centerPoint,o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);this._handleMapControls({terrain:o,tr:r,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:n,combinedEventsInProgress:r,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!r.drag&&!r.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,n)):this._terrainMovement||!r.drag&&!r.zoom?void(r.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,n)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,n));s.handleMapControlsPan(i,t,n)}_fireEvents(e,i,n){const r=No(this._eventsInProgress),o=No(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=No(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ho extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.l("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new t.l("zoomend",e)),r&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const n=t.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(n,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cx},e);const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,s=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(n.width,n.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},S=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},B=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(B)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*B/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==s,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*B,_=1/C(m),A=S(m);this._rotating&&n.setBearing(t.G.number(r,c,a)),this._pitching&&n.setPitch(t.G.number(o,u,a)),this._rolling&&n.setRoll(t.G.number(s,h,a)),this._padding&&(n.interpolatePadding(l,d,a),f=n.centerPoint.add(p)),g.easeFunc(a,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.W(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class $o{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=u.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=u.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=u.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=u.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Zo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=u.create("div","maplibregl-ctrl");const t=u.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){u.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Wo{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){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var qo=t.aT([{name:"a_pos3d",type:"Int16",components:3}]);class Ko extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ee(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.c6(r.terrainRttPosMatrix32f,0,t.a4,t.a4,0,0,1),this._tiles[r.key]=new de(r,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.bj();if(r.canonical.equals(e.canonical))t.c6(s,0,t.a4,t.a4,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<>i<>i;t.c6(s,0,a,a,0,0,1),t.O(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i;t.c6(s,0,t.a4,t.a4,0,0,1),t.O(s,s,[n*a,o*a,0]),t.Q(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.bj();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,n=e.canonical.y-o.canonical.y;t.c6(a,0,t.a4,t.a4,0,0,1),t.O(a,a,[i*t.a4,n*t.a4,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.a4>>i;t.c6(a,0,c,c,0,0,1),t.O(a,a,[-n*c+s*t.a4,-r*c+l*t.a4,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.a4<i.maxzoom&&(n=i.maxzoom),n=i.minzoom&&(!r||!r.dem);)r=this.tileManager.getTileByID(e.scaledTo(n--).key);return r}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Xo{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Ko(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,n,r=t.a4){var o;if(!(i>=0&&i=0&&ne.canonical.z&&(e.canonical.z>=n?r=e.canonical.z-n:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>r<>r<>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.tileManager.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const Yo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class es{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Jo(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),n=e.tileManagers[t].getSource(),r=n instanceof te?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,r);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],n=i.source;if(Yo[i.type]&&!this._coordsAscendingStr[n]){this._coordsAscendingStr[n]={};for(const e in this._coordsAscending[n])this._coordsAscendingStr[n][e]=this._coordsAscending[n][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yo[r]&&(this._prevType&&Yo[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(Yo[this._prevType]||Yo[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(zr(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bo.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,u.mousePos(this.element,e)),u.addEventListener(window,"mousemove",this.mousemove),u.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,u.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),u.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const r=new go;this._rotatePitchHandler=new co({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cw(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,u.addEventListener(i,"mousedown",this.mousedown),u.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),u.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),u.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;u.removeEventListener(e,"mousedown",this.mousedown),u.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend),u.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){u.enableDrag(),u.removeEventListener(window,"mousemove",this.mousemove),u.removeEventListener(window,"mouseup",this.mouseup),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend)}}let ss;function as(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.V(e.lng,e.lat);if(e=new t.V(e.lng,e.lat),i){const r=new t.V(e.lng-360,e.lat),o=new t.V(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const ls={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%)"};function cs(e,t,i){const n=e.classList;for(const e in ls)n.remove(`maplibregl-${i}-anchor-${e}`);n.add(`maplibregl-${i}-anchor-${t}`)}class us extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),u.setTransform(this._element,`${ls[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`),a.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},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._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=u.create("div");const i=u.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=u.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=u.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=u.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=u.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=u.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=u.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const d=u.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=u.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=u.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=u.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=u.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=u.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(a),s.appendChild(c),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),cs(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),u.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,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,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.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 this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const hs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,ps=!1;const fs={maxWidth:100,unit:"metric"};function ms(e,t,i){const n=i&&i.maxWidth||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?gs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):gs(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?gs(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?gs(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):gs(t,c,u,e._getUIString("ScaleControl.Meters"))}function gs(e,t,i,n){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}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r} ${n}`}const _s={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},As=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ys(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ys(new t.P(0,0))}const vs=i;e.AJAXError=t.cI,e.Event=t.l,e.Evented=t.E,e.LngLat=t.V,e.MercatorCoordinate=t.aa,e.Point=t.P,e.addProtocol=t.cJ,e.config=t.a,e.removeProtocol=t.cK,e.AttributionControl=$o,e.BoxZoomHandler=ro,e.CanvasSource=ne,e.CooperativeGesturesHandler=Uo,e.DoubleClickZoomHandler=Lo,e.DragPanHandler=Do,e.DragRotateHandler=Oo,e.EdgeInsets=Ft,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){u.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=u.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);u.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.V(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=Z.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&ps)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=u.create("button","maplibregl-ctrl-geolocate",this._container),u.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=u.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=u.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},hs,e)}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==ss&&!e)return ss;if(void 0===window.navigator.permissions)return ss=!!window.navigator.geolocation,ss;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ss="denied"!==e.state}catch(e){ss=!!window.navigator.geolocation}return ss})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),u.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,ps=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),n=e.distanceTo(i)/100,r=2*this._accuracy/n;this._circleElement.style.width=`${r.toFixed(2)}px`,this._circleElement.style.height=`${r.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("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 t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,ps=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ds++,ds>1?(e={maximumAge:6e5,timeout:0},ps=!0):(e=this.options.positionOptions,ps=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=u.create("button","maplibregl-ctrl-globe",this._container),u.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=jr,e.ImageSource=te,e.KeyboardHandler=Bo,e.LngLatBounds=Z,e.LogoControl=Zo,e.Map=class extends Ho{constructor(e){var i,n;t.cF.mark(t.cG.create);const r=Object.assign(Object.assign(Object.assign({},ns),e),{canvasContextAttributes:Object.assign(Object.assign({},ns.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Vt,s=new Qt;if(void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),null!==r.transformConstrain&&o.setConstrainOverride(r.transformConstrain),super(o,s,{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Wo,this._controls=[],this._mapId=t.ag(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},ts),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,void 0!==r.reduceMotion&&(a.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=_.addThrottleControl(()=>this.isMoving()),this._requestManager=new A(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Vr(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Go(this,r),this._hash=r.hash&&new jr("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const l="string"==typeof r.style||!("globe"===(null===(n=null===(i=r.style)||void 0===i?void 0:i.projection)||void 0===n?void 0:n.type));this.resize(null,l),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new $o("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Zo,r.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const e=t.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Ee(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){const[n,r]=this._containerDimensions(),o=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,o),this.painter.resize(n,r,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,t),this.painter.resize(n,r,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(Z.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),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.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new Jr(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new Jr(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new Jr(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const n=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:e)||{},o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ii(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(null===(n=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const n=this._requestManager.transformRequest(e,"Style");t.j(n,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Xo(this.painter,i,e),this.painter.renderToTexture=new es(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=be(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=be(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.tileManagers[e];if(!n)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.ad(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(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`")));{const{width:n,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:a},new Uint8Array(d)),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:o,height:s,data:l}=r;if(void 0===o||void 0===s)return this.fire(new t.k(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`")));if(o!==n.data.width||s!==n.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return _.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=u.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=u.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=u.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=u.create("div",`maplibregl-ctrl-${e} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Nr(i,this.transform),h.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(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)}_render(e){var i,n,r,o,s;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const n=new t.H(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(u=!0,this._crossFadingFactor=r),this.style.update(n)}const h=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==l;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cF.mark(t.cG.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cF.mark(t.cG.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),_.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),u.remove(this._canvasContainer),u.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cF.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{t.cF.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cH(e)&&!function(e){return e.message===er}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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 version(){return is}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Jr,e.MapTouchEvent=Yr,e.MapWheelEvent=eo,e.Marker=us,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},rs,e),this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=u.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new os(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){u.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=u.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&u.remove(this._content),this._container&&(u.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=u.create("div","maplibregl-popup",this._map.getContainer()),this._tip=u.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const n=ys(this.options.offset);if(!i){const e=this._container.offsetWidth,r=this._container.offsetHeight;let o;o=t.y+n.bottom.ythis._map.transform.height-r?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let r=t.add(n[i]);this.options.subpixelPositioning||(r=r.round()),u.setTransform(this._container,`${ls[i]} translate(${r.x}px,${r.y}px)`),cs(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(_s),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=u.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=u.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(As);e&&e.focus()}},e.RasterDEMTileSource=X,e.RasterTileSource=K,e.ScaleControl=class{constructor(e){this._onMove=()=>{ms(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ms(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fs),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){u.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Ro,e.Style=Ii,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=u.create("button","maplibregl-ctrl-terrain",this._container),u.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){u.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Co,e.TwoFingersTouchRotateHandler=To,e.TwoFingersTouchZoomHandler=bo,e.TwoFingersTouchZoomRotateHandler=zo,e.VectorTileSource=q,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(oe(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{re[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=O;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(F),O=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()"))},e.createTileMesh=ii,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return vs},e.getWorkerCount=function(){return k.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return V().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){U().acquire(F)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){k.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var n=e;return n}();var Ke=He(qe.exports),Xe=e({__proto__:null,default:Ke},[qe.exports]);const Je=[];function Ye(e,i=t){let n;const r=new Set;function o(t){if(a(e,t)&&(e=t,n)){const t=!Je.length;for(const t of r)t[1](),Je.push(t,e);if(t){for(let e=0;e{r.delete(l),0===r.size&&n&&(n(),n=null)}}}}const et=Ye([]),tt=Ye([]),it=Ye([]),nt=Ye(!0),rt=Ye(!0),ot=Ye([]),st=Ye({}),at=e=>{if(!Array.isArray(e))return!1;const t=["id","name","type"],i=e=>{const i=Object.keys(e);return t.filter(e=>!i.includes(e)).length>0};return!(e.filter(e=>"sublist"===e.type?e.presets.every(i):i(e)).length>0)},lt=(e,t)=>Math.round(e*10**t)/10**t;var ct="Expected a function",ut=/^\s+|\s+$/g,ht=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,pt=/^0o[0-7]+$/i,ft=parseInt,mt="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,gt="object"==typeof self&&self&&self.Object===Object&&self,_t=mt||gt||Function("return this")(),At=Object.prototype.toString,yt=Math.max,vt=Math.min,xt=function(){return _t.Date.now()};function bt(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(ct);function p(t){var i=n,o=r;return n=r=void 0,c=t,s=e.apply(o,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function m(){var e=xt();if(f(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-l);return h?vt(i,o-(e-c)):i}(e))}function g(e){return a=void 0,d&&n?p(e):(n=r=void 0,s)}function _(){var e=xt(),i=f(e);if(n=arguments,r=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?p(e):s}(l);if(h)return a=setTimeout(m,t),p(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=Tt(t)||0,wt(i)&&(u=!!i.leading,o=(h="maxWait"in i)?yt(Tt(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=r=a=void 0},_.flush=function(){return void 0===a?s:g(xt())},_}function wt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Tt(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==At.call(e)}(e))return NaN;if(wt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=wt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ut,"");var i=dt.test(e);return i||pt.test(e)?ft(e.slice(2),i?2:8):ht.test(e)?NaN:+e}var Et,Ct=function(e,t,i){var n=!0,r=!0;if("function"!=typeof e)throw new TypeError(ct);return wt(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),bt(e,t,{leading:n,maxWait:t,trailing:r})},St=Object.prototype.toString,Bt=function(e){var t=St.call(e),i="[object Arguments]"===t;return i||(i="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===St.call(e.callee)),i};if(!Object.keys){var It=Object.prototype.hasOwnProperty,Mt=Object.prototype.toString,Pt=Bt,Rt=Object.prototype.propertyIsEnumerable,Lt=!Rt.call({toString:null},"toString"),Ft=Rt.call(function(){},"prototype"),kt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Dt=function(e){var t=e.constructor;return t&&t.prototype===e},Ot={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},zt=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!Ot["$"+e]&&It.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{Dt(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();Et=function(e){var t=null!==e&&"object"==typeof e,i="[object Function]"===Mt.call(e),n=Pt(e),r=t&&"[object String]"===Mt.call(e),o=[];if(!t&&!i&&!n)throw new TypeError("Object.keys called on a non-object");var s=Ft&&i;if(r&&e.length>0&&!It.call(e,0))for(var a=0;a0)for(var l=0;l3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new ei("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new ei("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new ei("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new ei("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,r=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ti&&ti(e,t);if(Jt)Jt(e,t,{configurable:null===o&&a?a.configurable:!o,enumerable:null===n&&a?a.enumerable:!n,value:i,writable:null===r&&a?a.writable:!r});else{if(!s&&(n||r||o))throw new Yt("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=i}},ni=Zt,ri=function(){return!!ni};ri.hasArrayLengthDefineBug=function(){if(!ni)return null;try{return 1!==ni([],"length",{value:1}).length}catch(e){return!0}};var oi=ri,si=Qt,ai="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),li=Object.prototype.toString,ci=Array.prototype.concat,ui=ii,hi=oi(),di=function(e,t,i,n){if(t in e)if(!0===n){if(e[t]===i)return}else if(!function(e){return"function"==typeof e&&"[object Function]"===li.call(e)}(n)||!n())return;hi?ui(e,t,i,!0):ui(e,t,i)},pi=function(e,t){var i=arguments.length>2?arguments[2]:{},n=si(t);ai&&(n=ci.call(n,Object.getOwnPropertySymbols(t)));for(var r=0;r1&&"boolean"!=typeof t)throw new yn('"allowMissing" argument must be a boolean');if(null===Jn(/^%?[^%]*%?$/,e))throw new An("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(e){var t=Xn(e,0,1),i=Xn(e,-1);if("%"===t&&"%"!==i)throw new An("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new An("invalid intrinsic syntax, expected opening `%`");var n=[];return Kn(e,Yn,function(e,t,i,r){n[n.length]=i?Kn(r,er,"$1"):t||e}),n}(e),n=i.length>0?i[0]:"",r=tr("%"+n+"%",t),o=r.name,s=r.value,a=!1,l=r.alias;l&&(n=l[0],qn(i,Wn([0,1],l)));for(var c=1,u=!0;c=i.length){var f=Mn(s,h);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[h]}else u=Zn(s,h),s=s[h];u&&!a&&(jn[o]=s)}}return s},nr=ir,rr=ii,or=oi(),sr=Xt,ar=qt,lr=nr("%Math.floor%"),cr=function(e,t){if("function"!=typeof e)throw new ar("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||lr(t)!==t)throw new ar("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,r=!0;if("length"in e&&sr){var o=sr(e,"length");o&&!o.configurable&&(n=!1),o&&!o.writable&&(r=!1)}return(n||r||!i)&&(or?rr(e,"length",t,!0,!0):rr(e,"length",t)),e},ur=Vi,hr=Gi,dr=$i,pr=function(){return dr(ur,hr,arguments)};!function(e){var t=cr,i=Zt,n=Xi,r=pr;e.exports=function(e){var i=n(arguments),r=e.length-(arguments.length-1);return t(i,1+(r>0?r:0),!0)},i?i(e.exports,"apply",{value:r}):e.exports.apply=r}(gi);var fr=ir,mr=Xi,gr=mr([fr("%String.prototype.indexOf%")]),_r=function(e,t){var i=fr(e,!!t);return"function"==typeof i&&gr(e,".prototype.")>-1?mr([i]):i},Ar=Qt,yr=Pi(),vr=_r,xr=_i,br=vr("Array.prototype.push"),wr=vr("Object.prototype.propertyIsEnumerable"),Tr=yr?xr.getOwnPropertySymbols:null,Er=function(e,t){if(null==e)throw new TypeError("target must be an object");var i=xr(e);if(1===arguments.length)return i;for(var n=1;n2&&!!arguments[2]&&!$r||(Qr?Hr(e,"name",t,!0,!0):Hr(e,"name",t)),e},qr=qt,Kr=Object,Xr=Wr(function(){if(null==this||this!==Kr(this))throw new qr("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),Jr=Xr,Yr=mi.supportsDescriptors,eo=Object.getOwnPropertyDescriptor,to=function(){if(Yr&&"gim"===/a/gim.flags){var e=eo(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var t="",i={};if(Object.defineProperty(i,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(i,"sticky",{get:function(){t+="y"}}),e.get.call(i),"dy"===t)return e.get}}return Jr},io=mi.supportsDescriptors,no=to,ro=Xt,oo=Object.defineProperty,so=Ai,ao=cn,lo=/a/,co=mi,uo=Xr,ho=to,po=function(){if(!io||!ao)throw new so("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=no(),t=ao(lo),i=ro(t,"flags");return i&&i.get===e||oo(t,"flags",{configurable:!0,enumerable:!1,get:e}),e},fo=(0,gi.exports)(ho());co(fo,{getPolyfill:ho,implementation:uo,shim:po});var mo=fo,go=Symbol.iterator,_o=Qe(Object.freeze({__proto__:null,default:{}})),Ao="function"==typeof Map&&Map.prototype,yo=Object.getOwnPropertyDescriptor&&Ao?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,vo=Ao&&yo&&"function"==typeof yo.get?yo.get:null,xo=Ao&&Map.prototype.forEach,bo="function"==typeof Set&&Set.prototype,wo=Object.getOwnPropertyDescriptor&&bo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,To=bo&&wo&&"function"==typeof wo.get?wo.get:null,Eo=bo&&Set.prototype.forEach,Co="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,So="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Bo="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Io=Boolean.prototype.valueOf,Mo=Object.prototype.toString,Po=Function.prototype.toString,Ro=String.prototype.match,Lo=String.prototype.slice,Fo=String.prototype.replace,ko=String.prototype.toUpperCase,Do=String.prototype.toLowerCase,Oo=RegExp.prototype.test,zo=Array.prototype.concat,Uo=Array.prototype.join,No=Array.prototype.slice,Vo=Math.floor,jo="function"==typeof BigInt?BigInt.prototype.valueOf:null,Go=Object.getOwnPropertySymbols,Ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Qo="function"==typeof Symbol&&"object"==typeof Symbol.iterator,$o="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Qo||"symbol")?Symbol.toStringTag:null,Zo=Object.prototype.propertyIsEnumerable,Wo=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function qo(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Oo.call(/e/,t))return t;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-Vo(-e):Vo(e);if(n!==e){var r=String(n),o=Lo.call(t,r.length+1);return Fo.call(r,i,"$&_")+"."+Fo.call(Fo.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Fo.call(t,i,"$&_")}var Ko=_o,Xo=Ko.custom,Jo=as(Xo)?Xo:null,Yo={__proto__:null,double:'"',single:"'"},es={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ts=function e(t,i,n,r){var o=i||{};if(cs(o,"quoteStyle")&&!cs(Yo,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(cs(o,"maxStringLength")&&("number"==typeof o.maxStringLength?o.maxStringLength<0&&o.maxStringLength!==1/0:null!==o.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=!cs(o,"customInspect")||o.customInspect;if("boolean"!=typeof s&&"symbol"!==s)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(cs(o,"indent")&&null!==o.indent&&"\t"!==o.indent&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(cs(o,"numericSeparator")&&"boolean"!=typeof o.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=o.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return ds(t,o);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var l=String(t);return a?qo(t,l):l}if("bigint"==typeof t){var c=String(t)+"n";return a?qo(t,c):c}var u=void 0===o.depth?5:o.depth;if(void 0===n&&(n=0),n>=u&&u>0&&"object"==typeof t)return os(t)?"[Array]":"[Object]";var h=function(e,t){var i;if("\t"===e.indent)i="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;i=Uo.call(Array(e.indent+1)," ")}return{base:i,prev:Uo.call(Array(t+1),i)}}(o,n);if(void 0===r)r=[];else if(hs(r,t)>=0)return"[Circular]";function d(t,i,s){if(i&&(r=No.call(r)).push(i),s){var a={depth:o.depth};return cs(o,"quoteStyle")&&(a.quoteStyle=o.quoteStyle),e(t,a,n+1,r)}return e(t,o,n+1,r)}if("function"==typeof t&&!ss(t)){var p=function(e){if(e.name)return e.name;var t=Ro.call(Po.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),f=As(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Uo.call(f,", ")+" }":"")}if(as(t)){var m=Qo?Fo.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ho.call(t);return"object"!=typeof t||Qo?m:fs(m)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var g="<"+Do.call(String(t.nodeName)),_=t.attributes||[],A=0;A<_.length;A++)g+=" "+_[A].name+"="+is(ns(_[A].value),"double",o);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+=""}if(os(t)){if(0===t.length)return"[]";var y=As(t,d);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(y)?"["+_s(y,h)+"]":"[ "+Uo.call(y,", ")+" ]"}if(function(e){return"[object Error]"===us(e)&&rs(e)}(t)){var v=As(t,d);return"cause"in Error.prototype||!("cause"in t)||Zo.call(t,"cause")?0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Uo.call(v,", ")+" }":"{ ["+String(t)+"] "+Uo.call(zo.call("[cause]: "+d(t.cause),v),", ")+" }"}if("object"==typeof t&&s){if(Jo&&"function"==typeof t[Jo]&&Ko)return Ko(t,{depth:u-n});if("symbol"!==s&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!vo||!e||"object"!=typeof e)return!1;try{vo.call(e);try{To.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var x=[];return xo&&xo.call(t,function(e,i){x.push(d(i,t,!0)+" => "+d(e,t))}),gs("Map",vo.call(t),x,h)}if(function(e){if(!To||!e||"object"!=typeof e)return!1;try{To.call(e);try{vo.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Eo&&Eo.call(t,function(e){b.push(d(e,t))}),gs("Set",To.call(t),b,h)}if(function(e){if(!Co||!e||"object"!=typeof e)return!1;try{Co.call(e,Co);try{So.call(e,So)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return ms("WeakMap");if(function(e){if(!So||!e||"object"!=typeof e)return!1;try{So.call(e,So);try{Co.call(e,Co)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return ms("WeakSet");if(function(e){if(!Bo||!e||"object"!=typeof e)return!1;try{return Bo.call(e),!0}catch(e){}return!1}(t))return ms("WeakRef");if(function(e){return"[object Number]"===us(e)&&rs(e)}(t))return fs(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!jo)return!1;try{return jo.call(e),!0}catch(e){}return!1}(t))return fs(d(jo.call(t)));if(function(e){return"[object Boolean]"===us(e)&&rs(e)}(t))return fs(Io.call(t));if(function(e){return"[object String]"===us(e)&&rs(e)}(t))return fs(d(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||void 0!==Ge&&t===Ge)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===us(e)&&rs(e)}(t)&&!ss(t)){var w=As(t,d),T=Wo?Wo(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",C=!T&&$o&&Object(t)===t&&$o in t?Lo.call(us(t),8,-1):E?"Object":"",S=(T||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(C||E?"["+Uo.call(zo.call([],C||[],E||[]),": ")+"] ":"");return 0===w.length?S+"{}":h?S+"{"+_s(w,h)+"}":S+"{ "+Uo.call(w,", ")+" }"}return String(t)};function is(e,t,i){var n=i.quoteStyle||t,r=Yo[n];return r+e+r}function ns(e){return Fo.call(String(e),/"/g,""")}function rs(e){return!$o||!("object"==typeof e&&($o in e||void 0!==e[$o]))}function os(e){return"[object Array]"===us(e)&&rs(e)}function ss(e){return"[object RegExp]"===us(e)&&rs(e)}function as(e){if(Qo)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Ho)return!1;try{return Ho.call(e),!0}catch(e){}return!1}var ls=Object.prototype.hasOwnProperty||function(e){return e in this};function cs(e,t){return ls.call(e,t)}function us(e){return Mo.call(e)}function hs(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0,n=e.length;it.maxStringLength){var i=e.length-t.maxStringLength,n="... "+i+" more character"+(i>1?"s":"");return ds(Lo.call(e,0,t.maxStringLength),t)+n}var r=es[t.quoteStyle||"single"];return r.lastIndex=0,is(Fo.call(Fo.call(e,r,"\\$1"),/[\x00-\x1f]/g,ps),"single",t)}function ps(e){var t=e.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return i?"\\"+i:"\\x"+(t<16?"0":"")+ko.call(t.toString(16))}function fs(e){return"Object("+e+")"}function ms(e){return e+" { ? }"}function gs(e,t,i,n){return e+" ("+t+") {"+(n?_s(i,n):Uo.call(i,", "))+"}"}function _s(e,t){if(0===e.length)return"";var i="\n"+t.prev+t.base;return i+Uo.call(e,","+i)+"\n"+t.prev}function As(e,t){var i=os(e),n=[];if(i){n.length=e.length;for(var r=0;r=0&&"[object Array]"!==sa(e)&&"callee"in e&&"[object Function]"===sa(e.callee)},ca=function(){return aa(arguments)}();aa.isLegacyArguments=la;var ua,ha=ca?aa:la,da={}.toString,pa=Array.isArray||function(e){return"[object Array]"==da.call(e)},fa=gi.exports,ma=_r,ga=ir("%ArrayBuffer%",!0),_a=ma("ArrayBuffer.prototype.byteLength",!0),Aa=ma("Object.prototype.toString"),ya=!!ga&&!_a&&new ga(0).slice,va=!!ya&&fa(ya),xa=_a||va?function(e){if(!e||"object"!=typeof e)return!1;try{return _a?_a(e):va(e,0),!0}catch(e){return!1}}:ga?function(e){return"[object ArrayBuffer]"===Aa(e)}:function(e){return!1},ba=_r,wa=ba("Date.prototype.getDay"),Ta=ba("Object.prototype.toString"),Ea=ra(),Ca=_r,Sa=ra(),Ba=dn,Ia=Xt;if(Sa){var Ma=Ca("RegExp.prototype.exec"),Pa={},Ra=function(){throw Pa},La={toString:Ra,valueOf:Ra};"symbol"==typeof Symbol.toPrimitive&&(La[Symbol.toPrimitive]=Ra),ua=function(e){if(!e||"object"!=typeof e)return!1;var t=Ia(e,"lastIndex");if(!(t&&Ba(t,"value")))return!1;try{Ma(e,La)}catch(e){return e===Pa}}}else{var Fa=Ca("Object.prototype.toString");ua=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Fa(e)}}var ka=ua,Da=_r("SharedArrayBuffer.prototype.byteLength",!0),Oa=Da?function(e){if(!e||"object"!=typeof e)return!1;try{return Da(e),!0}catch(e){return!1}}:function(e){return!1},za=_r,Ua=za("String.prototype.valueOf"),Na=za("Object.prototype.toString"),Va=ra(),ja=_r,Ga=ja("Number.prototype.toString"),Ha=ja("Object.prototype.toString"),Qa=ra(),$a=_r,Za=$a("Boolean.prototype.toString"),Wa=$a("Object.prototype.toString"),qa=ra(),Ka={exports:{}},Xa=ka,Ja=_r("RegExp.prototype.exec"),Ya=qt,el=_r,tl=el("Object.prototype.toString"),il=function(e){if(!Xa(e))throw new Ya("`regex` must be a RegExp");return function(t){return null!==Ja(e,t)}};if(Fi()){var nl=el("Symbol.prototype.toString"),rl=il(/^Symbol\(.*\)$/);Ka.exports=function(e){if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||"[object Symbol]"!==tl(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&rl(nl(e))}(e)}catch(e){return!1}}}else Ka.exports=function(e){return!1};var ol={exports:{}},sl="undefined"!=typeof BigInt&&BigInt;if("function"==typeof sl&&"function"==typeof BigInt&&"bigint"==typeof sl(42)&&"bigint"==typeof BigInt(42)){var al=BigInt.prototype.valueOf;ol.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return al.call(e),!0}catch(e){}return!1}(e))}}else ol.exports=function(e){return!1};var ll,cl=function(e){return"string"==typeof e||!(!e||"object"!=typeof e)&&(Va?function(e){try{return Ua(e),!0}catch(e){return!1}}(e):"[object String]"===Na(e))},ul=function(e){return"number"==typeof e||!(!e||"object"!=typeof e)&&(Qa?function(e){try{return Ga(e),!0}catch(e){return!1}}(e):"[object Number]"===Ha(e))},hl=function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(qa?function(e){try{return Za(e),!0}catch(e){return!1}}(e):"[object Boolean]"===Wa(e))},dl=Ka.exports,pl=ol.exports,fl="function"==typeof Map&&Map.prototype?Map:null,ml="function"==typeof Set&&Set.prototype?Set:null;fl||(ll=function(e){return!1});var gl=fl?Map.prototype.has:null,_l=ml?Set.prototype.has:null;ll||gl||(ll=function(e){return!1});var Al,yl=ll||function(e){if(!e||"object"!=typeof e)return!1;try{if(gl.call(e),_l)try{_l.call(e)}catch(e){return!0}return e instanceof fl}catch(e){}return!1},vl="function"==typeof Map&&Map.prototype?Map:null,xl="function"==typeof Set&&Set.prototype?Set:null;xl||(Al=function(e){return!1});var bl=vl?Map.prototype.has:null,wl=xl?Set.prototype.has:null;Al||wl||(Al=function(e){return!1});var Tl,El=Al||function(e){if(!e||"object"!=typeof e)return!1;try{if(wl.call(e),bl)try{bl.call(e)}catch(e){return!0}return e instanceof xl}catch(e){}return!1},Cl="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,Sl="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;Cl||(Tl=function(e){return!1});var Bl=Cl?Cl.prototype.has:null,Il=Sl?Sl.prototype.has:null;Tl||Bl||(Tl=function(e){return!1});var Ml=Tl||function(e){if(!e||"object"!=typeof e)return!1;try{if(Bl.call(e,Bl),Il)try{Il.call(e,Il)}catch(e){return!0}return e instanceof Cl}catch(e){}return!1},Pl={exports:{}},Rl=_r,Ll=ir("%WeakSet%",!0),Fl=Rl("WeakSet.prototype.has",!0);if(Fl){var kl=Rl("WeakMap.prototype.has",!0);Pl.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(Fl(e,Fl),kl)try{kl(e,kl)}catch(e){return!0}return e instanceof Ll}catch(e){}return!1}}else Pl.exports=function(e){return!1};var Dl,Ol,zl=yl,Ul=El,Nl=Ml,Vl=Pl.exports,jl=Function.prototype.toString,Gl="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Gl&&"function"==typeof Object.defineProperty)try{Dl=Object.defineProperty({},"length",{get:function(){throw Ol}}),Ol={},Gl(function(){throw 42},null,Dl)}catch(L8){L8!==Ol&&(Gl=null)}else Gl=null;var Hl=/^\s*class\b/,Ql=function(e){try{var t=jl.call(e);return Hl.test(t)}catch(e){return!1}},$l=function(e){try{return!Ql(e)&&(jl.call(e),!0)}catch(e){return!1}},Zl=Object.prototype.toString,Wl="function"==typeof Symbol&&!!Symbol.toStringTag,ql=!(0 in[,]),Kl=function(){return!1};if("object"==typeof document){var Xl=document.all;Zl.call(Xl)===Zl.call(document.all)&&(Kl=function(e){if((ql||!e)&&(void 0===e||"object"==typeof e))try{var t=Zl.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var Jl=Gl?function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Gl(e,null,Dl)}catch(e){if(e!==Ol)return!1}return!Ql(e)&&$l(e)}:function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Wl)return $l(e);if(Ql(e))return!1;var t=Zl.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&$l(e)},Yl=Jl,ec=Object.prototype.toString,tc=Object.prototype.hasOwnProperty;var ic=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],nc="undefined"==typeof globalThis?Ge:globalThis,rc=function(e,t,i){if(!Yl(t))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=i),function(e){return"[object Array]"===ec.call(e)}(e)?function(e,t,i){for(var n=0,r=e.length;n-1?zr(i):i},xc=mo,bc=ir,wc=function(e){if(null!=e&&void 0!==e[go])return e[go]()},Tc=function(){var e,t={assert:function(e){if(!t.has(e))throw new Vs("Side channel does not contain "+js(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,i){e||(e=Hs()),e.set(t,i)}};return t},Ec=ia,Cc=ha,Sc=pa,Bc=xa,Ic=function(e){return"object"==typeof e&&null!==e&&(Ea?function(e){try{return wa(e),!0}catch(e){return!1}}(e):"[object Date]"===Ta(e))},Mc=ka,Pc=Oa,Rc=Qt,Lc=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:cl(e)?"String":ul(e)?"Number":hl(e)?"Boolean":dl(e)?"Symbol":pl(e)?"BigInt":void 0},Fc=function(e){if(e&&"object"==typeof e){if(zl(e))return"Map";if(Ul(e))return"Set";if(Nl(e))return"WeakMap";if(Vl(e))return"WeakSet"}return!1},kc=function(e){if(!e||"object"!=typeof e)return!1;if(!hc){var t=fc(uc(e),8,-1);return mc(pc,t)>-1?t:"Object"===t&&function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{i(e),t=fc(n,1)}catch(e){}}),t}(e)}return lc?function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{"$"+i(e)===n&&(t=fc(n,1))}catch(e){}}),t}(e):null},Dc=function(e){return Ac(e)?_c?_c(e):e.byteLength:NaN},Oc=vc("SharedArrayBuffer.prototype.byteLength",!0),zc=vc("Date.prototype.getTime"),Uc=Object.getPrototypeOf,Nc=vc("Object.prototype.toString"),Vc=bc("%Set%",!0),jc=vc("Map.prototype.has",!0),Gc=vc("Map.prototype.get",!0),Hc=vc("Map.prototype.size",!0),Qc=vc("Set.prototype.add",!0),$c=vc("Set.prototype.delete",!0),Zc=vc("Set.prototype.has",!0),Wc=vc("Set.prototype.size",!0);function qc(e,t,i,n){for(var r,o=wc(e);(r=o.next())&&!r.done;)if(eu(t,r.value,i,n))return $c(e,r.value),!0;return!1}function Kc(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Xc(e,t,i,n,r,o){var s=Kc(i);if(null!=s)return s;var a=Gc(t,s),l=yc({},r,{strict:!1});return!(void 0===a&&!jc(t,s)||!eu(n,a,l,o))&&(!jc(e,s)&&eu(n,a,l,o))}function Jc(e,t,i){var n=Kc(i);return null!=n?n:Zc(t,n)&&!Zc(e,n)}function Yc(e,t,i,n,r,o){for(var s,a,l=wc(e);(s=l.next())&&!s.done;)if(eu(i,a=s.value,r,o)&&eu(n,Gc(t,a),r,o))return $c(e,a),!0;return!1}function eu(e,t,i,n){var r=i||{};if(r.strict?Ec(e,t):e===t)return!0;if(Lc(e)!==Lc(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return r.strict?Ec(e,t):e==t;var o,s=n.has(e),a=n.has(t);if(s&&a){if(n.get(e)===n.get(t))return!0}else o={};return s||n.set(e,o),a||n.set(t,o),function(e,t,i,n){var r,o;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(Nc(e)!==Nc(t))return!1;if(Cc(e)!==Cc(t))return!1;var s=Sc(e),a=Sc(t);if(s!==a)return!1;var l=e instanceof Error,c=t instanceof Error;if(l!==c)return!1;if((l||c)&&(e.name!==t.name||e.message!==t.message))return!1;var u=Mc(e),h=Mc(t);if(u!==h)return!1;if((u||h)&&(e.source!==t.source||xc(e)!==xc(t)))return!1;var d=Ic(e),p=Ic(t);if(d!==p)return!1;if((d||p)&&zc(e)!==zc(t))return!1;if(i.strict&&Uc&&Uc(e)!==Uc(t))return!1;var f=kc(e),m=kc(t);if(f!==m)return!1;if(f||m){if(e.length!==t.length)return!1;for(r=0;r=0;r--)if(b[r]!=w[r])return!1;for(r=b.length-1;r>=0;r--)if(!eu(e[o=b[r]],t[o],i,n))return!1;var T=Fc(e),E=Fc(t);if(T!==E)return!1;if("Set"===T||"Set"===E)return function(e,t,i,n){if(Wc(e)!==Wc(t))return!1;var r,o,s,a=wc(e),l=wc(t);for(;(r=a.next())&&!r.done;)if(r.value&&"object"==typeof r.value)s||(s=new Vc),Qc(s,r.value);else if(!Zc(t,r.value)){if(i.strict)return!1;if(!Jc(e,t,r.value))return!1;s||(s=new Vc),Qc(s,r.value)}if(s){for(;(o=l.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!qc(s,o.value,i.strict,n))return!1}else if(!i.strict&&!Zc(e,o.value)&&!qc(s,o.value,i.strict,n))return!1;return 0===Wc(s)}return!0}(e,t,i,n);if("Map"===T)return function(e,t,i,n){if(Hc(e)!==Hc(t))return!1;var r,o,s,a,l,c,u=wc(e),h=wc(t);for(;(r=u.next())&&!r.done;)if(a=r.value[0],l=r.value[1],a&&"object"==typeof a)s||(s=new Vc),Qc(s,a);else if(void 0===(c=Gc(t,a))&&!jc(t,a)||!eu(l,c,i,n)){if(i.strict)return!1;if(!Xc(e,t,a,l,i,n))return!1;s||(s=new Vc),Qc(s,a)}if(s){for(;(o=h.next())&&!o.done;)if(a=o.value[0],c=o.value[1],a&&"object"==typeof a){if(!Yc(s,e,a,c,i,n))return!1}else if(!(i.strict||e.has(a)&&eu(Gc(e,a),c,i,n)||Yc(s,e,a,c,yc({},i,{strict:!1}),n)))return!1;return 0===Wc(s)}return!0}(e,t,i,n);return!0}(e,t,r,n)}function tu(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&(!(e.length>0&&"number"!=typeof e[0])&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))))}var iu,nu,ru=function(e,t,i){return eu(e,t,i,Tc())};function ou(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function su(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var au=(nu||(nu=1,iu=function e(t,i){if(t===i)return!0;if(t&&i&&"object"==typeof t&&"object"==typeof i){if(t.constructor!==i.constructor)return!1;var n,r,o;if(Array.isArray(t)){if((n=t.length)!=i.length)return!1;for(r=n;0!==r--;)if(!e(t[r],i[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===i.source&&t.flags===i.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===i.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===i.toString();if((n=(o=Object.keys(t)).length)!==Object.keys(i).length)return!1;for(r=n;0!==r--;)if(!Object.prototype.hasOwnProperty.call(i,o[r]))return!1;for(r=n;0!==r--;){var s=o[r];if(!e(t[s],i[s]))return!1}return!0}return t!=t&&i!=i}),iu),lu=su(au);const cu="__googleMapsScriptId";var uu;!function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"}(uu||(uu={}));class hu{constructor({apiKey:e,authReferrerPolicy:t,channel:i,client:n,id:r=cu,language:o,libraries:s=[],mapIds:a,nonce:l,region:c,retries:u=3,url:h="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=i,this.client=n,this.id=r||cu,this.language=o,this.libraries=s,this.mapIds=a,this.nonce=l,this.region=c,this.retries=u,this.url=h,this.version=d,hu.instance){if(!lu(this.options,hu.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(hu.instance.options)}`);return hu.instance}hu.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?uu.FAILURE:this.done?uu.SUCCESS:this.loading?uu.LOADING:uu.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(i=>{i?t(i.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id))return void this.callback();const i={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(i).forEach(e=>!i[e]&&delete i[e]),(null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)||(e=>{let t,i,n,r="The Google Maps JavaScript API",o="google",s="importLibrary",a="__ib__",l=document,c=window;c=c[o]||(c[o]={});const u=c.maps||(c.maps={}),h=new Set,d=new URLSearchParams,p=()=>t||(t=new Promise((s,c)=>ou(this,void 0,void 0,function*(){var p;for(n in yield i=l.createElement("script"),i.id=this.id,d.set("libraries",[...h]+""),e)d.set(n.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[n]);d.set("callback",o+".maps."+a),i.src=this.url+"?"+d,u[a]=s,i.onerror=()=>t=c(Error(r+" could not load.")),i.nonce=this.nonce||(null===(p=l.querySelector("script[nonce]"))||void 0===p?void 0:p.nonce)||"",l.head.append(i)})));u[s]?console.warn(r+" only loads once. Ignoring:",e):u[s]=(e,...t)=>h.add(e)&&p().then(()=>u[s](e,...t))})(i);const n=this.libraries.map(e=>this.importLibrary(e));n.length||n.push(this.importLibrary("core")),Promise.all(n).then(()=>this.callback(),e=>{const t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),!this.loading)if(this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading=!0,this.setScript()}}}function du(e){let i;return{c(){i=b("div"),B(i,"id",e[0]),B(i,"class","map svelte-16c2pp7")},m(e,t){y(e,i,t)},p(e,[t]){1&t&&B(i,"id",e[0])},i:t,o:t,d(e){e&&v(i)}}}function pu(e,t,i){let n,r,{id:o}=t,{bearing:s}=t,{center:a}=t,{pitch:l}=t,{zoom:c}=t,{mapStyle:u}=t,{numberOfMaps:h}=t,{onMapMount:d}=t;it.subscribe(e=>({googleMapsAPIKey:r}=e));const p=H();let f,m={};const g=new hu({apiKey:r,version:"beta"}),_=()=>({bearing:f.getHeading(),center:{lng:f.getCenter().lng(),lat:f.getCenter().lat()},pitch:f.getTilt(),zoom:f.getZoom()-1}),A=()=>{const e=y(_()),t=y(m);return!ru(e,t)},y=e=>({bearing:lt(e.bearing,1),pitch:lt(e.pitch,1),center:{lat:lt(e.center.lat,6),lng:lt(e.center.lng,6)},zoom:lt(e.zoom,2)});return j(()=>{g.load().then(()=>{var t;HTMLCanvasElement.prototype.getContext=(t=HTMLCanvasElement.prototype.getContext,function(e,i){return(i=i||{}).preserveDrawingBuffer=!0,t.call(this,e,i)}),i(8,f=new google.maps.Map(document.getElementById(o),{center:m.center,zoom:m.zoom,mapId:n,disableDefaultUI:!0,isFractionalZoomEnabled:!0,fullscreenControl:!1,zoomControl:!1})),d(f);const r=Ct(()=>{document.getElementById(o).querySelector('div[tabindex="0"]').focus()},250);document.getElementById(o).addEventListener("wheel",r,{passive:!0}),f.addListener("center_changed",e),f.addListener("heading_changed",e),f.addListener("tilt_changed",e),f.addListener("zoom_changed",e)});const e=()=>{document.getElementById(o).contains(document.activeElement)&&A()&&p("mapMove",{options:_()})}}),e.$$set=e=>{"id"in e&&i(0,o=e.id),"bearing"in e&&i(1,s=e.bearing),"center"in e&&i(2,a=e.center),"pitch"in e&&i(3,l=e.pitch),"zoom"in e&&i(4,c=e.zoom),"mapStyle"in e&&i(5,u=e.mapStyle),"numberOfMaps"in e&&i(6,h=e.numberOfMaps),"onMapMount"in e&&i(7,d=e.onMapMount)},e.$$.update=()=>{if(32&e.$$.dirty&&(n=u?.mapId),30&e.$$.dirty&&i(9,m={bearing:s,center:a,pitch:l,zoom:c}),768&e.$$.dirty&&(e=>{e&&A()&&e.moveCamera({center:{lat:a.lat,lng:a.lng},zoom:c+1,heading:s,tilt:l})})(f),321&e.$$.dirty&&f&&h){const e=document.getElementById(o);if(e){new ResizeObserver(()=>{google.maps.event.trigger(f,"resize")}).observe(e)}}},[o,s,a,l,c,u,h,d,f,m]}class fu extends ge{constructor(e){super(),me(this,e,pu,du,a,{id:0,bearing:1,center:2,pitch:3,zoom:4,mapStyle:5,numberOfMaps:6,onMapMount:7})}}const mu=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},gu=e=>{if(!e)return!1;let t;try{t=new URL(e)}catch(e){return!1}return"api.maptiler.com"===t.host&&!t.searchParams.has("key")},_u=(e,t)=>{const{mapboxKey:i,maptilerKey:n}=t;let r=e;return mu(e)&&i?r=((e,t)=>{if(!mu(e))return e;if(!t)return e;const[,,,i,n]=e.split("/");return`https://api.mapbox.com/styles/v1/${i}/${n}?title=true&access_token=${t}`})(r,i):gu(e)&&n&&(r=((e,t)=>{if(!t)return e;let i=new URL(e);return t&&gu(e)&&i.searchParams.append("key",t),i.toString()})(r,n)),r};let Au,yu;it.subscribe(e=>({mapboxGlAccessToken:Au,maptilerApiKey:yu}=e));const vu=async e=>{const t=mu(e);let i,n=e;try{n=new URL(e);const t={mapboxKey:Au,maptilerKey:yu};n=_u(n.toString(),t)}catch(e){}try{i=await fetch(n)}catch(e){throw{message:e.message}}if(!i.ok)throw{status:i.status,message:i.statusText};const r=await i.json();if(t&&r.message)throw{message:r.message};return r},xu=(e,t,i)=>e.replace("{branch}",t).replace("{style}",i),bu=["swipe","mirror","phone","responsive"];async function wu(e,t,i,n){return n._parse(e,t,i,n)}function Tu(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Eu=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Cu="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Cu&&parseFloat(Cu[1]);const Su=globalThis,Bu=globalThis.process||{},Iu=globalThis.navigator||{};function Mu(e){if("undefined"!=typeof window&&"renderer"===window.process?.type)return!0;if("undefined"!=typeof process&&Boolean(process.versions?.electron))return!0;const t="undefined"!=typeof navigator&&navigator.userAgent,i=e||t;return Boolean(i&&i.indexOf("Electron")>=0)}function Pu(){return!("object"==typeof process&&"[object process]"===String(process)&&!process?.browser)||Mu()}const Ru="4.1.0";class Lu{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}var Fu;!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Fu||(Fu={}));function ku(e){return"string"!=typeof e?e:(e=e.toUpperCase(),Fu[e]||Fu.WHITE)}function Du(e,t){if(!e)throw new Error(t||"Assertion failed")}function Ou(){let e;if(Pu()&&Su.performance)e=Su?.performance?.now?.();else if("hrtime"in Bu){const t=Bu?.hrtime?.();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const zu={debug:Pu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Uu={enabled:!0,level:0};function Nu(){}const Vu={},ju={once:!0};class Gu{constructor({id:e}={id:""}){this.VERSION=Ru,this._startTs=Ou(),this._deltaTs=Ou(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Lu(`__probe-${this.id}__`,Uu),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(i),r=e;for(const i of n){const n=r[i];"function"==typeof n&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ou()-this._startTs).toPrecision(10))}getDelta(){return Number((Ou()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,zu.warn,arguments,ju)}error(e){return this._getLogFunction(0,e,zu.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,zu.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,zu.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,zu.debug||zu.info,arguments,ju)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Nu,i&&[i],{tag:$u(t)}):Nu}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Nu)}group(e,t,i={collapsed:!1}){const n=Qu({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Nu)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Hu(e)}_getLogFunction(e,t,i,n,r){if(this._shouldLog(e)){r=Qu({logLevel:e,message:t,args:n,opts:r}),Du(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Ou();const o=r.tag||r.message;if(r.once&&o){if(Vu[o])return Nu;Vu[o]=Ou()}return t=function(e,t,i){if("string"==typeof t){const n=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return`${" ".repeat(i)}${e}`}(function(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}(i.total)):"";t=function(e,t,i){Pu||"string"!=typeof e||(t&&(e=`[${ku(t)}m${e}`),i&&(e=`[${ku(i)+10}m${e}`));return e}(t=i.time?`${e}: ${n} ${t}`:`${e}: ${t}`,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Nu}}function Hu(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Du(Number.isFinite(t)&&t>=0),t}function Qu(e){const{logLevel:t,message:i}=e;e.logLevel=Hu(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&n.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Du("string"===r||"object"===r),Object.assign(e,{args:n},e.opts)}function $u(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}Gu.VERSION=Ru,globalThis.probe={};var Zu=new Gu({id:"@probe.gl/log"});const Wu="4.3.3",qu=Wu[0]>="0"&&Wu[0]<="9"?`v${Wu}`:"";const Ku=function(){const e=new Gu({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=qu,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function Xu(e,t){return Ju(e||{},t)}function Ju(e,t,i=0){if(i>3)return t;const n={...e};for(const[e,r]of Object.entries(t))r&&"object"==typeof r&&!Array.isArray(r)?n[e]=Ju(n[e]||{},t[e],i+1):n[e]=t[e];return n}function Yu(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const eh="object"!=typeof process||"[object process]"!==String(process)||process.browser,th="undefined"!=typeof window&&void 0!==window.orientation,ih="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ih&&parseFloat(ih[1]);class nh{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Yu(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Yu(this.isRunning),this.isRunning=!1,this._reject(e)}}class rh{terminate(){}}const oh=new Map;function sh(e){Yu(e.source&&!e.url||!e.source&&e.url);let t=oh.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return ah((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),oh.set(e.url,t)),e.source&&(t=ah(e.source),oh.set(e.source,t))),Yu(t),t}function ah(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function lh(e,t=!0,i){const n=i||new Set;if(e){if(ch(e))n.add(e);else if(ch(e.buffer))n.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)lh(e[i],t,n)}else;return void 0===i?Array.from(n):[]}function ch(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const uh=()=>{};class hh{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&eh||void 0!==rh&&!eh}constructor(e){const{name:t,source:i,url:n}=e;Yu(i||n),this.name=t,this.source=i,this.url=n,this.onMessage=uh,this.onError=e=>console.log(e),this.worker=eh?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=uh,this.onError=uh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||lh(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=sh({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new rh(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new rh(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class dh{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return hh.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new nh(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!eh||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class fh{props;workerPools=new Map;static _workerFarm;static isSupported(){return hh.isSupported()}static getWorkerFarm(e={}){return fh._workerFarm=fh._workerFarm||new fh({}),fh._workerFarm.setProps(e),fh._workerFarm}constructor(e){this.props={...ph},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:n}=e;let r=this.workerPools.get(t);return r||(r=new dh({name:t,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}async function mh(e,t,i,n,r){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},n=eh?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r=eh?`modules/${e.module}/dist/${n}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${n}`}return Yu(r),r}(e,i),a=fh.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await a.startJob("process-on-worker",gh.bind(null,r));l.postMessage("process",{input:t,options:i,context:n});const c=await l.result;return await c.result}async function gh(e,t,i,n){switch(i){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:r,input:o,options:s}=n;try{const i=await e(o,s);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function _h(e,t,i){if(e.byteLength<=t+i)return"";const n=new DataView(e);let r="";for(let e=0;ee instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(i);let r=0;for(const e of t)n.set(e,r),r+=e.byteLength;return n.buffer}(e)}function vh(...e){const t=e,i=t&&t.length>1&&t[0].constructor||null;if(!i)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');const n=new i(t.reduce((e,t)=>e+t.length,0));let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}function xh(e,t,i){const n=void 0!==i?new Uint8Array(e).subarray(t,t+i):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}function bh(e,t){return Tu(e>=0),Tu(t>0),e+(t-1)&~(t-1)}function wh(e,t,i){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(n,i),i+bh(n.byteLength,4)}function Th(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Eh{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Th(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Th()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Ch{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:i}=e;let n=this.stats[t];return n||(n=e instanceof Eh?e:new Eh(t,i),this.stats[t]=n),n}}const Sh={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class Bh{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...Sh,...e},this.stats=new Ch({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const i={handle:e,priority:0,getPriority:t},n=new Promise(e=>(i.resolve=e,i));return this.requestQueue.push(i),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:i}=e;let n=!1;const r=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:r}):Promise.resolve({done:r})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;te.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}const Ih={};function Mh(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Ph(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Rh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function Lh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function Fh(...e){const t=[];for(let i=0;i=-1&&!r;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=Ph()),o=i),0!==o.length&&(n=`${o}/${n}`,r=o.charCodeAt(0)===kh)}return n=function(e,t){let i,n="",r=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=n.length-1;let t=e;for(;t>=0&&n.charCodeAt(t)!==kh;--t);if(t!==e){n=-1===t?"":n.slice(0,t),r=a,o=0,s=!1;continue}}else if(2===n.length||1===n.length){n="",r=a,o=0,s=!1;continue}t&&(n.length>0?n+="/..":n="..",s=!0)}else{const t=e.slice(r+1,a);n.length>0?n+=`/${t}`:n=t,s=!1}r=a,o=0}else i===Dh&&-1!==o?++o:o=-1}return n}(n,!r),r?`/${n}`:n.length>0?n:"."}const kh=47,Dh=46;const Oh=e=>"function"==typeof e,zh=e=>null!==e&&"object"==typeof e,Uh=e=>zh(e)&&e.constructor==={}.constructor,Nh=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,Vh=e=>"undefined"!=typeof Blob&&e instanceof Blob,jh=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||zh(e)&&Oh(e.tee)&&Oh(e.cancel)&&Oh(e.getReader))(e)||(e=>zh(e)&&Oh(e.read)&&Oh(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class Gh extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const Hh=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Qh=/^([-\w.]+\/[-\w.+]+)/;function $h(e,t){return e.toLowerCase()===t.toLowerCase()}function Zh(e){const t=Hh.exec(e);return t?t[1]:""}const Wh=/\?.*/;function qh(e){return e.replace(Wh,"")}function Kh(e){if(Nh(e)){return e.url}if(Vh(e)){return e.name||""}return"string"==typeof e?e:""}function Xh(e){if(Nh(e)){const t=e,i=t.headers.get("content-type")||"",n=qh(t.url);return function(e){const t=Qh.exec(e);return t?t[1]:e}(i)||Zh(n)}if(Vh(e)){return e.type||""}return"string"==typeof e?Zh(e):""}async function Jh(e){if(Nh(e))return e;const t={},i=function(e){if(Nh(e))return e.headers["content-length"]||-1;if(Vh(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const n=Kh(e),r=Xh(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const n={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");n.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(e){}return new Gh(i,n)}(e);throw t}}async function ed(e,t){if("string"==typeof e){const i=function(e){for(const t in Ih)if(e.startsWith(t)){const i=Ih[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await Jh(e)}const td=new Gu({id:"loaders.gl"});class id{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const nd={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Eu,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},rd={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function od(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function sd(){const e=od();return e.globalOptions=e.globalOptions||{...nd},e.globalOptions}function ad(e,t,i,n){return i=i||[],function(e,t){ld(e,null,nd,rd,t);for(const i of t){const n=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ld(n,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const n=e.options||{},r={...n};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(r,i),null===r.log&&(r.log=new id);return ud(r,sd()),ud(r,t),r}(t,e,n)}function ld(e,t,i,n,r){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&zh(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in n)td.warn(`${o} loader option '${s}${a}' no longer supported, use '${n[a]}'`)();else if(!l){const e=cd(a,r);td.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function cd(e,t){const i=e.toLowerCase();let n="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(n=n||`Did you mean '${r.id}.${t}'?`)}return n}function ud(e,t){for(const i in t)if(i in t){const n=t[i];Uh(n)&&Uh(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function hd(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function dd(e){let t;return Tu(e,"null loader"),Tu(hd(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const pd=()=>{const e=od();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const fd=/\.([^.]+)$/;function md(e,t=[],i,n){if(!gd(e))return null;if(t&&!Array.isArray(t))return dd(t);let r=[];t&&(r=r.concat(t)),i?.ignoreRegisteredLoaders||r.push(...pd()),function(e){for(const t of e)dd(t)}(r);const o=function(e,t,i,n){const r=Kh(e),o=Xh(e),s=qh(r)||n?.url;let a=null,l="";i?.mimeType&&(a=Ad(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&fd.exec(t),n=i&&i[1];return n?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,n):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||Ad(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(yd(t,i))return i}else if(ArrayBuffer.isView(t)){if(vd(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(vd(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${xd(e)}`:""),i?.fallbackMimeType&&(a=a||Ad(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&Ku.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,r,i,n);if(!o&&!i?.nothrow)throw new Error(_d(e));return o}function gd(e){return!(e instanceof Response&&204===e.status)}function _d(e){const t=Kh(e),i=Xh(e);let n="No valid loader found (";n+=t?`${Rh(t)}, `:"no url provided, ",n+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const r=e?xd(e):"";return n+=r?` first bytes: "${r}"`:"first bytes: not available",n+=")",n}function Ad(e,t){for(const i of e){if(i.mimeTypes?.some(e=>$h(t,e)))return i;if($h(t,`application/x.${i.id}`))return i}return null}function yd(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function vd(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,n){if(n instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+n)),i}throw new Error(Sd)}(e,t);if(Vh(e)&&(e=await Jh(e)),Nh(e)){const i=e;return await Yh(i),t.binary?await i.arrayBuffer():await i.text()}if(jh(e)&&(e=Cd(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return yh(...t)}(e);throw new Error(Sd)}function Id(e,t){const i=sd(),n=e||i;return"function"==typeof n.fetch?n.fetch:zh(n.fetch)?e=>ed(e,n.fetch):t?.fetch?t?.fetch:ed}function Md(e,t,i){if(i)return i;const n={fetch:Id(t,e),...e};if(n.url){const e=qh(n.url);n.baseUrl=e,n.queryString=function(e){const t=e.match(Wh);return t&&t[0]}(n.url),n.filename=Rh(e),n.baseUrl=Lh(e)}return Array.isArray(n.loaders)||(n.loaders=null),n}async function Pd(e,t,i,n){!t||Array.isArray(t)||hd(t)||(n=void 0,i=t,t=void 0),i=i||{};const r=Kh(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,n),s=await async function(e,t=[],i,n){if(!gd(e))return null;let r=md(e,t,{...i,nothrow:!0},n);if(r)return r;if(Vh(e)&&(r=md(e=await e.slice(0,10).arrayBuffer(),t,i,n)),!r&&!i?.nothrow)throw new Error(_d(e));return r}(e,o,i);return s?(n=Md({url:r,_parse:Pd,loaders:o},i=ad(i,s,o,r),n||null),await async function(e,t,i,n){if(function(e){wd(e,"no worker provided");const t=e.version}(e),i=Xu(e.options,i),Nh(t)){const e=t,{ok:i,redirected:r,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:i,redirected:r,status:o,statusText:s,type:a,url:l}}t=await Bd(t,e,i);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,i,n);if(function(e,t){return!!fh.isSupported()&&!(!eh&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await mh(e,t,i,n,Pd);if(r.parseText&&"string"==typeof t)return await r.parseText(t,i,n);if(r.parse)return await r.parse(t,i,n);throw wd(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,n)):null}function Rd(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=c>o?c:o,s=u>s?u:s}return[[t,i,n],[r,o,s]]}function Ld(e,t,i){const n=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),r=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:r}}async function Fd(e,t,i,n){let r,o;Array.isArray(t)||hd(t)?(r=t,o=i):(r=[],o=t);const s=Id(o);let a=e;return"string"==typeof e&&(a=await s(e)),Vh(e)&&(a=await s(e)),Array.isArray(r),await Pd(a,r,o)}const kd=globalThis.loaders?.parseImageNode,Dd="undefined"!=typeof Image,Od="undefined"!=typeof ImageBitmap,zd=Boolean(kd),Ud=!!Eu||zd;function Nd(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}function Vd(e){switch(Nd(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}const jd=/^data:image\/svg\+xml/,Gd=/\.svg((\?|#).*)?$/;function Hd(e){return e&&(jd.test(e)||Gd.test(e))}function Qd(e,t){if(Hd(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function $d(e,t,i){const n=function(e,t){if(Hd(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Qd(e,t)}(e,i),r=self.URL||self.webkitURL,o="string"!=typeof n&&r.createObjectURL(n);try{return await async function(e,t){const i=new Image;if(i.src=e,t.image&&t.image.decode&&i.decode)return await i.decode(),i;return await new Promise((e,t)=>{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||n,t)}finally{o&&r.revokeObjectURL(o)}}const Zd={};let Wd=!0;async function qd(e,t,i){let n;if(Hd(i)){n=await $d(e,t,i)}else n=Qd(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Zd)return!1;return!0}(t)&&Wd||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Wd=!1}return await createImageBitmap(e)}(n,r)}function Kd(e){return function(e,t,i=0){const n=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t=24&&2303741511===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,Xd),height:t.getUint32(20,Xd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=3&&65496===t.getUint16(0,Xd)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,Jd),height:t.getUint16(8,Jd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=14&&16973===t.getUint16(0,Xd)&&t.getUint32(2,Jd)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Jd),height:t.getUint32(22,Jd)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=Kd(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function ep(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const tp={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.3.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const n=((t=t||{}).image||{}).type||"auto",{url:r}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(Od)return"imagebitmap";if(Dd)return"image";if(Ud)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Od||Dd||Ud;case"imagebitmap":return Od;case"image":return Dd;case"data":return Ud;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n);let s;switch(o){case"imagebitmap":s=await qd(e,t,r);break;case"image":s=await $d(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Yd(e)||{},i=globalThis.loaders?.parseImageNode;return Tu(i),await i(e,t)}(e);break;default:Tu(!1)}return"data"===n&&(s=Vd(s)),s},tests:[e=>Boolean(Yd(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},ip={};function np(e){if(void 0===ip[e]){const t=Eu?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&i.includes(e)}(e);ip[e]=t}return ip[e]}var rp=new Gu({id:"deck"});const op={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]};let sp={};function ap(e){sp=e}function lp(e,t,i,n){rp.level>0&&sp[e]&&sp[e].call(null,t,i,n)}sp=(e=>({"layer.changeFlag":(t,i,n)=>{e.log(3,`${t.id} ${i}: `,n[i])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,i)=>{if(i){const i=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(i).filter(e=>i[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,i)=>{i&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,i,n)=>{i?e.log(2,`Composite layer rendered new subLayers ${t}`,n)():e.log(4,`Composite layer reused subLayers ${t}`,n)()},"layerManager.setLayers":(t,i,n)=>{i&&e.log(2,`Updating ${n.length} deck layers`)()},"layerManager.activateViewport":(t,i)=>{e.log(3,"Viewport changed",i)()},"attributeManager.invalidate":(t,i,n)=>{e.log(1,n?`invalidated attributes ${n} (${i}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{op.attributeUpdateMessages.length=0,op.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,i)=>{const n=Math.round(Date.now()-op.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${i} instances in ${t.id} in ${n}ms`)();for(const t of op.attributeUpdateMessages)e.log(3,t)();e.groupEnd(2)()},"attribute.updateStart":e=>{op.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const i=`${e.id} allocated ${t}`;op.attributeUpdateMessages.push(i)},"attribute.updateEnd":(e,t)=>{const i=Math.round(Date.now()-op.attributeUpdateStart),n=`${e.id} updated ${t} in ${i}ms`;op.attributeUpdateMessages.push(n)},"deckRenderer.renderLayers":(t,i,n)=>{const{pass:r,redrawReason:o,stats:s}=n;for(const n of i){const{totalCount:i,visibleCount:a,compositeCount:l,pickableCount:c}=n,u=i-l-a;e.log(2,`RENDER #${t.renderCount} ${a} (of ${i} layers) to ${r} because ${o} (${u} hidden, ${l} composite ${c} pickable)`)(),s&&s.get("Redraw Layers").add(a)}}}))(rp);var cp={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],i=e[e.length-1];return"{"===t&&"}"===i||"["===t&&"]"===i},parseTextSync:JSON.parse};const up=function(){const e="9.0.41",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(rp.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:rp,_registerLoggers:ap},function(e){const t=pd();e=Array.isArray(e)?e:[e];for(const i of e){const e=dd(i);t.find(t=>e===t)||t.unshift(e)}}([cp,[tp,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function hp(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const dp={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function pp(e){let t=fp(e);if("object"!==t)return{value:e,...dp[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...dp[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=fp(e.value),{...e,...dp[t],type:t}):{type:"object",value:null};throw new Error("props")}function fp(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const mp={vertex:"#ifdef MODULE_LOGDEPTH\nlogdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\ngl_FragColor = material_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_LIGHTING\ngl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_FOG\ngl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_PICKING\ngl_FragColor = picking_filterHighlightColor(gl_FragColor);\ngl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n#ifdef MODULE_LOGDEPTH\nlogdepth_setFragDepth();\n#endif\n"},gp=/void\s+main\s*\([^)]*\)\s*\{\n?/,_p=/}\n?[^{}]*$/,Ap=[],yp="__LUMA_INJECT_DECLARATIONS__";function vp(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function xp(e,t,i,n=!1){const r="vertex"===t;for(const t in i){const n=i[t];n.sort((e,t)=>e.order-t.order),Ap.length=n.length;for(let e=0,t=n.length;ee+o));break;case"vs:#main-end":r&&(e=e.replace(_p,e=>o+e));break;case"fs:#decl":r||(e=e.replace(yp,o));break;case"fs:#main-start":r||(e=e.replace(gp,e=>e+o));break;case"fs:#main-end":r||(e=e.replace(_p,e=>o+e));break;default:e=e.replace(t,e=>e+o)}}return e=e.replace(yp,""),n&&(e=e.replace(/\}\s*$/,e=>e+mp[t])),e}let bp=1;class wp{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(e=>{if(e instanceof wp)return e;hp("string"!=typeof e,`Shader module use by name is deprecated. Import shader module '${JSON.stringify(e)}' and use it directly.`),e.name||(console.warn("shader module has no name"),e.name="shader-module-"+bp++);const t=new wp(e);return t.dependencies=wp.instantiateModules(e.dependencies||[]),t})}constructor(e){const{name:t,vs:i,fs:n,dependencies:r=[],uniformTypes:o={},uniformPropTypes:s={},getUniforms:a,deprecations:l=[],defines:c={},inject:u={}}=e;hp("string"==typeof t),this.name=t,this.vs=i,this.fs=n,this.getModuleUniforms=a,this.dependencies=wp.instantiateModules(r),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=c,this.injections=function(e){const t={vertex:{},fragment:{}};for(const i in e){let n=e[i];"string"==typeof n&&(n={order:0,injection:n}),t[vp(i)][i]=n}return t}(u),this.uniformTypes=o,s&&(this.uniforms=function(e){const t={};for(const[i,n]of Object.entries(e))t[i]=pp(n);return t}(s))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:hp(!1)}const i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------\n\n#define MODULE_${i}\n${t}\n\n`}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):function(e,t,i){const n={};for(const[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&hp(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}_defaultGetUniforms(e={}){const t={},i=this.uniforms;for(const n in i){const r=i[n];n in e&&!r.private?(r.validate&&hp(r.validate(e[n],r),`${this.name}: invalid ${n}`),t[n]=e[n]):t[n]=r.value}return t}}function Tp(e){if(e.source&&"webgpu"===e.platformInfo.type){return{...e,vs:void 0,fs:void 0}}if(!e.vs)throw new Error("no vertex shader");const t=Ep(e.platformInfo,e.vs);let i;return e.fs&&(i=Ep(e.platformInfo,e.fs)),{...e,vs:t,fs:i}}function Ep(e,t){if("string"==typeof t)return t;if("webgpu"===e.type){if(t?.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders")}if(t?.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}function Cp(e){return function(e){const t={},i={};return Sp({modules:e,level:0,moduleMap:t,moduleDepth:i}),Object.keys(i).sort((e,t)=>i[t]-i[e]).map(e=>t[e])}(wp.instantiateModules(e))}function Sp(e){const{modules:t,level:i,moduleMap:n,moduleDepth:r}=e;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)n[e.name]=e,(void 0===r[e.name]||r[e.name]e.order-t.order);for(const t of e)i+=` ${t.injection}\n`}r.footer&&(i+=` ${r.footer}`),i+="}\n"}return i}function Fp(e){const t={vertex:{},fragment:{}};for(const i of e){let e,n;"string"!=typeof i?(e=i,n=e.hook):(e={},n=i),n=n.trim();const[r,o]=n.split(":"),s=n.replace(/\(.+/,""),a=Object.assign(e,{signature:o});switch(r){case"vs":t.vertex[s]=a;break;case"fs":t.fragment[s]=a;break;default:throw new Error(r)}}return t}function kp(e,t="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function Dp(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const Op=`\n\n${yp}\n`;function zp(e,t){const{source:i,stage:n,modules:r,hookFunctions:o=[],inject:s={},log:a}=t;hp("string"==typeof i,"shader source must be a string");const l=i;let c="";const u=Fp(o),h={},d={},p={};for(const e in s){const t="string"==typeof s[e]?{injection:s[e],order:0}:s[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?d[e]=[t]:p[e]=[t]:h[e]=[t]}else p[e]=[t]}const f="webgpu"!==e.type?r:[];for(const e of f){a&&e.checkDeprecations(l,a);c+=e.getModuleSource(n,"wgsl");const t=e.injections[n];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?d:p;n[e]=n[e]||[],n[e].push(t[e])}else h[e]=h[e]||[],h[e].push(t[e])}}return c+=Op,c=xp(c,n,d),c+=Lp(u[n],h),c+=l,c=xp(c,n,p),c}function Up(e,t){const{id:i,source:n,stage:r,language:o="glsl",modules:s,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:h}=t;hp("string"==typeof n,"shader source must be a string");const d="glsl"===o?function(e,t){return{name:kp(e,t),language:"glsl",version:Dp(e)}}(n).version:-1,p=e.shaderLanguageVersion,f=100===d?"#version 100":"#version 300 es",m=n.split("\n").slice(1).join("\n"),g={};s.forEach(e=>{Object.assign(g,e.getDefines())}),Object.assign(g,a);let _="";switch(o){case"wgsl":break;case"glsl":_=u?`${f}\n\n// ----- PROLOGUE -------------------------\n${function(e){const{id:t,source:i,stage:n}=e,r=t&&-1===i.indexOf("SHADER_NAME");return r?`\n#define SHADER_NAME ${t}_${n}\n\n`:""}({id:i,source:n,stage:r})}\n#define SHADER_TYPE_${r.toUpperCase()}\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const i in e){const n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}\n`)}return t}(g)}\n\n`:`${f}\n`}const A=Fp(l),y={},v={},x={};for(const e in c){const t="string"==typeof c[e]?{injection:c[e],order:0}:c[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?v[e]=[t]:x[e]=[t]:y[e]=[t]}else x[e]=[t]}for(const e of s){h&&e.checkDeprecations(m,h);_+=e.getModuleSource(r);const t=e.injections[r];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?v:x;n[e]=n[e]||[],n[e].push(t[e])}else y[e]=y[e]||[],y[e].push(t[e])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Op,_=xp(_,r,v),_+=Lp(A[r],y),_+=m,_=xp(_,r,x),"glsl"===o&&d!==p&&(_=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Pp(e,Ip);case"fragment":return Pp(e,Mp);default:throw new Error(t)}}(_,r)),_.trim()}function Np(e){return function(t){const i={};for(const n of e){const e=n.getUniforms(t,i);Object.assign(i,e)}return i}}class Vp{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Vp.defaultShaderAssembler=Vp.defaultShaderAssembler||new Vp,Vp.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,n=Tp(e),r=function(e){const t=Cp(e.modules||[]);return{source:zp(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:Np(t)}}({platformInfo:e.platformInfo,...n,modules:t,hookFunctions:i});return{...r,modules:t}}assembleShaderPair(e){const t=Tp(e),i=this._getModuleList(e.modules),n=this._hookFunctions,{platformInfo:r}=e,o="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=Cp(e.modules||[]);return{vs:zp(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:zp(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:Np(t)}}({platformInfo:r,...t,modules:i,hookFunctions:n}):function(e){const{vs:t,fs:i}=e,n=Cp(e.modules||[]);return{vs:Up(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:Up(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:Np(n)}}({platformInfo:r,...t,modules:i,hookFunctions:n});return{...o,modules:i}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let n=0;for(let e=0,r=this._defaultModules.length;eGp.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=Qp;constructor(e){this.props={...lf.defaultProps,...e},this.id=this.props.id||Wp(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Hp;_lumaData={};isTextureFormatCompressed(e){return t=e,tf.some(e=>t.startsWith(e));var t}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||"string"==typeof e)&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};return(e.usage||0)&Xp.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":Gp.warn("indices buffer content must be of integer type")()),t}}function cf(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const uf=new Map;class hf{static defaultProps={...lf.defaultProps,type:"best-available",devices:void 0};static stats=Hp;static log=Gp;static registerDevices(e){for(const t of e)cf(t.type&&t.isSupported&&t.create),uf.set(t.type,t)}static getAvailableDevices(){return Array.from(uf).map(e=>e.type)}static getSupportedDevices(){return Array.from(uf).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(lf.defaultProps,e)}static async attachDevice(e){const t=df(e.devices)||uf;if(e.handle instanceof WebGL2RenderingContext){const i=t.get("webgl");if(i)return await i.attach(e.handle)}if(null===e.handle){const e=t.get("unknown");if(e)return await e.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){(e={...hf.defaultProps,...e}).gl&&(e.type="webgl");const t=df(e.devices)||uf;let i,n;switch(e.type){case"webgpu":if(i=t.get("webgpu"),i)return await i.create(e);break;case"webgl":if(n=t.get("webgl"),n)return await n.create(e);break;case"unknown":const r=t.get("unknown");if(r)return await r.create(e);break;case"best-available":if(i=t.get("webgpu"),i?.isSupported?.())return await i.create(e);if(n=t.get("webgl"),n?.isSupported?.())return await n.create(e)}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){return"webgl"===e||"experimental-webgl"===e?this.originalGetContext("webgl2",t):this.originalGetContext(e,t)}}}function df(e){if(!e||0===e?.length)return null;const t=new Map;for(const i of e)t.set(i.type,i);return t}const pf=Pu()&&"undefined"!=typeof document,ff=()=>pf&&"complete"===document.readyState,mf={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"};class gf{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ff()}static pageLoaded=function(){if(ff()||"undefined"==typeof window)return Promise.resolve();return new Promise(e=>{window.addEventListener("load",()=>e())})}();constructor(e){if(this.props={...mf,...e},e=this.props,!Pu())return this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,void(this.canvas=null);if(e.canvas)"string"==typeof e.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas;else{const t=function(e){const{width:t,height:i}=e,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=t||1,n.height=i||1,n.style.width=Number.isFinite(t)?`${t}px`:"100%",n.style.height=Number.isFinite(i)?`${i}px`:"100%",n}(e),i=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!t)throw new Error(`${e} is not an HTML element`);return t}if(e)return e;return document.body}(e?.container||null);i.insertBefore(t,i.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(const t of e)t.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){if("undefined"!=typeof OffscreenCanvas&&this.canvas instanceof OffscreenCanvas)return 1;if(!(e=void 0===e?this.props.useDevicePixels:e)||e<=0)return 1;if(!0===e){return"undefined"!=typeof window&&window.devicePixelRatio||1}return e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":const e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){const[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),t=this._canvasSizeInfo.clientWidth||this.htmlCanvas?.clientWidth;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[n,r]=this.getDrawingBufferSize();return function(e,t,i,n,r){const o=e,s=_f(o[0],t,i);let a=Af(o[1],t,n,r),l=_f(o[0]+1,t,i);const c=l===i-1?l:l-1;let u;l=Af(o[1]+1,t,n,r),r?(l=0===l?l:l+1,u=a,a=l):u=l===n-1?l:l-1;return{x:s,y:a,width:Math.max(c-s+1,1),height:Math.max(u-a+1,1)}}(e,i,n,r,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let i="width"in t?t.width:this.htmlCanvas.clientWidth,n="height"in t?t.height:this.htmlCanvas.clientHeight;i&&n||(Gp.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);const r=this._canvasSizeInfo;if(r.clientWidth!==i||r.clientHeight!==n||r.devicePixelRatio!==e){let t=e;const r=Math.floor(i*t),o=Math.floor(n*t);this.htmlCanvas.width=r,this.htmlCanvas.height=o;const[s,a]=this.getDrawingBufferSize();s===r&&a===o||(t=Math.min(s/i,a/n),this.htmlCanvas.width=Math.floor(i*t),this.htmlCanvas.height=Math.floor(n*t),Gp.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){const e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){"lumagl-auto-created-canvas"===this.htmlCanvas?.id&&(this.htmlCanvas.id=e)}}function _f(e,t,i){return Math.min(Math.round(e*t),i-1)}function Af(e,t,i,n){return n?Math.max(0,i-1-Math.round(e*t)):Math.min(Math.round(e*t),i-1)}class yf extends Kp{static defaultProps={...Kp.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,t,i=yf.defaultProps){super(e,t,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}}class vf extends Kp{static defaultProps={...Kp.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,vf.defaultProps)}}function xf(e,t,i,n){if(n?.inlineSource){const n=function(e,t,i){let n="";for(let r=t-2;r<=t;r++){const o=e[r-1];void 0!==o&&(n+=bf(o,t,i))}return n}(t,i);return`\n${n}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}return n?.html?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function bf(e,t,i){const n=i?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e,t){let i="";for(let n=e.length;n":"\n"}`}function wf(e,t){return{name:Tf(e,t),language:"glsl",version:Ef(e)}}function Tf(e,t="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return i?i[1]:t}function Ef(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}return t}class Cf extends Kp{static defaultProps={...Kp.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Sf(t),...t},Cf.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}const t=await this.getCompilationInfo();"warnings"===this.props.debug&&0===t?.length||this._displayShaderLog(t)}_displayShaderLog(e){if("undefined"==typeof document||!document?.createElement)return;const t=wf(this.source).name,i=`${this.stage} ${t}`;let n=function(e,t,i){let n="";const r=t.split(/\r?\n/),o=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(i?.showSourceCode||"no"){case"all":let t=0;for(let e=1;e<=r.length;e++)for(n+=bf(r[e-1],e,i);o.length>t&&o[t].lineNum===e;){const e=o[t++];n+=xf(e,r,e.lineNum,{...i,inlineSource:!1})}return n;case"issues":case"no":for(const t of e)n+=xf(t,r,t.lineNum,{inlineSource:"no"!==i?.showSourceCode});return n}}(e,this.source,{showSourceCode:"all",html:!0});const r=this.getTranslatedSource();r&&(n+=`

Translated Source



${r}
`);const o=document.createElement("Button");o.innerHTML=`\n

Shader Compilation Error in ${i}



\n
\n${n}\n
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);const s=document.getElementsByClassName("luma-compiler-log-error");s[0]?.scrollIntoView&&s[0].scrollIntoView(),o.onclick=()=>{const e=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(e)}}}function Sf(e){return wf(e.source).name||e.id||Wp(`unnamed ${e.stage}-shader`)}class Bf extends Kp{static defaultProps={...Kp.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,Bf.defaultProps)}}class If extends Kp{static defaultProps={...Kp.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,If.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){const[i,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||i!==this.width,this.width=i,this.height=n}t&&(Gp.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(e=>{if("string"==typeof e){const t=this.createColorTexture(e);return this.attachResource(t),t.view}return e instanceof yf?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else this.depthStencilAttachment=e instanceof yf?e.view:e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Df={f32:4,f16:2,i32:4,u32:4};function Of(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[i,n]=e.split("x"),r=i,o=n?parseInt(n):1,s=Jp(r),a={type:r,components:o,byteLength:s.byteLength*o,integer:s.integer,signed:s.signed,normalized:s.normalized};return t&&(a.webglOnly=!0),a}function zf(e,t){const i={};for(const n of e.attributes)i[n.name]=Uf(e,t,n.name);return i}function Uf(e,t,i){const n=function(e,t){const i=e.attributes.find(e=>e.name===t);i||Gp.warn(`shader layout attribute "${t}" not present in shader`);return i||null}(e,i),r=function(e,t){Nf(e);let i=function(e,t){for(const i of e)if(i.format&&i.name===t)return{attributeName:i.name,bufferName:t,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}(e,t);if(i)return i;if(i=function(e,t){for(const i of e){let e=i.byteStride;if("number"!=typeof i.byteStride)for(const t of i.attributes||[]){e+=Of(t.format).byteLength}const n=i.attributes?.find(e=>e.attribute===t);if(n)return{attributeName:n.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:e}}return null}(e,t),i)return i;return Gp.warn(`layout for attribute "${t}" not present in buffer layout`),null}(t,i);if(!n)return null;const o=function(e){const[t,i]=kf[e],n="i32"===t||"u32"===t,r="u32"!==t,o=Df[t]*i,s=function(e,t){let i;switch(e){case"f32":i="float32";break;case"i32":i="sint32";break;case"u32":i="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return 1===t?i:`${i}x${t}`}(t,i);return{dataType:t,components:i,defaultVertexFormat:s,byteLength:o,integer:n,signed:r}}(n.type),s=r?.vertexFormat||o.defaultVertexFormat,a=Of(s);return{attributeName:r?.attributeName||n.name,bufferName:r?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:o.integer,stepMode:r?.stepMode||n.stepMode,byteOffset:r?.byteOffset||0,byteStride:r?.byteStride||0}}function Nf(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Gp.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}class Vf extends Kp{static defaultProps={...Kp.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Vf.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,i=16){const n=zf(e,t),r=new Array(i).fill(null);for(const e of Object.values(n))r[e.location]=e;return r}(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}}class jf extends Kp{static defaultProps={...Kp.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,jf.defaultProps)}}class Gf extends Kp{static defaultProps={...Kp.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Gf.defaultProps)}}const Hf={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Qf(e){const t=Hf[e];return cf(e),t}function $f(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}let Zf;function Wf(e){return(!Zf||Zf.byteLength"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const i=t;for(const e of i.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){(function(e,t){if(e!==t)return!1;const i=$p(e);if(!i)return!1;const n=$p(t);if(n&&i.length===n.length)for(let e=0;e4)throw new Error(`size ${t}`);const n=t;let r=Jf(e);if("uint8"===r&&i&&1===n)return"unorm8-webgl";if("uint8"===r&&i&&3===n)return"unorm8x3-webgl";if("uint8"===r||"sint8"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}if("uint16"===r||"sint16"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}return 1===n?r:`${r}x${n}`}function tm(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const n=e[i];var r;null!==$p(r=n)||"number"==typeof r||"boolean"==typeof r?t.uniforms[i]=n:t.bindings[i]=n}),t}async function im(e,t){return await new Promise((i,n)=>{try{const r=new Image;r.onload=()=>i(r),r.onerror=()=>n(new Error(`Could not load image ${e}.`)),r.crossOrigin=t?.crossOrigin||"anonymous",r.src=e.startsWith("http")?e:""+e}catch(e){n(e)}})}async function nm(e,t){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",e),t&&(n.id=t),new Promise((t,r)=>{n.onload=t,n.onerror=t=>r(new Error(`Unable to load script '${e}': ${t}`)),i.appendChild(n)})}function rm(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n`}}class cm extends om{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class um extends om{constructor(e,t,i,n){super(e,i),this.format=t,this.access=n}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+="f",e;if("i32"===this.format.name)return e+="i",e;if("u32"===this.format.name)return e+="u",e;if("bool"===this.format.name)return e+="b",e;if("f16"===this.format.name)return e+="h",e}e+=`<${this.format.name}>`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}var hm;(e=>{e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(hm||(hm={}));class dm{constructor(e,t,i,n,r,o,s){this.name=e,this.type=t,this.group=i,this.binding=n,this.attributes=r,this.resourceType=o,this.access=s}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class pm{constructor(e,t){this.name=e,this.type=t}}class fm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n,this.interpolation=null}}class mm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n}}class gm{constructor(e,t,i,n){this.name=e,this.type=t,this.attributes=i,this.id=n}}class _m{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Am{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class ym{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function vm(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0==i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))}const xm=new Float32Array(1),bm=new Int32Array(xm.buffer),wm=new Uint16Array(1);function Tm(e){xm[0]=e;const t=bm[0],i=t>>31&1;let n=t>>23&255,r=8388607&t;if(255===n)return wm[0]=i<<15|31744|(0!==r?512:0),wm[0];if(0===n){if(0===r)return wm[0]=i<<15,wm[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return n=127-e,r&=8388607,n>0?(r=(r>>126-n)+(r>>127-n&1),wm[0]=i<<15|n<<10|r>>13,wm[0]):(wm[0]=i<<15,wm[0])}return n=n-127+15,n>=31?(wm[0]=i<<15|31744,wm[0]):n<=0?n<-10?(wm[0]=i<<15,wm[0]):(r=(8388608|r)>>1-n,wm[0]=i<<15|r>>13,wm[0]):(r>>=13,wm[0]=i<<15|n<<10|r,wm[0])}const Em=new Uint32Array(1),Cm=new Float32Array(Em.buffer,0,1);function Sm(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Em[0]=t,Cm[0]}function Bm(e,t,i,n){const r=[0,0,0,0];for(let o=0;o{e.increment="++",e.decrement="--"})(Qm||(Qm={})),(e=>{e.parse=function(t){const i=t;if("parse"==i)throw new Error("Invalid value for IncrementOperator");return e[i]}})(Qm||(Qm={}));class qm extends km{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(e=>{e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})($m||($m={})),($m||($m={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class Km extends km{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Xm extends km{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Fm.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Jm extends km{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class Ym extends km{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class eg extends km{constructor(e,t,i,n){super(),this.condition=e,this.body=t,this.elseif=i,this.else=n}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class tg extends km{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class ig extends km{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class ng extends km{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class rg extends km{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class og extends km{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class sg extends km{constructor(){super()}get astNodeType(){return"discard"}}class ag extends km{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class lg extends km{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class cg extends km{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let i=1;i`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}dg.vec2f=new dg("vec2",cg.f32,null),dg.vec3f=new dg("vec3",cg.f32,null),dg.vec4f=new dg("vec4",cg.f32,null),dg.vec2i=new dg("vec2",cg.i32,null),dg.vec3i=new dg("vec3",cg.i32,null),dg.vec4i=new dg("vec4",cg.i32,null),dg.vec2u=new dg("vec2",cg.u32,null),dg.vec3u=new dg("vec3",cg.u32,null),dg.vec4u=new dg("vec4",cg.u32,null),dg.vec2h=new dg("vec2",cg.f16,null),dg.vec3h=new dg("vec3",cg.f16,null),dg.vec4h=new dg("vec4",cg.f16,null),dg.vec2b=new dg("vec2",cg.bool,null),dg.vec3b=new dg("vec3",cg.bool,null),dg.vec4b=new dg("vec4",cg.bool,null),dg.mat2x2f=new dg("mat2x2",cg.f32,null),dg.mat2x3f=new dg("mat2x3",cg.f32,null),dg.mat2x4f=new dg("mat2x4",cg.f32,null),dg.mat3x2f=new dg("mat3x2",cg.f32,null),dg.mat3x3f=new dg("mat3x3",cg.f32,null),dg.mat3x4f=new dg("mat3x4",cg.f32,null),dg.mat4x2f=new dg("mat4x2",cg.f32,null),dg.mat4x3f=new dg("mat4x3",cg.f32,null),dg.mat4x4f=new dg("mat4x4",cg.f32,null),dg.mat2x2h=new dg("mat2x2",cg.f16,null),dg.mat2x3h=new dg("mat2x3",cg.f16,null),dg.mat2x4h=new dg("mat2x4",cg.f16,null),dg.mat3x2h=new dg("mat3x2",cg.f16,null),dg.mat3x3h=new dg("mat3x3",cg.f16,null),dg.mat3x4h=new dg("mat3x4",cg.f16,null),dg.mat4x2h=new dg("mat4x2",cg.f16,null),dg.mat4x3h=new dg("mat4x3",cg.f16,null),dg.mat4x4h=new dg("mat4x4",cg.f16,null),dg.mat2x2i=new dg("mat2x2",cg.i32,null),dg.mat2x3i=new dg("mat2x3",cg.i32,null),dg.mat2x4i=new dg("mat2x4",cg.i32,null),dg.mat3x2i=new dg("mat3x2",cg.i32,null),dg.mat3x3i=new dg("mat3x3",cg.i32,null),dg.mat3x4i=new dg("mat3x4",cg.i32,null),dg.mat4x2i=new dg("mat4x2",cg.i32,null),dg.mat4x3i=new dg("mat4x3",cg.i32,null),dg.mat4x4i=new dg("mat4x4",cg.i32,null),dg.mat2x2u=new dg("mat2x2",cg.u32,null),dg.mat2x3u=new dg("mat2x3",cg.u32,null),dg.mat2x4u=new dg("mat2x4",cg.u32,null),dg.mat3x2u=new dg("mat3x2",cg.u32,null),dg.mat3x3u=new dg("mat3x3",cg.u32,null),dg.mat3x4u=new dg("mat3x4",cg.u32,null),dg.mat4x2u=new dg("mat4x2",cg.u32,null),dg.mat4x3u=new dg("mat4x3",cg.u32,null),dg.mat4x4u=new dg("mat4x4",cg.u32,null);class pg extends cg{constructor(e,t,i,n){super(e),this.storage=t,this.type=i,this.access=n}get astNodeType(){return"pointer"}}class fg extends cg{constructor(e,t,i,n){super(e),this.attributes=t,this.format=i,this.count=n}get astNodeType(){return"array"}get isArray(){return!0}}class mg extends cg{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class gg extends Pm{constructor(){super(),this.postfix=null}}class _g extends gg{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class Ag extends gg{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class yg extends gg{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Fm.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class vg extends gg{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class xg extends gg{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class bg extends gg{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Ug}get isVector(){return this.value instanceof Vg||this.value instanceof jg}get scalarValue(){return this.value instanceof Ug?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof Vg||this.value instanceof jg?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class wg extends gg{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class Tg extends gg{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Eg extends gg{constructor(){super()}}class Cg extends Eg{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Sg extends Eg{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?cg.f32:"u32"===e.name||"u32"===t.name?cg.u32:cg.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Bg extends Pm{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Ig extends gg{constructor(){super()}get astNodeType(){return"default"}}class Mg extends Bg{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Pg extends Bg{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Rg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class Lg extends Pm{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Fg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class kg extends Pm{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Dg{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Dg._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,n){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Dg._id=0;class Og extends Dg{constructor(){super(new om("void",null),null)}toString(){return"void"}}Og.void=new Og;class zg extends Dg{constructor(e){super(new cm("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,n){this.reference.setDataValue(e,t,i,n)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class Ug extends Dg{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):"f32"===this.typeInfo.name||"f16"===this.typeInfo.name?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new Ug(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Ug(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Ug(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,n){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof Ug))return void console.error("SetDataValue: Invalid value",t);let r=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?r=Math.floor(r):"bool"===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Ng(e,t,i){const n=t.length;return 2===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${i}`),null):3===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${i}`),null):4===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${i}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Vg extends Dg{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):"vec2"===t||"vec3"===t||"vec4"===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Vg(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Vg(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Vg(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,n){i instanceof _g?console.error("TODO: Set vector postfix"):t instanceof Vg?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(null===t)return this;let n=e.getTypeInfo("f32");if(this.typeInfo instanceof um)n=this.typeInfo.format||n;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?n=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?n=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?n=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?n=e.getTypeInfo("u32"):"vec2h"===t||"vec3h"===t||"vec4h"===t?n=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${t}`)}let r=this;for(;null!==t&&null!==r;){if(t instanceof Tg){const o=t.index;let s=-1;if(o instanceof bg){if(!(o.value instanceof Ug))return console.error(`GetSubData: Invalid array index ${o.value}`),null;s=o.value.value}else{const t=e.evalExpression(o,i);if(!(t instanceof Ug))return console.error("GetSubData: Unknown index type",o),null;s=t.value}if(s<0||s>=r.data.length)return console.error("GetSubData: Index out of range",s),null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}throw"GetSubData: Invalid data type"}if(!(t instanceof _g))return console.error("GetSubData: Unknown postfix",t),null;{const i=t.value.toLowerCase();if(1===i.length){let e=0;if("x"===i||"r"===i)e=0;else if("y"===i||"g"===i)e=1;else if("z"===i||"b"===i)e=2;else{if("w"!==i&&"a"!==i)return console.error(`GetSubData: Unknown member ${i}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}}const o=[];for(const e of i)"x"===e||"r"===e?o.push(this.data[0]):"y"===e||"g"===e?o.push(this.data[1]):"z"===e||"b"===e?o.push(this.data[2]):"w"===e||"a"===e?o.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);r=Ng(e,o,n.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const s=n.endsWith("h")?"h":"f";let a;if("mat2x2"===n||"mat2x2f"===n||"mat2x2h"===n||"mat3x2"===n||"mat3x2f"===n||"mat3x2h"===n||"mat4x2"===n||"mat4x2f"===n||"mat4x2h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${s}`));else if("mat2x3"===n||"mat2x3f"===n||"mat2x3h"===n||"mat3x3"===n||"mat3x3f"===n||"mat3x3h"===n||"mat4x3"===n||"mat4x3f"===n||"mat4x3h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${s}`));else{if("mat2x4"!==n&&"mat2x4f"!==n&&"mat2x4h"!==n&&"mat3x4"!==n&&"mat3x4f"!==n&&"mat3x4h"!==n&&"mat4x4"!==n&&"mat4x4f"!==n&&"mat4x4h"!==n)return console.error(`GetDataValue: Unknown type ${n}`),null;a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${s}`))}return t.postfix?a.getSubData(e,t.postfix,i):a}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t"!==o&&"x32"!==o)if("u32"!==o&&"atomic"!==o)if("bool"!==o){if("vec2f"===o||"vec2h"===o){const e=new Float32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===o||"vec3h"===o){const e=new Float32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===o||"vec4h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===o){const e=new Int32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===o){const e=new Int32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===o){const e=new Int32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===o||"mat2x2h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===o||"mat2x3h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===o||"mat2x4h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat3x2f"===o||"mat3x2h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===o||"mat3x3h"===o){const e=new Float32Array(this.buffer,n,9);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(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]))}if("mat3x4f"===o||"mat3x4h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x2f"===o||"mat4x2h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat4x3f"===o||"mat4x3h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x4f"===o||"mat4x4h"===o){const e=new Float32Array(this.buffer,n,16);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(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]))}if(t instanceof Gg){if(i===t.typeInfo)return void new Uint8Array(this.buffer,n,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Uint32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Float32Array(this.buffer,n,1)[0]=t.value)}getSubData(e,t,i){var n,r,o;if(null===t)return this;let s=this.offset,a=this.typeInfo;for(;t;){if(t instanceof Tg){const n=t.index,r=n instanceof gg?e.evalExpression(n,i):n;let o=0;if(r instanceof Ug?o=r.value:"number"==typeof r?o=r:console.error("GetDataValue: Invalid index type",n),a instanceof lm)s+=o*a.stride,a=a.format;else{const t=a.getTypeName();"mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t?(s+=16*o,a=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${a.getTypeName()} is not an array`)}}else{if(!(t instanceof _g))return console.error("GetDataValue: Unknown postfix type",t),null;{const i=t.value;if(a instanceof am){let e=!1;for(const t of a.members)if(t.name===i){s+=t.offset,a=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${i} not found`),null}else if(a instanceof om){const t=a.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(i.length>0&&i.length<5){let n="f";const r=[];for(let o=0;o=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const e=new Float32Array(this.buffer,s,3);r.push(e[l])}else if("vec4f"===t)r.push(new Float32Array(this.buffer,s,4)[l]);else if("vec2i"===t)n="i",r.push(new Int32Array(this.buffer,s,2)[l]);else if("vec3i"===t)n="i",r.push(new Int32Array(this.buffer,s,3)[l]);else if("vec4i"===t)n="i",r.push(new Int32Array(this.buffer,s,4)[l]);else if("vec2u"===t){n="u";const e=new Uint32Array(this.buffer,s,2);r.push(e[l])}else"vec3u"===t?(n="u",r.push(new Uint32Array(this.buffer,s,3)[l])):"vec4u"===t&&(n="u",r.push(new Uint32Array(this.buffer,s,4)[l]))}return 2===r.length?a=e.getTypeInfo(`vec2${n}`):3===r.length?a=e.getTypeInfo(`vec3${n}`):4===r.length?a=e.getTypeInfo(`vec4${n}`):console.error(`GetDataValue: Invalid vector length ${r.length}`),new Vg(r,a,null)}return console.error(`GetDataValue: Unknown member ${i}`),null}return console.error(`GetDataValue: Type ${t} is not a struct`),null}}}t=t.postfix}const l=a.getTypeName();return"f32"===l?new Ug(new Float32Array(this.buffer,s,1),a,this):"i32"===l?new Ug(new Int32Array(this.buffer,s,1),a,this):"u32"===l?new Ug(new Uint32Array(this.buffer,s,1),a,this):"vec2f"===l?new Vg(new Float32Array(this.buffer,s,2),a,this):"vec3f"===l?new Vg(new Float32Array(this.buffer,s,3),a,this):"vec4f"===l?new Vg(new Float32Array(this.buffer,s,4),a,this):"vec2i"===l?new Vg(new Int32Array(this.buffer,s,2),a,this):"vec3i"===l?new Vg(new Int32Array(this.buffer,s,3),a,this):"vec4i"===l?new Vg(new Int32Array(this.buffer,s,4),a,this):"vec2u"===l?new Vg(new Uint32Array(this.buffer,s,2),a,this):"vec3u"===l?new Vg(new Uint32Array(this.buffer,s,3),a,this):"vec4u"===l?new Vg(new Uint32Array(this.buffer,s,4),a,this):a instanceof um&&"atomic"===a.name?"u32"===(null===(n=a.format)||void 0===n?void 0:n.name)?new Ug(new Uint32Array(this.buffer,s,1)[0],a.format,this):"i32"===(null===(r=a.format)||void 0===r?void 0:r.name)?new Ug(new Int32Array(this.buffer,s,1)[0],a.format,this):(console.error(`GetDataValue: Invalid atomic format ${null===(o=a.format)||void 0===o?void 0:o.name}`),null):new Gg(this.buffer,a,s,this)}toString(){let e="";if(this.typeInfo instanceof lm)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i0?null!==(e=i[0])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.width)&&void 0!==t?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?null!==(e=i[1])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?null!==(e=i[2])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i>e);return t}get texelByteSize(){const e=this.format,t=Mm[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Mm[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Mm[e],i=this.width;if(!e||i<=0||!t)return-1;const n=this.height,r=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*("1d"===o?1:n/t.blockHeight)*t.bytesPerBlock*r}getPixel(e,t,i=0,n=0){const r=this.texelByteSize,o=this.bytesPerRow,s=this.height,a=this.data[n];return function(e,t,i,n,r,o,s,a,l){const c=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return[Bm(e,c,"8unorm",1)[0]];case"r8snorm":return[Bm(e,c,"8snorm",1)[0]];case"r8uint":return[Bm(e,c,"8uint",1)[0]];case"r8sint":return[Bm(e,c,"8sint",1)[0]];case"rg8unorm":{const t=Bm(e,c,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Bm(e,c,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Bm(e,c,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Bm(e,c,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Bm(e,c,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Bm(e,c,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Bm(e,c,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Bm(e,c,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Bm(e,c,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Bm(e,c,"16uint",1)[0]];case"r16sint":return[Bm(e,c,"16sint",1)[0]];case"r16float":return[Bm(e,c,"16float",1)[0]];case"rg16uint":{const t=Bm(e,c,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Bm(e,c,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Bm(e,c,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Bm(e,c,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Bm(e,c,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Bm(e,c,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Bm(e,c,"32uint",1)[0]];case"r32sint":return[Bm(e,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Bm(e,c,"32float",1)[0]];case"rg32uint":{const t=Bm(e,c,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Bm(e,c,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Bm(e,c,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Bm(e,c,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Bm(e,c,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Bm(e,c,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,c,1)[0],i=(4192256&t)>>11,n=(4290772992&t)>>22;return[Sm(2047&t),Sm(i),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Em[0]=t,Cm[0]}(n),1]}}return null}(new Uint8Array(a),e,t,i,n,s,o,r,this.format)}setPixel(e,t,i,n,r){const o=this.texelByteSize,s=this.bytesPerRow,a=this.height,l=this.data[n];!function(e,t,i,n,r,o,s,a,l,c){const u=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return void Im(e,u,"8unorm",1,c);case"r8snorm":return void Im(e,u,"8snorm",1,c);case"r8uint":return void Im(e,u,"8uint",1,c);case"r8sint":return void Im(e,u,"8sint",1,c);case"rg8unorm":return void Im(e,u,"8unorm",2,c);case"rg8snorm":return void Im(e,u,"8snorm",2,c);case"rg8uint":return void Im(e,u,"8uint",2,c);case"rg8sint":return void Im(e,u,"8sint",2,c);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Im(e,u,"8unorm",4,c);case"rgba8snorm":return void Im(e,u,"8snorm",4,c);case"rgba8uint":return void Im(e,u,"8uint",4,c);case"rgba8sint":return void Im(e,u,"8sint",4,c);case"r16uint":return void Im(e,u,"16uint",1,c);case"r16sint":return void Im(e,u,"16sint",1,c);case"r16float":return void Im(e,u,"16float",1,c);case"rg16uint":return void Im(e,u,"16uint",2,c);case"rg16sint":return void Im(e,u,"16sint",2,c);case"rg16float":return void Im(e,u,"16float",2,c);case"rgba16uint":return void Im(e,u,"16uint",4,c);case"rgba16sint":return void Im(e,u,"16sint",4,c);case"rgba16float":return void Im(e,u,"16float",4,c);case"r32uint":return void Im(e,u,"32uint",1,c);case"r32sint":return void Im(e,u,"32sint",1,c);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Im(e,u,"32float",1,c);case"rg32uint":return void Im(e,u,"32uint",2,c);case"rg32sint":return void Im(e,u,"32sint",2,c);case"rg32float":return void Im(e,u,"32float",2,c);case"rgba32uint":return void Im(e,u,"32uint",4,c);case"rgba32sint":return void Im(e,u,"32sint",4,c);case"rgba32float":return void Im(e,u,"32float",4,c);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}}(new Uint8Array(l),e,t,i,n,a,s,o,this.format,r)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(Wm||(Wm={}));class Qg{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class $g{}Zm=$g,$g.none=new Qg("",Wm.reserved,""),$g.eof=new Qg("EOF",Wm.token,""),$g.reserved={asm:new Qg("asm",Wm.reserved,"asm"),bf16:new Qg("bf16",Wm.reserved,"bf16"),do:new Qg("do",Wm.reserved,"do"),enum:new Qg("enum",Wm.reserved,"enum"),f16:new Qg("f16",Wm.reserved,"f16"),f64:new Qg("f64",Wm.reserved,"f64"),handle:new Qg("handle",Wm.reserved,"handle"),i8:new Qg("i8",Wm.reserved,"i8"),i16:new Qg("i16",Wm.reserved,"i16"),i64:new Qg("i64",Wm.reserved,"i64"),mat:new Qg("mat",Wm.reserved,"mat"),premerge:new Qg("premerge",Wm.reserved,"premerge"),regardless:new Qg("regardless",Wm.reserved,"regardless"),typedef:new Qg("typedef",Wm.reserved,"typedef"),u8:new Qg("u8",Wm.reserved,"u8"),u16:new Qg("u16",Wm.reserved,"u16"),u64:new Qg("u64",Wm.reserved,"u64"),unless:new Qg("unless",Wm.reserved,"unless"),using:new Qg("using",Wm.reserved,"using"),vec:new Qg("vec",Wm.reserved,"vec"),void:new Qg("void",Wm.reserved,"void")},$g.keywords={array:new Qg("array",Wm.keyword,"array"),atomic:new Qg("atomic",Wm.keyword,"atomic"),bool:new Qg("bool",Wm.keyword,"bool"),f32:new Qg("f32",Wm.keyword,"f32"),i32:new Qg("i32",Wm.keyword,"i32"),mat2x2:new Qg("mat2x2",Wm.keyword,"mat2x2"),mat2x3:new Qg("mat2x3",Wm.keyword,"mat2x3"),mat2x4:new Qg("mat2x4",Wm.keyword,"mat2x4"),mat3x2:new Qg("mat3x2",Wm.keyword,"mat3x2"),mat3x3:new Qg("mat3x3",Wm.keyword,"mat3x3"),mat3x4:new Qg("mat3x4",Wm.keyword,"mat3x4"),mat4x2:new Qg("mat4x2",Wm.keyword,"mat4x2"),mat4x3:new Qg("mat4x3",Wm.keyword,"mat4x3"),mat4x4:new Qg("mat4x4",Wm.keyword,"mat4x4"),ptr:new Qg("ptr",Wm.keyword,"ptr"),sampler:new Qg("sampler",Wm.keyword,"sampler"),sampler_comparison:new Qg("sampler_comparison",Wm.keyword,"sampler_comparison"),struct:new Qg("struct",Wm.keyword,"struct"),texture_1d:new Qg("texture_1d",Wm.keyword,"texture_1d"),texture_2d:new Qg("texture_2d",Wm.keyword,"texture_2d"),texture_2d_array:new Qg("texture_2d_array",Wm.keyword,"texture_2d_array"),texture_3d:new Qg("texture_3d",Wm.keyword,"texture_3d"),texture_cube:new Qg("texture_cube",Wm.keyword,"texture_cube"),texture_cube_array:new Qg("texture_cube_array",Wm.keyword,"texture_cube_array"),texture_multisampled_2d:new Qg("texture_multisampled_2d",Wm.keyword,"texture_multisampled_2d"),texture_storage_1d:new Qg("texture_storage_1d",Wm.keyword,"texture_storage_1d"),texture_storage_2d:new Qg("texture_storage_2d",Wm.keyword,"texture_storage_2d"),texture_storage_2d_array:new Qg("texture_storage_2d_array",Wm.keyword,"texture_storage_2d_array"),texture_storage_3d:new Qg("texture_storage_3d",Wm.keyword,"texture_storage_3d"),texture_depth_2d:new Qg("texture_depth_2d",Wm.keyword,"texture_depth_2d"),texture_depth_2d_array:new Qg("texture_depth_2d_array",Wm.keyword,"texture_depth_2d_array"),texture_depth_cube:new Qg("texture_depth_cube",Wm.keyword,"texture_depth_cube"),texture_depth_cube_array:new Qg("texture_depth_cube_array",Wm.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Qg("texture_depth_multisampled_2d",Wm.keyword,"texture_depth_multisampled_2d"),texture_external:new Qg("texture_external",Wm.keyword,"texture_external"),u32:new Qg("u32",Wm.keyword,"u32"),vec2:new Qg("vec2",Wm.keyword,"vec2"),vec3:new Qg("vec3",Wm.keyword,"vec3"),vec4:new Qg("vec4",Wm.keyword,"vec4"),bitcast:new Qg("bitcast",Wm.keyword,"bitcast"),block:new Qg("block",Wm.keyword,"block"),break:new Qg("break",Wm.keyword,"break"),case:new Qg("case",Wm.keyword,"case"),continue:new Qg("continue",Wm.keyword,"continue"),continuing:new Qg("continuing",Wm.keyword,"continuing"),default:new Qg("default",Wm.keyword,"default"),diagnostic:new Qg("diagnostic",Wm.keyword,"diagnostic"),discard:new Qg("discard",Wm.keyword,"discard"),else:new Qg("else",Wm.keyword,"else"),enable:new Qg("enable",Wm.keyword,"enable"),fallthrough:new Qg("fallthrough",Wm.keyword,"fallthrough"),false:new Qg("false",Wm.keyword,"false"),fn:new Qg("fn",Wm.keyword,"fn"),for:new Qg("for",Wm.keyword,"for"),function:new Qg("function",Wm.keyword,"function"),if:new Qg("if",Wm.keyword,"if"),let:new Qg("let",Wm.keyword,"let"),const:new Qg("const",Wm.keyword,"const"),loop:new Qg("loop",Wm.keyword,"loop"),while:new Qg("while",Wm.keyword,"while"),private:new Qg("private",Wm.keyword,"private"),read:new Qg("read",Wm.keyword,"read"),read_write:new Qg("read_write",Wm.keyword,"read_write"),return:new Qg("return",Wm.keyword,"return"),requires:new Qg("requires",Wm.keyword,"requires"),storage:new Qg("storage",Wm.keyword,"storage"),switch:new Qg("switch",Wm.keyword,"switch"),true:new Qg("true",Wm.keyword,"true"),alias:new Qg("alias",Wm.keyword,"alias"),type:new Qg("type",Wm.keyword,"type"),uniform:new Qg("uniform",Wm.keyword,"uniform"),var:new Qg("var",Wm.keyword,"var"),override:new Qg("override",Wm.keyword,"override"),workgroup:new Qg("workgroup",Wm.keyword,"workgroup"),write:new Qg("write",Wm.keyword,"write"),r8unorm:new Qg("r8unorm",Wm.keyword,"r8unorm"),r8snorm:new Qg("r8snorm",Wm.keyword,"r8snorm"),r8uint:new Qg("r8uint",Wm.keyword,"r8uint"),r8sint:new Qg("r8sint",Wm.keyword,"r8sint"),r16uint:new Qg("r16uint",Wm.keyword,"r16uint"),r16sint:new Qg("r16sint",Wm.keyword,"r16sint"),r16float:new Qg("r16float",Wm.keyword,"r16float"),rg8unorm:new Qg("rg8unorm",Wm.keyword,"rg8unorm"),rg8snorm:new Qg("rg8snorm",Wm.keyword,"rg8snorm"),rg8uint:new Qg("rg8uint",Wm.keyword,"rg8uint"),rg8sint:new Qg("rg8sint",Wm.keyword,"rg8sint"),r32uint:new Qg("r32uint",Wm.keyword,"r32uint"),r32sint:new Qg("r32sint",Wm.keyword,"r32sint"),r32float:new Qg("r32float",Wm.keyword,"r32float"),rg16uint:new Qg("rg16uint",Wm.keyword,"rg16uint"),rg16sint:new Qg("rg16sint",Wm.keyword,"rg16sint"),rg16float:new Qg("rg16float",Wm.keyword,"rg16float"),rgba8unorm:new Qg("rgba8unorm",Wm.keyword,"rgba8unorm"),rgba8unorm_srgb:new Qg("rgba8unorm_srgb",Wm.keyword,"rgba8unorm_srgb"),rgba8snorm:new Qg("rgba8snorm",Wm.keyword,"rgba8snorm"),rgba8uint:new Qg("rgba8uint",Wm.keyword,"rgba8uint"),rgba8sint:new Qg("rgba8sint",Wm.keyword,"rgba8sint"),bgra8unorm:new Qg("bgra8unorm",Wm.keyword,"bgra8unorm"),bgra8unorm_srgb:new Qg("bgra8unorm_srgb",Wm.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Qg("rgb10a2unorm",Wm.keyword,"rgb10a2unorm"),rg11b10float:new Qg("rg11b10float",Wm.keyword,"rg11b10float"),rg32uint:new Qg("rg32uint",Wm.keyword,"rg32uint"),rg32sint:new Qg("rg32sint",Wm.keyword,"rg32sint"),rg32float:new Qg("rg32float",Wm.keyword,"rg32float"),rgba16uint:new Qg("rgba16uint",Wm.keyword,"rgba16uint"),rgba16sint:new Qg("rgba16sint",Wm.keyword,"rgba16sint"),rgba16float:new Qg("rgba16float",Wm.keyword,"rgba16float"),rgba32uint:new Qg("rgba32uint",Wm.keyword,"rgba32uint"),rgba32sint:new Qg("rgba32sint",Wm.keyword,"rgba32sint"),rgba32float:new Qg("rgba32float",Wm.keyword,"rgba32float"),static_assert:new Qg("static_assert",Wm.keyword,"static_assert")},$g.tokens={decimal_float_literal:new Qg("decimal_float_literal",Wm.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new Qg("hex_float_literal",Wm.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new Qg("int_literal",Wm.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Qg("uint_literal",Wm.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new Qg("name",Wm.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new Qg("ident",Wm.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Qg("and",Wm.token,"&"),and_and:new Qg("and_and",Wm.token,"&&"),arrow:new Qg("arrow ",Wm.token,"->"),attr:new Qg("attr",Wm.token,"@"),forward_slash:new Qg("forward_slash",Wm.token,"/"),bang:new Qg("bang",Wm.token,"!"),bracket_left:new Qg("bracket_left",Wm.token,"["),bracket_right:new Qg("bracket_right",Wm.token,"]"),brace_left:new Qg("brace_left",Wm.token,"{"),brace_right:new Qg("brace_right",Wm.token,"}"),colon:new Qg("colon",Wm.token,":"),comma:new Qg("comma",Wm.token,","),equal:new Qg("equal",Wm.token,"="),equal_equal:new Qg("equal_equal",Wm.token,"=="),not_equal:new Qg("not_equal",Wm.token,"!="),greater_than:new Qg("greater_than",Wm.token,">"),greater_than_equal:new Qg("greater_than_equal",Wm.token,">="),shift_right:new Qg("shift_right",Wm.token,">>"),less_than:new Qg("less_than",Wm.token,"<"),less_than_equal:new Qg("less_than_equal",Wm.token,"<="),shift_left:new Qg("shift_left",Wm.token,"<<"),modulo:new Qg("modulo",Wm.token,"%"),minus:new Qg("minus",Wm.token,"-"),minus_minus:new Qg("minus_minus",Wm.token,"--"),period:new Qg("period",Wm.token,"."),plus:new Qg("plus",Wm.token,"+"),plus_plus:new Qg("plus_plus",Wm.token,"++"),or:new Qg("or",Wm.token,"|"),or_or:new Qg("or_or",Wm.token,"||"),paren_left:new Qg("paren_left",Wm.token,"("),paren_right:new Qg("paren_right",Wm.token,")"),semicolon:new Qg("semicolon",Wm.token,";"),star:new Qg("star",Wm.token,"*"),tilde:new Qg("tilde",Wm.token,"~"),underscore:new Qg("underscore",Wm.token,"_"),xor:new Qg("xor",Wm.token,"^"),plus_equal:new Qg("plus_equal",Wm.token,"+="),minus_equal:new Qg("minus_equal",Wm.token,"-="),times_equal:new Qg("times_equal",Wm.token,"*="),division_equal:new Qg("division_equal",Wm.token,"/="),modulo_equal:new Qg("modulo_equal",Wm.token,"%="),and_equal:new Qg("and_equal",Wm.token,"&="),or_equal:new Qg("or_equal",Wm.token,"|="),xor_equal:new Qg("xor_equal",Wm.token,"^="),shift_right_equal:new Qg("shift_right_equal",Wm.token,">>="),shift_left_equal:new Qg("shift_left_equal",Wm.token,"<<=")},$g.simpleTokens={"@":Zm.tokens.attr,"{":Zm.tokens.brace_left,"}":Zm.tokens.brace_right,":":Zm.tokens.colon,",":Zm.tokens.comma,"(":Zm.tokens.paren_left,")":Zm.tokens.paren_right,";":Zm.tokens.semicolon},$g.literalTokens={"&":Zm.tokens.and,"&&":Zm.tokens.and_and,"->":Zm.tokens.arrow,"/":Zm.tokens.forward_slash,"!":Zm.tokens.bang,"[":Zm.tokens.bracket_left,"]":Zm.tokens.bracket_right,"=":Zm.tokens.equal,"==":Zm.tokens.equal_equal,"!=":Zm.tokens.not_equal,">":Zm.tokens.greater_than,">=":Zm.tokens.greater_than_equal,">>":Zm.tokens.shift_right,"<":Zm.tokens.less_than,"<=":Zm.tokens.less_than_equal,"<<":Zm.tokens.shift_left,"%":Zm.tokens.modulo,"-":Zm.tokens.minus,"--":Zm.tokens.minus_minus,".":Zm.tokens.period,"+":Zm.tokens.plus,"++":Zm.tokens.plus_plus,"|":Zm.tokens.or,"||":Zm.tokens.or_or,"*":Zm.tokens.star,"~":Zm.tokens.tilde,_:Zm.tokens.underscore,"^":Zm.tokens.xor,"+=":Zm.tokens.plus_equal,"-=":Zm.tokens.minus_equal,"*=":Zm.tokens.times_equal,"/=":Zm.tokens.division_equal,"%=":Zm.tokens.modulo_equal,"&=":Zm.tokens.and_equal,"|=":Zm.tokens.or_equal,"^=":Zm.tokens.xor_equal,">>=":Zm.tokens.shift_right_equal,"<<=":Zm.tokens.shift_left_equal},$g.regexTokens={decimal_float_literal:Zm.tokens.decimal_float_literal,hex_float_literal:Zm.tokens.hex_float_literal,int_literal:Zm.tokens.int_literal,uint_literal:Zm.tokens.uint_literal,ident:Zm.tokens.ident},$g.storage_class=[Zm.keywords.function,Zm.keywords.private,Zm.keywords.workgroup,Zm.keywords.uniform,Zm.keywords.storage],$g.access_mode=[Zm.keywords.read,Zm.keywords.write,Zm.keywords.read_write],$g.sampler_type=[Zm.keywords.sampler,Zm.keywords.sampler_comparison],$g.sampled_texture_type=[Zm.keywords.texture_1d,Zm.keywords.texture_2d,Zm.keywords.texture_2d_array,Zm.keywords.texture_3d,Zm.keywords.texture_cube,Zm.keywords.texture_cube_array],$g.multisampled_texture_type=[Zm.keywords.texture_multisampled_2d],$g.storage_texture_type=[Zm.keywords.texture_storage_1d,Zm.keywords.texture_storage_2d,Zm.keywords.texture_storage_2d_array,Zm.keywords.texture_storage_3d],$g.depth_texture_type=[Zm.keywords.texture_depth_2d,Zm.keywords.texture_depth_2d_array,Zm.keywords.texture_depth_cube,Zm.keywords.texture_depth_cube_array,Zm.keywords.texture_depth_multisampled_2d],$g.texture_external_type=[Zm.keywords.texture_external],$g.any_texture_type=[...Zm.sampled_texture_type,...Zm.multisampled_texture_type,...Zm.storage_texture_type,...Zm.depth_texture_type,...Zm.texture_external_type],$g.texel_format=[Zm.keywords.r8unorm,Zm.keywords.r8snorm,Zm.keywords.r8uint,Zm.keywords.r8sint,Zm.keywords.r16uint,Zm.keywords.r16sint,Zm.keywords.r16float,Zm.keywords.rg8unorm,Zm.keywords.rg8snorm,Zm.keywords.rg8uint,Zm.keywords.rg8sint,Zm.keywords.r32uint,Zm.keywords.r32sint,Zm.keywords.r32float,Zm.keywords.rg16uint,Zm.keywords.rg16sint,Zm.keywords.rg16float,Zm.keywords.rgba8unorm,Zm.keywords.rgba8unorm_srgb,Zm.keywords.rgba8snorm,Zm.keywords.rgba8uint,Zm.keywords.rgba8sint,Zm.keywords.bgra8unorm,Zm.keywords.bgra8unorm_srgb,Zm.keywords.rgb10a2unorm,Zm.keywords.rg11b10float,Zm.keywords.rg32uint,Zm.keywords.rg32sint,Zm.keywords.rg32float,Zm.keywords.rgba16uint,Zm.keywords.rgba16sint,Zm.keywords.rgba16float,Zm.keywords.rgba32uint,Zm.keywords.rgba32sint,Zm.keywords.rgba32float],$g.const_literal=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.keywords.true,Zm.keywords.false],$g.literal_or_ident=[Zm.tokens.ident,Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.tokens.name],$g.element_count_expression=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.ident],$g.template_types=[Zm.keywords.vec2,Zm.keywords.vec3,Zm.keywords.vec4,Zm.keywords.mat2x2,Zm.keywords.mat2x3,Zm.keywords.mat2x4,Zm.keywords.mat3x2,Zm.keywords.mat3x3,Zm.keywords.mat3x4,Zm.keywords.mat4x2,Zm.keywords.mat4x3,Zm.keywords.mat4x4,Zm.keywords.atomic,Zm.keywords.bitcast,...Zm.any_texture_type],$g.attribute_name=[Zm.tokens.ident,Zm.keywords.block,Zm.keywords.diagnostic],$g.assignment_operators=[Zm.tokens.equal,Zm.tokens.plus_equal,Zm.tokens.minus_equal,Zm.tokens.times_equal,Zm.tokens.division_equal,Zm.tokens.modulo_equal,Zm.tokens.and_equal,Zm.tokens.or_equal,Zm.tokens.xor_equal,Zm.tokens.shift_right_equal,Zm.tokens.shift_left_equal],$g.increment_operators=[Zm.tokens.plus_plus,Zm.tokens.minus_minus];class Zg{constructor(e,t,i,n,r){this.type=e,this.lexeme=t,this.line=i,this.start=n,this.end=r}toString(){return this.lexeme}isTemplateType(){return-1!=$g.template_types.indexOf(this.type)}isArrayType(){return this.type==$g.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Wg{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Zg($g.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0;){if(this._isAtEnd())return!0;if(e=this._advance(),"\n"==e)this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),t--,0==t))return!0}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++)}return!0}}const t=$g.simpleTokens[e];if(t)return this._addToken(t),!0;let i=$g.none;const n=this._isAlpha(e),r="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(n){const t=$g.keywords[e];if(t)return this._addToken(t),!0}if(n||r)return this._addToken($g.tokens.ident),!0;for(;;){let t=this._findType(e);const n=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==n)return this._current++,e+=n,this._addToken($g.tokens.minus_equal),!0;if("-"==n)return this._current++,e+=n,this._addToken($g.tokens.minus_minus),!0;const i=this._tokens.length-1;if((-1!=$g.literal_or_ident.indexOf(this._tokens[i].type)||this._tokens[i].type==$g.tokens.paren_right)&&">"!=n)return this._addToken(t),!0}if(">"==e&&(">"==n||"="==n)){let e=!1,i=this._tokens.length-1;for(let t=0;t<5&&i>=0&&-1===$g.assignment_operators.indexOf(this._tokens[i].type);++t,--i)if(this._tokens[i].type===$g.tokens.less_than){i>0&&this._tokens[i-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===$g.none){let n=e,r=0;const o=2;for(let e=0;e=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"\t"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"\t"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Zg(e,t,this._line,this._start,this._current))}}function qg(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const Kg=new Float32Array(1),Xg=new Uint32Array(Kg.buffer),Jg=new Uint32Array(Kg.buffer),Yg=new Int32Array(1),e_=new Float32Array(Yg.buffer),t_=new Uint32Array(Yg.buffer),i_=new Uint32Array(1),n_=new Float32Array(i_.buffer),r_=new Int32Array(i_.buffer);function o_(e,t,i){if(t===i)return e;if("f32"===t){if("i32"===i||"x32"===i)return Kg[0]=e,Xg[0];if("u32"===i)return Kg[0]=e,Jg[0]}else if("i32"===t||"x32"===t){if("f32"===i)return Yg[0]=e,e_[0];if("u32"===i)return Yg[0]=e,t_[0]}else if("u32"===t){if("f32"===i)return i_[0]=e,n_[0];if("i32"===i||"x32"===i)return i_[0]=e,r_[0]}return console.error(`Unsupported cast from ${t} to ${i}`),e}class s_{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class a_{constructor(e,t){this.align=e,this.size=t}}class l_{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new ym,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(const t of e)t instanceof Dm&&this._functions.set(t.name,new s_(t));for(const t of e)if(t instanceof hg){const e=this.getTypeInfo(t,null);e instanceof am&&this.structs.push(e)}for(const t of e)if(t instanceof og)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof jm){const e=t,i=this._getAttributeNum(e.attributes,"id",0),n=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new gm(e.name,n,e.attributes,i));continue}if(this._isUniformVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Uniform,e.access);o.access||(o.access="read"),this.uniforms.push(o);continue}if(this._isStorageVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Storage,e.access);s.access||(s.access="read"),this.storage.push(s);continue}if(this._isTextureVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Texture,e.access);s.access||(s.access="read"),o?this.storage.push(s):this.textures.push(s);continue}if(this._isSamplerVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Sampler,e.access);this.samplers.push(o);continue}}for(const t of e)if(t instanceof Dm){const e=this._getAttribute(t,"vertex"),i=this._getAttribute(t,"fragment"),n=this._getAttribute(t,"compute"),r=e||i||n,o=new Am(t.name,null==r?void 0:r.name,t.attributes);o.attributes=t.attributes,o.startLine=t.startLine,o.endLine=t.endLine,this.functions.push(o),this._functions.get(t.name).info=o,r&&(this._functions.get(t.name).inUse=!0,o.inUse=!0,o.resources=this._findResources(t,!!r),o.inputs=this._getInputs(t.args),o.outputs=this._getOutputs(t.returnType),this.entry[r.name].push(o)),o.arguments=t.args.map(e=>new _m(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),o.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const e of this._functions.values())e.info&&(e.info.inUse=e.inUse,this._addCalls(e.node,e.info.calls));for(const e of this._functions.values())e.node.search(t=>{var i,n,r;if(t instanceof kg){if(t.value)if(qg(t.value))for(const n of t.value)for(const t of this.overrides)n===t.name&&(null===(i=e.info)||void 0===i||i.overrides.push(t));else for(const i of this.overrides)t.value===i.name&&(null===(n=e.info)||void 0===n||n.overrides.push(i))}else if(t instanceof vg)for(const i of this.overrides)t.name===i.name&&(null===(r=e.info)||void 0===r||r.overrides.push(i))});for(const e of this.uniforms)this._markStructsInUse(e.type);for(const e of this.storage)this._markStructsInUse(e.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const n of e.calls){const e=null===(i=this._functions.get(n.name))||void 0===i?void 0:i.info;e&&t.add(e)}}findResource(e,t,i){if(i){for(const n of this.entry.compute)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.vertex)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.fragment)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i}for(const i of this.uniforms)if(i.group==e&&i.binding==t)return i;for(const i of this.storage)if(i.group==e&&i.binding==t)return i;for(const i of this.textures)if(i.group==e&&i.binding==t)return i;for(const i of this.samplers)if(i.group==e&&i.binding==t)return i;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],n=this,r=[];return e.search(o=>{if(o instanceof Rm)r.push({});else if(o instanceof Lm)r.pop();else if(o instanceof Vm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof Ag){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(o instanceof Gm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof vg){const e=o;if(r.length>0&&r[r.length-1][e.name])return;const t=n._findResource(e.name);t&&i.push(t)}else if(o instanceof yg){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}else if(o instanceof Xm){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}}),[...new Map(i.map(e=>[e.name,e])).values()]}getBindGroups(){const e=[];function t(t,i){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),i>=e[t].length&&(e[t].length=i+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(void 0===t&&(t=[]),e instanceof hg)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);null!==i&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructOutputs(i.type,t);else{const e=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(null!==e){const n=this.getTypeInfo(i.type,i.type.attributes),r=this._parseInt(e.value),o=new mm(i.name,n,e.name,r);t.push(o)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this.getTypeInfo(e,e.attributes),n=this._parseInt(t.value);return new mm("",i,t.name,n)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const i of e)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this._getAttribute(e,"interpolation"),n=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(t.value),o=new fm(e.name,n,t.name,r);return null!==i&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new pm(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof pg){const i=e.type?this.getTypeInfo(e.type,e.attributes):null,n=new cm(e.name,i,t);return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof fg){const i=e,n=i.format?this.getTypeInfo(i.format,i.attributes):null,r=new lm(i.name,t);return r.format=n,r.count=i.count,this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof hg){const i=e,n=new am(i.name,t);n.startLine=i.startLine,n.endLine=i.endLine;for(const e of i.members){const t=this.getTypeInfo(e.type,e.attributes);n.members.push(new sm(e.name,t,e.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof mg){const i=e,n=i.format instanceof cg,r=i.format?n?this.getTypeInfo(i.format,null):new om(i.format,null):null,o=new um(i.name,r,t,i.access);return this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof dg){const i=e,n=i.format?this.getTypeInfo(i.format,null):null,r=new um(i.name,n,t,i.access);return this._types.set(e,r),this._updateTypeInfo(r),r}const i=new om(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,n;const r=this._getTypeSize(e);if(e.size=null!==(t=null==r?void 0:r.size)&&void 0!==t?t:0,e instanceof lm&&e.format){const t=this._getTypeSize(e.format);e.stride=Math.max(null!==(i=null==t?void 0:t.size)&&void 0!==i?i:0,null!==(n=null==t?void 0:t.align)&&void 0!==n?n:0),this._updateTypeInfo(e.format)}e instanceof cm&&this._updateTypeInfo(e.format),e instanceof am&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,n=0,r=0,o=0;for(let s=0,a=e.members.length;se.name),l_._samplerTypes=$g.sampler_type.map(e=>e.name);let c_=0;class u_{constructor(e,t,i){this.id=c_++,this.name=e,this.value=t,this.node=i}clone(){return new u_(this.name,this.value,this.node)}}class h_{constructor(e){this.id=c_++,this.name=e.name,this.node=e}clone(){return new h_(this.node)}}class d_{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=c_++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new u_(e,t,null!=i?i:null))}setVariable(e,t,i){const n=this.getVariable(e);null!==n?n.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return null!==(t=null==i?void 0:i.value)&&void 0!==t?t:null}clone(){return new d_(this)}}class p_{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class f_{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let n=!0;if(i instanceof Vg)return i.data.forEach(e=>{e||(n=!1)}),new Ug(n?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const e=i.data.some(e=>e);return new Ug(e?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof Ug))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.evalExpression(i,t);if(n instanceof Gg&&0===n.typeInfo.size){const e=n.typeInfo,t=n.buffer.byteLength/e.stride;return new Ug(t,this.getTypeInfo("u32"))}return new Ug(n.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.abs(e)),i.typeInfo);const n=i;return new Ug(Math.abs(n.value),n.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acos(e)),i.typeInfo);const n=i;return new Ug(Math.acos(n.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acosh(e)),i.typeInfo);const n=i;return new Ug(Math.acosh(n.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asin(e)),i.typeInfo);const n=i;return new Ug(Math.asin(n.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asinh(e)),i.typeInfo);const n=i;return new Ug(Math.asinh(n.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atan(e)),i.typeInfo);const n=i;return new Ug(Math.atan(n.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atanh(e)),i.typeInfo);const n=i;return new Ug(Math.atanh(n.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.atan2(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.atan2(r.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.ceil(e)),i.typeInfo);const n=i;return new Ug(Math.ceil(n.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>this._clamp(e,n.data[t],r.data[t])),i.typeInfo);const o=i,s=n,a=r;return new Ug(this._clamp(o.value,s.value,a.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cos(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cosh(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.clz32(e)),i.typeInfo);const n=i;return new Ug(Math.clz32(n.value),i.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countOneBits(e)),i.typeInfo);const n=i;return new Ug(this._countOneBits(n.value),i.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countTrailingZeros(e)),i.typeInfo);const n=i;return new Ug(this._countTrailingZeros(n.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){if(3!==i.data.length||3!==n.data.length)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const t=i.data,r=n.data;return new Vg([t[1]*r[2]-r[1]*t[2],t[2]*r[0]-r[2]*t[0],t[0]*r[1]-r[0]*t[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),n=180/Math.PI;return i instanceof Vg?new Vg(i.data.map(e=>e*n),i.typeInfo):new Ug(i.value*n,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof jg){const e=i.data,t=i.typeInfo.getTypeName(),n=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new Ug(e[0]*e[3]-e[1]*e[2],n);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t)console.error(`TODO: Determinant for ${t}`);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t)console.error(`TODO: Determinant for ${t}`);else{if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);"mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t||"mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t||"mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t?console.error(`TODO: Determinant for ${t}`):"mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||console.error(`TODO: Determinant for ${t}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){let e=0;for(let t=0;tMath.exp(e)),i.typeInfo);const n=i;return new Ug(Math.exp(n.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.pow(2,e)),i.typeInfo);const n=i;return new Ug(Math.pow(2,n.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if("u32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=n.value,s=r.value;if(i instanceof Vg)return new Vg(i.data.map(e=>e>>o&(1<>o&(1<-e),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstLeadingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstLeadingBit(n.value),i.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstTrailingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstTrailingBit(n.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.floor(e)),i.typeInfo);const n=i;return new Ug(Math.floor(n.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return i.data.length!==n.data.length||i.data.length!==r.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new Vg(i.data.map((e,t)=>e*n.data[t]+r.data[t]),i.typeInfo);const o=i,s=n,a=r;return new Ug(o.value*s.value+a.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>e-Math.floor(e)),i.typeInfo);const n=i;return new Ug(n.value-Math.floor(n.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const s=r.value,a=(1<e&l|n.data[t]<1/Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(1/Math.sqrt(n.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){let e=0;return i.data.forEach(t=>{e+=t*t}),new Ug(Math.sqrt(e),this.getTypeInfo("f32"))}const n=i;return new Ug(Math.abs(n.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log(e)),i.typeInfo);const n=i;return new Ug(Math.log(n.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log2(e)),i.typeInfo);const n=i;return new Ug(Math.log2(n.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.max(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.max(r.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.min(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.min(r.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>i.data[t]*(1-r.data[t])+n.data[t]*r.data[t]),i.typeInfo);const o=n,s=r;return new Ug(i.value*(1-s.value)+o.value*s.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>e%n.data[t]),i.typeInfo);const r=n;return new Ug(i.value%r.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const n=this.Length(e,t).value;return new Vg(i.data.map(e=>e/n),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.pow(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.pow(r.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e),i.typeInfo):new Ug(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e*Math.PI/180),i.typeInfo):new Ug(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){const e=this._dot(i.data,n.data);return new Vg(i.data.map((t,i)=>t-2*e*n.data[i]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Ug){const e=this._dot(n.data,i.data);return new Vg(i.data.map((t,i)=>{const o=1-r.value*r.value*(1-e*e);if(o<0)return 0;const s=Math.sqrt(o);return r.value*t-(r.value*e+s)*n.data[i]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.round(e)),i.typeInfo);const n=i;return new Ug(Math.round(n.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.min(Math.max(e,0),1)),i.typeInfo);const n=i;return new Ug(Math.min(Math.max(n.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sign(e)),i.typeInfo);const n=i;return new Ug(Math.sign(n.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sin(e)),i.typeInfo);const n=i;return new Ug(Math.sin(n.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sinh(e)),i.typeInfo);const n=i;return new Ug(Math.sinh(n.value),i.typeInfo)}_smoothstep(e,t,i){const n=Math.min(Math.max((i-e)/(t-e),0),1);return n*n*(3-2*n)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(r instanceof Vg&&i instanceof Vg&&n instanceof Vg)return new Vg(r.data.map((e,t)=>this._smoothstep(i.data[t],n.data[t],e)),r.typeInfo);const o=i,s=n,a=r;return new Ug(this._smoothstep(o.value,s.value,a.value),r.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(Math.sqrt(n.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(n instanceof Vg&&i instanceof Vg)return new Vg(n.data.map((e,t)=>eMath.tan(e)),i.typeInfo);const n=i;return new Ug(Math.tan(n.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.tanh(e)),i.typeInfo);const n=i;return new Ug(Math.tanh(n.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):("mat4x4f"===t||"mat4x4h"===t||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof jg))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const n=this._getTransposeType(i.typeInfo);if("mat2x2"===i.typeInfo.name||"mat2x2f"===i.typeInfo.name||"mat2x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[2],e[1],e[3]],n)}if("mat2x3"===i.typeInfo.name||"mat2x3f"===i.typeInfo.name||"mat2x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7]],n)}if("mat2x4"===i.typeInfo.name||"mat2x4f"===i.typeInfo.name||"mat2x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],n)}if("mat3x2"===i.typeInfo.name||"mat3x2f"===i.typeInfo.name||"mat3x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[1],e[4],e[2],e[5]],n)}if("mat3x3"===i.typeInfo.name||"mat3x3f"===i.typeInfo.name||"mat3x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],n)}if("mat3x4"===i.typeInfo.name||"mat3x4f"===i.typeInfo.name||"mat3x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],n)}if("mat4x2"===i.typeInfo.name||"mat4x2f"===i.typeInfo.name||"mat4x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[1],e[5],e[2],e[6]],n)}if("mat4x3"===i.typeInfo.name||"mat4x3f"===i.typeInfo.name||"mat4x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],n)}if("mat4x4"===i.typeInfo.name||"mat4x4f"===i.typeInfo.name||"mat4x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],n)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.trunc(e)),i.typeInfo);const n=i;return new Ug(Math.trunc(n.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],n=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof vg){const r=i.name,o=t.getVariableValue(r);if(o instanceof Hg){if(n<0||n>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const t=o.getMipLevelSize(n),i=o.dimension;return"1d"===i?new Ug(t[0],this.getTypeInfo("u32")):"3d"===i?new Vg(t,this.getTypeInfo("vec3u")):"2d"===i?new Vg(t.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${i} not found. Line ${e.line}`),null)}return console.error(`Texture ${r} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof vg){const o=i.name,s=t.getVariableValue(o);if(s instanceof Hg){const t=Math.floor(n.data[0]),i=Math.floor(n.data[1]);if(t<0||t>=s.width||i<0||i>=s.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const a=s.getPixel(t,i,0,r);return null===a?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new Vg(a,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,o=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==o.length)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof vg){const s=i.name,a=t.getVariableValue(s);if(a instanceof Hg){const t=a.getMipLevelSize(0),i=Math.floor(n.data[0]),l=Math.floor(n.data[1]);return i<0||i>=t[0]||l<0||l>=t[1]?(console.error(`Texture ${s} out of bounds. Line ${e.line}`),null):(a.setPixel(i,l,0,r,Array.from(o)),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t);return t.getVariable(n).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value+=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicSub(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value-=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMax(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.max(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMin(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.min(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicAnd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value&s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicOr(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value|s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicXor(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value^s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicExchange(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const m_={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},g_={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class __ extends p_{constructor(e,t){var i;super(),this.ast=null!=e?e:[],this.reflection=new l_,this.reflection.updateAST(this.ast),this.context=null!==(i=null==t?void 0:t.clone())&&void 0!==i?i:new d_,this.builtins=new f_(this),this.typeInfo={bool:this.getTypeInfo(cg.bool),i32:this.getTypeInfo(cg.i32),u32:this.getTypeInfo(cg.u32),f32:this.getTypeInfo(cg.f32),f16:this.getTypeInfo(cg.f16),vec2f:this.getTypeInfo(dg.vec2f),vec2u:this.getTypeInfo(dg.vec2u),vec2i:this.getTypeInfo(dg.vec2i),vec2h:this.getTypeInfo(dg.vec2h),vec3f:this.getTypeInfo(dg.vec3f),vec3u:this.getTypeInfo(dg.vec3u),vec3i:this.getTypeInfo(dg.vec3i),vec3h:this.getTypeInfo(dg.vec3h),vec4f:this.getTypeInfo(dg.vec4f),vec4u:this.getTypeInfo(dg.vec4u),vec4i:this.getTypeInfo(dg.vec4i),vec4h:this.getTypeInfo(dg.vec4h),mat2x2f:this.getTypeInfo(dg.mat2x2f),mat2x3f:this.getTypeInfo(dg.mat2x3f),mat2x4f:this.getTypeInfo(dg.mat2x4f),mat3x2f:this.getTypeInfo(dg.mat3x2f),mat3x3f:this.getTypeInfo(dg.mat3x3f),mat3x4f:this.getTypeInfo(dg.mat3x4f),mat4x2f:this.getTypeInfo(dg.mat4x2f),mat4x3f:this.getTypeInfo(dg.mat4x3f),mat4x4f:this.getTypeInfo(dg.mat4x4f)}}getVariableValue(e){var t,i;const n=null!==(i=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==i?i:null;if(null===n)return null;if(n instanceof Ug)return n.value;if(n instanceof Vg)return Array.from(n.data);if(n instanceof jg)return Array.from(n.data);if(n instanceof Gg&&n.typeInfo instanceof lm){if("u32"===n.typeInfo.format.name)return Array.from(new Uint32Array(n.buffer,n.offset,n.typeInfo.count));if("i32"===n.typeInfo.format.name)return Array.from(new Int32Array(n.buffer,n.offset,n.typeInfo.count));if("f32"===n.typeInfo.format.name)return Array.from(new Float32Array(n.buffer,n.offset,n.typeInfo.count))}return console.error(`Unsupported return variable type ${n.typeInfo.name}`),null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,n){const r=this.context.clone();(n=null!=n?n:{}).constants&&this._setOverrides(n.constants,r),this._execStatements(this.ast,r);const o=r.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return void console.error("Invalid dispatch count");1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const s=t[0],a=t[1],l=t[2],c=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new Vg(t,c));const u=this.reflection.getFunctionInfo(e);null===u&&console.error(`Function ${e} not found in reflection data`);for(const e in i)for(const t in i[e]){const n=i[e][t];r.variables.forEach(i=>{var r;const o=i.node;if(null==o?void 0:o.attributes){let s=null,a=null;for(const e of o.attributes)"binding"===e.name?s=e.value:"group"===e.name&&(a=e.value);if(t==s&&e==a){let s=!1;for(const n of u.resources)if(n.name===i.name&&n.group===parseInt(e)&&n.binding===parseInt(t)){s=!0;break}if(s)if(void 0!==n.texture&&void 0!==n.descriptor){const e=new Hg(n.texture,this.getTypeInfo(o.type),n.descriptor,null!==(r=n.texture.view)&&void 0!==r?r:null);i.value=e}else void 0!==n.uniform?i.value=new Gg(n.uniform,this.getTypeInfo(o.type)):i.value=new Gg(n,this.getTypeInfo(o.type))}}})}for(let e=0;e0){const e=i.getVariableValue(t.value[0]);n[0]=e instanceof Ug?e.value:parseInt(t.value[0])}if(t.value.length>1){const e=i.getVariableValue(t.value[1]);n[1]=e instanceof Ug?e.value:parseInt(t.value[1])}if(t.value.length>2){const e=i.getVariableValue(t.value[2]);n[2]=e instanceof Ug?e.value:parseInt(t.value[2])}}const r=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new Vg(n,r));const s=n[0],a=n[1],l=n[2];for(let c=0,u=0;c",r=null;if(e.variable instanceof Cg){const i=this._getVariableData(e.variable,t),n=this.evalExpression(e.value,t),r=e.operator;if("="===r){if(i instanceof Ug||i instanceof Vg||i instanceof jg){if(n instanceof Ug||n instanceof Vg||n instanceof jg&&i.data.length===n.data.length)return void i.data.set(n.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(i instanceof Gg&&n instanceof Gg&&i.buffer.byteLength-i.offset>=n.buffer.byteLength-n.offset)return void(i.buffer.byteLength%4==0?new Uint32Array(i.buffer,i.offset,i.typeInfo.size/4).set(new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4)):new Uint8Array(i.buffer,i.offset,i.typeInfo.size).set(new Uint8Array(n.buffer,n.offset,n.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if("+="===r)return i instanceof Ug||i instanceof Vg||i instanceof jg?n instanceof Ug||n instanceof Vg||n instanceof jg?void i.data.set(n.data.map((e,t)=>i.data[t]+e)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if("-="===r)return(i instanceof Ug||i instanceof Vg||i instanceof jg)&&(n instanceof Ug||n instanceof Vg||n instanceof jg)?void i.data.set(n.data.map((e,t)=>i.data[t]-e)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Cg){if("*"===e.variable.operator){n=this.getVariableName(e.variable.right,t);const r=t.getVariable(n);if(!(r&&r.value instanceof zg))return void console.error(`Variable ${n} is not a pointer. Line ${e.line}`);i=r.value.reference;let o=e.variable.postfix;if(!o){let t=e.variable.right;for(;t instanceof Cg;){if(t.postfix){o=t.postfix;break}t=t.right}}o&&(i=i.getSubData(this,o,t))}}else{r=e.variable.postfix,n=this.getVariableName(e.variable,t);const o=t.getVariable(n);if(null===o)return void console.error(`Variable ${n} not found. Line ${e.line}`);i=o.value}if(i instanceof zg&&(i=i.reference),null===i)return void console.error(`Variable ${n} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),s=e.operator;if("="!==s){const n=i.getSubData(this,r,t);if(n instanceof Vg&&o instanceof Ug){const t=n.data,i=o.value;if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i;else console.error(`Invalid operator ${s}. Line ${e.line}`)}else if(n instanceof Vg&&o instanceof Vg){const t=n.data,i=o.data;if(t.length!==i.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i[e];else console.error(`Invalid operator ${s}. Line ${e.line}`)}else{if(!(n instanceof Ug&&o instanceof Ug))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);"+="===s?n.value+=o.value:"-="===s?n.value-=o.value:"*="===s?n.value*=o.value:"/="===s?n.value/=o.value:"%="===s?n.value%=o.value:"&="===s?n.value&=o.value:"|="===s?n.value|=o.value:"^="===s?n.value^=o.value:"<<="===s?n.value<<=o.value:">>="===s?n.value>>=o.value:console.error(`Invalid operator ${s}. Line ${e.line}`)}return void(i instanceof Gg&&i.setDataValue(this,n,r,t))}if(i instanceof Gg)i.setDataValue(this,o,r,t);else if(r){if(!(i instanceof Vg||i instanceof jg))return void console.error(`Variable ${n} is not a vector or matrix. Line ${e.line}`);if(r instanceof Tg){const s=this.evalExpression(r.index,t).value;if(i instanceof Vg){if(!(o instanceof Ug))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[s]=o.value}else{if(!(i instanceof jg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const s=this.evalExpression(r.index,t).value;if(s<0)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const t=i.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(s<2&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(s<2&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(s<2&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(s<3&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(s<3&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(s<3&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(s<4&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(s<4&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(s<4&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}}}}}else if(r instanceof _g){const t=r.value;if(!(i instanceof Vg))return void console.error(`Invalid assignment to ${t}. Variable ${n} is not a vector. Line ${e.line}`);if(o instanceof Ug){if(t.length>1)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);if("x"===t)i.data[0]=o.value;else if("y"===t){if(i.data.length<2)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[1]=o.value}else if("z"===t){if(i.data.length<3)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[2]=o.value}else if("w"===t){if(i.data.length<4)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(t.length!==o.data.length)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);for(let r=0;r+e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(+e,t)}case"-":{if(qg(n)){const e=n.map((e,t)=>-e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(-e,t)}case"!":{if(qg(n)){const e=n.map((e,t)=>e?0:1);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(e?0:1,t)}case"~":{if(qg(n)){const e=n.map((e,t)=>~e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(~e,t)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),n=this.evalExpression(e.right,t),r=i instanceof Ug?i.value:i instanceof Vg||i instanceof jg?Array.from(i.data):null,o=n instanceof Ug?n.value:n instanceof Vg||n instanceof jg?Array.from(n.data):null;switch(e.operator){case"+":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e+n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t+e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e+t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t+s,a)}case"-":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e-n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t-e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e-t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t-s,a)}case"*":{if(qg(r)&&qg(o)){const t=r,s=o;if(i instanceof jg&&n instanceof jg){const r=function(e,t,i,n){if(void 0===g_[t.name]||void 0===g_[n.name])return null;const r=g_[t.name][0],o=g_[t.name][1],s=g_[n.name][0];if(r!==g_[n.name][1])return null;const a=new Array(s*o);for(let t=0;te*s[t]);return new Vg(n,i.typeInfo)}}if(qg(r)){const e=o,t=r.map((t,i)=>t*e);return i instanceof jg?new jg(t,i.typeInfo):new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e*t);return n instanceof jg?new jg(t,n.typeInfo):new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t*s,a)}case"%":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e%n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t%e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e%t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t%s,a)}case"/":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e/n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t/e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e/t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t/s,a)}case"&":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t&s,a)}case"|":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e|n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t|e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e|t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t|s,a)}case"^":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e^n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t^e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e^t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t^s,a)}case"<<":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<t<e<>":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>>n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>>e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>>t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t>>s,a)}case">":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>o?1:0,this.getTypeInfo("bool"));case"<":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>etee===n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r===o?1:0,this.getTypeInfo("bool"));case"!=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e!==n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t!==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e!==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r!==o?1:0,this.getTypeInfo("bool"));case">=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>=o?1:0,this.getTypeInfo("bool"));case"<=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t<=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e<=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r<=o?1:0,this.getTypeInfo("bool"));case"&&":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&&n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&&e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&&t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r&&o?1:0,this.getTypeInfo("bool"));case"||":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e||n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t||e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e||t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const n=t.getFunction(e.name);if(!n)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let t=0;tr?o.slice(0,r):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),n=e.type.getTypeName(),r=g_[n];if(void 0===r)return console.error(`Invalid matrix constructor ${n}. Line ${e.line}`),null;const o=[];if(e instanceof bg)if(e.isVector){const t=e.vectorValue;for(const e of t)o.push(e)}else o.push(e.scalarValue);else if(e.args)for(const i of e.args){const e=this.evalExpression(i,t);e instanceof Vg?o.push(...e.data):e instanceof Ug?o.push(e.value):e instanceof jg&&o.push(...e.data)}if(i instanceof um&&null===i.format&&(i.format=this.getTypeInfo("f32")),0===o.length){const n=new Array(r[2]).fill(0);return new jg(n,i).getSubData(this,e.postfix,t)}return o.length!==r[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new jg(o,i).getSubData(this,e.postfix,t)}}__._breakObj=new Dg(new om("BREAK",null),null),__._continueObj=new Dg(new om("CONTINUE",null),null),__._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class A_{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class y_{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new A_,this._exec=new __,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const i=t.arrayType,n=t.countNode;if(n instanceof vg){const t=n.name,r=this._context.constants.get(t);if(r)try{const e=r.constEvaluate(this._exec);i.count=e}catch(e){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const e of t)e.search(e=>{e instanceof Fg||e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg?e.format=this._forwardType(e.format):e instanceof Vm||e instanceof Gm||e instanceof Hm?e.type=this._forwardType(e.type):e instanceof Dm?e.returnType=this._forwardType(e.returnType):e instanceof Rg&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof ug){const t=this._getType(e.name);if(t)return t}else e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new Wg(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==$g.eof}_match(e){if(e instanceof Qg)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check($g.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match($g.keywords.continue)){const t=this._updateNode(new lg);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume($g.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match($g.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Om(t),e)}_while_statement(){if(!this._match($g.keywords.while))return null;const e=this._updateNode(new zm(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match($g.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new Um(i,e),t)}_for_statement(){if(!this._match($g.keywords.for))return null;this._consume($g.tokens.paren_left,"Expected '('.");const e=this._updateNode(new Nm(null,null,null,null));return this._currentLoop.push(e),e.init=this._check($g.tokens.semicolon)?null:this._for_init(),this._consume($g.tokens.semicolon,"Expected ';'."),e.condition=this._check($g.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume($g.tokens.semicolon,"Expected ';'."),e.increment=this._check($g.tokens.paren_right)?null:this._for_increment(),this._consume($g.tokens.paren_right,"Expected ')'."),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check($g.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match($g.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Vm(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match($g.keywords.let)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for let.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for let.");const n=this._short_circuit_or_expression();return this._updateNode(new Gm(t,i,null,null,n),e)}if(this._match($g.keywords.const)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for const.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for const.");const n=this._short_circuit_or_expression();return null===i&&n instanceof bg&&(i=n.type),this._updateNode(new Hm(t,i,null,null,n),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check($g.increment_operators))return this._current=e,null;const i=this._consume($g.increment_operators,"Expected increment operator");return this._updateNode(new qm(i.type===$g.tokens.plus_plus?Qm.increment:Qm.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check($g.tokens.brace_right))return null;let i=this._match($g.tokens.underscore);if(i||(e=this._unary_expression()),!i&&null==e)return null;const n=this._consume($g.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new Km($m.parse(n.lexeme),e,r),t)}_func_call_statement(){if(!this._check($g.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume($g.tokens.ident,"Expected function name."),n=this._argument_expression_list();return null===n?(this._current=t,null):this._updateNode(new Xm(i.lexeme,n),e)}_loop_statement(){if(!this._match($g.keywords.loop))return null;this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Jm([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof Um){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume($g.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match($g.keywords.switch))return null;const e=this._updateNode(new Ym(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume($g.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([$g.keywords.default,$g.keywords.case]);){if(this._match($g.keywords.case)){const i=this._case_selectors();for(const e of i)if(e instanceof Ig){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch case.");const n=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Mg(i,n)))}if(this._match($g.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Pg(i)))}}return e}_case_selectors(){const e=[];for(this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());this._match($g.tokens.comma);)this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());return e}_case_body(){if(this._match($g.keywords.fallthrough))return this._consume($g.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);const t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match($g.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check($g.tokens.attr)&&this._attribute();const i=this._compound_statement();let n=[];this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),n=this._elseif_statement(n));let r=null;return this._match($g.keywords.else)&&(this._check($g.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new eg(t,i,n,r),e)}_match_elseif(){return this._tokens[this._current].type===$g.keywords.else&&this._tokens[this._current+1].type===$g.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new Lg(t,i))),this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match($g.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new tg(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match($g.tokens.or_or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match($g.tokens.and_and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match($g.tokens.or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match($g.tokens.xor);)e=this._updateNode(new Sg(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match($g.tokens.and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([$g.tokens.equal_equal,$g.tokens.not_equal])?this._updateNode(new Sg(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([$g.tokens.less_than,$g.tokens.greater_than,$g.tokens.less_than_equal,$g.tokens.greater_than_equal]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([$g.tokens.shift_left,$g.tokens.shift_right]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([$g.tokens.plus,$g.tokens.minus]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([$g.tokens.star,$g.tokens.forward_slash,$g.tokens.modulo]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([$g.tokens.minus,$g.tokens.bang,$g.tokens.tilde,$g.tokens.star,$g.tokens.and])?this._updateNode(new Cg(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match($g.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume($g.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new Tg(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match($g.tokens.period)){const e=this._consume($g.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new _g(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(null!==t)return t;switch(e){case"void":return cg.void;case"bool":return cg.bool;case"i32":return cg.i32;case"u32":return cg.u32;case"f32":return cg.f32;case"f16":return cg.f16;case"vec2f":return dg.vec2f;case"vec3f":return dg.vec3f;case"vec4f":return dg.vec4f;case"vec2i":return dg.vec2i;case"vec3i":return dg.vec3i;case"vec4i":return dg.vec4i;case"vec2u":return dg.vec2u;case"vec3u":return dg.vec3u;case"vec4u":return dg.vec4u;case"vec2h":return dg.vec2h;case"vec3h":return dg.vec3h;case"vec4h":return dg.vec4h;case"mat2x2f":return dg.mat2x2f;case"mat2x3f":return dg.mat2x3f;case"mat2x4f":return dg.mat2x4f;case"mat3x2f":return dg.mat3x2f;case"mat3x3f":return dg.mat3x3f;case"mat3x4f":return dg.mat3x4f;case"mat4x2f":return dg.mat4x2f;case"mat4x3f":return dg.mat4x3f;case"mat4x4f":return dg.mat4x4f;case"mat2x2h":return dg.mat2x2h;case"mat2x3h":return dg.mat2x3h;case"mat2x4h":return dg.mat2x4h;case"mat3x2h":return dg.mat3x2h;case"mat3x3h":return dg.mat3x3h;case"mat3x4h":return dg.mat3x4h;case"mat4x2h":return dg.mat4x2h;case"mat4x3h":return dg.mat4x3h;case"mat4x4h":return dg.mat4x4h;case"mat2x2i":return dg.mat2x2i;case"mat2x3i":return dg.mat2x3i;case"mat2x4i":return dg.mat2x4i;case"mat3x2i":return dg.mat3x2i;case"mat3x3i":return dg.mat3x3i;case"mat3x4i":return dg.mat3x4i;case"mat4x2i":return dg.mat4x2i;case"mat4x3i":return dg.mat4x3i;case"mat4x4i":return dg.mat4x4i;case"mat2x2u":return dg.mat2x2u;case"mat2x3u":return dg.mat2x3u;case"mat2x4u":return dg.mat2x4u;case"mat3x2u":return dg.mat3x2u;case"mat3x3u":return dg.mat3x3u;case"mat3x4u":return dg.mat3x4u;case"mat4x2u":return dg.mat4x2u;case"mat4x3u":return dg.mat4x3u;case"mat4x4u":return dg.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match($g.tokens.ident)){const e=this._previous().toString();if(this._check($g.tokens.paren_left)){const t=this._argument_expression_list(),i=this._getType(e);return null!==i?this._updateNode(new Ag(i,t)):this._updateNode(new yg(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new xg(e,t.value))}return this._updateNode(new vg(e))}if(this._match($g.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?cg.i32:e.endsWith("u")||e.endsWith("U")?cg.u32:cg.x32;const i=parseInt(e);return this._validateTypeRange(i,t),this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(t)),t))}if(this._match($g.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,cg.u32),this._updateNode(new bg(new Ug(e,this._exec.getTypeInfo(cg.u32)),cg.u32))}if(this._match([$g.tokens.decimal_float_literal,$g.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));const i=parseFloat(e);this._validateTypeRange(i,t?cg.f16:cg.f32);const n=t?cg.f16:cg.f32;return this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(n)),n))}if(this._match([$g.keywords.true,$g.keywords.false])){let e=this._previous().toString()===$g.keywords.true.rule;return this._updateNode(new bg(new Ug(e?1:0,this._exec.getTypeInfo(cg.bool)),cg.bool))}if(this._check($g.tokens.paren_left))return this._paren_expression();if(this._match($g.keywords.bitcast)){this._consume($g.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume($g.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new wg(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Ag(e,t))}_argument_expression_list(){if(!this._match($g.tokens.paren_left))return null;const e=[];do{if(this._check($g.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match($g.tokens.comma));return this._consume($g.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match($g.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match($g.tokens.paren_right),e}_paren_expression(){this._consume($g.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume($g.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match($g.keywords.struct))return null;const e=this._currentLine,t=this._consume($g.tokens.ident,"Expected name for struct.").toString();this._consume($g.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check($g.tokens.brace_right);){const e=this._attribute(),t=this._consume($g.tokens.name,"Expected variable name.").toString();this._consume($g.tokens.colon,"Expected ':' for struct member type.");const n=this._attribute(),r=this._type_decl();null!=r&&(r.attributes=n),this._check($g.tokens.brace_right)?this._match($g.tokens.comma):this._consume($g.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new Fg(t,r,e)))}this._consume($g.tokens.brace_right,"Expected '}' after struct body.");const n=this._currentLine,r=this._updateNode(new hg(t,i,e,n),e);return this._context.structs.set(t,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match($g.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof bg){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof bg&&(e.type="x32"===e.value.type.name?cg.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match($g.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match($g.keywords.const))return null;const t=this._consume($g.tokens.name,"Expected variable name"),i=this._currentLine;let n=null;if(this._match($g.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}let r=null;this._consume($g.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let e=[cg.f32],i=o.constEvaluate(this._exec,e);i instanceof Ug&&this._validateTypeRange(i.value,e[0]),e[0]instanceof dg&&null===e[0].format&&i.typeInfo instanceof um&&null!==i.typeInfo.format&&("f16"===i.typeInfo.format.name?e[0].format=cg.f16:"f32"===i.typeInfo.format.name?e[0].format=cg.f32:"i32"===i.typeInfo.format.name?e[0].format=cg.i32:"u32"===i.typeInfo.format.name?e[0].format=cg.u32:"bool"===i.typeInfo.format.name?e[0].format=cg.bool:console.error(`TODO: impelement template format type ${i.typeInfo.format.name}`)),r=this._updateNode(new bg(i,e[0])),this._exec.context.setVariable(t.toString(),i)}catch(e){r=o}if(null!==n&&r instanceof bg){if("x32"!==r.type.name&&n.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${n.name}. Line:${this._currentLine}`);r.type=n,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else null===n&&r instanceof bg&&(n=null!==(e=null==r?void 0:r.type)&&void 0!==e?e:cg.f32,n===cg.x32&&(n=cg.i32));const s=this._updateNode(new Hm(t.toString(),n,"","",r),i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match($g.keywords.let))return null;const e=this._currentLine,t=this._consume($g.tokens.name,"Expected variable name");let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}let n=null;if(this._match($g.tokens.equal)&&(n=this._const_expression()),null!==i&&n instanceof bg){if("x32"!==n.type.name&&i.getTypeName()!==n.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${n.type.name} to ${i.name}. Line:${this._currentLine}`);n.type=i}else null===i&&n instanceof bg&&(i="x32"===n.type.name?cg.i32:n.type);return n instanceof bg&&n.isScalar&&this._validateTypeRange(n.scalarValue,i),this._updateNode(new Gm(t.toString(),i,"","",n),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match($g.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match($g.tokens.less_than)&&(t=this._consume($g.storage_class,"Expected storage_class.").toString(),this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode.").toString()),this._consume($g.tokens.greater_than,"Expected '>'."));const n=this._consume($g.tokens.name,"Expected variable name");let r=null;if(this._match($g.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}return this._updateNode(new Vm(n.toString(),r,t,i,null),e)}_override_decl(){if(!this._match($g.keywords.override))return null;const e=this._consume($g.tokens.name,"Expected variable name");let t=null;if(this._match($g.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new jm(e.toString(),t,null))}_diagnostic(){this._consume($g.tokens.paren_left,"Expected '('");const e=this._consume($g.tokens.ident,"Expected severity control name.");this._consume($g.tokens.comma,"Expected ','");let t=this._consume($g.tokens.ident,"Expected diagnostic rule name.").toString();return this._match($g.tokens.period)&&(t+=`.${this._consume($g.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume($g.tokens.paren_right,"Expected ')'"),this._updateNode(new rg(e.toString(),t))}_enable_directive(){const e=this._consume($g.tokens.ident,"identity expected.");return this._updateNode(new ig(e.toString()))}_requires_directive(){const e=[this._consume($g.tokens.ident,"identity expected.").toString()];for(;this._match($g.tokens.comma);){const t=this._consume($g.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new ng(e))}_type_alias(){const e=this._consume($g.tokens.ident,"identity expected.");this._consume($g.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new og(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([$g.tokens.ident,...$g.texel_format,$g.keywords.bool,$g.keywords.f32,$g.keywords.i32,$g.keywords.u32])){const e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){const t=this._updateNode(new ug(e));return this._forwardTypeCount++,t}return this._updateNode(new cg(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check($g.template_types)){let e=this._advance().toString(),t=null,i=null;return this._match($g.tokens.less_than)&&(t=this._type_decl(),i=null,this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new dg(e,t,i))}if(this._match($g.keywords.ptr)){let e=this._previous().toString();this._consume($g.tokens.less_than,"Expected '<' for pointer.");const t=this._consume($g.storage_class,"Expected storage_class for pointer");this._consume($g.tokens.comma,"Expected ',' for pointer.");const i=this._type_decl();let n=null;return this._match($g.tokens.comma)&&(n=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new pg(e,t.toString(),i,n))}const t=this._attribute();if(this._match($g.keywords.array)){let i=null,n=-1;const r=this._previous();let o=null;if(this._match($g.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let t="";if(this._match($g.tokens.comma)){o=this._shift_expression();try{t=o.constEvaluate(this._exec).toString(),o=null}catch(e){t="1"}}this._consume($g.tokens.greater_than,"Expected '>' for array."),n=t?parseInt(t):0}const s=this._updateNode(new fg(r.toString(),t,i,n));return o&&this._deferArrayCountEval.push({arrayType:s,countNode:o}),s}return null}_texture_sampler_types(){if(this._match($g.sampler_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.depth_texture_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.sampled_texture_type)||this._match($g.multisampled_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,null))}if(this._match($g.storage_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume($g.texel_format,"Invalid texel format.").toString();this._consume($g.tokens.comma,"Expected ',' after texel format.");const i=this._consume($g.access_mode,"Expected access mode for storage texture type.").toString();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match($g.tokens.attr);){const t=this._consume($g.attribute_name,"Expected attribute name"),i=this._updateNode(new kg(t.toString(),null));if(this._match($g.tokens.paren_left)){if(i.value=this._consume($g.literal_or_ident,"Expected attribute value").toString(),this._check($g.tokens.comma)){this._advance();do{const e=this._consume($g.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(e)}while(this._match($g.tokens.comma))}this._consume($g.tokens.paren_right,"Expected ')'")}e.push(i)}return 0==e.length?null:e}}class v_ extends l_{constructor(e){super(),e&&this.update(e)}update(e){const t=(new y_).parse(e);this.updateAST(t)}}function x_(e){const t={attributes:[],bindings:[]};let i;try{i=function(e){try{return new v_(e)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw"object"==typeof e&&e?.message&&(t+=`: ${e.message} `),"object"==typeof e&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}(e)}catch(e){return Gp.error(e.message)(),t}for(const e of i.uniforms){const i=[];for(const t of e.type?.members||[])i.push({name:t.name,type:b_(t.type)});t.bindings.push({type:"uniform",name:e.name,location:e.binding,group:e.group,members:i})}const n=i.entry.vertex[0],r=n?.inputs.length||0;for(let e=0;e`:e.name}const w_={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\nfloat sin_taylor_fp32(float a) {\nfloat r, s, t, x;\nif (a == 0.0) {\nreturn 0.0;\n}\nx = -a * a;\ns = a;\nr = a;\nr = r * x;\nt = r * INVERSE_FACTORIAL_3;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_5;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_7;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_9;\ns = s + t;\nreturn s;\n}\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\nif (a == 0.0) {\nsin_t = 0.0;\ncos_t = 1.0;\n}\nsin_t = sin_taylor_fp32(a);\ncos_t = sqrt(1.0 - sin_t * sin_t);\n}\nfloat tan_taylor_fp32(float a) {\nfloat sin_a;\nfloat cos_a;\nif (a == 0.0) {\nreturn 0.0;\n}\nfloat z = floor(a / TWO_PI);\nfloat r = a - TWO_PI * z;\nfloat t;\nfloat q = floor(r / PI_2 + 0.5);\nint j = int(q);\nif (j < -2 || j > 2) {\nreturn 1.0 / 0.0;\n}\nt = r - PI_2 * q;\nq = floor(t / PI_16 + 0.5);\nint k = int(q);\nint abs_k = int(abs(float(k)));\nif (abs_k > 4) {\nreturn 1.0 / 0.0;\n} else {\nt = t - PI_16 * q;\n}\nfloat u = 0.0;\nfloat v = 0.0;\nfloat sin_t, cos_t;\nfloat s, c;\nsincos_taylor_fp32(t, sin_t, cos_t);\nif (k == 0) {\ns = sin_t;\nc = cos_t;\n} else {\nif (abs(float(abs_k) - 1.0) < 0.5) {\nu = COS_TABLE_0;\nv = SIN_TABLE_0;\n} else if (abs(float(abs_k) - 2.0) < 0.5) {\nu = COS_TABLE_1;\nv = SIN_TABLE_1;\n} else if (abs(float(abs_k) - 3.0) < 0.5) {\nu = COS_TABLE_2;\nv = SIN_TABLE_2;\n} else if (abs(float(abs_k) - 4.0) < 0.5) {\nu = COS_TABLE_3;\nv = SIN_TABLE_3;\n}\nif (k > 0) {\ns = u * sin_t + v * cos_t;\nc = u * cos_t - v * sin_t;\n} else {\ns = u * sin_t - v * cos_t;\nc = u * cos_t + v * sin_t;\n}\n}\nif (j == 0) {\nsin_a = s;\ncos_a = c;\n} else if (j == 1) {\nsin_a = c;\ncos_a = -s;\n} else if (j == -1) {\nsin_a = -c;\ncos_a = s;\n} else {\nsin_a = -s;\ncos_a = -c;\n}\nreturn sin_a / cos_a;\n}\n#endif\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nreturn tan_taylor_fp32(a);\n#else\nreturn tan(a);\n#endif\n}\n"},T_={name:"picking",vs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nout vec4 picking_vRGBcolor_Avalid;\nvec3 picking_normalizeColor(vec3 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nvec4 picking_normalizeColor(vec4 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nbool picking_isColorZero(vec3 color) {\nreturn dot(color, vec3(1.0)) < 0.00001;\n}\nbool picking_isColorValid(vec3 color) {\nreturn dot(color, vec3(1.0)) > 0.00001;\n}\nbool isVertexHighlighted(vec3 vertexColor) {\nvec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\nreturn\nbool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\nvoid picking_setPickingColor(vec3 pickingColor) {\npickingColor = picking_normalizeColor(pickingColor);\nif (bool(picking.isActive)) {\npicking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\nif (!bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = pickingColor;\n}\n} else {\npicking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n}\n}\nvoid picking_setPickingAttribute(float value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.r = value;\n}\n}\nvoid picking_setPickingAttribute(vec2 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rg = value;\n}\n}\nvoid picking_setPickingAttribute(vec3 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = value;\n}\n}\n",fs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\nif (picking.isActive > 0.5) {\nreturn color;\n}\nbool selected = bool(picking_vRGBcolor_Avalid.a);\nif (selected) {\nfloat highLightAlpha = picking.highlightColor.a;\nfloat blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\nfloat highLightRatio = highLightAlpha / blendedAlpha;\nvec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\nreturn vec4(blendedRGB, blendedAlpha);\n} else {\nreturn color;\n}\n}\nvec4 picking_filterPickingColor(vec4 color) {\nif (bool(picking.isActive)) {\nif (picking_vRGBcolor_Avalid.a == 0.0) {\ndiscard;\n}\nreturn picking_vRGBcolor_Avalid;\n}\nreturn color;\n}\nvec4 picking_filterColor(vec4 color) {\nvec4 highlightColor = picking_filterHighlightColor(color);\nreturn picking_filterPickingColor(highlightColor);\n}\n",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},getUniforms:function(e={},t){const i={};if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=t}if(e.highlightColor){const t=Array.from(e.highlightColor,e=>e/255);Number.isFinite(t[3])||(t[3]=1),i.highlightColor=t}void 0!==e.isActive&&(i.isActive=Boolean(e.isActive),i.isAttribute=Boolean(e.isAttribute));void 0!==e.useFloatColors&&(i.useFloatColors=Boolean(e.useFloatColors));return i}};function E_(e,t=[],i=0){const n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function C_(e){return e-Math.fround(e)}function S_(e){const t=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){const r=4*i+n;E_(e[4*n+i],t,2*r)}return t}const B_={ONE:1};const I_={name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\nconst float SPLIT = 4097.0;\nfloat t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat a_hi = t * ONE - (t - a);\nfloat a_lo = a * ONE - a_hi;\n#else\nfloat a_hi = t - (t - a);\nfloat a_lo = a - a_hi;\n#endif\nreturn vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\nvec2 b = split(a.x);\nb.y += a.y;\nreturn b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat sum = (a + b) * ONE;\nfloat err = b - (sum - a) * ONE;\n#else\nfloat sum = a + b;\nfloat err = b - (sum - a);\n#endif\nreturn vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\nfloat s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) + (b - v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSub(float a, float b) {\nfloat s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) - (b + v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSqr(float a) {\nfloat prod = a * a;\nvec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\na_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\nfloat err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\nreturn vec2(prod, err);\n}\nvec2 twoProd(float a, float b) {\nfloat prod = a * b;\nvec2 a_fp64 = split(a);\nvec2 b_fp64 = split(b);\nfloat err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\na_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\nreturn vec2(prod, err);\n}\nvec2 sum_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSum(a.x, b.x);\nt = twoSum(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 sub_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSub(a.x, b.x);\nt = twoSub(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 mul_fp64(vec2 a, vec2 b) {\nvec2 prod = twoProd(a.x, b.x);\nprod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nprod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nreturn prod;\n}\nvec2 div_fp64(vec2 a, vec2 b) {\nfloat xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nvec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\nvec2 yn = a * xn;\n#endif\nfloat diff = (sub_fp64(a, mul_fp64(b, yn))).x;\nvec2 prod = twoProd(xn, diff);\nreturn sum_fp64(yn, prod);\n}\nvec2 sqrt_fp64(vec2 a) {\nif (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\nif (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\nfloat x = 1.0 / sqrt(a.x);\nfloat yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nvec2 yn_sqr = twoSqr(yn) * ONE;\n#else\nvec2 yn_sqr = twoSqr(yn);\n#endif\nfloat diff = sub_fp64(a, yn_sqr).x;\nvec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nreturn sum_fp64(split(yn), prod);\n#else\nreturn sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",getUniforms:function(){return B_},fp64ify:E_,fp64LowPart:C_,fp64ifyMatrix4:S_},M_=1/Math.PI*180,P_=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};const R_=globalThis.mathgl.config;function L_(e,{precision:t=R_.precision}={}){return e=function(e){return Math.round(e/R_.EPSILON)*R_.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function F_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function k_(e){return function(e,t){return V_(e,e=>e*P_,t)}(e)}function D_(e){return O_(e)}function O_(e,t){return V_(e,e=>e*M_,t)}function z_(e,t,i){return V_(e,e=>Math.max(t,Math.min(i,e)))}function U_(e,t,i){return F_(e)?e.map((e,n)=>U_(e,t[n],i)):i*t+(1-i)*e}function N_(e,t,i){const n=R_.EPSILON;i&&(R_.EPSILON=i);try{if(e===t)return!0;if(F_(e)&&F_(t)){if(e.length!==t.length)return!1;for(let i=0;i0?", ":"")+L_(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t=0&&e=0&&e0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(TA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=n,this[2]=s,this[3]=t,this[4]=r,this[5]=a,this[6]=i,this[7]=o,this[8]=l,this.check()}determinant(){return function(e){const t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*(c*o-s*l)+i*(-c*r+s*a)+n*(l*r-o*a)}(this)}transpose(){return function(e,t){if(e===t){const i=t[1],n=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=n,e[7]=r}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]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*s-a*c,d=-u*o+a*l,p=c*o-s*l;let f=i*h+n*d+r*p;f&&(f=1/f,e[0]=h*f,e[1]=(-u*n+r*c)*f,e[2]=(a*n-r*s)*f,e[3]=d*f,e[4]=(u*i-r*l)*f,e[5]=(-a*i+r*o)*f,e[6]=p*f,e[7]=(-c*i+n*l)*f,e[8]=(s*i-n*o)*f)}(this,this),this.check()}multiplyLeft(e){return xA(this,e,this),this.check()}multiplyRight(e){return xA(this,this,e),this.check()}rotate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(i),p=Math.cos(i);e[0]=p*n+d*s,e[1]=p*r+d*a,e[2]=p*o+d*l,e[3]=p*s-d*n,e[4]=p*a-d*r,e[5]=p*l-d*o,e[6]=c,e[7]=u,e[8]=h}(this,this,e),this.check()}scale(e){return Array.isArray(e)?bA(this,this,e):bA(this,this,[e,e]),this.check()}translate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1];e[0]=n,e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*n+p*s+c,e[7]=d*r+p*a+u,e[8]=d*o+p*l+h}(this,this,e),this.check()}transform(e,t){let i;switch(e.length){case 2:i=J_(t||[-0,-0],e,this);break;case 3:i=uA(t||[-0,-0,-0],e,this);break;case 4:i=iA(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return H_(i,e.length),i}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let CA,SA=null;function BA(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g;let M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(M=1/M,e[0]=(a*I-l*B+c*S)*M,e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function IA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15];let y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*n+v*a+x*h+b*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*n+v*a+x*h+b*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*n+v*a+x*h+b*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function MA(e,t,i){const n=i[0],r=i[1],o=i[2];let s,a,l,c,u,h,d,p,f,m,g,_;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*o+t[12],e[13]=t[1]*n+t[5]*r+t[9]*o+t[13],e[14]=t[2]*n+t[6]*r+t[10]*o+t[14],e[15]=t[3]*n+t[7]*r+t[11]*o+t[15]):(s=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*n+u*r+f*o+t[12],e[13]=a*n+h*r+m*o+t[13],e[14]=l*n+d*r+g*o+t[14],e[15]=c*n+p*r+_*o+t[15]),e}function PA(e,t,i){const n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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}function RA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function LA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}const FA=function(e,t,i,n,r){const o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=r&&r!==1/0){const t=1/(n-r);e[10]=(r+n)*t,e[14]=2*r*n*t}else e[10]=-1,e[14]=-2*n;return e};const kA=function(e,t,i,n,r,o,s){const a=1/(t-i),l=1/(n-r),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]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e};function DA(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}function OA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}var zA;!function(){const e=function(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}(),function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(zA||(zA={}));const UA=45*Math.PI/180,NA=1,VA=.1,jA=500,GA=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class HA extends vA{static get IDENTITY(){return function(){$A||($A=new HA,Object.freeze($A));return $A}()}static get ZERO(){return function(){QA||(QA=new HA([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(QA));return QA}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return zA}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this[9]=c,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=f,this[15]=m,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=r,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=c,this[7]=p,this[8]=i,this[9]=s,this[10]=u,this[11]=f,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(GA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:i,bottom:n,top:r,near:o=VA,far:s=jA}=e;return s===1/0?function(e,t,i,n,r,o){const s=2*o/(i-t),a=2*o/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),u=-1,h=-1,d=-2*o;e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=l,e[9]=c,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,i,n,r,o):function(e,t,i,n,r,o,s){const a=1/(i-t),l=1/(r-n),c=1/(o-s);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]=(r+n)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0}(this,t,i,n,r,o,s),this.check()}lookAt(e){const{eye:t,center:i=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,i,n){let r,o,s,a,l,c,u,h,d,p;const f=t[0],m=t[1],g=t[2],_=n[0],A=n[1],y=n[2],v=i[0],x=i[1],b=i[2];Math.abs(f-v)2*Math.PI)throw Error("expected radians")}function WA(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function qA(e,t,i){i*=.5;const n=Math.sin(i);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i),e}function KA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=n*u+s*a+r*c-o*l,e[1]=r*u+s*l+o*a-n*c,e[2]=o*u+s*c+n*l-r*a,e[3]=s*u-n*a-r*l-o*c,e}function XA(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];let l,c,u,h,d,p=i[0],f=i[1],m=i[2],g=i[3];return l=r*p+o*f+s*m+a*g,l<0&&(l=-l,p=-p,f=-f,m=-m,g=-g),1-l>Z_?(c=Math.acos(l),d=Math.sin(c),u=Math.sin((1-n)*c)/d,h=Math.sin(n*c)/d):(u=1-n,h=n),e[0]=u*r+h*p,e[1]=u*o+h*f,e[2]=u*s+h*m,e[3]=u*a+h*g,e}function JA(e,t){const i=t[0]+t[4]+t[8];let n;if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);const r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e}const YA=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},ey=DA,ty=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},iy=function(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},ny=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)},ry=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return t*t+i*i+n*n+r*r},oy=function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3];let s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e},sy=function(){const e=rA(),t=sA(1,0,0),i=sA(0,1,0);return function(n,r,o){const s=aA(r,o);return s<-.999999?(lA(e,t,r),pA(e)<1e-6&&lA(e,i,r),function(e,t){const i=t[0],n=t[1],r=t[2];let o=i*i+n*n+r*r;o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o}(e,e),qA(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(lA(e,r,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,oy(n,n))}}();!function(){const e=WA(),t=WA()}(),function(){const e=function(){const e=new W_(9);return W_!=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}()}();const ay=[0,0,0,1];class ly extends j_{constructor(e=0,t=0,i=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,i,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,i,n){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return JA(this,e),this.check()}fromAxisRotation(e,t){return qA(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=G_(e)}get y(){return this[1]}set y(e){this[1]=G_(e)}get z(){return this[2]}set z(e){this[2]=G_(e)}get w(){return this[3]}set w(e){this[3]=G_(e)}len(){return ny(this)}lengthSquared(){return ry(this)}dot(e){return ty(this,e)}rotationTo(e,t){return sy(this,e,t),this.check()}add(e){return YA(this,this,e),this.check()}calculateW(){return function(e,t){const i=t[0],n=t[1],r=t[2];e[0]=i,e[1]=n,e[2]=r,e[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o,a=s?1/s:0;e[0]=-i*a,e[1]=-n*a,e[2]=-r*a,e[3]=o*a}(this,this),this.check()}lerp(e,t,i){return void 0===i?this.lerp(this,e,t):(iy(this,e,t,i),this.check())}multiplyRight(e){return KA(this,this,e),this.check()}multiplyLeft(e){return KA(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a}(this,this,e),this.check()}rotateY(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=o*l+s*a,e[3]=s*l-o*a}(this,this,e),this.check()}scale(e){return ey(this,this,e),this.check()}slerp(e,t,i){let n,r,o;switch(arguments.length){case 1:({start:n=ay,target:r,ratio:o}=e);break;case 2:n=this,r=e,o=t;break;default:n=e,r=t,o=i}return XA(this,n,r,o),this.check()}transformVector4(e,t=new yA){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],u=c*n+a*o-l*r,h=c*r+l*n-s*o,d=c*o+s*r-a*n,p=-s*n-a*r-l*o;e[0]=u*c+p*-s+h*-l-d*-a,e[1]=h*c+p*-a+d*-s-u*-l,e[2]=d*c+p*-l+u*-a-h*-s,e[3]=t[3]}(t,e,this),H_(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const cy="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\nvec3 color;\n};\nstruct PointLight {\nvec3 color;\nvec3 position;\nvec3 attenuation;\n};\nstruct DirectionalLight {\nvec3 color;\nvec3 direction;\n};\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\nuniform bool lighting_uEnabled;\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\nreturn pointLight.attenuation.x\n+ pointLight.attenuation.y * distance\n+ pointLight.attenuation.z * distance * distance;\n}\n#endif\n",uy={lightSources:{}};function hy(e={}){const{color:t=[0,0,0],intensity:i=1}=e;return t.map(e=>e*i/255)}const dy={name:"lights",vs:cy,fs:cy,getUniforms:function e(t=uy){if("lightSources"in t){const{ambientLight:e,pointLights:i,directionalLights:n}=t.lightSources||{};return e||i&&i.length>0||n&&n.length>0?Object.assign({},function({ambientLight:e,pointLights:t=[],directionalLights:i=[]}){const n={};return n["lighting_uAmbientLight.color"]=e?hy(e):[0,0,0],t.forEach((e,t)=>{n[`lighting_uPointLight[${t}].color`]=hy(e),n[`lighting_uPointLight[${t}].position`]=e.position,n[`lighting_uPointLight[${t}].attenuation`]=e.attenuation||[1,0,0]}),n.lighting_uPointLightCount=t.length,i.forEach((e,t)=>{n[`lighting_uDirectionalLight[${t}].color`]=hy(e),n[`lighting_uDirectionalLight[${t}].direction`]=e.direction}),n.lighting_uDirectionalLightCount=i.length,n}({ambientLight:e,pointLights:i,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const i={pointLights:[],directionalLights:[]};for(const e of t.lights||[])switch(e.type){case"ambient":i.ambientLight=e;break;case"directional":i.directionalLights?.push(e);break;case"point":i.pointLights?.push(e)}return e({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}},py="uniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\nvec3 halfway_direction = normalize(light_direction + view_direction);\nfloat lambertian = dot(light_direction, normal_worldspace);\nfloat specular = 0.0;\nif (lambertian > 0.0) {\nfloat specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\nspecular = pow(specular_angle, lighting_uShininess);\n}\nlambertian = max(lambertian, 0.0);\nreturn (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = surfaceColor;\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nlightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = vec3(0, 0, 0);\nvec3 surfaceColor = vec3(0, 0, 0);\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\n",fy={};function my(e=fy){if(!("material"in e))return{};const{material:t}=e;return t?function(e){const{ambient:t=.35,diffuse:i=.6,shininess:n=32,specularColor:r=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:i,lighting_uShininess:n,lighting_uSpecularColor:r.map(e=>e/255)}}(t):{lighting_uEnabled:!1}}const gy={name:"gouraud-lighting",dependencies:[dy],vs:py,defines:{LIGHTING_VERTEX:1},getUniforms:my},_y={name:"phong-lighting",dependencies:[dy],fs:py,defines:{LIGHTING_FRAGMENT:1},getUniforms:my},Ay={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\nout vec3 pbr_vPosition;\nout vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\nvec4 pos = u_ModelMatrix * position;\npbr_vPosition = vec3(pos.xyz) / pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\nvec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\nvec3 bitangentW = cross(normalW, tangentW) * tangent.w;\npbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\npbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"precision highp float;\nuniform bool pbr_uUnlit;\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\nstruct PBRInfo\n{\nfloat NdotL;\nfloat NdotV;\nfloat NdotH;\nfloat LdotH;\nfloat VdotH;\nfloat perceptualRoughness;\nfloat metalness;\nvec3 reflectance0;\nvec3 reflectance90;\nfloat alphaRoughness;\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 n;\nvec3 v;\n};\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\nvec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\nvec3 bLess = step(vec3(0.04045),srgbIn.xyz);\nvec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\nreturn vec4(linOut,srgbIn.w);;\n#else\nreturn srgbIn;\n#endif\n}\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\nvec3 pos_dx = dFdx(pbr_vPosition);\nvec3 pos_dy = dFdy(pbr_vPosition);\nvec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\nvec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\nvec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng = normalize(pbr_vNormal);\n#else\nvec3 ng = cross(pos_dx, pos_dy);\n#endif\nt = normalize(t - ng * dot(ng, t));\nvec3 b = normalize(cross(ng, t));\nmat3 tbn = mat3(t, b, ng);\n#else\nmat3 tbn = pbr_vTBN;\n#endif\n#ifdef HAS_NORMALMAP\nvec3 n = texture(u_NormalSampler, pbr_vUV).rgb;\nn = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\nvec3 n = normalize(tbn[2].xyz);\n#endif\nreturn n;\n}\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\nfloat mipCount = 9.0;\nfloat lod = (pbrInputs.perceptualRoughness * mipCount);\nvec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,\nvec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\nvec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n#ifdef USE_TEX_LOD\nvec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\nvec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\nvec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\nvec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\ndiffuse *= u_ScaleIBLAmbient.x;\nspecular *= u_ScaleIBLAmbient.y;\nreturn diffuse + specular;\n}\n#endif\nvec3 diffuse(PBRInfo pbrInputs)\n{\nreturn pbrInputs.diffuseColor / M_PI;\n}\nvec3 specularReflection(PBRInfo pbrInputs)\n{\nreturn pbrInputs.reflectance0 +\n(pbrInputs.reflectance90 - pbrInputs.reflectance0) *\npow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\nfloat NdotL = pbrInputs.NdotL;\nfloat NdotV = pbrInputs.NdotV;\nfloat r = pbrInputs.alphaRoughness;\nfloat attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\nfloat attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\nreturn attenuationL * attenuationV;\n}\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\nfloat roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\nfloat f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\nreturn roughnessSq / (M_PI * f * f);\n}\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\npbrInputs.NdotL = 1.0;\npbrInputs.NdotH = 0.0;\npbrInputs.LdotH = 0.0;\npbrInputs.VdotH = 1.0;\n}\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\nvec3 n = pbrInputs.n;\nvec3 v = pbrInputs.v;\nvec3 l = normalize(lightDirection);\nvec3 h = normalize(l+v);\npbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\npbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\npbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\npbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\nvec3 light_direction = normalize(pointLight.position - pbr_vPosition);\nPBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\nvec3 F = specularReflection(pbrInputs);\nfloat G = geometricOcclusion(pbrInputs);\nfloat D = microfacetDistribution(pbrInputs);\nvec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\nvec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\nreturn pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\nvec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\nvec4 baseColor = u_BaseColorFactor;\n#endif\n#ifdef ALPHA_CUTOFF\nif (baseColor.a < u_AlphaCutoff) {\ndiscard;\n}\n#endif\nvec3 color = vec3(0, 0, 0);\nif(pbr_uUnlit){\ncolor.rgb = baseColor.rgb;\n}\nelse{\nfloat perceptualRoughness = u_MetallicRoughnessValues.y;\nfloat metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\nvec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);\nperceptualRoughness = mrSample.g * perceptualRoughness;\nmetallic = mrSample.b * metallic;\n#endif\nperceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat alphaRoughness = perceptualRoughness * perceptualRoughness;\nvec3 f0 = vec3(0.04);\nvec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\ndiffuseColor *= 1.0 - metallic;\nvec3 specularColor = mix(f0, baseColor.rgb, metallic);\nfloat reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\nfloat reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\nvec3 specularEnvironmentR0 = specularColor.rgb;\nvec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\nvec3 n = getNormal();\nvec3 v = normalize(u_Camera - pbr_vPosition);\nfloat NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\nvec3 reflection = -normalize(reflect(v, n));\nPBRInfo pbrInputs = PBRInfo(\n0.0,\nNdotV,\n0.0,\n0.0,\n0.0,\nperceptualRoughness,\nmetallic,\nspecularEnvironmentR0,\nspecularEnvironmentR90,\nalphaRoughness,\ndiffuseColor,\nspecularColor,\nn,\nv\n);\n#ifdef USE_LIGHTS\nPBRInfo_setAmbientLight(pbrInputs);\ncolor += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\nfor(int i = 0; i < lighting_uDirectionalLightCount; i++) {\nif (i < lighting_uDirectionalLightCount) {\nPBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\ncolor += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n}\n}\nfor(int i = 0; i < lighting_uPointLightCount; i++) {\nif (i < lighting_uPointLightCount) {\nPBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\nfloat attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\ncolor += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n}\n}\n#endif\n#ifdef USE_IBL\ncolor += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\nfloat ao = texture(u_OcclusionSampler, pbr_vUV).r;\ncolor = mix(color, color * ao, u_OcclusionStrength);\n#endif\n#ifdef HAS_EMISSIVEMAP\nvec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\ncolor += emissive;\n#endif\n#ifdef PBR_DEBUG\ncolor = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\ncolor = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\ncolor = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n}\nreturn vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[dy]},yy="#define SMOOTH_EDGE_RADIUS 0.5";var vy={name:"geometry",vs:`\n${yy}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`\n${yy}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};const xy={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(xy,"IDENTITY",{get:()=>(rp.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const by={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},wy={common:0,meters:1,pixels:2},Ty={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var Ey=`${Object.keys(xy).map(e=>`const int COORDINATE_SYSTEM_${e} = ${xy[e]};`).join("")}\n${Object.keys(by).map(e=>`const int PROJECTION_MODE_${e} = ${by[e]};`).join("")}\n${Object.keys(wy).map(e=>`const int UNIT_${e.toUpperCase()} = ${wy[e]};`).join("")}\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject_uPseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project_uCommonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project_uWrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project_uModelMatrix * position;\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project_uCoordinateOrigin;\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project_uCommonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n(project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project_uCoordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\nreturn offset * project_uFocalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project_uScale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project_uScale;\n}\n`;function Cy(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let n=0;n{for(const r in n)if(!Cy(n[r],i[r])){t=e(n),i=n;break}return t}}const By=[0,0,0,0],Iy=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],My=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Py=[0,0,0],Ry=[0,0,0],Ly=Sy(function({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:r,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,i){const{viewMatrixUncentered:n,projectionMatrix:r}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=By,l=By,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=Fy(e,t,i);d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=OA([],l,s),o=n||o,s=IA([],r,o),s=IA([],s,Iy));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,i,n),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=OA([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={project_uCoordinateSystem:i,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:s.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:t,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Py,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:o,project_uModelMatrix:My,project_uCameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(i){case xy.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=t.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case xy.LNGLAT:case xy.LNGLAT_OFFSETS:e._pseudoMeters||(p.project_uCommonUnitsPerMeter=t.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=t.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case xy.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return p});function Fy(e,t,i=Ry){i.length<3&&(i=[i[0],i[1],0]);let n,r=i,o=!0;switch(n=t===xy.LNGLAT_OFFSETS||t===xy.METER_OFFSETS?i:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case by.WEB_MERCATOR:t!==xy.LNGLAT&&t!==xy.CARTESIAN||(n=[0,0,0],o=!1);break;case by.WEB_MERCATOR_AUTO_OFFSET:t===xy.LNGLAT?r=n:t===xy.CARTESIAN&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],n=e.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case by.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case by.GLOBE:o=!1,n=null;break;default:o=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:r,offsetMode:o}}function ky({viewport:e,devicePixelRatio:t=1,modelMatrix:i=null,coordinateSystem:n=xy.DEFAULT,coordinateOrigin:r=Ry,autoWrapLongitude:o=!1}){n===xy.DEFAULT&&(n=e.isGeospatial?xy.LNGLAT:xy.CARTESIAN);const s=Ly({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r});return s.project_uWrapLongitude=o,s.project_uModelMatrix=i||My,s}const Dy={};var Oy={name:"project",dependencies:[w_,vy],vs:Ey,getUniforms:function(e=Dy){return"viewport"in e?ky(e):{}}};var zy={name:"project32",dependencies:[Oy],vs:"\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};function Uy(e,t){const i=OA([],t,e);return DA(i,i,1/i[3]),i}function Ny(e,t){const i=e%t;return i<0?t+i:i}function Vy(e,t,i){return ei?i:e}const jy=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Gy(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Hy=Math.PI,Qy=Hy/4,$y=Hy/180,Zy=180/Hy,Wy=512,qy=4003e4,Ky=85.051129,Xy=1.5;function Jy(e){const[t,i]=e;Gy(Number.isFinite(t)),Gy(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const n=i*$y;return[Wy*(t*$y+Hy)/(2*Hy),Wy*(Hy+Math.log(Math.tan(Qy+.5*n)))/(2*Hy)]}function Yy(e){const[t,i]=e,n=t/Wy*(2*Hy)-Hy,r=2*(Math.atan(Math.exp(i/Wy*(2*Hy)-Hy))-Qy);return[n*Zy,r*Zy]}function ev(e){const{latitude:t}=e;Gy(Number.isFinite(t));const i=Math.cos(t*$y);return function(e){return jy(e)}(qy*i)-9}function tv(e){return 12790407194604047e-21/Math.cos(e*$y)}function iv(e){const{latitude:t,longitude:i,highPrecision:n=!1}=e;Gy(Number.isFinite(t)&&Number.isFinite(i));const r=Wy,o=Math.cos(t*$y),s=r/360,a=s/o,l=12790407194604047e-21/o,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[s,a,l],degreesPerUnit:[.703125,1/a,1/l]};if(n){const e=$y*Math.tan(t*$y)/o,i=s*e/2,n=12790407194604047e-21*e,r=n/a*l;c.unitsPerDegree2=[0,i,n],c.unitsPerMeter2=[r,0,r]}return c}function nv(e,t){const[i,n,r]=e,[o,s,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=iv({longitude:i,latitude:n,highPrecision:!0}),u=Jy(e);u[0]+=o*(l[0]+c[0]*s),u[1]+=s*(l[1]+c[1]*s);const h=Yy(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function rv(e){return 2*Math.atan(.5/e)*Zy}function ov(e){return.5/Math.tan(.5*e*$y)}function sv(e,t){const[i,n,r=0]=e;return Gy(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)),Uy(t,[i,n,r,1])}function av(e,t,i=0){const[n,r,o]=e;if(Gy(Number.isFinite(n)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(o)){return Uy(t,[n,r,o,1])}const s=Uy(t,[n,r,0,1]),a=Uy(t,[n,r,1,1]),l=s[2],c=a[2];return X_([],s,a,l===c?0:((i||0)-l)/(c-l))}function lv(e){const{width:t,height:i,bounds:n,minExtent:r=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,l],[c,u]]=n,h=function(e=0){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return Gy(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e}(e.padding),d=Jy([a,Vy(u,-85.051129,Ky)]),p=Jy([c,Vy(l,-85.051129,Ky)]),f=[Math.max(Math.abs(p[0]-d[0]),r),Math.max(Math.abs(p[1]-d[1]),r)],m=[t-h.left-h.right-2*Math.abs(s[0]),i-h.top-h.bottom-2*Math.abs(s[1])];Gy(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],A=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/_,v=Yy([(p[0]+d[0])/2+A,(p[1]+d[1])/2+y]),x=Math.min(o,jy(Math.abs(Math.min(g,_))));return Gy(Number.isFinite(x)),{longitude:v[0],latitude:v[1],zoom:x}}const cv=Math.PI/180;function uv(e,t,i){const{pixelUnprojectionMatrix:n}=e,r=Uy(n,[t,0,1,1]),o=Uy(n,[t,e.height,1,1]),s=Yy(X_([],r,o,(i*e.distanceScales.unitsPerMeter[2]-r[2])/(o[2]-r[2])));return s.push(i),s}const hv=Sy(function({viewport:e,center:t}){return new HA(e.viewProjectionMatrix).invert().transform(t)}),dv=Sy(function({viewport:e,shadowMatrices:t}){const i=[],n=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,o=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[i,n,r]=e,o=av([i,n,r],t);if(Number.isFinite(r))return o;return[o[0],o[1],0]}(e,n));for(const n of t){const t=n.clone().translate(new AA(e.center).negate()),r=o.map(e=>t.transform(e)),s=(new HA).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});i.push(s.multiplyRight(n))}return i}),pv=[0,0,0,1],fv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var mv={name:"shadow",dependencies:[Oy],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n if (shadow_uDrawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n }\n if (shadow_uUseShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow_uLightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow_uDrawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow_uUseShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow_uLightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?function(e,t){const{shadowEnabled:i=!0}=e;if(!i||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const n={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,shadow_uColor:e.shadowColor||pv,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},r=hv({viewport:e.viewport,center:t.project_uCenter}),o=[],s=dv({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let i=0;ithis.device.clearWebGL(e))}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let i=0;i{const s=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in t)&&n(r.parent,!1),l in i){const e=i[l]=i[l]||Pv(t[l],t);c=e(r,o),i[a]=e}else Number.isFinite(s)?(c=s+(t[l]||0),i[a]=null):c=e;return o&&c>=e&&(e=c+1),t[a]=c,c};return n}class Rv extends Mv{constructor(e,t){super(e,t),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],r=n.width*i,o=n.height*i;r===t.width&&o===t.height||t.resize({width:r,height:o}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const Lv={color:[255,255,255],intensity:1},Fv=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],kv=[0,0,0,200/255];class Dv{constructor(e={}){this.id="lighting-effect",this.shadowColor=kv,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(mv),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const t in e){const i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:n,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;ot.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},t}cleanup(e){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(mv))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const i=(new HA).lookAt({eye:new AA(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tn&&(r=n);const o=this._pool,s=e.BYTES_PER_ELEMENT*r,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,r);return i&&t.fill(0),t}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:i}=e,{byteLength:n}=i,r=t.findIndex(e=>e.byteLength>=n);r<0?t.push(i):(r>0||t.lengththis.opts.poolSize&&t.shift()}};const zv=new AA;function Uv(e,t,i,n){zv.set(e,t,i);const r=zv.len();return{distance:n/r,normal:new AA(-e/r,-t/r,-i/r)}}function Nv(e){return e-Math.fround(e)}let Vv;function jv(e,t){const{size:i=1,startIndex:n=0}=t,r=void 0!==t.endIndex?t.endIndex:e.length,o=(r-n)/i;Vv=Ov.allocate(Vv,o,{type:Float32Array,size:2*i});let s=n,a=0;for(;s(90-e.pitch)*cv-.01?(l=uv(e,0,t),c=uv(e,i,t)):(l=r([0,0],o),c=r([i,0],o)),[s,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:i,height:n}=this,{longitude:r,latitude:o,zoom:s}=lv({width:i,height:n,bounds:e,...t});return new Kv({width:i,height:n,longitude:r,latitude:o,zoom:s})}}Kv.displayName="WebMercatorViewport";var Xv=Kv;const Jv=[0,0,0];function Yv(e,t,i=!1){const n=t.projectPosition(e);if(i&&t instanceof Xv){const[i,r,o=0]=e,s=t.getDistanceScales([i,r]);n[2]=o*s.unitsPerMeter[2]}return n}function ex(e,{viewport:t,modelMatrix:i,coordinateSystem:n,coordinateOrigin:r,offsetMode:o}){let[s,a,l=0]=e;switch(i&&([s,a,l]=OA([],[s,a,l,1],i)),n){case xy.LNGLAT:return Yv([s,a,l],t,o);case xy.LNGLAT_OFFSETS:return Yv([s+r[0],a+r[1],l+(r[2]||0)],t,o);case xy.METER_OFFSETS:return Yv(nv(r,[s,a,l]),t,o);case xy.CARTESIAN:default:return t.isGeospatial?[s+r[0],a+r[1],l+r[2]]:t.projectPosition([s,a,l])}}function tx(e,t){const{viewport:i,coordinateSystem:n,coordinateOrigin:r,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:i,coordinateOrigin:n}=e;let{coordinateSystem:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}=e;return r===xy.DEFAULT&&(r=t.isGeospatial?xy.LNGLAT:xy.CARTESIAN),void 0===o&&(o=r),void 0===s&&(s=n),{viewport:t,coordinateSystem:r,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=Jv,shaderCoordinateOrigin:u=Jv,offsetMode:h=!1}=l?Fy(i,n,r):{},d=ex(e,{viewport:i,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){const e=i.projectPosition(c||u);dA(d,d,e)}return d}const ix=[255,255,255],nx=1,rx=[0,0,1],ox=[0,0,1];let sx=0;class ax{constructor(e={}){this.type="point";const{color:t=ix}=e,{intensity:i=nx}=e,{position:n=ox}=e;this.id=e.id||"point-"+sx++,this.color=t,this.intensity=i,this.type="point",this.position=n,this.attenuation=function(e){if(e.attenuation)return e.attenuation;if("intensity"in e)return[0,0,e.intensity||0];return rx}(e),this.projectedLight={...this}}getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r}=e.props,o=tx(this.position,{viewport:i,coordinateSystem:n,coordinateOrigin:r,fromCoordinateSystem:i.isGeospatial?xy.LNGLAT:xy.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=o,t}}class lx extends ax{getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r,modelMatrix:o}=e.props,{project_uCameraPosition:s}=ky({viewport:i,modelMatrix:o,coordinateSystem:n,coordinateOrigin:r});return t.color=this.color,t.intensity=this.intensity,t.position=s,t}}let cx=1,ux=1;class hx{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){const{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=e,o=cx++,s={time:0,delay:t,duration:i,rate:n,repeat:r};return this._setChannelTime(s,this.time),this.channels.set(o,s),o}removeChannel(e){this.channels.delete(e);for(const[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const i=this.animations.values();for(const e of i){const{animation:t,channel:i}=e;t.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const i=ux++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const i=t-e.delay;i>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}let dx=0;const px={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:hf.stats.get("animation-loop-"+dx++),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class fx{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...px,...e},!(e=this.props).device)throw new Error("No device provided");const{useDevicePixels:t=!0}=this.props;this.stats=e.stats||new Ch({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:t}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){var e;this._running&&(this._animationFrameId=(e=this._animationFrame.bind(this),"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)))}_cancelAnimationFrame(){var e;null!==this._animationFrameId&&(e=this._animationFrameId,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),this.device.submit())}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:i}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,t]=this.device?.canvasContext?.getPixelSize()||[1,1];let i=1;const n=this.device?.canvasContext?.canvas;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:e>0&&t>0&&(i=e/t),{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class mx{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Wp("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&cf(this.indices.usage===Xp.INDEX)}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function gx(e,t){if(t instanceof mx)return t;const i=function(e,t){if(!t.indices)return;const i=t.indices.value;return e.createBuffer({usage:Xp.INDEX,data:i})}(e,t),{attributes:n,bufferLayout:r}=function(e,t){const i=[],n={};for(const[r,o]of Object.entries(t.attributes)){let t=r;switch(r){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}n[t]=e.createBuffer({data:o.value,id:`${r}-buffer`});const{value:s,size:a,normalized:l}=o;i.push({name:t,format:em(s,a,l)})}const r=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:i,vertexCount:r}}(e,t);return new mx({topology:t.topology||"triangle-list",bufferLayout:r,vertexCount:t.vertexCount,indices:i,attributes:n})}class _x{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){const t=Cp(Object.values(e).filter(e=>e.dependencies));for(const i of t)e[i.name]=i;Gp.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[t,i]of Object.entries(e)){const e=t;this.moduleUniforms[e]=i.defaultUniforms||{},this.moduleBindings[e]={}}}destroy(){}setProps(e){for(const t of Object.keys(e)){const i=t,n=e[i],r=this.modules[i];if(!r){Gp.warn(`Module ${t} not found`)();continue}const o=this.moduleUniforms[i],s=this.moduleBindings[i],a=r.getUniforms?.(n,o)||n,{uniforms:l,bindings:c}=tm(a);this.moduleUniforms[i]={...o,...l},this.moduleBindings[i]={...s,...c}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){const e={};for(const[t,i]of Object.entries(this.moduleUniforms))for(const[n,r]of Object.entries(i))e[`${t}.${n}`]={type:this.modules[t].uniformTypes?.[n],value:String(r)};return e}}class Ax{static defaultProps={...Mf.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Ax(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){const t={...Mf.defaultProps,...e},i=this._hashRenderPipeline(t);if(!this._renderPipelineCache[i]){const e=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._renderPipelineCache[i]={pipeline:e,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){const t={...Rf.defaultProps,...e},i=this._hashComputePipeline(t);if(!this._computePipelineCache[i]){const e=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._computePipelineCache[i]={pipeline:e,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){const t=e.hash,i=e instanceof Rf?this._computePipelineCache:this._renderPipelineCache;i[t].useCount--,0===i[t].useCount&&(i[t].pipeline.destroy(),delete i[t])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const t=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,n=this._getHash(JSON.stringify(e.bufferLayout));if("webgl"===this.device.type)return`${t}/${i}V-BL${n}`;{const r=this._getHash(JSON.stringify(e.parameters));return`${t}/${i}V-T${e.topology}P${r}BL${n}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}}class yx{static defaultProps={...Cf.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new yx(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){const t=this._hashShader(e);let i=this._cache[t];if(!i){const n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:n,useCount:0}}return i.useCount++,i.shader}release(e){const t=this._hashShader(e),i=this._cache[t];i&&(i.useCount--,0===i.useCount&&(delete this._cache[t],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}}let vx=null,xx=null;class bx{static defaultProps={...Mf.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Vp.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(e,t){this.props={...bx.defaultProps,...t},t=this.props,this.id=t.id||Wp("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]);this.setShaderInputs(t.shaderInputs||new _x(i));const n=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(e),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if("webgpu"===this.device.type&&this.props.source){this.props.shaderLayout||=x_(this.props.source);const{source:e,getUniforms:t}=this.props.shaderAssembler.assembleShader({platformInfo:n,...this.props,modules:r});this.source=e,this._getModuleUniforms=t}else{const{vs:e,fs:t,getUniforms:i}=this.props.shaderAssembler.assembleShaderPair({platformInfo:n,...this.props,modules:r});this.vs=e,this.fs=t,this._getModuleUniforms=i}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ax.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||yx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.uniforms&&this.setUniforms(t.uniforms),t.moduleSettings&&this.updateModuleSettings(t.moduleSettings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t;this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),qp(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:i}=this.vertexArray,n=i?i.byteLength/("uint32"===i.indexType?4:2):void 0;t=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:n,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),t?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",t}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&gx(this.device,e);t&&(this.setTopology(t.topology||"triangle-list"),this.bufferLayout=wx(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)),this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?wx(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){rm(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Xf(this.shaderInputs.modules);for(const e of Object.keys(this.shaderInputs.modules)){const t=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){e.indices&&Gp.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[i,n]of Object.entries(e)){const e=this.bufferLayout.find(e=>Tx(e).includes(i));if(!e){Gp.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}const r=Tx(e);let o=!1;for(const e of r){const t=this._attributeInfos[e];t&&(this.vertexArray.setBuffer(t.location,n),o=!0)}o||(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,n]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,n):(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){qp(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:t,uniforms:i}=tm(this._getModuleUniforms(e));Object.assign(this.bindings,t),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof vf?e=Math.max(e,t.texture.updateTimestamp):t instanceof Xp||t instanceof yf?e=Math.max(e,t.updateTimestamp):t instanceof Bf||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[e]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(t=>t.name===e)||"positions"===e||delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Gp.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let n=null;this.source?n=i:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:n}),this._attributeInfos=zf(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=Gp.level>3?0:1e4;Gp.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Gp.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},i="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(const n of e.attributes)n&&(t[`in ${n.location} ${n.name}: ${n.type}`]={[i]:n.stepMode||"vertex"});for(const n of e.varyings||[])t[`out ${n.location} ${n.name}`]={[i]:JSON.stringify(n.accessor)};return t}(this.pipeline.shaderLayout,this.id);Gp.table(2,e)();const t=this.shaderInputs.getDebugTable();for(const[e,i]of Object.entries(this.uniforms))t[e]={value:i};Gp.table(2,t)();const i=this._getAttributeDebugTable();Gp.table(2,this._attributeInfos)(),Gp.table(2,i)(),Gp.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=Gp.get("framebuffer");if(this._drawCount++,!t||this._drawCount++>3&&this._drawCount%60)return;const i=e.props.framebuffer;i&&function(e,{id:t,minimap:i,opaque:n,top:r="0",left:o="0",rgbaScale:s=1}){vx||(vx=document.createElement("canvas"),vx.id=t,vx.title=t,vx.style.zIndex="100",vx.style.position="absolute",vx.style.top=r,vx.style.left=o,vx.style.border="blue 1px solid",vx.style.transform="scaleY(-1)",document.body.appendChild(vx),xx=vx.getContext("2d")),vx.width===e.width&&vx.height===e.height||(vx.width=e.width/2,vx.height=e.height/2,vx.style.width="400px",vx.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),l=xx.createImageData(e.width,e.height);for(let e=0;et.name===e.name);t<0?i.push(e):i[t]=e}return i}function Tx(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}class Ex{device;model;transformFeedback;static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=bx.defaultProps){cf(Ex.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new bx(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||jp(),topology:t.topology||"point-list",...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(t instanceof Xp)return t.readAsync();const{buffer:i,byteOffset:n=0,byteLength:r=i.byteLength}=t;return i.readAsync(n,r)}}class Cx{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:i=null,vertexCount:n=null}=e;this.id=e.id||Wp("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(const[e,i]of Object.entries(t)){const t=ArrayBuffer.isView(i)?{value:i}:i;cf(ArrayBuffer.isView(t.value),`${this._print(e)}: must be typed array or object with value as typed array`),"POSITION"!==e&&"positions"!==e||t.size||(t.size=3),"indices"===e?(cf(!this.indices),this.indices=t):this.attributes[e]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(const t of Object.values(e)){const{value:e,size:n,constant:r}=t;!r&&e&&n>=1&&(i=Math.min(i,e.length/n))}return cf(Number.isFinite(i)),i}}class Sx{id;matrix=new HA;display=!0;position=new AA;rotation=new AA;scale=new AA(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||Wp(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return cf(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return cf(3===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return cf(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:i,scale:n,update:r=!0}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),r&&this.updateMatrix(),this}updateMatrix(){const e=this.position,t=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(i),this}update(e={}){const{position:t,rotation:i,scale:n}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){cf(e),t=t||this.matrix;const i=new HA(e).multiplyRight(t),n=i.invert(),r=n.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:i,worldInverseMatrix:n,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class Bx extends Sx{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;Gp.assert(t.every(e=>e instanceof Sx),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:i})=>{const n=t.getBounds();if(!n)return;const[r,o]=n,s=new AA(r).add(o).divide([2,2,2]);i.transformAsPoint(s,s);const a=new AA(o).subtract(r).divide([2,2,2]);i.transformAsVector(a,a);for(let t=0;t<8;t++){const i=new AA(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(a).add(s);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],i[t]),e[1][t]=Math.max(e[1][t],i[t])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,i=t.indexOf(e);return i>-1&&t.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new HA}={}){const i=new HA(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof Bx?t.traverse(e,{worldMatrix:i}):e(t,{worldMatrix:i})}}class Ix extends Sx{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}}const Mx={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class Px extends Mv{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,pickingFBO:o,deviceRect:{x:s,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:p,moduleParameters:f}){this.pickZ=p;const m=this._resetColorEncoder(p),g=[s,a,l,c],_=super.render({target:o,layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,cullRect:u,effects:h?.filter(e=>e.useInPicking),pass:d,isPicking:!0,moduleParameters:f,clearColor:[0,0,0,0],colorMask:15,scissorRect:g});this._colorEncoderState=null;return{decodePickingColor:m&&Rx.bind(null,m),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,t,i){const n={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:r,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?n.blend=!1:r&&o.includes("draw")&&(Object.assign(n,Mx),n.blend=!0,n.blendColor=function(e,t,i){const{byLayer:n,byAlpha:r}=e;let o,s=n.get(t);s?(s.viewports.push(i),o=s.a):(o=n.size+1,o<=255?(s={a:o,layer:t,viewports:[i]},n.set(t,s),r[o]=s):(rp.warn("Too many pickable layers, only picking the first 255")(),o=0));return[0,0,0,o/255]}(this._colorEncoderState,e,i)),n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function Rx(e,t){const i=e.byAlpha[t[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(t)}}const Lx="Awaiting state",Fx="Matched. State transferred from previous layer",kx="Initialized",Dx="Discarded. Awaiting garbage collection",Ox="No longer matched. Awaiting garbage collection",zx="Finalized! Awaiting garbage collection",Ux=Symbol.for("component"),Nx=Symbol.for("propTypes"),Vx=Symbol.for("deprecatedProps"),jx=Symbol.for("asyncPropDefaults"),Gx=Symbol.for("asyncPropOriginal"),Hx=Symbol.for("asyncPropResolved");function Qx(e,t=()=>!0){return Array.isArray(e)?$x(e,t,[]):t(e)?[e]:[]}function $x(e,t,i){let n=-1;for(;++n0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const i=++this._loadCount;let n=e;"string"==typeof e&&(n=Fd(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class qx{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:n=!0}){let r=this._resources[e];r?r.setData(t,i):(r=new Wx(e,t,this._context),this._resources[e]=r),r.persistent=n}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const i=t[e],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:n="default"}){const{_resources:r,protocol:o}=this;e.startsWith(o)&&(r[e=e.replace(o,"")]||this.add({resourceId:e,data:null,persistent:!1}));const s=r[e];if(this._track(i,n,s,t),s)return s.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,i,n){const r=this._consumers,o=r[e]=r[e]||{};let s=o[t];const a=s&&s.resourceId&&this._resources[s.resourceId];a&&(a.unsubscribe(s),this.prune()),i&&(s?(s.onChange=n,s.resourceId=i.id):s={onChange:n,resourceId:i.id},o[t]=s,i.subscribe(s))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}class Kx{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{lp("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:i,stats:n,viewport:r,timeline:o}=t||{};this.layers=[],this.resourceManager=new qx({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:yv(),defaultShaderModules:[],renderPass:void 0,stats:n||new Ch({id:"deck.gl"}),viewport:r||new qv({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new hx,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const n=i.getNeedsRedraw(e);t=t||n}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){lp("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const i=Qx(e,Boolean);for(const e of i)e.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,i=t.findIndex(t=>t.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){const i={};for(const t of e)i[t.id]?rp.warn(`Multiple old layers with same id ${t.id}`)():i[t.id]=t;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const n=[];this._updateSublayersRecursively(t,i,n),this._finalizeOldLayers(i);let r=!1;for(const e of n)if(e.hasUniformTransition()){r=`Uniform transition in ${e}`;break}this._needsUpdate=r,this.layers=n}_updateSublayersRecursively(e,t,i){for(const n of e){n.context=this.context;const e=t[n.id];null===e&&rp.warn(`Multiple new layers with same id ${n.id}`)(),t[n.id]=null;let r=null;try{this._debug&&e!==n&&n.validateProps(),e?(this._transferLayerState(e,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),r=n.isComposite?n.getSubLayers():null}catch(e){this._handleError("matching",e,n)}r&&this._updateSublayersRecursively(r,t,i)}}_finalizeOldLayers(e){for(const t in e){const i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=kx}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Fx,t!==e&&(e.lifecycle=Dx)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ox;try{e._finalize(),e.lifecycle=zx}catch(t){this._handleError("finalization",t,e)}}}function Xx(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;nt.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,t){const i=this.getViewports(),n={x:e[0],y:e[1]};for(let r=i.length-1;r>=0;--r){const o=i[r];if(o.containsPixel(n)){const i=e.slice();return i[0]-=o.x,i[1]-=o.y,o.unproject(i,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Qx(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!Xx(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else rp.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height})})}_updateController(e,t,i,n){const r=e.controller;if(r&&i){const o={...t,...r,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return n&&n.constructor===r.type||(n=this._createController(e,o)),n&&n.setProps(o),n}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=e.length;n--;){const r=e[n],o=this.getViewState(r),s=r.makeViewport({viewState:o,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(i=!0),!i&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,o,s,a),s&&this._viewports.unshift(s)}for(const e in t){const i=t[e];i&&!this.controllers[e]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((i,n)=>!e[n].equals(t[n]))}}const Yx=/([0-9]+\.?[0-9]*)(%|px)/;function eb(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=Yx.exec(e);if(t&&t.length>=3){const e="%"===t[2],i=parseFloat(t[1]);return{position:e?i/100:i,relative:e}}default:throw new Error(`Could not parse position string ${e}`)}}function tb(e,t){return e.relative?Math.round(e.position*t):e.position}class ib{constructor(e){const{id:t,x:i=0,y:n=0,width:r="100%",height:o="100%",padding:s=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=eb(i),this._y=eb(n),this._width=eb(r),this._height=eb(o),this._padding=s&&{left:eb(s.left||0),right:eb(s.right||0),top:eb(s.top||0),bottom:eb(s.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.ViewportType===e.ViewportType&&Xx(this.props,e.props,2)}makeViewport({width:e,height:t,viewState:i}){i=this.filterViewState(i);const n=this.getDimensions({width:e,height:t});return n.height&&n.width?new this.ViewportType({...i,...this.props,...n}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const i={x:tb(this._x,e),y:tb(this._y,t),width:tb(this._width,e),height:tb(this._height,t)};return this._padding&&(i.padding={left:tb(this._padding.left,e),top:tb(this._padding.top,t),right:tb(this._padding.right,e),bottom:tb(this._padding.bottom,t)}),i}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class nb{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const rb=()=>{},ob=2,sb=3,ab=e=>e,lb=1;class cb{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:i,startProps:n,endProps:r,duration:o,easing:s}}=e,a=s(t/o),l=i.interpolateProps(n,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new nb(e.timeline),this.onViewStateChange=e.onViewStateChange||rb,this.onStateChange=e.onStateChange||rb}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let n=i;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;n={...i,...e===ob?t:this.propsInTransition||i}}this._triggerTransition(n,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||"auto"===t)&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){if(this.transition.inProgress){return this.transition.settings.interruption===sb||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const i=this.getControllerState(e),n=this.getControllerState(t).shortestPathFrom(i),r=t.transitionInterpolator,o=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===o)return;const s=r.initializeProps(e,n);this.propsInTransition={};const a={duration:o,easing:t.transitionEasing||ab,interpolator:r,interruption:t.transitionInterruption||lb,startProps:s.start,endProps:s.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}function ub(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class hb{constructor(e){const{compare:t,extract:i,required:n}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=n}arePropsEqual(e,t){for(const i of this._propsToCompare)if(!(i in e)||!(i in t)||!N_(e[i],t[i]))return!1;return!0}initializeProps(e,t){const i={},n={};for(const r of this._propsToExtract)(r in e||r in t)&&(i[r]=e[r],n[r]=t[r]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const i=e[t];ub(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}}const db=["longitude","latitude","zoom","bearing","pitch"],pb=["longitude","latitude","zoom"];class fb extends hb{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:db,required:pb},super(i.transitionProps),this.opts=i}initializeProps(e,t){const i=super.initializeProps(e,t),{makeViewport:n,around:r}=this.opts;if(n&&r){const o=n(e),s=n(t),a=o.unproject(r);i.start.around=r,Object.assign(i.end,{around:s.project(a),aroundPosition:a,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){const n={};for(const r of this._propsToExtract)n[r]=U_(e[r]||0,t[r]||0,i);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...n});Object.assign(n,r.panByPosition(t.aroundPosition,U_(e.around,t.around,i)))}return n}}const mb={transitionDuration:0},gb=e=>1-(1-e)*(1-e),_b=["wheel"],Ab=["panstart","panmove","panend"],yb=["pinchstart","pinchmove","pinchend"],vb=["tripanstart","tripanmove","tripanend"],xb=["doubletap"],bb=["keydown"],wb={};class Tb{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new cb({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return!t&&this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:i}=this.props,{offsetCenter:n}=e;return[n.x-t,n.y-i]}isPointInBounds(e,t){const{width:i,height:n}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=n;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:i=!0,dragPan:n=!0,dragRotate:r=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(_b,c&&i),this.toggleEvents(Ab,c),this.toggleEvents(yb,c&&(s||a)),this.toggleEvents(vb,c&&a),this.toggleEvents(xb,c&&o),this.toggleEvents(bb,c&&l),this.scrollZoom=i,this.dragPan=n,this.dragRotate=r,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,i={}){const n={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const n=this.controllerState[i?"panStart":"rotateStart"]({pos:t});return this._panMove=i,this.updateViewport(n,mb,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),i=this.controllerState.pan({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:i=.01,smooth:n=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let o=2/(1+Math.exp(-Math.abs(r*i)));r<0&&0!==o&&(o=1/o);const s=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(s,{...this._getTransitionProps({around:t}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.rotateStart({pos:t});return this.updateViewport(i,mb,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const i=this.getCenter(e),n=[i[0],i[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:n});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return wb._startPinchRotation=e.rotation,wb._lastPinchEvent=e,this.updateViewport(i,mb,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:i}=e,n=this.getCenter(e);t=t.zoom({pos:n,scale:i})}if(this.touchRotate){const{rotation:i}=e;t=t.rotate({deltaAngleX:wb._startPinchRotation-i})}return this.updateViewport(t,mb,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),wb._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:i}=wb;if(this.touchZoom&&t&&i&&e.scale!==i.scale){const n=this.getCenter(e);let r=this.controllerState.rotateEnd();const o=Math.log2(e.scale),s=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),a=Math.pow(2,o+s*t/2);r=r.zoom({pos:n,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:n}),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return wb._startPinchRotation=null,wb._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:t,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:r,rotateSpeedY:o}=!0===this.keyboard?{}:this.keyboard,{controllerState:s}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?s.zoomOut(i).zoomOut(i):s.zoomOut(i),l.isZooming=!0;break;case"Equal":a=t?s.zoomIn(i).zoomIn(i):s.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":t?(a=s.rotateLeft(r),l.isRotating=!0):(a=s.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":t?(a=s.rotateRight(r),l.isRotating=!0):(a=s.moveRight(n),l.isPanning=!0);break;case"ArrowUp":t?(a=s.rotateUp(o),l.isRotating=!0):(a=s.moveUp(n),l.isPanning=!0);break;case"ArrowDown":t?(a=s.rotateDown(o),l.isRotating=!0):(a=s.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new fb({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:mb}}class Eb{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Cb extends Eb{constructor(e){const{width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y,normalize:v=!0}=e;ub(Number.isFinite(r)),ub(Number.isFinite(n)),ub(Number.isFinite(o)),super({width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:p,normalize:v,position:c},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){const{startRotatePos:n,startBearing:r,startPitch:o}=this.getState();if(!n||void 0===r||void 0===o)return this;let s;return s=e?this._getNewRotation(e,n,o,r):{bearing:r+t,pitch:o+i},this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:i}){let{startZoom:n,startZoomLngLat:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const{maxZoom:o,minZoom:s}=this.getViewportProps();let a=n+Math.log2(i);a=z_(a,s,o);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:r}=i;return Math.abs(n-t.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(r-t.longitude)>180&&(i.longitude=r<0?r+360:r-360),i}applyConstraints(e){const{maxZoom:t,minZoom:i,zoom:n}=e;e.zoom=z_(n,i,t);const{maxPitch:r,minPitch:o,pitch:s}=e;e.pitch=z_(s,o,r);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:i,pitch:n=0}=e;let{longitude:r,latitude:o,zoom:s,bearing:a=0}=e;(r<-180||r>180)&&(r=Ny(r+180,360)-180),(a<-180||a>180)&&(a=Ny(a+180,360)-180);const l=jy(i/512);if(s<=l)s=l,o=0;else{const e=i/2/Math.pow(2,s),t=Yy([0,e])[1];if(ot&&(o=t)}}return{width:t,height:i,longitude:r,latitude:o,zoom:s,pitch:n,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.zoom({pos:[t/2,i/2],scale:e})}_panFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.pan({startPos:[t/2,i/2],pos:[t/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,i,n){const r=e[0]-t[0],o=e[1]-t[1],s=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;o>0?Math.abs(c-a)>5&&(h=o/(a-c)*1.2):o<0&&a>5&&(h=1-s/a),h=z_(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=i;return h>0?f=i+h*(p-i):h<0&&(f=i-h*(d-i)),{pitch:f,bearing:n+180*u}}}class Sb extends Tb{constructor(){super(...arguments),this.ControllerState=Cb,this.transition={transitionDuration:300,transitionInterpolator:new fb({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e);(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class Bb extends ib{constructor(e={}){super(e)}get ViewportType(){return Xv}get ControllerType(){return Sb}}Bb.displayName="MapView";var Ib=Bb;const Mb=new Dv;class Pb{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const i=t.findIndex(t=>{return i=e,(t.order??1/0)-(i.order??1/0)>0;var i});i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Xx(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const i=[];for(const n of e){const e=t[n.id];let r=n;e&&e!==n?e.setProps?(e.setProps(n.props),r=e):e.cleanup(this._context):e||n.setup(this._context),i.push(r),delete t[n.id]}for(const e in t)t[e].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(e=>e instanceof Dv)||this._resolvedEffects.push(Mb),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class Rb extends Mv{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Lb{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Rb(e),this.pickLayersPass=new Px(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);const n=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);const r=t.render({...i,target:n});i.effects&&this._postRender(i.effects,i),this.renderCount++,lp("deckRenderer.renderLayers",this,r,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize();0===e.length&&[0,1].map(t=>{const i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(const i of e)i.resize(t)}_postRender(e,t){const{renderBuffers:i}=this,n={...t,inputBuffer:i[0],swapBuffer:i[1]};for(const r of e)if(r.postRender){n.target=r.id===this.lastPostProcessEffect?t.target:void 0;const e=r.postRender(n);n.inputBuffer=e,n.swapBuffer=e===i[0]?i[1]:i[0]}}}const Fb={pickedColor:null,pickedObjectIndex:-1};function kb({pickedColors:e,decodePickingColor:t,deviceX:i,deviceY:n,deviceRadius:r,deviceRect:o}){const{x:s,y:a,width:l,height:c}=o;let u=r*r,h=-1,d=0;for(let t=0;tu)d+=4*l;else for(let t=0;t=0){const e=t+s-i,n=e*e+o;n<=u&&(u=n,h=d)}d+=4}}if(h>=0){const i=e.slice(h,h+4),n=t(i);if(n){const e=Math.floor(h/4/l),t=h/4-e*l;return{...n,pickedColor:i,pickedX:s+t,pickedY:a+e}}rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Fb}function Db({pickInfo:e,viewports:t,pixelRatio:i,x:n,y:r,z:o}){let s,a=t[0];if(t.length>1&&(a=function(e,t){for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.containsPixel(t))return n}return e[0]}(e?.pickedViewports||t,{x:n,y:r})),a){const e=[n-a.x,r-a.y];void 0!==o&&(e[2]=o),s=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:n,y:r,pixel:[n,r],coordinate:s,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:i}}function Ob(e){const{pickInfo:t,lastPickedInfo:i,mode:n,layers:r}=e,{pickedColor:o,pickedLayer:s,pickedObjectIndex:a}=t,l=s?[s]:[];if("hover"===n){const e=i.index,t=i.layerId,n=s?s.props.id:null;if(n!==t||a!==e){if(n!==t){const e=r.find(e=>e.props.id===t);e&&l.unshift(e)}i.layerId=n,i.index=a,i.info=null}}const c=Db(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===s&&(t.color=o,t.index=a,t.picked=!0),t=zb({layer:e,info:t,mode:n});const r=t.layer;e===s&&"hover"===n&&(i.info=t),u.set(r.id,t),"hover"===n&&r.updateAutoHighlight(t)}),u}function zb({layer:e,info:t,mode:i}){for(;e&&t;){const n=t.layer||null;t.sourceLayer=n,t.layer=e,t=e.getPickingInfo({info:t,mode:i,sourceLayer:n}),e=e.parent}return t}class Ub{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Px(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:n},r=this.lastPickedInfo.info){const o=r&&r.layer&&r.layer.id,s=r&&r.viewport&&r.viewport.id,a=o?i.find(e=>e.id===o):null,l=s&&n.find(e=>e.id===s)||n[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const e=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=e}const{canvas:e}=this.device.getCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}_pickClosestObject({layers:e,views:t,viewports:i,x:n,y:r,radius:o=0,depth:s=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===i.length)return{result:[],emptyInfo:Db({viewports:i,x:n,y:r,pixelRatio:h})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([n,r],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*h),{width:g,height:_}=this.pickingFBO,A=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),y={x:n-o,y:r-o,width:2*o+1,height:2*o+1};let v;const x=[],b=new Set;for(let e=0;e=0){const r=e.slice(n,n+4),o=r.join(",");if(!i.has(o)){const e=t(r);e?i.set(o,{...e,color:r}):rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(i.values())}(this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:y,cullRect:{x:n,y:r,width:o,height:s},effects:u,pass:`picking:${a}`})),x=new Map,b=[],w=Number.isFinite(l);for(let e=0;e=l);e++){const t=v[e];let i={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:n,y:r,pixelRatio:d};i=zb({layer:t.pickedLayer,info:i,mode:a});const o=i.layer.id;x.has(o)||x.set(o,new Set);const s=x.get(o),l=i.object??i.index;s.has(l)||(s.add(l),b.push(i))}return b}_drawAndSample({layers:e,views:t,viewports:i,onViewportActive:n,deviceRect:r,cullRect:o,effects:s,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:n,pickingFBO:c,deviceRect:r,cullRect:o,effects:s,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of s)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:p,width:f,height:m}=r,g=new(l?Float32Array:Uint8Array)(f*m*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:n,deviceHeight:r}){const o=Math.max(0,e-i),s=Math.max(0,t-i),a=Math.min(n,e+i+1)-o,l=Math.min(r,t+i+1)-s;return a<=0||l<=0?null:{x:o,y:s,width:a,height:l}}}const Nb={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Vb="top-left",jb="__root";class Gb{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Xx(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const t={};for(const e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(const e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let i of e){const e=t[i.id];e?e.viewId!==i.viewId||e.placement!==i.placement?(this._remove(e),this._add(i)):i!==e&&(e.setProps(i.props),i=e):this._add(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(const e in t){const i=t[e];i&&this._remove(i)}this.widgets=e}_add(e){const{viewId:t=null,placement:i=Vb}=e,n=e.onAdd({deck:this.deck,viewId:t});n&&this._getContainer(t,i).append(n),e._element=n}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,t){const i=e||jb;let n=this.containers[i];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[i]=n);let r=n.querySelector(`.${t}`);return r||(r=document.createElement("div"),r.className=t,r.style.position="absolute",r.style.zIndex="2",Object.assign(r.style,Nb[t]),n.append(r)),r}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const i in this.containers){const n=this.lastViewports[i]||null,r=i===jb||n,o=this.containers[i];r?(o.style.display="block",o.style.left=`${n?n.x:0}px`,o.style.top=`${n?n.y:0}px`,o.style.width=`${n?n.width:e}px`,o.style.height=`${n?n.height:t}px`):o.style.display="none"}}onRedraw({viewports:e,layers:t}){const i=e.reduce((e,t)=>(e[t.id]=t,e),{}),{lastViewports:n}=this;for(const r of this.getWidgets()){const{viewId:o}=r;if(o){const e=i[o];e&&(r.onViewportChange&&!e.equals(n[o])&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(const t of e)t.equals(n[t.id])||r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(const i of this.getWidgets()){const{viewId:n}=i;n&&n!==e.viewport?.id||i.onHover?.(e,t)}}onEvent(e,t){const i=Ty[t.type];if(i)for(const n of this.getWidgets()){const{viewId:r}=n;r&&r!==e.viewport?.id||n[i.handler]?.(e,t)}}}const Hb={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Qb{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const t=document.createElement("div");return t.className="deck-tooltip",Object.assign(t.style,Hb),this.deck=e,this.element=t,t}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;const n=i(e);this.lastViewport=e.viewport,this.setTooltip(n,e.x,e.y)}setTooltip(e,t,i){const n=this.element;if(n){if("string"==typeof e)n.innerText=e;else{if(!e)return this.isVisible=!1,void(n.style.display="none");e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className)}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${t}px, ${i}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(n.style,e.style)}}}var $b;!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}($b||($b={}));const Zb={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Wb=(e,t,i)=>t?e.enable(i):e.disable(i),qb=(e,t,i)=>e.hint(i,t),Kb=(e,t,i)=>e.pixelStorei(i,t),Xb=(e,t,i)=>{const n=36006===i?36009:36008;return e.bindFramebuffer(n,t)},Jb=(e,t,i)=>{const n={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];e.bindBuffer(n,t)};function Yb(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const ew={3042:Wb,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Wb,2885:(e,t)=>e.cullFace(t),2929:Wb,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Wb,35723:qb,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Xb,36010:Xb,34964:Jb,36662:Jb,36663:Jb,35053:Jb,35055:Jb,2886:(e,t)=>e.frontFace(t),33170:qb,2849:(e,t)=>e.lineWidth(t),32823:Wb,32824:"polygonOffset",10752:"polygonOffset",35977:Wb,32926:Wb,32928:Wb,32938:"sampleCoverage",32939:"sampleCoverage",3089:Wb,3088:(e,t)=>e.scissor(...t),2960:Wb,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:Wb,10754:Wb,12288:Wb,12289:Wb,12290:Wb,12291:Wb,12292:Wb,12293:Wb,12294:Wb,12295:Wb,3333:Kb,3317:Kb,37440:Kb,37441:Kb,37443:Kb,3330:Kb,3332:Kb,3331:Kb,3314:Kb,32878:Kb,3316:Kb,3315:Kb,32877:Kb,framebuffer:(e,t)=>{const i=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,i)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const i="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...i)},blendFunc:(e,t)=>{const i=2===t?.length?[...t,...t]:t;e.blendFuncSeparate(...i)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Yb(t)?t:[t,t];const[i,n]=t;e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilFuncSeparate(1028,i,n,r),e.stencilFuncSeparate(1029,o,s,a)},stencilOp:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilOpSeparate(1028,i,n,r),e.stencilOpSeparate(1029,o,s,a)},viewport:(e,t)=>e.viewport(...t)};function tw(e,t,i){return void 0!==t[e]?t[e]:i[e]}const iw={blendEquation:(e,t,i)=>e.blendEquationSeparate(tw(32777,t,i),tw(34877,t,i)),blendFunc:(e,t,i)=>e.blendFuncSeparate(tw(32969,t,i),tw(32968,t,i),tw(32971,t,i),tw(32970,t,i)),polygonOffset:(e,t,i)=>e.polygonOffset(tw(32824,t,i),tw(10752,t,i)),sampleCoverage:(e,t,i)=>e.sampleCoverage(tw(32938,t,i),tw(32939,t,i)),stencilFuncFront:(e,t,i)=>e.stencilFuncSeparate(1028,tw(2962,t,i),tw(2967,t,i),tw(2963,t,i)),stencilFuncBack:(e,t,i)=>e.stencilFuncSeparate(1029,tw(34816,t,i),tw(36003,t,i),tw(36004,t,i)),stencilOpFront:(e,t,i)=>e.stencilOpSeparate(1028,tw(2964,t,i),tw(2965,t,i),tw(2966,t,i)),stencilOpBack:(e,t,i)=>e.stencilOpSeparate(1029,tw(34817,t,i),tw(34818,t,i),tw(34819,t,i))},nw={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,i)=>e({[t]:i}),hint:(e,t,i)=>e({[t]:i}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,i)=>e({36007:i}),bindTransformFeedback:(e,t,i)=>e({36389:i}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,i)=>{switch(t){case 36160:return e({36006:i,36010:i});case 36009:return e({36006:i});case 36008:return e({36010:i});default:return null}},bindBuffer:(e,t,i)=>{const n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return n?e({[n]:i}):{valueChanged:!0}},blendColor:(e,t,i,n,r)=>e({32773:new Float32Array([t,i,n,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,i)=>e({32777:t,34877:i}),blendFunc:(e,t,i)=>e({32969:t,32968:i,32971:t,32970:i}),blendFuncSeparate:(e,t,i,n,r)=>e({32969:t,32968:i,32971:n,32970:r}),clearColor:(e,t,i,n,r)=>e({3106:new Float32Array([t,i,n,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,i,n,r)=>e({3107:[t,i,n,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,i)=>e({2928:new Float32Array([t,i])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,i)=>e({32824:t,10752:i}),sampleCoverage:(e,t,i)=>e({32938:t,32939:i}),scissor:(e,t,i,n,r)=>e({3088:new Int32Array([t,i,n,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,i)=>e({[1028===t?2968:36005]:i}),stencilFunc:(e,t,i,n)=>e({2962:t,2967:i,2963:n,34816:t,36003:i,36004:n}),stencilFuncSeparate:(e,t,i,n,r)=>e({[1028===t?2962:34816]:i,[1028===t?2967:36003]:n,[1028===t?2963:36004]:r}),stencilOp:(e,t,i,n)=>e({2964:t,2965:i,2966:n,34817:t,34818:i,34819:n}),stencilOpSeparate:(e,t,i,n,r)=>e({[1028===t?2964:34817]:i,[1028===t?2965:34818]:n,[1028===t?2966:34819]:r}),viewport:(e,t,i,n,r)=>e({2978:[t,i,n,r]})},rw=(e,t)=>e.isEnabled(t),ow={3042:rw,2884:rw,2929:rw,3024:rw,32823:rw,32926:rw,32928:rw,3089:rw,2960:rw,35977:rw},sw=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function aw(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const i={};for(const n in t){const r=Number(n),o=ew[n];o&&("string"==typeof o?i[o]=!0:o(e,t[n],r))}const n=e.state&&e.state.cache;if(n)for(const r in i){(0,iw[r])(e,t,n)}}function lw(e,t=Zb){if("number"==typeof t){const i=t,n=ow[i];return n?n(e,i):e.getParameter(i)}const i=Array.isArray(t)?t:Object.keys(t),n={};for(const t of i){const i=ow[t];n[t]=i?i(e,Number(t)):e.getParameter(Number(t))}return n}function cw(e,t){if(e===t)return!0;const i=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(i&&n&&e.length===t.length){for(let i=0;i{}}={}){this.gl=e,this.cache=t?lw(e):Object.assign({},Zb),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){cf(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];aw(this.gl,e),this.stateStack.pop()}_updateCache(e){let t,i=!1;const n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){cf(void 0!==r);const o=e[r],s=this.cache[r];cw(o,s)||(i=!0,t=s,n&&!(r in n)&&(n[r]=s),this.cache[r]=o)}return{valueChanged:i,oldValue:t}}}function hw(e){return e.state}function dw(e,t){const{enable:i=!0,copyState:n}=t;if(cf(void 0!==n),!e.state){e.state=new uw(e,{copyState:n}),function(e){const t=e.useProgram.bind(e);e.useProgram=function(i){const n=hw(e);n.program!==i&&(t(i),n.program=i)}}(e);for(const t in nw){gw(e,t,nw[t])}mw(e,"getParameter"),mw(e,"isEnabled")}return hw(e).enable=i,e}function pw(e){let t=hw(e);t||(dw(e,{copyState:!1}),t=hw(e)),t.push()}function fw(e){const t=hw(e);cf(t),t.pop()}function mw(e,t){const i=e[t].bind(e);e[t]=function(t){if(void 0===t||sw.has(t))return i(t);const n=hw(e);return t in n.cache||(n.cache[t]=i(t)),n.enable?n.cache[t]:i(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function gw(e,t,i){if(!e[t])return;const n=e[t].bind(e);e[t]=function(...t){const r=hw(e),{valueChanged:o,oldValue:s}=i(r._updateCache,...t);return o&&n(...t),s},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}const _w={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Aw(e,t,i){return void 0===i[t]&&(i[t]=e.getExtension(t)||null),i[t]}function yw(e,t){const i=e.getParameter(7936),n=e.getParameter(7937);Aw(e,"WEBGL_debug_renderer_info",t);const r=t.WEBGL_debug_renderer_info,o=e.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936)||i,s=e.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937)||n,a=e.getParameter(7938),l=vw(o,s),c=function(e,t){if(/Metal/i.exec(e)||/Metal/i.exec(t))return"metal";if(/ANGLE/i.exec(e)||/ANGLE/i.exec(t))return"opengl";return"unknown"}(o,s),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(vw(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(o,s);return{type:"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:o,renderer:s,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function vw(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function xw(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const bw="texture-compression-bc",ww="texture-compression-astc",Tw="texture-compression-etc2",Ew="texture-compression-pvrtc-webgl",Cw="texture-compression-atc-webgl",Sw="float32-renderable-webgl",Bw="float16-renderable-webgl",Iw="snorm8-renderable-webgl",Mw="norm16-renderable-webgl",Pw="snorm16-renderable-webgl",Rw="float32-filterable",Lw="float16-filterable-webgl",Fw="WEBGL_compressed_texture_s3tc",kw="WEBGL_compressed_texture_s3tc_srgb",Dw="EXT_texture_compression_rgtc",Ow="EXT_texture_compression_bptc",zw="EXT_texture_norm16",Uw="EXT_render_snorm",Nw={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Uw],"norm16-renderable-webgl":[zw],"snorm16-renderable-webgl":[zw,Uw],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Fw,kw,Dw,Ow],"texture-compression-bc5-webgl":[Dw],"texture-compression-bc7-webgl":[Ow],"texture-compression-etc2":["WEBGL_compressed_texture_etc"],"texture-compression-astc":["WEBGL_compressed_texture_astc"],"texture-compression-etc1-webgl":["WEBGL_compressed_texture_etc1"],"texture-compression-pvrtc-webgl":["WEBGL_compressed_texture_pvrtc"],"texture-compression-atc-webgl":["WEBGL_compressed_texture_atc"]};const Vw={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:Iw},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:Iw},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:Bw,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Mw,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:Pw},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:Iw},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:Bw,filter:Lw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Mw},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:Pw},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Sw,filter:Rw},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"rgb9e5ufloat_renderable-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Sw,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Mw},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Mw},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Sw,filter:Rw,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:Bw,filter:Lw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Mw,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:Pw},"rgb32float-webgl":{gl:34837,render:Sw,filter:Rw,gl2ext:"EXT_color_buffer_float",dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Sw,filter:Rw,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fw,f:bw},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:kw,f:bw},"bc1-rgba-unorm":{gl:33777,x:Fw,f:bw},"bc1-rgba-unorm-srgb":{gl:35916,x:kw,f:bw},"bc2-rgba-unorm":{gl:33778,x:Fw,f:bw},"bc2-rgba-unorm-srgb":{gl:35918,x:kw,f:bw},"bc3-rgba-unorm":{gl:33779,x:Fw,f:bw},"bc3-rgba-unorm-srgb":{gl:35919,x:kw,f:bw},"bc4-r-unorm":{gl:36283,x:Dw,f:bw},"bc4-r-snorm":{gl:36284,x:Dw,f:bw},"bc5-rg-unorm":{gl:36285,x:Dw,f:bw},"bc5-rg-snorm":{gl:36286,x:Dw,f:bw},"bc6h-rgb-ufloat":{gl:36495,x:Ow,f:bw},"bc6h-rgb-float":{gl:36494,x:Ow,f:bw},"bc7-rgba-unorm":{gl:36492,x:Ow,f:bw},"bc7-rgba-unorm-srgb":{gl:36493,x:Ow,f:bw},"etc2-rgb8unorm":{gl:37492,f:Tw},"etc2-rgb8unorm-srgb":{gl:37494,f:Tw},"etc2-rgb8a1unorm":{gl:37496,f:Tw},"etc2-rgb8a1unorm-srgb":{gl:37497,f:Tw},"etc2-rgba8unorm":{gl:37493,f:Tw},"etc2-rgba8unorm-srgb":{gl:37495,f:Tw},"eac-r11unorm":{gl:37488,f:Tw},"eac-r11snorm":{gl:37489,f:Tw},"eac-rg11unorm":{gl:37490,f:Tw},"eac-rg11snorm":{gl:37491,f:Tw},"astc-4x4-unorm":{gl:37808,f:ww},"astc-4x4-unorm-srgb":{gl:37840,f:ww},"astc-5x4-unorm":{gl:37809,f:ww},"astc-5x4-unorm-srgb":{gl:37841,f:ww},"astc-5x5-unorm":{gl:37810,f:ww},"astc-5x5-unorm-srgb":{gl:37842,f:ww},"astc-6x5-unorm":{gl:37811,f:ww},"astc-6x5-unorm-srgb":{gl:37843,f:ww},"astc-6x6-unorm":{gl:37812,f:ww},"astc-6x6-unorm-srgb":{gl:37844,f:ww},"astc-8x5-unorm":{gl:37813,f:ww},"astc-8x5-unorm-srgb":{gl:37845,f:ww},"astc-8x6-unorm":{gl:37814,f:ww},"astc-8x6-unorm-srgb":{gl:37846,f:ww},"astc-8x8-unorm":{gl:37815,f:ww},"astc-8x8-unorm-srgb":{gl:37847,f:ww},"astc-10x5-unorm":{gl:37819,f:ww},"astc-10x5-unorm-srgb":{gl:37851,f:ww},"astc-10x6-unorm":{gl:37817,f:ww},"astc-10x6-unorm-srgb":{gl:37849,f:ww},"astc-10x8-unorm":{gl:37818,f:ww},"astc-10x8-unorm-srgb":{gl:37850,f:ww},"astc-10x10-unorm":{gl:37819,f:ww},"astc-10x10-unorm-srgb":{gl:37851,f:ww},"astc-12x10-unorm":{gl:37820,f:ww},"astc-12x10-unorm-srgb":{gl:37852,f:ww},"astc-12x12-unorm":{gl:37821,f:ww},"astc-12x12-unorm-srgb":{gl:37853,f:ww},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Ew},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Ew},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Ew},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Ew},"etc1-rbg-unorm-webgl":{gl:36196,f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{gl:35986,f:Cw},"atc-rgba-unorm-webgl":{gl:35986,f:Cw},"atc-rgbai-unorm-webgl":{gl:34798,f:Cw}},jw={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},Gw={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function Hw(e,t,i){const n=Vw[t];if(!n)return!1;if(void 0===n.gl)return!1;const r=n.x||n.gl2ext;return!r||Boolean(Aw(e,r,i))}function Qw(e){const t=Vw[e],i=t?.gl;if(void 0===i)throw new Error(`Unsupported texture format ${e}`);return i}function $w(e){const t=Vw[e],i=Qw(e),n=rf(e);return{format:i,dataFormat:t?.dataFormat||Ww(n.format,n.integer,n.normalized,i),type:n.dataType?xw(n.dataType):t?.types?.[0]||5121,compressed:n.compressed}}function Zw(e){const t=$w(e);return(jw[t.dataFormat]||4)*(Gw[t.type]||1)}function Ww(e,t,i,n){if(6408===n||6407===n)return n;switch(e){case"r":return t&&!i?36244:6403;case"rg":return t&&!i?33320:33319;case"rgb":return t&&!i?36248:6407;case"rgba":return t&&!i?36249:6408;default:return 6408}}const qw={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Kw extends af{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,Aw(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){return!this.disabledFeatures[e]&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in Nw}(e)&&function(e,t,i){return(Nw[t]||[]).every(t=>Aw(e,t,i))}(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(qw),...Object.keys(Nw)]}getWebGLFeature(e){const t=qw[e];return"string"==typeof t?Boolean(Aw(this.gl,t,this.extensions)):Boolean(t)}}class Xw extends sf{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}}function Jw(e,t,i){if(function(e){for(const t in e)return!1;return!0}(t))return i(e);const{nocatch:n=!0}=t;let r;if(pw(e),aw(e,t),n)r=i(e),fw(e);else try{r=i(e)}finally{fw(e)}return r}function Yw(e,t,i,n){if(qp(t))return n(e);const r=e;pw(r.gl);try{return function(e,t){const i=e,{gl:n}=i;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029)}t.frontFace&&n.frontFace(rT("frontFace",t.frontFace,{ccw:2305,cw:2304}));t.unclippedDepth&&e.features.has("depth-clip-control")&&n.enable(34383);void 0!==t.depthBias&&(n.enable(32823),n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0));if(t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=rT("provokingVertex",t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(n)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=rT("polygonMode",t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,n),e?.polygonModeWEBGL(1029,n)}t.polygonOffsetLine&&n.enable(10754)}e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&n.enable(12288),t.clipDistance1&&n.enable(12289),t.clipDistance2&&n.enable(12290),t.clipDistance3&&n.enable(12291),t.clipDistance4&&n.enable(12292),t.clipDistance5&&n.enable(12293),t.clipDistance6&&n.enable(12294),t.clipDistance7&&n.enable(12295));void 0!==t.depthWriteEnabled&&n.depthMask(t.depthWriteEnabled);t.depthCompare&&("always"!==t.depthCompare?n.enable(2929):n.disable(2929),n.depthFunc(eT("depthCompare",t.depthCompare)));if(t.stencilWriteMask){const e=t.stencilWriteMask;n.stencilMaskSeparate(1028,e),n.stencilMaskSeparate(1029,e)}t.stencilReadMask&&Gp.warn("stencilReadMask not supported under WebGL");if(t.stencilCompare){const e=t.stencilReadMask||4294967295,i=eT("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,i,0,e),n.stencilFuncSeparate(1029,i,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=tT("stencilPassOperation",t.stencilPassOperation),i=tT("stencilFailOperation",t.stencilFailOperation),r=tT("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,i,r,e),n.stencilOpSeparate(1029,i,r,e)}if(t.blendColorOperation||t.blendAlphaOperation){n.enable(3042);const e=iT("blendColorOperation",t.blendColorOperation||"add"),i=iT("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(e,i);const r=nT("blendColorSrcFactor",t.blendColorSrcFactor||"one"),o=nT("blendColorDstFactor",t.blendColorDstFactor||"zero"),s=nT("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=nT("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(r,o,s,a)}}(e,t),aw(r.gl,i),n(e)}finally{fw(r.gl)}}function eT(e,t){return rT(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function tT(e,t){return rT(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function iT(e,t){return rT(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function nT(e,t){return rT(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function rT(e,t,i){if(!(t in i))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return i[t]}function oT(e){const t={};return e.addressModeU&&(t[10242]=sT(e.addressModeU)),e.addressModeV&&(t[10243]=sT(e.addressModeV)),e.addressModeW&&(t[32882]=sT(e.addressModeW)),e.magFilter&&(t[10240]=aT(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t){if(!t)return aT(e);switch(e){case"nearest":return"nearest"===t?9984:9986;case"linear":return"nearest"===t?9985:9987}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=eT("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function sT(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function aT(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class lT extends Xp{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const i="object"==typeof t?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=function(e){if(e&Xp.INDEX)return 34963;if(e&Xp.VERTEX)return 34962;if(e&Xp.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&Xp.INDEX)return 35044;if(e&Xp.VERTEX)return 35044;if(e&Xp.UNIFORM)return 35048;return 35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,i=e.byteLength+t){const n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.glUsage),this.gl.bufferSubData(n,t,e),this.gl.bindBuffer(n,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){cf(e>=0);let t=e;0===e&&(t=new Float32Array(0));const i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){const i=36663;this.gl.bindBuffer(i,this.handle),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const i=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}class cT extends Bf{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=oT(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,i]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,i);break;default:this.device.gl.samplerParameteri(this.handle,e,i)}}}}class uT extends vf{device;gl;handle;texture;constructor(e,t){super(e,{...yf.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}const hT={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0};class dT extends yf{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...hT,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=function(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;default:throw new Error(e.dimension)}}(this.props),this.loaded=!1,"string"==typeof this.props?.data&&Object.assign(this.props,{data:im(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new uT(this.device,{...e,texture:this})}initialize(e={}){if("cube"===this.props.dimension)return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(t=>this.initialize(Object.assign({},e,{pixels:t,data:t}))),this;const i="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(i&&t.readyStatethis.initialize(e)),this;const{parameters:n={}}=e,{pixels:r=null,pixelStore:o={},textureUnit:s,mipmaps:a=!0}=e;t||(t=r);let{width:l,height:c,dataFormat:u,type:h,compressed:d=!1}=e;const{depth:p=0}=e,f=Qw(e.format);return({width:l,height:c,compressed:d,dataFormat:u,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:u,compressed:d,data:t,width:l,height:c})),this.width=l,this.height=c,this.glFormat=f,this.type=h,this.dataFormat=u,this.textureUnit=s,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=a,this.setImageData({data:t,width:l,height:c,depth:p,format:e.format,type:h,dataFormat:u,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(n),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),a&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:t,parameters:n,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){const{mipmaps:t=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let t;e instanceof cT?(this.sampler=e,t=e.props):(this.sampler=new cT(this.device,e),t=e);const i=oT(t);return this._setSamplerParameters(i),this}resize(e){const{height:t,width:i,mipmaps:n=!1}=e;return i!==this.width||t!==this.height?this.initialize({width:i,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:n}):this}update(){if(this._video){const{video:e,parameters:t,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if("3d"===this.props.dimension||"2d-array"===this.props.dimension)return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");const{target:t=this.target,pixels:i=null,level:n=0,glFormat:r=this.glFormat,offset:o=0,parameters:s={}}=e;let{data:a=null,type:l=this.type,width:c=this.width,height:u=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;a||(a=i),({type:l,dataFormat:h,compressed:d,width:c,height:u}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:a,width:c,height:u}));const{gl:p}=this;p.bindTexture(this.target,this.handle);let f=null;if(({data:a,dataType:f}=this._getDataType({data:a,compressed:d})),Jw(this.gl,s,()=>{switch(f){case"null":case"browser-object":p.texImage2D(t,n,r,c,u,0,h,l,a);break;case"typed-array":p.texImage2D(t,n,r,c,u,0,h,l,a,o);break;case"buffer":this.device.gl.bindBuffer(35052,a.handle||a),this.device.gl.texImage2D(t,n,r,c,u,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"compressed":for(const[e,i]of a.entries())p.compressedTexImage2D(t,e,i.format,i.width,i.height,0,i.data);break;default:cf(!1,"Unknown image data type")}}),a&&a.byteLength)this.trackAllocatedMemory(a.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*e,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:i=null,x:n=0,y:r=0,width:o=this.width,height:s=this.height,level:a=0,glFormat:l=this.glFormat,type:c=this.type,dataFormat:u=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if(({type:c,dataFormat:u,compressed:h,width:o,height:s}=this._deduceParameters({format:this.props.format,type:c,dataFormat:u,compressed:h,data:i,width:o,height:s})),cf(1===this.depth,"texSubImage not supported for 3D textures"),i||(i=t),i&&i.data){const e=i;i=e.data,o=e.shape[0],s=e.shape[1]}i instanceof lT&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Jw(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,a,n,r,o,s,l,i):null===i?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,i,d):"undefined"!=typeof WebGLBuffer&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return Gp.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof lT?{data:e.handle,dataType:"buffer"}:"undefined"!=typeof WebGLBuffer&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){const{format:t,data:i}=e;let{width:n,height:r,dataFormat:o,type:s,compressed:a}=e;const l=$w(t);return o=o||l.dataFormat,s=s||l.type,a=a||l.compressed,({width:n,height:r}=this._deduceImageSize(i,n,r)),{dataFormat:o,type:s,compressed:a,width:n,height:r,format:t,data:i}}_deduceImageSize(e,t,i){let n;return n="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:i}:{width:t>=0?t:1,height:i>=0?i:1},cf(n,"Could not deduced texture size"),cf(void 0===t||n.width===t,"Deduced texture width does not match supplied width"),cf(void 0===i||n.height===i,"Deduced texture height does not match supplied height"),n}async setCubeMapImageData(e){const{gl:t}=this,{width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,l=r||o,c=await Promise.all(dT.FACES.map(e=>{const t=l[e];return Promise.all(Array.isArray(t)?t:[t])}));this.bind(),dT.FACES.forEach((e,r)=>{c[r].length>1&&!1!==this.props.mipmaps&&Gp.warn(`${this.id} has mipmap and multiple LODs.`)(),c[r].forEach((r,o)=>{i&&n?t.texImage2D(e,o,s,i,n,0,s,a,r):t.texImage2D(e,o,s,s,a,r)})}),this.unbind()}setImageDataForFace(e){const{face:t,width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,{gl:l}=this,c=r||o;return this.bind(),c instanceof Promise?c.then(i=>this.setImageDataForFace(Object.assign({},e,{face:t,data:i,pixels:i}))):this.width||this.height?l.texImage2D(t,0,s,i,n,0,s,a,c):l.texImage2D(t,0,s,s,a,c),this}setImageData3D(e){const{level:t=0,dataFormat:i,format:n,type:r,width:o,height:s,depth:a=1,offset:l=0,data:c,parameters:u={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const h=$w(n);if(Jw(this.gl,u,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,t,h.format,o,s,a,0,h.dataFormat,h.type,c),c instanceof lT&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,t,i,o,s,a,0,n,r,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*e,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!qp(e)){!function(e){Gp.log(1,"texture sampler parameters",e)()}(e),this.gl.bindTexture(this.target,this.handle);for(const[t,i]of Object.entries(e)){const e=Number(t),n=i;switch(e){case 33082:case 33083:this.gl.texParameterf(this.target,e,n);break;default:this.gl.texParameteri(this.target,e,n)}}this.gl.bindTexture(this.target,null)}}}class pT extends If{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);const i=null===t.handle;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const i=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;evoid 0===e?"undefined":e);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${e}(${i})`}function xT(e,t,i,n){n=Array.from(n).map(e=>void 0===e?"undefined":e);const r=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${i}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(i,n)})`;if(Gp.error(r)(),e.throwOnError)throw new Error(r)}function bT(e,t,i){let n="";if(Gp.level>=1&&(n=vT(t,i),Gp.log(1,n)()),e.break&&e.break.length>0){n=n||vT(t,i);e.break.every(e=>-1!==n.indexOf(e))}for(const r of i)if(void 0===r){if(n=n||vT(t,i),e.throwOnError)throw new Error(`Undefined argument: ${n}`);Gp.error(`Undefined argument: ${n}`)()}}function wT(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class TT extends Cf{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){return function(e){const t=e.split(/\r?\n/),i=[];for(const e of t){if(e.length<=1)continue;const t=e.split(":");if(2===t.length){const[e,n]=t;i.push({message:n.trim(),type:wT(e),lineNum:0,linePos:0});continue}const[n,r,o,...s]=t;let a=parseInt(o,10);isNaN(a)&&(a=0);let l=parseInt(r,10);isNaN(l)&&(l=0),i.push({message:s.join(":").trim(),type:wT(n),lineNum:a,linePos:l})}return i}(this.device.gl.getShaderInfoLog(this.handle))}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(e=>e.startsWith("#version ")?e:`#version 100\n${e}`)(e);const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),0!==Gp.level){if(this.device.features.has("compilation-status-async-webgl"))Gp.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),Gp.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader();else if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}const ET=6144,CT=[1,2,4,8];class ST extends Pf{device;glParameters;constructor(e,t){super(e,t),this.device=e,pw(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){fw(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(t.colorMask=CT.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,aw(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;!1!==this.props.clearColor&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&Jw(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Jw(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(ET,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(ET,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(ET,e,t)}})}}function BT(e,t){const{clamped:i=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return i?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}const IT={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},MT={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class PT{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return BT(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){cf(e.size);return BT(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new PT(...[IT,...e])}constructor(...e){e.forEach(e=>this._assign(e)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return PT.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return PT.getBytesPerVertex(this)}_assign(e={}){return void 0!==(e=function(e,t,i){const{removedProps:n={},deprecatedProps:r={},replacedProps:o={}}=i;for(const i in n)if(i in t){const t=n[i]?`${e}.${n[i]}`:"N/A";Gp.removed(`${e}.${i}`,t)()}for(const i in r)if(i in t){const t=r[i];Gp.deprecated(`${e}.${i}`,`${e}.${t}`)()}let s=null;for(const[i,n]of Object.entries(o))i in t&&(Gp.deprecated(`${e}.${i}`,`${e}.${n}`)(),s=s||Object.assign({},t),s[n]=t[i],delete s[i]);return s||t}("Accessor",e,MT)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalize&&(this.normalized=e.normalize),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),void 0===this.offset&&delete this.offset,void 0===this.stride&&delete this.stride,void 0===this.type&&delete this.type,void 0===this.size&&delete this.size,void 0===this.divisor&&delete this.divisor,void 0===this.normalized&&delete this.normalized,void 0===this.integer&&delete this.integer,void 0===this.buffer&&delete this.buffer,void 0===this.index&&delete this.index,this}}function RT(e){return LT.includes(e)}const LT=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],FT={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function kT(e){const t=FT[e];if(!t)throw new Error("uniform");const[i,n,,r]=t;return{format:r,components:n,glType:i}}function DT(e){const t=FT[e];if(!t)throw new Error("attribute");const[,i,,n,r]=t;return{attributeType:n,vertexFormat:r,components:i}}function OT(e,t){const i={attributes:[],bindings:[]};i.attributes=function(e,t){const i=[],n=e.getProgramParameter(t,35721);for(let r=0;r=0){const{attributeType:e}=DT(s),t=/instance/i.test(o)?"instance":"vertex";i.push({name:o,location:a,stepMode:t,type:e})}}return i.sort((e,t)=>e.location-t.location),i}(e,t);const n=function(e,t){const i=(i,n)=>e.getActiveUniformBlockParameter(t,i,n),n=[],r=e.getProgramParameter(t,35382);for(let o=0;oe.location-t.location),n}(e,t);for(const e of n){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));i.bindings.push({type:"uniform",name:e.name,location:e.location,visibility:(e.vertex?1:0)&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}const r=function(e,t){const i=[],n=e.getProgramParameter(t,35718);for(let r=0;r1)for(let n=0;ne.location-t.location),i}(e,t);return s?.length&&(i.varyings=s),i}const zT={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function UT(e){const t=zT[e];if(!t)throw new Error("sampler");const[i,n]=t;return{viewDimension:i,sampleType:n}}function NT(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}function VT(e,t,i,n){const r=e;let o=n;!0===o&&(o=1),!1===o&&(o=0);const s="number"==typeof o?[o]:o;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof n)throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,s);case 35664:return e.uniform2fv(t,s);case 35665:return e.uniform3fv(t,s);case 35666:return e.uniform4fv(t,s);case 5124:case 35670:return e.uniform1iv(t,s);case 35667:case 35671:return e.uniform2iv(t,s);case 35668:case 35672:return e.uniform3iv(t,s);case 35669:case 35673:return e.uniform4iv(t,s);case 5125:return r.uniform1uiv(t,s,1);case 36294:return r.uniform2uiv(t,s,2);case 36295:return r.uniform3uiv(t,s,3);case 36296:return r.uniform4uiv(t,s,4);case 35674:return e.uniformMatrix2fv(t,!1,s);case 35675:return e.uniformMatrix3fv(t,!1,s);case 35676:return e.uniformMatrix4fv(t,!1,s);case 35685:return r.uniformMatrix2x3fv(t,!1,s);case 35686:return r.uniformMatrix2x4fv(t,!1,s);case 35687:return r.uniformMatrix3x2fv(t,!1,s);case 35688:return r.uniformMatrix3x4fv(t,!1,s);case 35689:return r.uniformMatrix4x2fv(t,!1,s);case 35690:return r.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}class jT extends Mf{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;const{varyings:i,bufferMode:n=35981}=t;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,n)),this._linkShaders(),Gp.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=OT(this.device.gl,this.handle),Gp.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=function(e,t){const i={...e,attributes:e.attributes.map(e=>({...e}))};for(const e of t?.attributes||[]){const t=i.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Gp.warn(`shader layout attribute ${e.name} not present in shader`)}return i}(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":Gp.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`)}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,t){for(const[i,n]of Object.entries(e)){const e=this.shaderLayout.bindings.find(e=>e.name===i)||this.shaderLayout.bindings.find(e=>e.name===`${i}Uniforms`);if(!e){const e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||Gp.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${e}`)();continue}switch(n||Gp.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(n instanceof lT||n.buffer instanceof lT))throw new Error("buffer value");break;case"texture":if(!(n instanceof uT||n instanceof dT||n instanceof pT))throw new Error("texture value");break;case"sampler":Gp.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(e.type)}this.bindings[i]=n}}draw(e){const{renderPass:t,parameters:i=this.props.parameters,topology:n=this.props.topology,vertexArray:r,vertexCount:o,instanceCount:s,isInstanced:a=!1,firstVertex:l=0,transformFeedback:c}=e,u=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}(n),h=Boolean(r.indexBuffer),d=r.indexBuffer?.glIndexType;if("success"!==this.linkStatus)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),r.bindBeforeRender(t),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const p=t;return Yw(this.device,i,p.glParameters,()=>{h&&a?this.device.gl.drawElementsInstanced(u,o||0,d,l,s||0):h?this.device.gl.drawElements(u,o||0,d,l):a?this.device.gl.drawArraysInstanced(u,l,o||0,s||0):this.device.gl.drawArrays(u,l,o||0),c&&c.end()}),r.unbindAfterRender(t),!0}setUniformsWebGL(e){const{bindings:t}=tm(e);Object.keys(t).forEach(e=>{Gp.warn(`Unsupported value "${JSON.stringify(t[e])}" used in setUniforms() for key ${e}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Gp.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Gp.timeEnd(4,`linkProgram for ${this.id}`)(),Gp.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}Gp.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Gp.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){if("success"!==e){if("error"===this.vs.compilationStatus)throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);if("error"===this.fs?.compilationStatus)throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);throw new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){const{gl:e}=this.device;if(!e.getProgramParameter(this.handle,35714))return this.linkStatus="error","linking";e.validateProgram(this.handle);return e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const[,t]of Object.entries(this.bindings))t instanceof dT&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if("success"!==this.linkStatus)return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=0;for(const n of this.shaderLayout.bindings){const r=this.bindings[n.name]||this.bindings[n.name.replace(/Uniforms$/,"")];if(!r)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":const{name:o}=n,s=e.getUniformBlockIndex(this.handle,o);if(4294967295===s)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,s),r instanceof lT?e.bindBufferBase(35345,i,r.handle):e.bindBufferRange(35345,i,r.buffer.handle,r.offset||0,r.size||r.buffer.byteLength-r.offset),i+=1;break;case"texture":if(!(r instanceof uT||r instanceof dT||r instanceof pT))throw new Error("texture");let a;if(r instanceof uT)a=r.texture;else if(r instanceof dT)a=r;else{if(!(r instanceof pT&&r.colorAttachments[0]instanceof uT))throw new Error("No texture");Gp.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=r.colorAttachments[0].texture}e.activeTexture(33984+t),e.bindTexture(a.target,a.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:i,type:n,textureUnit:r}=e,o=this.uniforms[t]??r;void 0!==o&&VT(this.device.gl,i,n,o)}}}class GT extends Ff{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":HT(this.device,t.options);break;case"copy-buffer-to-texture":QT(this.device,t.options);break;case"copy-texture-to-buffer":$T(this.device,t.options);break;case"copy-texture-to-texture":ZT(this.device,t.options)}}}function HT(e,t){const i=t.source,n=t.destination;e.gl.bindBuffer(36662,i.handle),e.gl.bindBuffer(36663,n.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function QT(e,t){throw new Error("Not implemented")}function $T(e,t){const{source:i,mipLevel:n=0,aspect:r="all",width:o=t.source.width,height:s=t.source.height,depthOrArrayLayers:a=0,origin:l=[0,0],destination:c,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if("all"!==r)throw new Error("not supported");if(0!==n||0!==a||h||d)throw new Error("not implemented");const{framebuffer:p,destroyFramebuffer:f}=WT(i);let m;try{const t=c,i=o||p.width,n=s||p.height,r=$w(p.texture.props.format),a=r.dataFormat,h=r.type;e.gl.bindBuffer(35051,t.handle),m=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(l[0],l[1],i,n,a,h,u)}finally{e.gl.bindBuffer(35051,null),void 0!==m&&e.gl.bindFramebuffer(36160,m),f&&p.destroy()}}function ZT(e,t){const{source:i,destinationMipLevel:n=0,origin:r=[0,0],destinationOrigin:o=[0,0],destination:s}=t;let{width:a=t.destination.width,height:l=t.destination.height}=t;const{framebuffer:c,destroyFramebuffer:u}=WT(i),[h,d]=r,[p,f,m]=o,g=e.gl.bindFramebuffer(36160,c.handle);let _,A=null;if(!(s instanceof dT))throw new Error("invalid destination");switch(A=s,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A.bind(0),_=A.target,_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,n,p,f,h,d,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,n,p,f,m,h,d,a,l)}A&&A.unbind(),e.gl.bindFramebuffer(36160,g),u&&c.destroy()}function WT(e){if(e instanceof yf){const{width:t,height:i,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:i,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class qT extends Lf{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new GT(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){}}class KT extends Vf{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||Pu()?Mu(t)?"Electron":(t||Iu.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node");var t}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const i=t;if(34963===i.glTarget)throw new Error("Use .setIndexBuffer()");const{size:n,type:r,stride:o,offset:s,normalized:a,integer:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,n,r,o,s):this.device.gl.vertexAttribPointer(e,n,r,a,o,s),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,c||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const i=this._getVaryingIndex(e),{buffer:n,byteLength:r,byteOffset:o}=this._getBufferRange(t);if(i<0)return this.unusedBuffers[e]=n,void Gp.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[i]={buffer:n,byteLength:r,byteOffset:o},this.bindOnUse||this._bindBuffer(i,n,o,r)}getBuffer(e){if(JT(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof lT)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:i=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:n}}_getVaryingIndex(e){if(JT(e))return Number(e);for(const t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:i,byteOffset:n}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,n,i)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,n){const r=t&&t.handle;r&&void 0!==n?this.gl.bindBufferRange(35982,e,r,i,n):this.gl.bindBufferBase(35982,e,r)}}function JT(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class YT extends Gf{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((i,n)=>{const r=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):t++>e?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}}function eE(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return cf(!1),0}}function tE(e,t){const{sourceX:i=0,sourceY:n=0,sourceFormat:r=6408,sourceAttachment:o=36064}=t||{};let{target:s=null,sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u);const{gl:d,handle:p}=u;a=a||u.width,l=l||u.height;const f=o-36064;c=c||u.colorAttachments[f]?.texture?.type||5121,s=function(e,t,i,n,r){if(e)return e;t=t||5121;const o=BT(t,{clamped:!1}),s=eE(i);return new o(n*r*s)}(s,c,r,a,l),c=c||function(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}(s);const m=d.bindFramebuffer(36160,p);return d.readPixels(i,n,a,l,r,c,s),d.bindFramebuffer(36160,m||null),h&&u.destroy(),s}function iE(e,t){const{target:i,sourceX:n=0,sourceY:r=0,sourceFormat:o=6408,targetByteOffset:s=0}=t||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u),a=a||u.width,l=l||u.height;const d=u;c=c||5121;let p=i;if(!p){const e=eE(o),t=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return cf(!1),0}}(c),i=s+a*l*e*t;p=d.device.createBuffer({byteLength:i})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({source:e,width:a,height:l,origin:[n,r],destination:p,byteOffset:s}),f.destroy(),h&&u.destroy(),p}function nE(e){return e instanceof If?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:rE(e),deleteFramebuffer:!0}}function rE(e,t){const{device:i,width:n,height:r,id:o}=e;return i.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:n,height:r,colorAttachments:[e]})}class oE extends lf{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return"undefined"!=typeof WebGL2RenderingContext}static attach(e){if(e instanceof oE)return e;if(e?.device instanceof lf)return e.device;if(!function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return!0;return Boolean(e&&Number.isFinite(e._version))}(e))throw new Error("Invalid WebGL2RenderingContext");return new oE({gl:e})}static async create(e={}){Gp.groupCollapsed(1,"WebGLDevice created")();const t=[];e.debug&&t.push(async function(){Pu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await nm("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.spector&&t.push(async function(){if(!globalThis.SPECTOR)try{await nm("https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js")}catch(e){Gp.warn(String(e))}}()),"string"==typeof e.canvas&&t.push(gf.pageLoaded);const i=await Promise.allSettled(t);for(const e of i)"rejected"===e.status&&Gp.error(`Failed to initialize debug libraries ${e.reason}`)();if(Gp.probe(2,"DOM is loaded")(),e.gl?.device)return Gp.warn("reattaching existing device")(),oE.attach(e.gl);const n=new oE(e),r=`Created ${n.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Gp.probe(1,r)(),Gp.table(1,n.info)(),Gp.groupEnd(1)(),n}constructor(e){super({...e,id:e.id||Wp("webgl-device")});const t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);const i=e.gl?.canvas||e.canvas,n=!e.gl;this.canvasContext=new fT(this,{...e,autoResize:n,canvas:i}),this.lost=new Promise(e=>{this._resolveContextLost=e});let r=e.gl||null;if(r||=function(e,t){t={..._w,...t};let i=null;const n=e=>i=e.statusMessage||i;e.addEventListener("webglcontextcreationerror",n,!1);let r=null;if(r||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",n,!1),!r)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(t.onContextLost){const{onContextLost:i}=t;e.addEventListener("webglcontextlost",e=>i(e),!1)}if(t.onContextRestored){const{onContextRestored:i}=t;e.addEventListener("webglcontextrestored",e=>i(e),!1)}return r}(this.canvasContext.canvas,{...e,onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!r)throw new Error("WebGL context creation failed");this.handle=r,this.gl=r,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=function(e){if(e={...mT,...e},!e?.spector)return null;if(!gT&&globalThis.SPECTOR&&(Gp.probe(1,"SPECTOR found and initialized")(),gT=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=gT)),!gT)return null;if(_T||(_T=!0,gT.spyCanvases(),gT?.onCaptureStarted.add(e=>Gp.info("Spector capture started:",e)()),gT?.onCapture.add(e=>{Gp.info("Spector capture complete:",e)(),gT?.getResultUI(),gT?.resultView.display(),gT?.resultView.addCapture(e)})),e?.canvas){if("string"==typeof e.spector&&e.spector!==e.canvas.id)return gT;gT?.startCapture(e?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{Gp.info("Spector capture stopped after 2 seconds")(),gT?.stopCapture()})}return gT}({...this.props,canvas:this.handle.canvas})),this.info=yw(this.gl,this._extensions),this.limits=new Xw(this.gl),this.features=new Kw(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),n&&this.canvasContext.resize();const{enable:o=!0,copyState:s=!1}=e;dw(this.gl,{enable:o,copyState:s,log:(...e)=>Gp.log(1,...e)()}),e.debug&&(this.gl=yT(this.gl,{...e,throwOnError:!0}),this.debug=!0,Gp.level=Math.max(Gp.level,1),Gp.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return Hw(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return function(e,t,i){if(!Hw(e,t,i))return!1;if(t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(rf(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(Aw(e,"OES_texture_float_linear, extensions",i)):!t.endsWith("16float")||Boolean(Aw(e,"OES_texture_half_float_linear, extensions",i))}(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return function(e,t,i){return!!Hw(e,t,i)&&"number"!=typeof t}(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._getBufferProps(e);return new lT(this,t)}_createTexture(e){return new dT(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new cT(this,e)}createShader(e){return new TT(this,e)}createFramebuffer(e){return new pT(this,e)}createVertexArray(e){return new KT(this,e)}createTransformFeedback(e){return new XT(this,e)}createQuerySet(e){return new YT(this,e)}createRenderPipeline(e){return new jT(this,e)}beginRenderPass(e){return new ST(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new qT(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return tE(e,t)}readPixelsToBufferWebGL(e,t){return iE(e,t)}setParametersWebGL(e){aw(this.gl,e)}getParametersWebGL(e){return lw(this.gl,e)}withParametersWebGL(e,t){return Jw(this.gl,e,t)}clearWebGL(e){!function(e,t){const{framebuffer:i=null,color:n=null,depth:r=null,stencil:o=null}=t||{},s={};i&&(s.framebuffer=i);let a=0;n&&(a|=16384,!0!==n&&(s.clearColor=n)),r&&(a|=256,!0!==r&&(s.clearDepth=r)),o&&(a|=1024,!0!==r&&(s.clearStencil=r)),cf(0!==a,"clear: bad arguments");const l=e.gl;Jw(l,s,()=>{l.clear(a)})}(this,e)}resetWebGL(){Gp.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),function(e){aw(e,Zb)}(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1;const t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){pw(this.gl)}popState(){fw(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;const i=Number(e);for(const e in t)if(t[e]===i)return`GL.${e}`;return String(e)}_constants;setConstantAttributeWebGL(e,t){const i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);const n=this._constants[e];switch(n&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let i=0;i{e.push(new Te(o,i+(o-t)/(n-t)*(r-i)))}:(e,t,i,n,r,o)=>{e.push(new Te(t+(o-i)/(r-i)*(n-t),o))};for(const s of e){const e=[];for(const r of s){if(r.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,u,t):h>i?d=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=r[r.length-1];const l=0===n?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&&r.push(e)}return r}function md(e,t){const i=_d(e),n=_d([t]),r=pd.intersection(i,n);return null==r?[]:Ad(r)}function gd(e,t){const i=65536;let n=_d(e,i);const r=[];for(;t.valid();t.next()){const[e,n]=t.get(),o=e.x*i,s=e.y*i,a=n.x*i,l=n.y*i,c=a-o,u=l-s,h=Math.hypot(c,u);if(0===h)continue;const d=Math.trunc(u/h*3),p=-Math.trunc(c/h*3);r.push([[[o,s],[a,l],[a+d,l+p],[o+d,s+p],[o,s]]])}return r.length>0&&(n=pd.diff(n,r)),Ad(n,1/i)}function _d(e,t=1){return[e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Ad(e,t=1){return e.map(e=>e.map((e,i)=>{const n=e.map(e=>new Te(e[0]*t,e[1]*t).round());return i>0&&n.reverse(),n}))}class yd{constructor(e,t){this.layoutVertexArray=new pa,this.indexArray=new Fa,this.lineIndexArray=new Ia,this.triangleSegments=new hl,this.lineSegments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new ga)}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Sh.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,i,n,r,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,n,r,o,void 0,s)}}class vd{constructor(e){this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,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.lut=e.lut,this.bufferData=new yd(e,!1),this.elevationBufferData=new yd(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("fill",this.layers,this.pixelRatio,t);const r=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,u=Ic(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(s,i,n),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=sd("fill",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n,r,o,s){this.bufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevationBufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,n,r,o,s,this.worldview)}addFeatures(e,t,i,n,r,o){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,o,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,i,n,r,o=[],s,a){const l=id(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,t,i,n,r){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,n,r,this.worldview))}addElevatedRoadFeature(e,t,i,n,r){const o=new Array,s=tu.getElevationFeature(e,r);if(!s)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:n};for(const t of o)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ud(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let n=0;e.properties.hasOwnProperty(zc)&&(n=+e.properties[zc]);for(const e of t.polygons)this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,e,i,t.elevationFeature,n)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const r=new iu(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,r,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a)}}addElevatedGeometry(e,t,i,n,r,o){const s={elevation:i,elevationSampler:t,bias:n,index:r,featureInfo:o},[a,l]=this.addGeometry(e,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=null;i&&(o=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=o&&(n=o,r=o));const s=(e,s,a)=>{if(null!=i)if(s.push(e),null!=o)t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),n=Math.min(n,o),r=Math.max(r,o)}};for(const n of e){let e=0;for(const t of n)e+=t.length;const r=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),o=r.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(a.length/2);const r=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=r.vertexLength;i&&h.push(t.layoutVertexArray.length-d),s(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),a.push(e[0].x),a.push(e[0].y);for(let i=1;i0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,n=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,n,e);const r=h.length;if(r>0){for(let o=0;o=i&&c.max.x<=r&&c.min.y>=n&&c.max.y<=o?a:l).push(t)}if(a.length===e.length)return e;const c=[new Te(i,n),new Te(r,n),new Te(r,o),new Te(i,o),new Te(i,n)],u=a;for(const e of l)u.push(...md(e,c));return u}}let xd,bd,wd,Td;es(vd,"FillBucket",{omit:["layers","patternFeatures"]}),es(yd,"FillBufferData"),es(ud,"ElevatedStructures");class Ed{constructor(e,t,i,n){if(this.triangleCount=t.length/3,this.min=new Te(0,0),this.max=new Te(0,0),this.xScale=0,this.yScale=0,this.cellsX=0,this.cellsY=0,this.cells=[],this.payload=[],0===this.triangleCount||0===e.length)return;const[r,o]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let c=0;for(;cthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Cd(e.x-this.min.x,this.xScale,this.cellsX),n=Cd(e.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Cd(e.x-this.min.x,this.xScale,this.cellsX),r=Cd(t.x-this.min.x,this.xScale,this.cellsX),o=Cd(e.y-this.min.y,this.yScale,this.cellsY),s=Cd(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=n;t<=r;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;ee.fqid),this.index=e.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.footprints=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){}populate(e,t,i,n){const r=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Bc(o,i,n),patterns:{}};r.push(u)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,n,r,o,s){}destroy(){}addFeature(e,t,i,n,r,o=[],s){for(const e of id(t,2)){const t=[],i=[],n=[],r=new Te(1/0,1/0),o=new Te(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&n.push(i.length/2);for(let e=0;et===e)}(n,e.clipScope)}function Ud(e,t){return e.x-t.x||e.y-t.y}function Nd(e,t){return 0===Ud(e.min,t.min)&&0===Ud(e.max,t.max)}function Vd(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Te((e.x+o.x*Nn)*a-s.x*Nn,(e.y+o.y*Nn)*a-s.y*Nn))}return Qd(i,r,e.indices,0,e.indices.length,0,0)}function Zd(e,t,i,n){const r=Math.pow(2,n.z-i.z);return new Te((e+i.x*Nn)*r-n.x*Nn,(t+i.y*Nn)*r-n.y*Nn)}function Wd(e,t){const i=[];t.grid.queryPoint(e,i);const n=t.indices,r=t.vertices;for(let t=0;t0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const Xd=Mc.types,Jd=["fill-extrusion-base","fill-extrusion-height","fill-extrusion-color","fill-extrusion-pattern","fill-extrusion-flood-light-wall-radius","fill-extrusion-line-width","fill-extrusion-emissive-strength"],Yd=["fill-extrusion-flood-light-ground-radius"],ep=Math.pow(2,13),tp=Math.pow(2,15)-1,ip=new Te(0,1),np=2147483648,rp=7,op=450;function sp(e,t,i,n,r,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(n*ep)<<1)+r,Math.round(a))}function ap(e,t,i){e.emplaceBack(t.x*Nn,t.y*Nn,i?1:0)}function lp(e,t,i,n,r,o){e.emplaceBack(t.x,t.y,(i.x<<1)+n,(i.y<<1)+r,o)}function cp(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class up{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class hp{constructor(){this.centroidXY=new Te(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 Te(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Te(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new Te(this.max.x-this.min.x,this.max.y-this.min.y)}}class dp{constructor(){this.acc=new Te(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 n=!!this.borders;t.xe.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Nn)&&t.x===i.x)!=((0===t.y||t.y===Nn)&&t.y===i.y)&&this.processBorderOverlap(t,i),n&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,di(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Nn!=e.x>Nn&&this.addBorderIntersection(1,di(t.y,e.y,(Nn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,di(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Nn!=e.y>Nn&&this.addBorderIntersection(3,di(t.x,e.x,(Nn-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];ti[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 Te(0,0):new Te(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 pp(e,t){const i=e.add(t)._unit(),n=Fe(e.x*i.x+e.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*tp*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const fp=[e=>e.x<0,e=>e.x>Nn,e=>e.y<0,e=>e.y>Nn];function mp(e,t,i,n){const r=[4];if(0===n)return r;i._mult(n);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(fp[e](t)){r.push(e);break}return r}class gp{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ya,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yd.includes(e)),this._segments=new hl,this.hiddenByLandmarkVertexArray=new Wa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new hl}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,n=!1){const r=e.length;if(r>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*r,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=pp(t.sub(e[r-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let i=0;ie+t,0);let o=0;for(let e=0;e<=4;e++){const t=r[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new hl);const r={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+o,vertexLength:n.vertexLength,primitiveLength:t};i.get().push(r)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ld.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.groundRadiusBuffer&&this.groundRadiusBuffer.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 _p{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.pixelRatio=e.pixelRatio,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 Fa,this.footprintVertices=new pa,this.footprintSegments=[],this.layoutVertexArray=new ma,this.centroidVertexArray=new ol,this.wallVertexArray=new al,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Jd.includes(e)),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new gp(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.features=[],this.hasPattern=od("fill-extrusion",this.layers,this.pixelRatio,t),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.selfDEMTileTimestamp=Number.MAX_VALUE,this.borderDEMTileTimestamp=[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],this.tileToMeter=yc(i),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter,this.wallMode=0!==this.layers[0].paint.get("fill-extrusion-line-width").constantOr(1);for(const{feature:r,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ic(r,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Bc(r,i,n),properties:r.properties,type:r.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===Xd[c.type];if(this.hasPattern)this.features.push({featureId:r.id,feature:sd("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const o of Kd(e,h))this.addFeature(r.id,c,[o],s,i,{},t.availableImages,n,t.brightness);else this.addFeature(r.id,c,c.geometry,s,i,{},t.availableImages,n,t.brightness);t.featureIndex.insert(r,c.geometry,s,a,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,n,r,o){for(const{featureId:e,feature:s}of this.features){const a="Polygon"===Xd[s.type],{geometry:l}=s;if(this.wallMode)for(const c of l)for(const l of Kd(c,a))this.addFeature(e,s,[l],s.index,t,i,n,r,o);else this.addFeature(e,s,l,s.index,t,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,this.worldview),this.groundEffect.update(e,t,r,i,n,o,s,this.worldview)}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,kd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Rd.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Fd.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,Pd.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,n,r,o,s,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Te(0,0),new Te(Nn,Nn)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Xd[t.type],f=new dp;f.centroidDataIndex=this.centroidData.length;const m=new hp;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=t.properties.building_id);const g=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},r);let A;if(m.height=_,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ta),this.wallMode){if(d)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;A=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let n=0;n=0}(e);i||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return n;let l,c,u,h,d,p=0;for(;p0;let _="miter";const A=2;"miter"===_&&m>A&&(_="bevel"),"bevel"===_&&(m>100&&(_="flipbevel"),m{const a=new Te(e.x,e.y),l=new Te(e.x,e.y);a.x+=t.x*n,a.y+=t.y*n,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),r.push(a),o.push(l)};if("miter"===_)n._mult(m),y(l,n,0,0);else if("flipbevel"===_)n=d.mult(-1),y(l,n,0,0),y(l,n.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=g?e:0,i=g?0:e;c&&y(l,h,t,i),u&&y(l,d,t,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:id(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||(x=t[0]).every(e=>e.x<=0)||x.every(e=>e.x>=Nn)||x.every(e=>e.y<=0)||x.every(e=>e.y>=Nn))&&v.splice(e,1)}var x;let b;if(d)b=Cp(v,u,r);else{b=[];for(const e of v)b.push({polygon:e,bounds:u})}const w=p?this.edgeRadius:0,T=w>0&&this.zoom<17,E=(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 b){let i=0,n=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new up;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const n=[],s=[];i=o.vertexLength;for(let i=0;i4&&wp(s[s.length-2],s[0],s[1]),l=w?yp(s[s.length-2],s[0],s[1],w):0;const u=[];let _,v,x;v=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,n=0;e0?1:0,I=c.dist(p);if(n+I>32768&&(n=0),w){x=T.sub(p)._perp()._unit();let e=vp(c,p,T,Ap(v,x),w);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=x,g&&this.zoom>=17&&(E(u,c)||u.push(c),E(u,p)||u.push(p))}const M=o.vertexLength,P=s.length>4&&wp(c,p,T);let R=Tp(n,a,b);if(sp(this.layoutVertexArray,c.x,c.y,S,B,0,0,R),sp(this.layoutVertexArray,c.x,c.y,S,B,0,1,R),this.wallMode){const t=y(e-1,s),i=A.joinNormals[e-1];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(n+=I,R=Tp(n,P,!b),a=P,sp(this.layoutVertexArray,p.x,p.y,S,B,0,0,R),sp(this.layoutVertexArray,p.x,p.y,S,B,0,1,R),this.wallMode){const t=y(e,s),i=A.joinNormals[e];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(M+0,M+1,M+2),this.indexArray.emplaceBack(M+1,M+3,M+2),o.primitiveLength+=2,w){const n=i+(1===e?s.length-2:e-2),r=1===e?i:n+1;if(this.indexArray.emplaceBack(M+1,n,M+3),this.indexArray.emplaceBack(n,r,M+3),o.primitiveLength+=2,void 0===_&&(_=M),!xp(T,s[e],t)){const t=e===s.length-1?_:o.vertexLength;this.indexArray.emplaceBack(M+2,M+3,t),this.indexArray.emplaceBack(M+3,t+1,t),this.indexArray.emplaceBack(M+3,r,t+1),o.primitiveLength+=3}b=!b}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,r),i=h.projectTilePoint(p.x,p.y,r),n=h.upVector(r,c.x,c.y),o=h.upVector(r,p.x,p.y);cp(e,t,n),cp(e,t,n),cp(e,i,o),cp(e,i,o)}}p&&(i+=s.length-1),g&&w&&this.zoom>=17&&(0!==u.length&&E(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?ip:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;tNn),r=2*n+(+(i.min.x+i.max.x>Nn)^n);for(let n=0;ne.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let i=0,n=0,r=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;r++}const o=e.length;for(;n!==e.length;){i=e[n].triangleSegmentIdx;let s=0,a=n,l=n;for(let t=a;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t[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/Nn,d[1]=e.min.y/Nn,p[0]=e.max.x/Nn,p[1]=e.max.y/Nn;const t=h(c,u,d),s=h(c,u,p);if(0===new Jc([t[0],t[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&n.segments.push(l),n}encodeCentroid(e,t){const i=e.centroid(),n=t.span(),r=Math.min(7,Math.round(n.x*this.tileToMeter/10)),o=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Te(Fe(i.x,1,Nn-1)<<3|r,Fe(i.y,1,Nn-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Te(0,0);const t=e.borders,i=Number.MAX_VALUE;if(t[0][0]!==i||t[1][0]!==i){const e=t[0][0]!==i?0:1;return new Te(6|(t[0][0]!==i?0:65528),(t[e][0]+t[e][1])/2<<3|6)}{const e=t[2][0]!==i?2:3;return new Te((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=2147483647,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,n=e.flags&np?ip:e.centroidXY,r=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==n.y||r!==n.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(n=!n)}s=i}}return n}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Nn)*Nn+(t+Nn);if(this.partLookup.hasOwnProperty(r)){const e=this.partLookup[r];return e?{height:e.height,hidden:!!(e.flags&np)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||this.footprintContainsPoint(e,t,o)&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&np));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function Ap(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function yp(e,t,i,n){const r=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return vp(e,t,i,Ap(r,o),n)}function vp(e,t,i,n,r){const o=Math.sqrt(1-n*n);return Math.min(e.dist(t)/3,t.dist(i)/3,r*o/n)}function xp(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function bp(e,t){return e.xt[1].x||e.yt[1].y}function wp(e,t,i){if(e.x<0||e.x>=Nn||t.x<0||t.x>=Nn||i.x<0||i.x>=Nn)return!1;const n=i.sub(t),r=n.perp(),o=e.sub(t);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y<0}function Tp(e,t,i){const n=t?2|e:-3&e;return i?1|n:-2&n}function Ep(){const e=Math.PI/32,t=Math.tan(e),i=ic;return i*Math.sqrt(1+2*t*t)-i}function Cp(e,t,i){const n=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),u=l-c,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Te(0===i?u:n.x,1===i?u:n.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,(e,t,r)=>{if(0===e)return.5*(t+r);{const e=pc((i.y+t/Nn)/n);return(uc(.5*(pc((i.y+r/Nn)/n)+e))*n-i.y)*Nn}})}function Sp(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a=s[i]&&(n=t,s=e),n[i]r&&Rp(n,s,i,r),n[i]o&&Rp(s,n,i,o)}}function Fp(e,t,i,n,r,o){const s=[];for(let a=0;a=n&&d.x>=n||(u.x>=n?u=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=n&&(d=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=r&&d.y>=r||(u.y>=r?u=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round():d.y>=r&&(d=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round()),c&&u.equals(c[c.length-1])||(c=[u],s.push(c),o&&o.push({progress:{min:f+Dp(m,g,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:g})),c.push(d),o&&(o[o.length-1].progress.max=f+Dp(m,g,d)*p,o[o.length-1].nextPoint=g)))))}if(o&&h>0)for(let e=u;ee.t-t.t);let s=0,a=0,l=[];for(n.push(l);s!==e.length;){if(a===o.length){for(;s!==e.length;)0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++)}}function Dp(e,t,i){return e.x!==t.x?(i.x-e.x)/(t.x-e.x):e.y!==t.y?(i.y-e.y)/(t.y-e.y):0}function Op(e,t){return e.x*t.x+e.y*t.y}function zp(e,t){if(1===e.length){let i=0;const n=t[i++];let r;for(;!r||n.equals(r);)if(r=t[i++],!r)return 1/0;for(;i{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=Ep();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],A=[];for(const h of _){const d=h.x+r.x,_=h.y+r.y,y=e.projection.projectTilePoint(d,_,u),v=e.projection.upVector(u,h.x,h.y);let x=i,b=n;if(s){const e=Vp(d,_,i,n,s,a,l,c);x+=e.base,b+=e.top}0!==i?g(f,y.x+v[0]*p*x,y.y+v[1]*p*x,y.z+v[2]*p*x):g(f,y.x,y.y,y.z),g(m,y.x+v[0]*p*b,y.y+v[1]*p*b,y.z+v[2]*p*b),j(f,f,o),j(m,m,o),t.push(new Mp(f[0],f[1],f[2])),A.push(new Mp(m[0],m[1],m[2]))}h.push(t),d.push(A)}return[h,d]}(e,t,i,n,r,o,s,a,l,c,u):s?function(e,t,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+n.x,d=c.y+n.y,f=Vp(u,d,t,i,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(g)}c.push(e),u.push(p)}return[c,u]}(t,i,n,r,o,s,a,l,c):function(e,t,i,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+n.x,s=o.y+n.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=m+a,v=g+l,x=_+c,b=Math.max(A+u,1e-5),w=m+h,T=g+d,E=_+p,C=Math.max(A+f,1e-5);e.push(new Mp(y/b,v/b,x/b)),i.push(new Mp(w/C,T/C,E/C))}o.push(e),s.push(i)}return[o,s]}(t,i,n,r,o)}function Vp(e,t,i,n,r,o,s,a){const l=s*r.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/rp-op):s*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),o=10*(t[0]-8*n),s=10*(t[1]-8*r),a=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(n,r),d=2*c+1,p=2*u+1,f=function(e,t,i,n,r){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+r,i,!0),e.getElevationAtPixel(t,i+r,!0),e.getElevationAtPixel(t+n,i+r,!0)]}(e,h.x-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),A=Math.min(.25,.5*l*(m+g)/d),y=Math.min(.25,.5*l*_/p);return a+Math.max(A*o,y*s)}(r,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+n,l+i+2):l+n}}class jp{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 Gp{constructor(){this.tasks={},this.taskQueue=[],Ve(["process"],this),this.invoker=new jp(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=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===n){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){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{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||Xe(self)){const e=this.callbacks[i],n=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(rs(t.error)):i(null,rs(t.data)))}else{const i=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?ns(t):null,data:ns(n,i)},i)}:()=>{},r=rs(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:o}=r;this.parent.getWorkerSource(t.sourceMapId,e[0],i,o)[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Qp={workerUrl:"",workerClass:null,workerParams:void 0};const $p="mapboxgl_preloaded_worker_pool";class Zp{constructor(){this.active={}}acquire(e,t=Zp.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$p]}numActive(){return Object.keys(this.active).length}}Zp.workerCount=2;class Wp{constructor(e,t,i="Worker",n=Zp.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ue();const r=this.workerPool.acquire(this.id,n);for(let e=0;e{this.ready=!0})}broadcast(e,t,i){Oe(this.actors,(i,n)=>{i.send(e,t,n)},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)}}let qp,Kp;function Xp(){return qp||(qp=new Zp),qp}Wp.Actor=Hp;class Jp{constructor(e){this.module=e}createIntArray(e){const t=new Int32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heap32.set(t,i/t.BYTES_PER_ELEMENT),i}createFloatArray(e){const t=new Float32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heapF32.set(t,i/t.BYTES_PER_ELEMENT),i}createStringBuffer(e){const t=this.module.malloc(e.length+1);for(let i=0;ie.arrayBuffer()).then(e=>{t.buffers[i]=e})}function Tf(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ef(e,t,i,n){if(e.uri){const r=bf(e.uri,n);return fetch(r).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{t.images[i]=e})}if(void 0!==e.bufferView){const n=Tf(t,e.bufferView),r=new Blob([n],{type:e.mimeType});return createImageBitmap(r).then(e=>{t.images[i]=e})}}function Cf(e,t=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===vf){const i=new Uint32Array(e,t);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(xf.decode(i.subarray(r,r+s))),r+=s,r{const e=[],t=a&&a.includes(gf),r=a&&a.includes(Af);if(t&&e.push(function(){if(!tf)return null!=Yp?Yp:(Yp=function(e){let t,i=null;function n(){t=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={a:{a:r,d:function(e,i,n){return t.copyWithin(e,i,i+n)},c:function(e){const r=t.length,o=Math.max(e>>>0,Math.ceil(1.2*r)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(e){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:g,e:_,yb:A,zb:y,Ab:v,Bb:x,Db:b,Gb:w}=e.instance.exports;i=_;const T=(()=>{let e=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(e),i+=n,n=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(n=l,c=s=o(l));for(let e=0;e{tf=e,Yp=void 0}))}()),r&&e.push(function(){if(rf)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors()}),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,n,r,o,s){const a=e.exports.sbrk,l=n+3&-4,c=a(l*r),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,n,r,u,o.length);if(0===d&&s&&s(c,l,r),i.set(h.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[r[a]],e,i,o,s,t.exports[n[l]])}}}(fetch(uf()));return e.ready.then(()=>{rf=e})}()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)_f(t,n);if(r&&s&&l)for(const e of l)yf(e,n);return n})})}function Sf(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>Cf(t,0,e))}function Bf(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.RGBA;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.DEPTH_COMPONENT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.DEPTH_STENCIL;case WebGL2RenderingContext.R8:case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.RED}}function If(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.DEPTH_COMPONENT16:return WebGL2RenderingContext.UNSIGNED_SHORT;case WebGL2RenderingContext.DEPTH24_STENCIL8:return WebGL2RenderingContext.UNSIGNED_INT_24_8;case WebGL2RenderingContext.R8:return WebGL2RenderingContext.UNSIGNED_BYTE;case WebGL2RenderingContext.R32F:return WebGL2RenderingContext.FLOAT}}class Mf{constructor(e,t,i,n){this.context=e,this.format=i,this.useMipmap=n&&n.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:n&&n.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,n=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:r}=this,{gl:o}=r,{x:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=s+i,c=a+n;!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),r.pixelStoreUnpackFlipY.set(!1),r.pixelStoreUnpack.set(1),r.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Bf(this.format),If(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Bf(this.format),If(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,t,i=!1){const{context:n}=this,{gl:r}=n;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&&!i?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_LINEAR: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,n,r){const{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),t!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n),r!==this.compareMode&&(r?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,r)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Pf{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_2D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}}const Rf=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),Lf=ha([{name:"a_color_3f",components:3,type:"Float32"}]),Ff=ha([{name:"a_color_4f",components:4,type:"Float32"}]),kf=ha([{name:"a_uv_2f",components:2,type:"Float32"}]),Df=ha([{name:"a_normal_3f",components:3,type:"Float32"}]),Of=ha([{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"}]),zf=ha([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Uf(e,t){const i=Vf(e.projection,e.zoom,e.width,e.height),n=function(e,t,i,n,r){const o=new rc(i.lng-180*jf,i.lat),s=new rc(i.lng+180*jf,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),u=-Math.atan2(l.y-a.y,l.x-a.x),d=vc.fromLngLat(i);d.y=Fe(d.y,-1+jf,1-jf);const f=d.toLngLat(),m=e.project(f.lng,f.lat),_=vc.fromLngLat(f);_.x+=jf;const A=_.toLngLat(),y=e.project(A.lng,A.lat),v=Hf(y.x-m.x,y.y-m.y,u),x=vc.fromLngLat(f);x.y+=jf;const b=x.toLngLat(),w=e.project(b.lng,b.lat),T=Hf(w.x-m.x,w.y-m.y,u),E=Math.abs(v.x)/Math.abs(T.y),C=c([]);g(C,C,-u*(1-(r?0:n)));const S=c([]);return p(S,S,[1,1-(1-E)*n,1]),S[4]=-T.x/T.y*n,g(S,S,u),h(S,C,S),S}(e.projection,0,e.center,i,t),r=Nf(e);return p(n,n,[r,r,1]),n}function Nf(e){const t=e.projection,i=Vf(e.projection,e.zoom,e.width,e.height),n=Gf(t,e.center),r=Gf(t,rc.convert(t.center));return Math.pow(2,n*i+(1-i)*r)}function Vf(e,t,i,n,r=1/0){const o=e.range;if(!o)return 0;const s=Math.min(r,Math.max(i,n)),a=Math.log2(s/1024);return ke(o[0]+a,o[1]+a,t)}const jf=1/4e4;function Gf(e,t){const i=Fe(t.lat,-mc,mc),n=new rc(t.lng-180*jf,i),r=new rc(t.lng+180*jf,i),o=e.project(n.lng,i),s=e.project(r.lng,i),a=vc.fromLngLat(n),l=vc.fromLngLat(r),c=s.x-o.x,u=s.y-o.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Hf(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}function Qf(e,t,i){c(e),g(e,e,Be(t[2])),f(e,e,Be(t[0])),m(e,e,Be(t[1])),p(e,e,i),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function $f(e,t,i,n,r,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[n[0]-t[0],n[1]-t[1],0];if(T(l)<1e-12||T(c)<1e-12)return te(e);const u=N([],l,c);z(u,u),B(c,n,t),l[2]=(o-r)*a,c[2]=(s-r)*a;const h=l;return N(h,l,c),z(h,h),le(e,u,h)}function Zf(e,t,i=!1){const n=th(t.zoom),r=function(e,t,i){const n=t.worldSize,r=[e[12],e[13],e[14]],o=pc(r[1]/n),s=dc(r[0]/n),a=c([]),l=hc(1,o)*n,u=hc(1,0)*n*_c(o,t.zoom),f=1/Ju(n);let m=u*f;if(i){const e=Vf(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,n,e)}const g=tc(o,s);S(g,g,R([],z([],g),l*m*r[2]));const _=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const n=N([],i,t);return N(i,t,n),0===D(i)&&(i=[0,1,0],N(n,t,i)),z(n,n),z(i,i),z(t,t),[n[0],n[1],n[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(g);p(a,a,[m,m,m*l]),d(a,a,[-r[0],-r[1],-r[2]]);const A=h([],t.globeMatrix,_);return h(A,A,a),h(A,A,e),A}(e,t,i);if(n>0){const i=function(e,t){const i=t.worldSize,n=hc(1,0)*i*_c(t.center.lat,t.zoom)/Ju(i),r=hc(1,t.center.lat)*i,o=c([]);m(o,o,Be(t.center.lng)),f(o,o,Be(t.center.lat)),d(o,o,[0,0,$l]),p(o,o,[n,n,n*r]);const s=t.point;return d(o,o,[-s.x,-s.y,0]),h(o,o,e),h(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const n=(e,t,i)=>{const n=T(e),r=T(t),o=ju(e,t,i);return R(o,o,1/T(o)*di(n,r,i))},r=n([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=n([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=ju([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[r[0],r[1],r[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function Wf(e,t,i,n){const r=Jc.projectAabbCorners(n,i);let o=Number.MAX_VALUE;for(let e=0;e0||0===s&&i[0]*o[0]+i[1]*o[1]>=0&&i[0]*i[0]+i[1]*i[1]>o[0]*o[0]+o[1]*o[1])&&(n=t)}r=n}while(r!==i);return t.length>0&&t.push(t[0]),t}(r);if(ru(e,s))return o}const qf=64,Kf={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xf(e,t,i,n,r,o,s,a,l,u=!1){const f=i.zoom,m=i.project(n),g=_c(n.lat,f),_=1/g;c(e),d(e,e,[m.x+s[0]*_,m.y+s[1]*_,s[2]]);let A=1,y=1;const x=i.worldSize;if(u){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new vc(m.x/x,m.y/x),0));const t=Y([],[m.x,m.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;A=t,y=t*_c(i.center.lat,f)}else if("globe"===i.projection.name){const t=Zf(e,i),r=[0,0,0,1];Y(r,r,h([],i.projMatrix,t));const o=r[3]/i.cameraToCenterDistance,s=th(f),a=i.projection.pixelsPerMeter(n.lat,x)*_c(n.lat,f),l=i.projection.pixelsPerMeter(i.center.lat,x)*_c(i.center.lat,f);A=o/di(a,gc(i.center.lat),s),y=o*g/a,A*=l,y*=l}}else A=_;p(e,e,[A,A,y]);const b=[...e],w=t.orientation,T=[];if(Qf(T,[w[0]+(r?r[0]:0),w[1]+(r?r[1]:0),w[2]+(r?r[2]:0)],o),h(e,b,T),a&&i.elevation){let r=0;const o=[];if(l&&i.elevation){r=function(e,t,i,n,r){const o=t.elevation;if(!o)return 0;const s=Jc.projectAabbCorners(i,n),a=hc(1,r.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],n=[{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 r of n){const n=e[r.corners[0]],o=e[r.corners[1]],s=e[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])],l=N(a,a,[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])]);z(l,l),r.dotProductWithUp=U(l,i)}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(s,a),c=s[l[0]],u=s[l[1]],h=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new vc(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new vc(u[0]/t.worldSize,u[1]/t.worldSize),0),m=o.getAtPointOrZero(new vc(h[0]/t.worldSize,h[1]/t.worldSize),0),g=o.getAtPointOrZero(new vc(d[0]/t.worldSize,d[1]/t.worldSize),0),_=(p+g)/2,A=(f+m)/2;return _>A?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function em(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Rf.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Df.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kf.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Lf:Ff).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,zf.members,!0)),e.segments=hl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&Yf(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&Yf(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&Yf(n.normalTexture,t),n.occlusionTexture&&Yf(n.occlusionTexture,t,i),n.emissionTexture&&Yf(n.emissionTexture,t)}function tm(e,t,i){if(e.meshes)for(const n of e.meshes)em(n,t,i);if(e.children)for(const n of e.children)tm(n,t,i)}function im(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)im(t)}function nm(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)nm(t)}function rm(e,t){const i=e.json.bufferViews[t.bufferView],n=df[t.componentType];return new n(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==ff[t.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:ff[t.type]))}function om(e,t,i,n){const r=df[t.componentType],o=function(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(r),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:ff[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e0){for(let r=0;r0){o.texcoordArray=new ja;const e=t.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=rm(t,e);om(t,e,o.texcoordArray,i)}if(void 0!==r._FEATURE_ID_RGBA4444){const e=t.json.accessors[r._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=rm(t,e))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(rm(t,t.json.accessors[r._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){const e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new li(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new li(...i),alphaMode:n,alphaCutoff:r,normalTexture:o?t[o.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function am(e,t,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:c,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=n||function(e,t,i,n){var r=t[0],o=t[1],s=t[2],a=t[3],l=r+r,c=o+o,u=s+s,h=r*l,d=r*c,p=r*u,f=o*c,m=o*u,g=s*u,_=a*l,A=a*c,y=a*u,v=n[0],x=n[1],b=n[2];return e[0]=(1-(f+g))*v,e[1]=(d+y)*v,e[2]=(p-A)*v,e[3]=0,e[4]=(d-y)*x,e[5]=(1-(h+g))*x,e[6]=(m+_)*x,e[7]=0,e[8]=(p+A)*b,e[9]=(m-_)*b,e[10]=(1-(h+f))*b,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],r||[0,0,0,1],o||[0,0,0],s||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==a){d.meshes=i[a];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:n}=t.aabb;e[0]+=i[0]+n[0],e[1]+=i[1]+n[1]}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2)}if(c&&(c.id&&(d.id=c.id),c.lights&&(d.lights=function(e){if(!e.length)return[];const t=function(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let e=0;e0&&n.reverse();const o=Mh(n.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:n,indices:o}}function um(e,t){const i=[],n=[];let r=0;const o=[];for(const s of e){r=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:i,indices:n}}function hm(e){const t=function(e,t){const i=[],n=WebGL2RenderingContext;if(e.json.textures)for(const r of e.json.textures){const o={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==r.sampler&&Object.assign(o,e.json.samplers[r.sampler]),i.push({image:t[r.source],sampler:o,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const n of e.json.meshes){const r=[];for(const i of n.primitives)r.push(sm(i,e,t));i.push(r)}return i}(e,t),{scenes:n,scene:r,nodes:o}=e.json,s=n?n[r||0].nodes:[...o.keys()],a=[];for(const t of s)a.push(am(o[t],e,i));return function(e,t,i){const n={},r=new Set;for(let o=0;o0){const t=Array.from(r.values()).sort((e,t)=>e-t);for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(a,s,e.json.nodes),a}function dm(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,n=e.aabb.min[1]-1,r=qf/(e.aabb.max[0]-i+2),o=qf/(e.aabb.max[1]-n+2);for(let s=0;se.heightmap[c*qf+l]&&(e.heightmap[c*qf+l]=a)}}function pm(e,t,i,n,r){i.reserve(i.length+4*e.length),n.reserve(n.length+10*e.length),r.reserve(r.length+10*e.length);let o=n.length;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*t,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),c=s.width-2*s.depth*t*(l+.01),u=L([],s.pos,a,c/2),h=L([],s.pos,a,-c/2),d=[u[0],u[1],u[2]+s.height],p=[h[0],h[1],h[2]+s.height],f=L([],s.normal,a,l);R(f,f,e);const m=L([],s.normal,a,-l);R(m,m,e),S(f,u,f),S(m,h,m),u[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const g=c/e/2;r.emplaceBack(-g-l,-1,g,.8),r.emplaceBack(g+l,-1,g,.8),r.emplaceBack(-g,0,g,1.3),r.emplaceBack(g,0,g,1.3),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(0,0,g,1.3),r.emplaceBack(0,0,g,1.3),r.emplaceBack(g+l,-1.2,g,.8),r.emplaceBack(g+l,-1.2,g,.8),i.emplaceBack(6+o,4+o,8+o),i.emplaceBack(7+o,9+o,5+o),i.emplaceBack(0+o,1+o,2+o),i.emplaceBack(1+o,3+o,2+o),o+=10}}function fm(e,t){const i={};i.indexArray=new Fa,i.vertexArray=new xa,i.colorArray=new Sa,pm(e,t,i.indexArray,i.vertexArray,i.colorArray);const n={defined:!0};n.emissiveFactor=li.black;const r={};return r.baseColorFactor=li.white,n.pbrMetallicRoughness=r,i.material=n,i.aabb=new Jc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}const mm=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),gm=ha([{name:"a_normal_3",components:3,type:"Int16"}]),_m=ha([{name:"a_centroid_3",components:3,type:"Int16"}]),Am=ha([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ym=ha([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),vm=ha([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),xm=ha([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),bm=ha([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wm=ha([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Tm=Mc.types,Em=32767;function Cm(e,t){const i=Nn+t;for(const n of e)for(const e of n)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return!1;return!0}class Sm{constructor(){this.layoutVertexArray=new xa,this.layoutAttenuationArray=new Sa,this.layoutColorArray=new Ia,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl}}class Bm{constructor(){this.layoutVertexArray=new xa,this.layoutNormalArray=new fa,this.layoutCentroidArray=new fa,this.layoutColorArray=new Ia,this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.layoutFloodLightDataArray=new Ha,this.layoutAOArray=new ga,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl,this.entranceBloom=new Sm}}class Im{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.featuresOnBorder=[],this.buildingFeatures=[],this.buildingWithoutFacade=new Bm,this.buildingWithFacade=new Bm,this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,this.footprintLookup={},this.zoom=e.zoom,this.canonical=e.canonical,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.index=e.index,this.hasPattern=!1,this.worldview=e.worldview,this.lut=e.lut,this.buildingWithFacade.layoutFacadePaintArray=new Ia,this.buildingWithFacade.layoutFacadeDataArray=new wa,this.buildingWithFacade.layoutFacadeVerticalRangeArray=new Ia,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.groundEffect=new gp(e),this.groundEffect.groundRadiusArray=new ga,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){}prepare(){return function(){if(null!=lf||null!=af)return null;if(null!=sf)return sf;const e=fetch(st.BUILDING_GEN_URL);return sf=function(e){let t,i,n,r;function o(){t=new Uint8Array(r.buffer),i=new Int32Array(r.buffer),n=new Float32Array(r.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const a=()=>{},l={a:{a:s,f:function(e){const i=t.length,n=Math.max(e>>>0,Math.ceil(1.2*i)),s=Math.ceil((n-i)/65536);try{return r.grow(s),o(),!0}catch(e){return!1}},g:s,b:a,c:a,d:a,e:a}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,l):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,l))).then(e=>{const s=e.instance.exports;return(0,s.g)(),r=s.f,o(),new Jp({setStyle:s.h,setAOOptions:s.i,setMetricOptions:s.j,setStructuralOptions:s.k,setFacadeOptions:s.l,setFauxFacadeOptions:s.m,setFacadeClassifierOptions:s.n,addFeature:s.o,addFacade:s.p,generateMesh:s.q,getLastError:s.r,getOuterRingLength:s.s,getMeshCount:s.t,getPositionsPtr:s.u,getPositionsLength:s.v,getNormalsPtr:s.w,getNormalsLength:s.x,getColorsPtr:s.y,getColorsLength:s.z,getAOPtr:s.A,getAOLength:s.B,getUVPtr:s.C,getUVLength:s.D,getFauxFacadePtr:s.E,getFauxFacadeLength:s.F,getIndicesPtr:s.G,getIndicesLength:s.H,getBuildingPart:s.I,getRingCount:s.J,getRingPtr:s.K,getRingLength:s.L,free:s.M,malloc:s.N,heapU8:t,heap32:i,heapF32:n})})}(e).then(e=>(sf=null,lf=e,lf)).catch(e=>{Ze("Could not load building-gen"),sf=null,af=e}),sf}()}populate(e,t,i,n){const r=hf();if(!r)return;const o=yc(i);this.tileToMeter=o,this.brightness=t.brightness,r.setStyle({convertToMeters:!1,entranceColorRgb:[1,1,1],facadeGlazingColorRgb:[.5607843137254902,.6745098039215687,.7215686274509804],normalScale:[1,-1,o],ridgeHeight:3,roofColorRgb:[.886274516,.784313738,.713725507],tileToMeters:o,tileZoom:16,wallColorRgb:[.988235294,.933333337,.811764717]}),r.setAOOptions(!1,.3),r.setMetricOptions(!1,16),r.setStructuralOptions(!0),r.setFacadeClassifierOptions(3);const s=new Map,a=new Map;for(const{feature:t}of e){if("LineString"!==Tm[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry,r=Ic(t,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),r,i))continue;const o=e?r.geometry:Bc(t,i,n),l=[];for(const e of o)for(const t of e)l.push({x:t.x,y:t.y});const c={coordinates:l,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},u=t.properties.source_id;let h=a.get(u);h||(h=[],a.set(u,h)),h.push(c)}this.maxHeight=0;for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of e){if("LineString"===Tm[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry,d=Ic(l,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),d,i))continue;const p=e?d.geometry:Bc(l,i,n),f=id(p,500);if(!Cm(p,163))continue;const m=this.layers[0],g=m.layout.get("building-roof-shape").evaluate(l,{},i);if("flat"===g)continue;const _=m.layout.get("building-base").evaluate(l,{},i),A=m.layout.get("building-height").evaluate(l,{},i),y=m.layout.get("building-flood-light-ground-radius").evaluate(l,{},i),v=m.paint.get("building-ambient-occlusion-intensity"),x=y/this.tileToMeter;let b=m.layout.get("building-flood-light-wall-radius").evaluate(l,{},i);b=Fe(b,0,2048);const w=b/2048*Em,T=s.get(c);let E;E=a.has(T)?a.get(T):[];const C=0!==E.length&&m.layout.get("building-facade").evaluate(l,{},i);r.setFacadeOptions(4,!0),r.setFauxFacadeOptions(C,!1,1);let S=0,B=0,I=0,M=0,P=0,R=0;if(C){let e=Math.round(m.layout.get("building-facade-floors").evaluate(l,{},i));if(0===_){e=Math.max(1,e-(E.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0],r.setFacadeOptions(t,!0)}P=1.6803*t/o}else P=_/o;R=A/o,P=Math.min(P,R),I=m.layout.get("building-facade-unit-width").evaluate(l,{},i)/o,M=(R-P)/e,r.setFauxFacadeOptions(!0,!0,I);const t=m.layout.get("building-facade-window").evaluate(l,{},i);S=t[0],B=t[1]}const L=[],F=new Te(1/0,1/0),k=new Te(-1/0,-1/0),D=new Te(0,0);let O=0;for(const e of f)if(e.length>0){const t=[];for(const i of e){const e=[];for(let t=i.length-1;t>=0;t--){const n=i[t];e.push({x:n.x,y:n.y}),F.x=Math.min(F.x,n.x),F.y=Math.min(F.y,n.y),k.x=Math.max(k.x,n.x),k.y=Math.max(k.y,n.y),D.x+=n.x,D.y+=n.y,O++}t.push(e)}L.push({id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:g,coordinates:t})}D.x/=O||1,D.y/=O||1;const z=r.generateMesh(L,E);if("string"==typeof z){Ze(`Unable to generate building ${l.id}: ${z}`);continue}if(0===z.meshes.length||0===z.modifiedPolygonRings.length)continue;let U=0;for(const e of z.meshes)U+=e.positions.length/3;const N=C?this.buildingWithFacade:this.buildingWithoutFacade,V=N.segmentsBucket.prepareSegment(U,N.layoutVertexArray,N.indexArray),j=[];let G=null,H=0,Q=-1;const $=N.layoutVertexArray.length,Z=N.indexArray.length;let W=0;for(const e of z.meshes){const t=N.layoutVertexArray.length;if("entrance"===e.buildingPart){const t=new Array;for(let i=0;iNn||F.y<0||k.y>Nn)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=Mh(K,null,2),t=new Ed(X,e,8,256);let i=l.id;l.properties&&l.properties.hasOwnProperty("building_id")&&(i=l.properties.building_id);const n={vertices:X,indices:e,grid:t,min:J,max:Y,buildingId:i,hiddenFlags:0,indicesOffset:Z,indicesLength:q,bloomIndicesOffset:H,bloomIndicesLength:Q,groundEffectVertexOffset:ee,groundEffectVertexLength:te,hasFauxFacade:C,segment:V,height:W};void 0!==l.id&&this.featureFootprintLookup.set(l.id,this.footprints.length),this.footprints.push(n)}this.programConfigurations.populatePaintArrays(N.layoutVertexArray.length,l,u,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(l,u,{},t.availableImages,i,t.brightness),t.featureIndex.insert(l,p,u,h,this.index,$)}this.groundEffect.prepareBorderSegments(),this.evaluate(this.layers[0],{})}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s),this.groundEffect.update(e,t,r,i,n,o,s),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}isEmpty(){return 0===this.buildingWithoutFacade.layoutVertexArray.length&&0===this.buildingWithFacade.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(e){const t=t=>{t.layoutVertexBuffer=e.createVertexBuffer(t.layoutVertexArray,mm.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,gm.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,_m.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,wm.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,vm.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,xm.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,mm.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,bm.members)),this.uploadUpdatedColorBuffer(e),this.uploadUpdatedIndexBuffer(e)};this.uploaded||(t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.groundEffect.upload(e)),this.groundEffect.uploadPaintProperties(e),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){const e=e=>{e.layoutVertexBuffer&&(e.layoutVertexBuffer.destroy(),e.layoutNormalBuffer.destroy(),e.layoutColorBuffer.destroy(),e.segmentsBucket.destroy(),e.indexBuffer&&e.indexBuffer.destroy(),e.entranceBloom.layoutVertexBuffer&&(e.entranceBloom.layoutVertexBuffer.destroy(),e.entranceBloom.layoutColorBuffer.destroy(),e.entranceBloom.layoutAttenuationBuffer.destroy(),e.entranceBloom.indexBuffer.destroy(),e.entranceBloom.segmentsBucket.destroy()))};e(this.buildingWithoutFacade),e(this.buildingWithFacade),this.groundEffect.destroy(),this.programConfigurations.destroy()}updateFootprintHiddenFlags(e,t,i=!0){let n=!1;const r=i?t:0,o=0|(i?-1:~t);0===this.groundEffect.hiddenByLandmarkVertexArray.length&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const t of e){const e=this.footprints[t],i=e.hiddenFlags&o|r;e.hiddenFlags!==i&&(e.hiddenFlags=i,n=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return n&&(this.indexArrayForConflationUploaded=!1),n}uploadUpdatedIndexBuffer(e){if(this.groundEffect.uploadHiddenByLandmark(e),this.indexArrayForConflationUploaded)return;const t=e=>{0!==e.indexArray.length&&(e.indexArrayForConflation.resize(e.indexArray.length),e.indexArrayForConflation.uint16.set(e.indexArray.uint16),e.entranceBloom.indexArrayForConflation.resize(e.entranceBloom.indexArray.length),e.entranceBloom.indexArrayForConflation.uint16.set(e.entranceBloom.indexArray.uint16))};t(this.buildingWithoutFacade),t(this.buildingWithFacade);for(const e of this.footprints){const t=e.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,i=e.indicesOffset+e.indicesLength;if(0!==e.hiddenFlags){for(let n=e.indicesOffset;n{0!==t.indexArray.length&&(t.indexBuffer?t.indexBuffer.updateData(t.indexArrayForConflation):t.indexBuffer=e.createIndexBuffer(t.indexArrayForConflation,!0),t.entranceBloom.indexBuffer?t.entranceBloom.indexBuffer.updateData(t.entranceBloom.indexArrayForConflation):t.entranceBloom.indexBuffer=e.createIndexBuffer(t.entranceBloom.indexArrayForConflation,!0))};i(this.buildingWithoutFacade),i(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(e){const t=t=>{t.layoutColorBuffer?t.layoutColorBuffer.updateData(t.layoutColorArray):t.layoutColorBuffer=e.createVertexBuffer(t.layoutColorArray,Am.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,ym.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Am.members,!0)};t(this.buildingWithoutFacade),t(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(e,t){const i=e.paint.get("building-ambient-occlusion-intensity");for(const n of this.buildingFeatures){const r=t[n.promoteId],o=n.feature;o.properties["building-part"]="roof";const s=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),c=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="window";const u=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,r=s;"roof"===e.part?(r=s,t=a):"wall"===e.part?(r=l,t=c):"facade_glazing"===e.part?(r=u,t=h):"entrance"===e.part&&(r=d,t=p),t=Fe(t,0,1);for(let o=0;ot.max.x||n.max.xt.max.y||n.max.ys.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=i||Wd(o,s)&&(i=s.height,this.footprintLookup[r]=s,n=0!==s.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.footprintLookup[r]=void 0}}function Mm(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const i=e[0],n=e[e.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+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 n="round"===t,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new xa,this.patternVertexArray=new xa,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new hl,this.maxLineLength=0,this.zOffsetVertexArray=new xa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:Nn/64,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("line",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("line-sort-key");this.tileToMeter=yc(i);const o=this.layers[0].layout.get("line-elevation-reference");if("hd-road-markup"===o)this.elevationType="road";else{const e=this.layers[0].layout.get("line-z-offset"),t=e.isConstant()&&!e.constantOr(0);this.elevationType="sea"!==o&&"ground"!==o&&t?"none":"offset","offset"===this.elevationType&&"none"===o&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i):void 0,d={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(o,i,n),patterns:{},sortKey:h};a.push(d)}r&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const n of a){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(u&&this.addFeatureDashes(n,l),this.hasPattern){const e=sd("line",this.layers,n,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures);c.insert(e[o].feature,r,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)t=!0;else{const t=r.value,i=n.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[n.id]=[t.getKey(s,a)]}}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}addFeatures(e,t,i,n,r,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n,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,Om)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Um)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Fm.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,km),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let i,n;if(t&&t>0?(i=`mapbox_clip_start_${t}`,n=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",n="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(i)&&e.properties.hasOwnProperty(n))return{start:+e.properties[i],end:+e.properties[n]}}addFeature(e,t,i,n,r,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),"road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,a,c,u,h,d)){const[r,o]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n,s,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Fp(e,-t,-t,Nn+t,Nn+t)}clipRuntimeLinesToTile(e,t){const i=[];return[Fp(e,-t,-t,Nn+t,Nn+t,i),i]}addElevatedRoadFeature(e,t,i,n,r,o,s,a){const l=[],c=tu.getElevationFeature(e,n);if(c){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,c,i);for(const e of n)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,r,o,s,a);const l=new iu(i,t.elevationTileID);if(t.elevation)for(let e=n;e>1,this.layoutVertexArray.int16[6*e+1]>>1),n=l.pointElevation(i,t.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0)}else this.fillNonElevatedRoadSegment(n)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const n=[],r=1/yc(i);for(const i of e)kp(i,new Yc(t,r),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:ot(e.min,t,i),max:ot(e.max,t,i)}}(a.progress,{min:0,max:1},i),e>0&&(n=(i.max-i.min)/e)}const r=+t.properties.mapbox_clip_feature_len,o=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(r)||Number.isNaN(o)){for(let t=0;t=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,M=this.overscaling<=16?15*Nn/(512*this.overscaling):0;if(i&&"round"===a)if(Co&&(a="bevel"),"bevel"===a&&(C>2&&(a="flipbevel"),C2*M){const t=g.sub(g.sub(_)._mult(M/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,y,0,0,m,w),_=t}this.updateDistance(_,g),T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);const t=g.dist(A);if(t>2*M){const e=g.add(A.sub(g)._mult(M/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,v,0,0,m,w),g=e}}else T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);else if("flipbevel"===a){if(C>100)T=v.mult(-1);else{const e=C*y.add(v).mag()/y.sub(v).mag();T._perp()._mult(e*(I?-1:1))}this.addCurrentVertex(g,T,0,0,m,w),this.addCurrentVertex(g,T.mult(-1),0,0,m,w)}else if("bevel"===a||"fakeround"===a){null!=w&&_&&this.addCurrentVertex(g,b||y,-1,-1,m,w);const e=g.dist(_)<=2*M&&"bevel"!==a,t=T.mult(I?1:-1);t._mult(C);const i=v.mult(I?-1:1),n=y.mult(I?-1:1),r=this.evaluateLineProgressFeatures(this.distance);if(null==w&&(this.addHalfVertex(g,t.x,t.y,!1,!I,0,m,r),e||this.addHalfVertex(g,t.x+2*n.x,t.y+2*n.y,!1,I,0,m,r)),"fakeround"===a){const e=Math.round(180*S/Math.PI/20);this.addHalfVertex(g,n.x,n.y,!1,I,0,m,r);for(let t=0;t1){this.lineSoFar=e.w;const d=(t.x-e.x)/u,p=(t.y-e.y)/u,f=(t.z-e.z)/u,m=(t.w-e.w)/u;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}updateScaledDistance(){this.lineClips?(this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=this.totalFeatureLength*this.lineClips.start+this.distance):this.lineSoFar=this.distance}updateDistance(e,t){this.prevDistance=this.distance,this.distance+=e.dist(t),this.updateScaledDistance()}}function Qm(e,t,i){return e.xi||e.yi}let $m,Zm;function Wm(e,t,i){return t*(Nn/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}es(Hm,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const qm=(e,t,i)=>(1-i)*e+i*t;function Km(e,t){return 1/Wm(e,1,t.tileZoom)}function Xm(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Jm=e=>{const t=[];Ym(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");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");const n="none"===e.layout.get("line-join").constantOr("miter"),r=!!e.paint.get("line-pattern").constantOr(1);return n&&r&&t.push("LINE_JOIN_NONE"),t};function Ym(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let eg;const tg=()=>eg||(eg={layout:$m||($m=new Os({"line-cap":new ks(zs.layout_line["line-cap"]),"line-join":new ks(zs.layout_line["line-join"]),"line-miter-limit":new Fs(zs.layout_line["line-miter-limit"]),"line-round-limit":new Fs(zs.layout_line["line-round-limit"]),"line-sort-key":new ks(zs.layout_line["line-sort-key"]),"line-z-offset":new ks(zs.layout_line["line-z-offset"]),"line-elevation-reference":new Fs(zs.layout_line["line-elevation-reference"]),"line-cross-slope":new Fs(zs.layout_line["line-cross-slope"]),visibility:new Fs(zs.layout_line.visibility),"line-width-unit":new Fs(zs.layout_line["line-width-unit"])})),paint:Zm||(Zm=new Os({"line-opacity":new ks(zs.paint_line["line-opacity"]),"line-color":new ks(zs.paint_line["line-color"]),"line-translate":new Fs(zs.paint_line["line-translate"]),"line-translate-anchor":new Fs(zs.paint_line["line-translate-anchor"]),"line-width":new ks(zs.paint_line["line-width"]),"line-gap-width":new ks(zs.paint_line["line-gap-width"]),"line-offset":new ks(zs.paint_line["line-offset"]),"line-blur":new ks(zs.paint_line["line-blur"]),"line-dasharray":new ks(zs.paint_line["line-dasharray"]),"line-pattern":new ks(zs.paint_line["line-pattern"]),"line-pattern-cross-fade":new Fs(zs.paint_line["line-pattern-cross-fade"]),"line-gradient":new Ds(zs.paint_line["line-gradient"]),"line-trim-offset":new Fs(zs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Fs(zs.paint_line["line-trim-fade-range"]),"line-trim-color":new Fs(zs.paint_line["line-trim-color"]),"line-emissive-strength":new Fs(zs.paint_line["line-emissive-strength"]),"line-border-width":new ks(zs.paint_line["line-border-width"]),"line-border-color":new ks(zs.paint_line["line-border-color"]),"line-occlusion-opacity":new Fs(zs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},eg);class ig extends ks{possiblyEvaluate(e,t){return t=new Es(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let ng;function rg(e,t){return t>0?t+2*e:e}const og=ha([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sg=ha([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ag=ha([{name:"a_projected_pos",components:4,type:"Float32"}],4);ha([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const lg=ha([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),cg=ha([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ug=ha([{name:"a_texb",components:2,type:"Uint16"}]),hg=ha([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dg=ha([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ha([{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 pg=ha([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fg=ha([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ha([{name:"triangle",components:3,type:"Uint16"}]),ha([{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"}]),ha([{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"},{type:"Uint16",name:"elevationFeatureIndex"}]),ha([{type:"Float32",name:"offsetX"}]),ha([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var mg=24;function gg(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Ts.applyArabicShaping&&(e=Ts.applyArabicShaping(e)),e}(e.text,t,i)}),e}const _g={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Ag(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function yg(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const vg=4294967296,xg=1/vg,bg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let wg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*vg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*vg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Tg(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&bg?bg.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Eg(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Eg(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Cg,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Sg,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Mg,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Bg,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ig,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Pg,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Rg,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lg,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Fg,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Tg(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Eg(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Cg(e,t){for(let i=0;i=0&&i>=e&&Hg[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 jg;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(Vg.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gg(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m=1){const g=jg.fromFeature(e,r,m);h===Ng.vertical&&g.verticalizePunctuation(d);let _=[];const A=function(e,t,i,n,r,o){if(!e)return[];const s=[],a=function(e,t,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>x&&(x=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const n=t[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(y=o.metrics,C=8203!==m?mg:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*_;b-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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function h_(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=di(n.x,r.x,u),d=di(n.y,r.y,u),p=new c_(h,d,0,r.angleTo(n),i);return!s||u_(e,p,a,s,t)?p:void 0}l+=o}}function m_(e,t,i,n,r,o,s,a,l){const c=d_(n,o,s),u=p_(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new c_(_,A,0,m,t);n&&!u_(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=g_(e,h/2,i,n,r,o,s,!0,l)),p}function __(e){let t=0,i=0;for(const n of e)t+=n.w*n.h,i=Math.max(i,n.w);e.sort((e,t)=>t.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e1?s-1:s,wh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),wh.copy(n.data,l,{x:0,y:h-s},{x:a,y:c-s},{width:u,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a,y:c+h},{width:u,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:u-s,y:h-s},{x:a-s,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:h-s},{x:a+u,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c+h},{width:s,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c+h},{width:s,height:s},i)}this.lut=i,this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(e,t,i,n){for(const[r,o]of e.entries()){const{bin:e,imagePosition:s,imageVariant:a}=v_(r,o,i);t.set(r,s),n.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n of e.getUpdatedImages(i)){for(const r of this.iconPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.iconPositions.get(r),o,t,null)}}for(const r of this.patternPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.patternPositions.get(r),o,t,this.lut)}}}}patchUpdatedImage(e,t,i,n=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,o]=e.tl,s=e.sdf;if(this.lut||s){const e={width:t.data.width,height:t.data.height},a=new wh(e);wh.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,n,s),i.update(a,{position:{x:r,y:o}})}else i.update(t.data,{position:{x:r,y:o}})}}es(y_,"ImagePosition"),es(x_,"ImageAtlas");const b_=1e20;function w_(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=b_}for(let a=0,l=0;a{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=r.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(r,e,t),o)return r.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const s=Math.floor(t/256);if(256*s>65535)return Ze("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=r.requests[s];a||(a=r.requests[s]=[],S_.loadGlyphRange(e,s,n,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((n,r)=>{n?i(n):r&&i(null,{stack:e,id:t,glyph:r.glyphs[t]||null})})},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:n,glyph:r}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==C_.none&&(this.localGlyphMode===C_.all?!!this.localFontFamily:!!this.localFontFamily&&(os["CJK Unified Ideographs"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os.Katakana(e)||os["CJK Symbols and Punctuation"](e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs Extension B"](e)||os.Osage(e)))}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),r=e.tinySDF=new S_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*E_,buffer:3*E_,radius:8*E_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new bh({width:a,height:l},s),metrics:{width:c/E_,height:u/E_,left:h/E_,top:d/E_-27,advance:p/E_,localGlyph:!0}}}}S_.loadGlyphRange=function(e,t,i,n,r){const o=256*t,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),kt.Glyphs);Ut(a,(e,t)=>{if(e)r(e);else if(t){const e={},i=function(e){return new wg(e).readFields(Dg,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},S_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(b_,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}w_(_,0,0,c,u,c,this.f,this.v,this.z),w_(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e{const d=k_(n.stretch-A,y,u,e.left*r),p=D_(n.fixed-b,w,n.stretch,f),g=k_(o.stretch-v,x,h,e.top*r),_=D_(o.fixed-T,E,o.stretch,m),C=k_(l.stretch-A,y,u,e.left*r),S=D_(l.fixed-b,w,l.stretch,f),B=k_(c.stretch-v,x,h,e.top*r),I=D_(c.fixed-T,E,c.stretch,m),M=new Te(d,g),P=new Te(C,g),R=new Te(C,B),L=new Te(d,B),F=new Te(p/a,_/a),k=new Te(S/a,I/a),D=t*Math.PI/180;if(D){const e=Math.sin(D),t=Math.cos(D),i=[t,-e,e,t];M._matMult(i),P._matMult(i),L._matMult(i),R._matMult(i)}const O=n.stretch+n.fixed,z=l.stretch+l.fixed,U=o.stretch+o.fixed,N=c.stretch+c.fixed,V=e.imageSecondary;return{tl:M,tr:P,bl:L,br:R,texPrimary:{x:s.paddedRect.x+B_+O,y:s.paddedRect.y+B_+U,w:z-O,h:N-U},texSecondary:V?{x:V.paddedRect.x+B_+O,y:V.paddedRect.y+B_+U,w:z-O,h:N-U}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:k,minFontScaleX:w/a/u,minFontScaleY:E/a/h,isSDF:i}};if(n&&(s.stretchX||s.stretchY)){const e=L_(d,g,f),t=L_(p,_,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-n,s-r);let c=l/2;const u=new Un([],U_);if(0===l)return new Te(n,r);for(let t=n;th.d||!h.d)&&(h=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(c=n.h/2,u.push(new N_(n.p.x-c,n.p.y-c,c,e)),u.push(new N_(n.p.x+c,n.p.y-c,c,e)),u.push(new N_(n.p.x-c,n.p.y+c,c,e)),u.push(new N_(n.p.x+c,n.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function U_(e,t){return t.max-e.max}class N_{constructor(e,t,i,n){this.p=new Te(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,pu(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const V_=Object.keys,j_=Number.POSITIVE_INFINITY,G_=Math.sqrt(2);function H_(e,t,i,n){const r=e.collisionPadding||[0,0,0,0],o={top:e.top-r[1],bottom:e.bottom+r[3],left:e.left-r[0],right:e.right+r[2],scaled:!1};return void 0!==n&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0}(o,n),i&&function(e,t){if(!t)return;const i=Be(t),n=new Te(e.left,e.top),r=new Te(e.right,e.top),o=new Te(e.left,e.bottom),s=new Te(e.right,e.bottom);n._rotateAround(i,new Te(0,0)),r._rotateAround(i,new Te(0,0)),o._rotateAround(i,new Te(0,0)),s._rotateAround(i,new Te(0,0)),e.left=Math.min(n.x,r.x,o.x,s.x),e.right=Math.max(n.x,r.x,o.x,s.x),e.top=Math.min(n.y,r.y,o.y,s.y),e.bottom=Math.max(n.y,r.y,o.y,s.y)}(o,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function Q_(e,[t,i]){let n=0,r=0;if(i===j_){t<0&&(t=0);const i=t/G_;switch(e){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=t;break;case"right":n=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}}return[n,r]}function $_(e,t,i,n,r,o,s,a,l,c,u){const h=e.layers[0],d=h.appearances;if(0===d.length)return{iconBBox:null,iconVerticalBBox:null};let p=null,f=null;const m=n.get("icon-rotate").evaluate(r,{},o);t&&(p=H_(t,p,m,s),i)&&(f=H_(i,f,m+90,s));const[g,_]=n.get("icon-size-scale-range"),A=Fe(1,g,_);for(const i of d){const n=i.getUnevaluatedProperties(),d=void 0!==n._values["icon-image"].value,g=void 0!==n._values["icon-size"].value,_=void 0!==n._values["icon-offset"].value,y=void 0!==n._values["icon-rotate"].value;if(d||g||_||y){const v=_?h.getAppearanceValueAndResolveTokens(i,"icon-offset",r,o,[]):null,x=v&&Array.isArray(v)?v:a,b=y?h.getAppearanceValueAndResolveTokens(i,"icon-rotate",r,o,[]):null,w="number"==typeof b?b:m,T=g?h.getAppearanceValueAndResolveTokens(i,"icon-size",r,o,[]):null,E="number"==typeof T?T*l.iconScaleFactor:s;let C=null,S=null,B=null;if(d){const t=h.getAppearanceValueAndResolveTokens(i,"icon-image",r,o,[]);if(t){const i=e.getResolvedImageFromTokens(t),s=n._values["icon-size"],a=q_(i,s_(e.zoom,s,e.worldview),s,o,e.zoom,r,e.pixelRatio,A,e.worldview);B=c.get(a.iconPrimary.toString())}}else t&&(B=t.imagePrimary);B&&(C=e_(B,null,x,u),e.allowVerticalPlacement&&(S=e_(B,null,x,u))),C&&(p=H_(C,p,w,E)),S&&(f=H_(S,f,w+90,E))}}return{iconBBox:p,iconVerticalBBox:f}}function Z_(e,t,i,n,r,o,s,a,l){if(!t||!t.usvg)return;const c=r_(n),u=r_(r),h="both"!==o&&"width"!==o||!i_(n)?1:u.width/c.width,d="both"!==o&&"height"!==o||!n_(n)?1:u.height/c.height;i.scaleSelf(h,d);const p=i.toString();s.set(p,i),a.set(p,t);const{imagePosition:f}=v_(p,t,A_);l.set(p,f)}function W_(e,t,i,n,r,o,s,a,l){if(!e)return;const c=function(e,t,i,n,r,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Es(e.maxZoom,{worldview:o}),i).evaluate(r,{},i),s=t.possiblyEvaluate(new Es(e.minZoom,{worldview:o}),i).evaluate(r,{},i);return Math.max(n,s)}return t.possiblyEvaluate(new Es(n,{worldview:o})).evaluate(r,{},i)}(t,i,n,r,o,l);return e.scaleSelf(c*a*s)}function q_(e,t,i,n,r,o,s,a,l){return{iconPrimary:W_(e.getPrimary(),t,i,n,r,o,s,a,l),iconSecondary:W_(e.getSecondary(),t,i,n,r,o,s,a,l)}}function K_(e,t,i){if(!t)return;const n=i.get(e.toString()),r=i.get(t.toString());n&&r&&(n.paddedRect.w===r.paddedRect.w&&n.paddedRect.h===r.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==r.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`))}function X_(e,t,i,n){if(!e)return;const r=t.get(i.toString());if(e.imagePrimary=r,n){const i=t.get(n.toString());e.imageSecondary=i}}function J_(e,t){for(const i in e.horizontal)Y_(e.horizontal[i],t);Y_(e.vertical,t)}function Y_(e,t){if(e)for(const i of e.positionedLines)for(const e of i.positionedGlyphs)if(null!==e.image){const i=e.image.toString();e.rect=t.get(i).paddedRect}}function eA(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 tA(e,t,i,n,r,o,s,a,l){const c=sA(o.horizontal)||o.vertical,u=i.get("icon-text-fit-padding").evaluate(n,{},r);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&o.vertical&&(h=t_(t,o.vertical,l,u,a,s)),c&&(d=t_(t,c,l,u,a,s))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function iA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){let b=s.textMaxSize.evaluate(t,{},d);void 0===b?b=a*s.textScaleFactor:b*=s.textScaleFactor;const w=e.layers[0].layout,T=mg,E=a*s.textScaleFactor/T,C=sA(i.horizontal)||i.vertical;if("none"!==g&&e.appearanceFeatureData&&t.index18&&k>2&&(k>>=1),Math.max(Nn/(512*k),1)*w.get("symbol-spacing")),M=w.get("text-padding")*e.tilePixelRatio,P=w.get("icon-padding")*e.tilePixelRatio,R=Be(w.get("text-max-angle")),L="map"===w.get("icon-rotation-alignment")&&"point"!==y,F=I/2;var k;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);const D=t.properties?+t.properties[Oc]:null,O=D&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(D):65535,z=(a,l,y)=>{if(l.x<0||l.x>=Nn||l.y<0||l.y>=Nn)return;let b=null;if(S){const{x:e,y:t,z:i}=p.projectTilePoint(l.x,l.y,y);b={anchor:new c_(e,t,i,0,void 0),up:p.upVector(y,l.x,l.y)}}!function(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M){const P=e.addToLineVertexArray(t,n);let R,L,F,k,D,O,z,U=0,N=0,V=0,j=0,G=-1,H=-1;const Q={};let $=Jt("");const Z=i?i.anchor:t,W="none"!==S;let q=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(v,{},T);q=e[0]*mg,K=e[1]*mg}else q=l.layout.get("text-radial-offset").evaluate(v,{},T)*mg,K=j_;if(e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)O=lA(e),a&&(z=lA(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},T)+90;F=aA(c,Z,t,u,h,d,e,p,i,m),a&&(k=aA(c,Z,t,u,h,d,a,_,i,null,M))}}if(o){const n=e.iconSizeData,r=l.layout.get("icon-rotate").evaluate(v,{},T),s=M_(o,r,b,W,x.iconScaleFactor),p=a?M_(a,r,b,W,x.iconScaleFactor):void 0;L=aA(c,Z,t,u,h,d,o,_,r,null,I);const f=function(e,t,i,n,r,o,s,a){const l=e.layers[0],c=l.appearances;let u=t.length;if(i&&(u=Math.max(u,i.length)),0===c.length)return u;const[h,d]=n.get("icon-size-scale-range"),p=Fe(1,h,d);for(const t of c){const i=t.getUnevaluatedProperties();if(void 0!==i._values["icon-image"].value){const n=l.getAppearanceValueAndResolveTokens(t,"icon-image",r,o,[]);if(n){const t=e.getResolvedImageFromTokens(n);if(t){const n=i._values["icon-size"],l=q_(t,s_(e.zoom,n,e.worldview),n,o,e.zoom,r,e.pixelRatio,p,e.worldview),c=s.get(l.iconPrimary.toString());u=Math.max(u,P_(c,a))}}}}return u}(e,s,p,l.layout,v,T,e.iconAtlasPositions,W);U=4*f;let m=null;"source"===n.kind?(m=[o_*l.layout.get("icon-size").evaluate(v,{},T)*x.iconScaleFactor],m[0]>rA&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)):"composite"===n.kind&&(m=[o_*x.compositeIconSizes[0].evaluate(v,{},T)*x.iconScaleFactor,o_*x.compositeIconSizes[1].evaluate(v,{},T)*x.iconScaleFactor],(m[0]>rA||m[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,y,A,v,void 0,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),G=e.icon.placedSymbolArray.length-1,p&&(N=4*f,e.addSymbols(e.icon,p,m,y,A,v,Ng.vertical,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),H=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=n,a=r.horizontal[o];R||($=Jt(a.text),f?D=lA(a):R=aA(c,Z,t,u,h,d,a,p,l.layout.get("text-rotate").evaluate(v,{},T),m));const g=1===a.positionedLines.length;if(V+=oA(e,i,t,a,s,l,f,v,m,P,r.vertical?Ng.horizontal:Ng.horizontalOnly,g?V_(r.horizontal):[o],Q,G,x,w,T,e.symbolInstances.length,E),g)break}r.vertical&&(j+=oA(e,i,t,r.vertical,s,l,f,v,m,P,Ng.vertical,["vertical"],Q,H,x,w,T,e.symbolInstances.length,E));let X=-1;const J=(e,t)=>e?Math.max(e,t):t;X=J(D,X),X=J(O,X),X=J(z,X);const Y=X>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("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,Z.x,Z.y,Z.z,Q.right>=0?Q.right:-1,Q.center>=0?Q.center:-1,Q.left>=0?Q.left:-1,Q.vertical>=0?Q.vertical:-1,G,H,$,void 0!==R?R:e.collisionBoxArray.length,void 0!==R?R+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,void 0!==L?L:e.collisionBoxArray.length,void 0!==L?L+1:e.collisionBoxArray.length,k||e.collisionBoxArray.length,k?k+1:e.collisionBoxArray.length,u,V,j,U,N,Y,0,q,K,X,0,W?1:0,B)}(e,l,b,a,i,n,o,r,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,A,c,0,P,L,_,t,s,u,h,d,f,m,g,O,v,x)};if("line"===y)for(const r of Fp(t.geometry,0,0,Nn,Nn)){const t=m_(r,I,R,i.vertical||C,n,T,B,e.overscaling,Nn);for(const i of t)C&&cA(e,C.text,F,i)||z(r,i,d)}else if("line-center"===y){for(const e of t.geometry)if(e.length>1){const t=f_(e,R,i.vertical||C,n,T,B);t&&z(e,t,d)}}else if("Polygon"===t.type)for(const e of id(t.geometry,0)){const t=z_(e,16);z(e[0],new c_(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new c_(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new c_(t.x,t.y,0,0,void 0),d)}const nA=255,rA=nA*o_;function oA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=function(e,t,i,n,r,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(e){const t=e[0],i=e[1],n=t*i;return n>0?[t,-i]:n<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,p=h/d;let f=t.top-i[1];for(let e=0;erA&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[o_*f.compositeTextSizes[0].evaluate(a,{},g)*f.textScaleFactor,o_*f.compositeTextSizes[1].evaluate(a,{},g)*f.textScaleFactor],(x[0]>rA||x[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,l,s,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,g,A,!1,_,y.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function sA(e){for(const t in e)return e[t];return null}function aA(e,t,i,n,r,o,s,a,l,c,u){let h,d,p,f;if(h=u?u.top:s.top,d=u?u.bottom:s.bottom,p=u?u.left:s.left,f=u?u.right:s.right,Yg(s)&&s.collisionPadding){const e=s.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3]}if(l){const e=new Te(p,h),t=new Te(f,h),i=new Te(p,d),n=new Te(f,d),r=Be(l);let o=new Te(0,0);c&&(o=new Te(c[0],c[1])),e._rotateAround(r,o),t._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),p=Math.min(e.x,t.x,i.x,n.x),f=Math.max(e.x,t.x,i.x,n.x),h=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,h,f,d,a,n,r,o),e.length-1}function lA(e){Yg(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 cA(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])y&&(v(e,c,n,r,a,l),v(c,i,a,l,o,s))}v(h,d,n,o,r,o),v(d,p,r,o,r,s),v(p,f,r,s,n,s),v(f,h,n,s,n,o),m-=y,g-=y,_+=y,A+=y;const x=1/Math.max(_-m,A-g);return{scale:x,x:m*x,y:g*x,x2:_*x,y2:A*x,projection:t}}function dA(e,{x:t,y:i},n=0){return new Te(((t-n)*e.scale-e.x)*Nn,(i*e.scale-e.y)*Nn)}const pA=c(new Float32Array(16));class fA{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 rc(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i,n=!0){return e._coordinatePoint(e.locationCoordinate(t,i),n)}pixelsPerMeter(e,t){return hc(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return uA(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const r=e.horizonLineFromTop(!1),o=new Te(t,Math.max(r,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,n))}pointCoordinate3D(e,t,i){const n=new Te(t,i);if(e.elevation)return e.elevation.pointCoordinate(n);{const t=this.pointCoordinate(e,n.x,n.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation&&e.elevation.visibleDemTiles.length)return!this.pointCoordinate3D(e,t.x,t.y);const i=e.horizonLineFromTop();return t.y0?t<-wA+i&&(t=-wA+i):t>wA-i&&(t=wA-i);const o=r/Math.pow(TA(t),n);let s=o*Math.sin(n*e),a=r-o*Math.cos(n*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:n}=this,r=n-t,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Fe(Ie(a/i)+this.center[0],-180,180),c=Fe(Ie(2*Math.atan(Math.pow(n/s,1/i))-wA),-mc,mc);return new rc(l,this.southernCenter?-c:c)}}class CA extends fA{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:cc(e),y:uc(t),z:0}}unproject(e,t){const i=dc(e),n=pc(t);return new rc(i,n)}}const SA=Be(mc);class BA extends fA{project(e,t){const i=(t=Be(t))*t,n=i*i;return{x:.5*((e=Be(e))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const e=o*o;r=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=Fe(i-r,-SA,SA)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=Fe(Ie(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ie(i);return new rc(s,a)}}const IA=Be(mc);class MA extends fA{project(e,t){t=Be(t),e=Be(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,s=.5*(e*n+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,n=t=(2*(1-t)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(r*h)*Math.sqrt(1/m):0,A=.5*(2*_*r*d+2*i/Math.PI)-e,y=.5*(_*o+n)-t,v=.5*g*(u*f+_*r*h*c)+1/Math.PI,x=g*(p*l/4-_*o*d),b=.125*g*(l*d-_*o*u*p),w=.5*g*(c*h+_*f*r)+.5,T=x*b-w*v;s=(y*x-A*w)/T,a=(A*b-y*v)/T,i=Fe(i-s,-Math.PI,Math.PI),n=Fe(n-a,-IA,IA)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new rc(Ie(i),Ie(n))}}class PA extends fA{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Be(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:n}=this;return{x:Be(e)*n*i+.5,y:-Math.sin(Be(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=Fe(Ie((e-.5)/i)/n,-180,180),s=Math.asin(Fe(r*n,-1,1)),a=Fe(Ie(s),-mc,mc);return new rc(o,a)}}class RA extends CA{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 n=Zu(e,t,i);return j(n,n,Ku(Vu(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,i){const n=tc(t.lat,t.lng),r=z([],n),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;L(n,n,r,hc(1,0)*Nn*o);const s=c(new Float64Array(16));return h(s,e.pixelMatrix,e.globeMatrix),j(n,n,s),new Te(n[0],n[1])}pixelsPerMeter(e,t){return hc(1,0)*t}pixelSpaceConversion(e,t,i){const n=hc(1,e)*t,r=di(hc(1,45)*t,n,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const n=Xu(Vu(i.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=Ku(Vu(t));return m(n,n,Be(i.lng)),f(n,n,Be(i.lat)),p(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return zu(e,t,i,!0)||new vc(0,0)}pointCoordinate3D(e,t,i){const n=this.pointCoordinate(e,t,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(e,t){return!zu(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,n=e._centerAltitude*t,r=e._camera,o=e._camera.forward(),s=S([],R([],o,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=R([],r.up(),u),d=R([],r.right(),u*c),p=z([],S([],S([],o,h),d)),f=[];let m;if(new Qc(s,p).closestPointOnSphere(l,a,f)){const t=S([],f,l),i=Z([],t,s);m=Math.cos(e.fovAboveCenter)*T(i)}else{const e=Z([],s,l),t=Z([],l,s);z(t,t);const i=T(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(U(o,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=th(e.zoom);if(i>0){const n=uA(e,hc(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return di(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Zu(t,i,e,1)}upVectorScale(e){return{metersToTile:Du(Wu(Vu(e)))}}}function LA(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new CA(e);case"equirectangular":return new bA(e);case"naturalEarth":return new BA(e);case"equalEarth":return new xA(e);case"winkelTripel":return new MA(e);case"albers":return i?new PA(e):new mA(e);case"lambertConformalConic":return i?new PA(e):new EA(e);case"globe":return new RA(e)}throw new Error(`Invalid projection name: ${e.name}`)}const FA=Mc.types,kA=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function DA(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=a?Math.min(rA,Math.round(a[0])):0,f=a?Math.min(rA,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,s,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function OA(e,t,i){e.emplaceBack(t,i)}function zA(e,t,i,n,r,o,s){e.emplaceBack(t,i,n,r,o,s)}const UA=(e,t,i,n)=>{for(let r=0;r0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,ug.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,lg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,cg.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&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(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}es(jA,"SymbolBuffers");class GA{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new La,this.collisionVertexArrayExt=new Sa}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,dg.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}es(GA,"CollisionBuffers");class HA{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=c([]),this.placementViewportMatrix=c([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.textSizeData=s_(this.zoom,t["text-size"],this.worldview),this.iconSizeData=s_(this.zoom,t["icon-size"],this.worldview);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.lut=e.lut,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"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>Ng[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=!1,this.elevationType="none",this.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();return!(!t||0===t.length)&&t.some(t=>null!=t.getProperty(e))}createArrays(){this.text=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new tl,this.lineVertexArray=new il,this.symbolInstances=new el}calculateGlyphDependencies(e,t,i,n,r){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,n&&r&&e<=65535){const e=_g[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,n,r,o){let s=1;const a=e.getUnevaluatedProperties()._values["icon-size"],l=s_(this.zoom,a,this.worldview),c=l_(l,t);if("constant"!==l.kind&&"camera"!==l.kind||(s=c.uSize),"composite"===l.kind){const{minZoom:e,maxZoom:t}=l,o=a.possiblyEvaluate(new Es(e,{worldview:this.worldview}),n),u=a.possiblyEvaluate(new Es(t,{worldview:this.worldview}),n),h=o.evaluate(i,{},n,r);s=h+(u.evaluate(i,{},n,r)-h)*c.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new Es(this.zoom,{worldview:this.worldview}),n).evaluate(i,{},n,r)),s*o}updateFootprints(e,t){}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);return!jd(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?zi.build(e):e}populate(e,t,i,n){const r=this.layers[0],o=r.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[u,h]=o.get("icon-size-scale-range"),d=Fe(t.scaleFactor||1,u,h),p=("constant"!==l.value.kind||l.value.value instanceof Di&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=this.hasAnyAppearanceProperty("icon-image"),g=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!p&&!f&&!m)return;const _=t.iconDependencies,A=t.glyphDependencies,y=t.availableImages,v=new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),x=e=>{const t=e.id.toString();_.has(t)?_.get(t).push(e):_.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=r._featureFilter.needGeometry,b=Ic(e,h);if(!r._featureFilter.filter(v,b,i))continue;if(h||(b.geometry=Bc(e,i,n)),s&&1!==e.type&&i.z<=5){const e=b.geometry,t=.98078528056,n=(e,n)=>U(Zu(e.x,e.y,i,1),Zu(n.x,n.y,i,1)){if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,E,b,i,y,B,d);t&&x(t)}),w){const e=a.evaluate(b,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ng.vertical)>=0;for(const i of w.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio),t=e.id.toString(),n=_.get(t)||[];n.push(e),_.set(t,n)}else{const n=ss(w.toString()),r=i.fontStack||e,o=A[r]=A[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n)}}}if("line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e)}}else o.get("symbol-z-elevate")&&(this.elevationType="offset");"none"!==this.elevationType&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}getCombinedIconPrimary(e,t,i,n,r,o,s){let a,l;const c=e.getUnevaluatedProperties();if(void 0!==c._values["icon-image"].value){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,n,r);a=this.getResolvedImageFromTokens(o)}else{const e=t.getValueAndResolveTokens("icon-image",i,n,r);a=this.getResolvedImageFromTokens(e)}if(a){const e=c._values["icon-size"]||t._unevaluatedLayout._values["icon-size"];l=q_(a,s_(this.zoom,e,this.worldview),e,n,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(e,t,i,n){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const r=this.layers[0];let o=!1,s=0;const a=r.layout,[l,c]=a.get("icon-size-scale-range"),u=Fe(1,l,c);for(let a=0;a=0){const a=c.id,h=t&&void 0!==a?t[String(a)]:void 0,d={type:"Point",id:c.id,properties:c.properties,geometry:[]},p=this.layers[0].appearances&&this.layers[0].appearances.find(t=>t.isActive({globals:n,feature:d,canonical:e,featureState:h}));if(c.activeAppearance===p)continue;if(p){c.activeAppearance=p;const t={sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:c.properties,type:"Point",id:c.id};if(!p.hasCachedIconPrimary()){const n=this.getCombinedIconPrimary(p,r,d,e,i,t,u);p.setCachedIconPrimary(n)}const a=p.getCachedIconPrimary();if(!a)continue;const h=a.toString(),f=this.iconAtlasPositions&&this.iconAtlasPositions.get(h);if(f){const t=r.getAppearanceValueAndResolveTokens(p,"icon-offset",d,e,i),a=t&&Array.isArray(t)?t:[0,0];let h=e_(f,void 0,a,r.layout.get("icon-anchor").evaluate(d,{},e));const m=r.getAppearanceValueAndResolveTokens(p,"icon-rotate",d,e,i),g="number"==typeof m?m:0,_=f.sdf,A=r.layout.get("icon-text-fit").constantOr("none");"none"!==A&&c.textShaping&&c.iconTextFitPadding&&c.fontScale&&(h=t_(h,c.textShaping,A,c.iconTextFitPadding,a,c.fontScale));const y=this.calculateEffectiveAppearanceIconSize(p,n.zoom,d,e,i,u),v=0,x=1+(Math.min(rA,Math.round(y*o_))<<1),b=M_(h,g,_,"none"!==A,u);c.isUsingAppearanceVertexData||(c.isUsingAppearanceVertexData=!0,c.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let e=0;e0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,c.activeAppearance=null;else if(c.isUsingAppearanceVertexData){const e=12,t=c.layoutBasedVertexData.length/e;for(let i=0;i0||u>0,f=h>0,m=this.elevationFeatures[s.elevationFeatureIndex];if(m){const e=new Te(s.tileAnchorX,s.tileAnchorY),c=.075+m.pointElevation(e);s.zOffset!==c&&(t=!0,s.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,n),h=le(ee(),E(0,0,1),u);H(a,a,h),H(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(r=r||p,o=o||f)}if(p&&(UA(this.text.orientationVertexArray,c,a,l),UA(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=s;e>=0&&UA(this.icon.orientationVertexArray,h,a,l),t>=0&&UA(this.icon.orientationVertexArray,d,a,l)}}r||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(e,t,n)=>{i+=t,i>e.length&&e.resize(i);for(let r=-t;r<0;r++)e.emplace(r+i,n)},t=(e,t,i)=>{n+=t,n>e.length&&e.resize(n);for(let r=-t;r<0;r++)e.emplace(r+n,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,n=0;for(let i=0;i0;if((r>0||o>0)&&(e(this.text.zOffsetVertexArray,r,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=n;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,n.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,t,i,n,r){!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,!1),null===this.hasAppearances&&(this.hasAppearances=this.layers.some(e=>e.appearances&&e.appearances.length>0)),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload,this.hasAppearances),this.uploaded=!0}updateAppearances(e,t,i,n){return!!(e&&t&&i)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(e,t,i,n)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=LA(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,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,x=e.segments.prepareSegment(4*_,y,A,this.canOverlap?o.sortKey:void 0),b=this.glyphOffsetArray.length,w=x.vertexLength,T=this.allowVerticalPlacement&&s===Ng.vertical?Math.PI/2:0,E=o.text&&o.text.sections;for(let n=0;n=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=a_(this.textSizeData,e,r)/mg;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=a_(this.iconSizeData,e,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(e,t,i,n){e.emplaceBack(t,-i,-i,n),e.emplaceBack(t,i,-i,n),e.emplaceBack(t,i,i,n),e.emplaceBack(t,-i,i,n)}_updateTextDebugCollisionBoxes(e,t,i,n,r,o,s){for(let s=n;s0}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),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.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:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),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)}}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let i;return this.elevationFeatures&&ti in e?String(e[i]):"")}let $A,ZA,WA;es(HA,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),HA.addDynamicAttributes=NA;class qA{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:_i,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}}es(qA,"FormatSectionOverride",{omit:["defaultValue"]});const KA=()=>WA||(WA={layout:$A||($A=new Os({"symbol-placement":new Fs(zs.layout_symbol["symbol-placement"]),"symbol-spacing":new Fs(zs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fs(zs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(zs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fs(zs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Fs(zs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Fs(zs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Fs(zs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Fs(zs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fs(zs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fs(zs.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-size-scale-range":new Fs(zs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ks(zs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(zs.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-image-use-theme":new Fs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-padding":new Fs(zs.layout_symbol["icon-padding"]),"icon-keep-upright":new Fs(zs.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"]),"icon-anchor":new ks(zs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fs(zs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fs(zs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fs(zs.layout_symbol["text-rotation-alignment"]),"text-field":new ks(zs.layout_symbol["text-field"]),"text-font":new ks(zs.layout_symbol["text-font"]),"text-size":new ks(zs.layout_symbol["text-size"]),"text-size-scale-range":new Fs(zs.layout_symbol["text-size-scale-range"]),"text-max-width":new ks(zs.layout_symbol["text-max-width"]),"text-line-height":new ks(zs.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(zs.layout_symbol["text-letter-spacing"]),"text-justify":new ks(zs.layout_symbol["text-justify"]),"text-radial-offset":new ks(zs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fs(zs.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(zs.layout_symbol["text-anchor"]),"text-max-angle":new Fs(zs.layout_symbol["text-max-angle"]),"text-writing-mode":new Fs(zs.layout_symbol["text-writing-mode"]),"text-rotate":new ks(zs.layout_symbol["text-rotate"]),"text-padding":new Fs(zs.layout_symbol["text-padding"]),"text-keep-upright":new Fs(zs.layout_symbol["text-keep-upright"]),"text-transform":new ks(zs.layout_symbol["text-transform"]),"text-offset":new ks(zs.layout_symbol["text-offset"]),"text-allow-overlap":new Fs(zs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Fs(zs.layout_symbol["text-ignore-placement"]),"text-optional":new Fs(zs.layout_symbol["text-optional"]),visibility:new Fs(zs.layout_symbol.visibility)})),paint:ZA||(ZA=new Os({"icon-opacity":new ks(zs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(zs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(zs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(zs.paint_symbol["text-emissive-strength"]),"icon-color":new ks(zs.paint_symbol["icon-color"]),"icon-halo-color":new ks(zs.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(zs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(zs.paint_symbol["icon-halo-blur"]),"icon-translate":new Fs(zs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fs(zs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Fs(zs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(zs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(zs.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(zs.paint_symbol["text-color"],{runtimeType:xi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ks(zs.paint_symbol["text-halo-color"]),"text-halo-width":new ks(zs.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(zs.paint_symbol["text-halo-blur"]),"text-translate":new Fs(zs.paint_symbol["text-translate"]),"text-translate-anchor":new Fs(zs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Fs(zs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Fs(zs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Fs(zs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Fs(zs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(zs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},WA);class XA extends aa{constructor(e,t,i,n){super(e,KA(),t,i,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=c([]),this.hasOcclusionOpacityProperties=void 0!==e.paint&&("icon-occlusion-opacity"in e.paint||"text-occlusion-opacity"in e.paint)}_handleSpecialPaintPropertyUpdate(e){"icon-occlusion-opacity"!==e&&"text-occlusion-opacity"!==e||(this.hasOcclusionOpacityProperties=!0)}recalculate(e,t){super.recalculate(e,t),this.appearances&&this.appearances.forEach(i=>{i.recalculate(e,t,this.iconImageUseTheme)}),"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()}getColorAdjustmentMatrix(e,t,i,n){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===n||(this._colorAdjustmentMatrix=function(e,t,i,n){e=rt(e),t=nt(t);const r=a(),o=e/3,s=1-2*o,l=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],c=.5-.5*t,u=n-i;return h(r,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),h(r,r,l),r}(e,t,i,n),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=n),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||jo(o.value)||!r?r:QA(t.properties,r)}getAppearanceValueAndResolveTokens(e,t,i,n,r){const o=e.getProperty(t);if(!o)return;const s=o.evaluate(i,{},n,r),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||jo(a.value)||!s||"string"!=typeof s?s:QA(i.properties,s)}createBucket(e){return new HA(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of KA().paint.overridableProperties){if(!XA.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new qA(t),n=new Vo(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new Ho("source",n):new Qo("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Rs(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&XA.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=KA().paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Di)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Gi&&Vi(t.value)===Ei?o(t.value.sections):t instanceof Zi?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new Ul(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let JA,YA,ey,ty;var iy=ha([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function ny(e,t,i,n,r,a,l,c){const u=[e,t,1,i,n,1,r,a,1],h=[l,c,1],d=o([],u),[p,f,m]=G(h,h,d);return s(u,u,[p,0,0,0,f,0,0,0,m])}function ry(e,t,i,n,r,a,l,c){const u=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1),h=ny(e,t,i,n,r,a,l,c);return s(h,h,o([],u))}(e,t,i,n,r,a,l,c);return[u[2]/u[8]/Nn,u[5]/u[8]/Nn]}function oy(e){return[e[0],Math.min(Math.max(e[1],-mc),mc)]}class sy extends ni{constructor(e,t,i,n){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(n),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Yt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ht(this.map._requestManager.transformRequest(this.url,kt.Image),(t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ei(t)):i&&(this.image=i instanceof HTMLImageElement?gt.getImageData(i):i,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 Pf(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 Yt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Pf||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const n of e)n[1]>i&&(i=n[1]),n[1]mc?this.onNorthPole=!0:n<-mc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(vc.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);const o=Math.max(n-t,r-i),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((t+n)/2*a);return l>1&&(l-=1),new Su(s,l,Math.floor((i+r)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Yt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Pf||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_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||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const t=hA(new Su(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(e){const t=e[1].x-e[0].x,i=e[1].y-e[0].y,n=e[2].x-e[1].x,r=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-n*i,u=n*s-o*r,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=hA(this.tileID,this.map.transform.projection),[r,a,l,c]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return dA(n,t)._round()});this.perspectiveTransform=ry(r.x,r.y,a.x,a.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new ma;u.emplaceBack(r.x,r.y,0,0),u.emplaceBack(a.x,a.y,Nn,0),u.emplaceBack(c.x,c.y,0,Nn),u.emplaceBack(l.x,l.y,Nn,Nn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,iy.members),this.boundsSegments=hl.simpleSegment(0,0,4,2);const h=[],d=[oy((p=this.coordinates)[0]),oy(p[1]),oy(p[2]),oy(p[3])];var p;const[f,m,g,_]=function(e){let t=e[0][0],i=t,n=e[0][1],r=n;for(let o=1;oi&&(i=e[o][0]),e[o][1]r&&(r=e[o][1]);return[t,n,i-t,r-n]}(d);{const n=new ma,[r,a,l,c]=function(e){let t=e[0].x,i=t,n=e[0].y,r=n;for(let o=1;oi&&(i=e[o].x),e[o].yr&&(r=e[o].y);return[t,n,i-t,r-n]}(i),u=e=>[(e.x-r)/l,(e.y-a)/c],[d,p,A,y]=i.map(u),v=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1);return s(u,u,o([],ny(e,t,i,n,r,a,l,c)))}(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=ry(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);const x=(e,t)=>{h.push(e.lng);const i=Math.round((e.lng-f)/g*Nn),r=Math.round((e.lat-m)/_*Nn),o=u(t),s=G([],[o[0],o[1],1],v),a=Math.round(s[0]/s[2]*Nn),l=Math.round(s[1]/s[2]*Nn);n.emplaceBack(i,r,a,l)},b=i[3].x-i[0].x,w=i[3].y-i[0].y,T=i[2].x-i[1].x,E=i[2].y-i[1].y;for(let e=0;e<65;e++){const n=e/64,r=[i[0].x+n*b,i[0].y+n*w],o=[i[1].x+n*T,i[1].y+n*E],s=o[0]-r[0],a=o[1]-r[1];for(let e=0;e<65;e++){const i=e/64,n={x:r[0]+s*i,y:r[1]+a*i};x(t.projection.unproject(n.x,n.y),n)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,iy.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new Fa;const n=(e,n,r)=>{i.emplaceBack(e,n,r);const o=h[e],s=h[n],a=h[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,r=i+1,o=i+65,s=o+1;n(i,o,r),n(r,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},(e,t)=>t);i.sort((t,i)=>e[t]-e[i]);const n=[],r=new Fa;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)<=a){const e=it(i,0,i.length,n+a);return e===i.length||s(e,tt(i,e+1,i.length,n+360-a)-e),o}nNn?n-Nn:n,new Te(Math.trunc(n),Math.trunc(i[t+1]))}translationForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+4],i[t+5],i[t+6]]}rotationScaleForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+10],i[t+11],i[t+12],i[t+13],i[t+14],i[t+15]]}transformForInstance(e){const t=16*e,i=this.instancedDataArray.float32;return[i[t+7],i[t+8],i[t+9],i[t+4],i[t+10],i[t+11],i[t+12],i[t+5],i[t+13],i[t+14],i[t+15],i[t+6],0,0,0,1]}}class by{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaledZ=this.canonical.z+Math.log2(e.overscaling),this.layers=e.layers,this.layerIds=this.layers.map(e=>e.fqid),this.projection=e.projection,this.index=e.index,this.worldview=e.worldview,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+1?0: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},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.styleDefinedModelURLs=e.styleDefinedModelURLs,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.tileToMeter=yc(i);const r=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=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Ic(o,r);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Bc(o,i,n),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Nn/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const n of this.modelUris){const r=e.getModel(n,t);if(!r)continue;const o=this.instancesPerModel[n];if(o){const e=.5*F(r.aabb.max,r.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Nn,Math.max(e/this.tileToMeter,Nn/32));i=Math.max(t,i)}}return i}update(e,t,i,n){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.uploaded=!1)}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 n=this.layers[0],r=t.feature,o=this.canonical,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);$(t.rotation,s)&&$(t.scale,a)&&$(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,n){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const r=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(jd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],s=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;tNn;l=c?l-Nn:l;const u=Math.floor(l),h=Math.floor(s.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!zd(t,i,_y.Model,n)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=Wd(Zd(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Nn:l,o=o||d!==c}}}return o}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,Of.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()}const e=this.layers[0].modelManager;if(e&&this.modelUris&&this.modelsRequested)for(const t of this.modelUris)e.removeModel(t,"",!0)}addFeature(e,t,i){const n=this.layers[0],r=n.layout.get("model-id").evaluate(i,{},this.canonical);if(!r)return Ze(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),r;(yy(r,!1)||void 0!==this.styleDefinedModelURLs[r])&&(this.modelUris.includes(r)||this.modelUris.push(r)),this.instancesPerModel[r]||(this.instancesPerModel[r]=new xy);const o=this.instancesPerModel[r],s=o.instancedDataArray,a=new vy(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Nn||t.y<0||t.y>=Nn)continue;if(0!==this.lookupDim){const e=(this.lookupDim-1)/Nn,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 e=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=t.x,s.float32[16*e+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)),r}getModelUris(){return this.modelUris}evaluate(e,t,i,n){const r=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=r.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=r.paint.get("model-scale").evaluate(o,t,s),c=e.translation=r.paint.get("model-translation").evaluate(o,t,s),u=Object.assign({},r.paint.get("model-color").evaluate(o,t,s));u.a=r.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Qf(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t10?this.tileToMeter:yc(s,d)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[r]=c[2]}}}let wy,Ty;es(by,"ModelBucket",{omit:["layers"]}),es(xy,"PerModelAttributes"),es(vy,"ModelFeature");class Ey{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const n=i||e.findDEMTileFor(t);if(!n||!n.dem)return;const r=n.dem,o=n.tileID,s=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Kf.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Kf.HasMapboxMeshFeatures),r&&(this.modelTraits|=Kf.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Py(e)),Iy(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const i of this.getNodesInfo()){const n=i.node;n.footprint&&t.push({footprint:n.footprint,id:e})}}updateAppearances(e,t,i,n){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Ee(e,this.states))for(const t of i)this.evaluate(t,e);this.states=structuredClone(e)}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):tm(t,e,!0)}for(const e of t)im(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 n=e.transform.projectionOptions,r=e.style.getBrightness(),o=this.brightness!==r;if(!this.uploaded||this.dirty||n.name!==this.projection.name||Ly(i.paint.get("model-color").value,o)||Ly(i.paint.get("model-color-mix-intensity").value,o)||Ly(i.paint.get("model-roughness").value,o)||Ly(i.paint.get("model-emissive-strength").value,o)||Ly(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=n,this.brightness=r;const e=this.getNodesInfo();for(const t of e)t.state=null;return!0}return!1}evaluateTransform(e,t){if(e.transform.zoom===this.zoom)return;this.zoom=e.transform.zoom;const i=this.getNodesInfo(),n=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},n),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},n)}}evaluate(e,t){const i=this.getNodesInfo();for(const n of i){if(!n.node.meshes)continue;const i=n.feature,r=t&&t[i.id];if(Ee(r,n.state))continue;n.state=structuredClone(r);const o=n.node.meshes&&n.node.meshes[0].featureData,s=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,o){for(let t=0;t=e)continue;const h=Cy[c],d=Math.abs(h);d>a&&(s=h,a=d,l=r,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(n,i)+s*o;const h=t._dem.get(n+l,i+u),d=t._dem.get(n-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),Cy[r]=t._dem.set(n,i,a),Sy[r]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=gt.now())}setFilter(e){this.filter=e?js(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Es(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)im(t.node),nm(t.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(e,t){if(t.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=t.updateTime;const i=t.getReplacementRegionsForTile(e.toUnwrapped());for(const e of this.getNodesInfo()){const t=e.node.footprint;e.hiddenByReplacement=!!t&&!i.find(e=>e.footprint===t)}}getHeightAtTileCoord(e,t){const i=[],n=[0,0,0],r=c([]);for(const o of this.getNodesInfo()){const s=o.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};u(r,o.node.globalMatrix),n[0]=e,n[1]=t,j(n,n,r);const l=(n[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*qf|0,c=Math.min(63,(n[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*qf|0)*qf+Math.min(63,l),h=s.heightmap[c];if(!(h<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:h,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Te(e,t),new Te(e,t),i),i.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Ly(e,t){return e instanceof Ho&&!e.isLightConstant&&t}function Fy(e,t,i,n,r,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=di(l,255*i[0],i[3]),c=di(c,255*i[1],i[3]),u=di(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*n[3]),p=function(e){const t=Fe(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=Fe(r[0],0,1),m=Fe(r[1],0,1),g=Fe(r[2],0,1),_=Fe(r[3],0,1);let A,y,v,x;if(f!==m&&s!==o&&m!==f){const e=s-o;y=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Fe(r[4],-1,1);x=Math.pow(10,t),A=255*g<<8|255*_}else A=65535,y=0,v=1,x=1;if(e.emplaceBack(h,d,p,A,y,v,x),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&n.lights&&(d=new $a,d.resize(10*n.lights.length)),Fy(i.featureArray,r,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),r++}}es(Ry,"Tiled3dModelBucket",{omit:["layers"]}),es(Py,"Tiled3dModelFeature");const Dy=["id","tile","layer","source","sourceLayer","state"];class Oy{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=n,this.properties=e?e.properties:{},this.id=r}clone(){const e=new Oy(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},this.layer)),this.source&&(e.source=this.source),this.sourceLayer&&(e.sourceLayer=this.sourceLayer),e}get geometry(){return void 0===this._geometry&&this._vectorTileFeature&&(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};for(const t of Dy)void 0!==this[t]&&(e[t]=this[t]);return e}}class zy extends ni{constructor(e,t,i,n){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t,this._modelsInfo=new Map}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],n=this._modelsInfo.get(t);if(n){const e=n.model;e.position=null!=i.position?new rc(i.position[0],i.position[1]):new rc(0,0),e.orientation=null!=i.orientation?i.orientation:[0,0,0],n.modelSpec=i,zy.applyModelSpecification(e,i),e.computeBoundsAndApplyParent(),this.models.push(e)}else{const n=Sf(this.map._requestManager.transformRequest(i.uri,kt.Model).url).then(e=>{if(!e)return;const n=hm(e),r=new Jf(t,i.uri,i.position,i.orientation,n);zy.applyModelSpecification(r,i),r.computeBoundsAndApplyParent(),this.models.push(r),this._modelsInfo.set(t,{modelSpec:i,model:r})}).catch(e=>{this.fire(new ei(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)))});e.push(n)}}Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this._loaded=!0,this.fire(new ei(new Error(`Could not load models: ${e.message}`)))})}static applyModelSpecification(e,t){t.nodeOverrides&&zy.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&zy.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}static convertNodeOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.nodeOverrideNames=[];for(const i of t)e.nodeOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={orientation:[0,0,0]};if(i.hasOwnProperty("orientation")){const e=i.orientation;e&&(n.orientation=e)}e.nodeOverrides.set(t,n)})}static convertMaterialOverrides(e,t){if(Array.isArray(t)&&t.every(e=>"string"==typeof e)){e.materialOverrideNames=[];for(const i of t)e.materialOverrideNames.push(i)}else Object.entries(t).forEach(([t,i])=>{const n={color:new li(1,1,1),colorMix:0,emissionStrength:0,opacity:1},r=i["model-color"];void 0!==r&&(n.color.r=r[0],n.color.g=r[1],n.color.b=r[2]);const o=i["model-color-mix-intensity"];void 0!==o&&(n.colorMix=o);const s=i["model-emissive-strength"];void 0!==s&&(n.emissionStrength=s);const a=i["model-opacity"];void 0!==a&&(n.opacity=a),e.materialOverrides.set(t,n)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){const e=ta(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(e){this.models=[];const t=new Map;for(const i in e){const n=e[i];if(this._modelsInfo.has(i)){const e=this._modelsInfo.get(i);e&&e.modelSpec.uri===n.uri&&t.set(i,e)}}this._modelsInfo=t,this._options.models=e,this._loaded=!1,this.load()}}function Uy(e,t,i,n){const r=1<e.polygon).flat());const g=p?a:null,[_,A]=Np(o,n,h,u,c,s,g,d,f,o.center.lat,e.tileID.canonical),y=e.queryGeometry;return Up(_,A,y.isPointQuery()?y.screenBounds:y.screenGeometry)}},building:class extends aa{constructor(e,t,i,n){super(e,{layout:Pm||(Pm=new Os({visibility:new Fs(zs.layout_building.visibility),"building-facade":new ks(zs.layout_building["building-facade"]),"building-facade-floors":new ks(zs.layout_building["building-facade-floors"]),"building-facade-unit-width":new ks(zs.layout_building["building-facade-unit-width"]),"building-facade-window":new ks(zs.layout_building["building-facade-window"]),"building-roof-shape":new ks(zs.layout_building["building-roof-shape"]),"building-height":new ks(zs.layout_building["building-height"]),"building-base":new ks(zs.layout_building["building-base"]),"building-flood-light-wall-radius":new ks(zs.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ks(zs.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ks(zs.layout_building["building-flip-roof-orientation"])})),paint:Rm||(Rm=new Os({"building-opacity":new Fs(zs.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Fs(zs.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Fs(zs.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Fs(zs.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Fs(zs.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Fs(zs.paint_building["building-vertical-scale"]),"building-cast-shadows":new Fs(zs.paint_building["building-cast-shadows"]),"building-color":new ks(zs.paint_building["building-color"]),"building-emissive-strength":new ks(zs.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Fs(zs.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Fs(zs.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Fs(zs.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Fs(zs.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Fs(zs.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Im(e)}cutoffRange(){return this.paint.get("building-cutoff-fade-range")}hasShadowPass(){return this.paint.get("building-cast-shadows")}hasLightBeamPass(){return!0}canCastShadows(){return!0}is3D(e){return!0}queryRadius(e){return 0}queryIntersectsFeature(e,t,i,n,r,o,s,a,l){let c=this.layout.get("building-height").evaluate(t,i);const u=this.layout.get("building-base").evaluate(t,i),h=e.tile.getBucket(this).getFootprint(t);if(h){if(0!==h.hiddenFlags)return!1;c=h.height}const[d,p]=Np(o,n,u,c,new Te(0,0),s,null,[0,0],1,o.center.lat,e.tileID.canonical),f=e.queryGeometry;return Up(d,p,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class extends aa{constructor(e,t,i,n){const r=tg();super(e,r,t,i,n),r.layout&&(this.layout=new Ls(r.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Br,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"]=(()=>{if(ng)return ng;const e=tg();return ng=new ig(e.paint.properties["line-width"].specification),ng.useIntegerZoom=!0,ng})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hm(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const n=Jm(this);return{config:new Ul(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,i=rg(vu("line-width",this,t),vu("line-gap-width",this,t)),n=vu("line-offset",this,t);return i/2+Math.abs(n)+xu(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,r,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=bu(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*rg(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&&(n=function(e,t){const i=[],n=new Te(0,0);for(let r=0;r=3)for(let t=0;t>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function hv(e,t,i){1===e?(t.rgb_color=uv(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function dv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function pv(e,t){return e.readFields(fv,{offset:0,opacity:255,rgb_color:jy},t)}function fv(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=uv(i.readVarint()))}function mv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function gv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(nv(i,i.readVarint()+i.pos))}function _v(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(nv(i,i.readVarint()+i.pos))}class Av{static calculate(e={},t=[]){const i=new Map,n=new Map;if(0===Object.keys(e).length)return i;t.forEach(e=>{n.set(e.name,e.rgb_color||new li(0,0,0))});for(const[t,r]of Object.entries(e))n.has(t)?i.set(n.get(t).toString(),r):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function yv(e,t=255,i){const n=t/255,r=e.toString(),o=i.has(r)?i.get(r).clone():e.clone();return o.a*=n,o.toString()}function vv(e,t){if(!mt()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}function xv(e,t){const i=Av.calculate(t.params,e.metadata?e.metadata.variables:[]),n=e.usvg_tree,r=n.width,o=n.height,s=t.transform?t.transform:new DOMMatrix,a=Math.max(1,Math.round(r*s.a)),l=Math.max(1,Math.round(o*s.d)),c=new DOMMatrix([a/r,0,0,l/o,0,0]),u=vv(a,l).getContext("2d");return bv(u,c,n,n,i),u.getImageData(0,0,a,l)}function bv(e,t,i,n,r){for(const o of n.children)wv(e,t,i,o,r)}function wv(e,t,i,n,r){n.group?(e.save(),function(e,t,i,n,r){const o=null!=n.mask_idx?i.masks[n.mask_idx]:null,s=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=Rv(n.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(n,null!=s,null!=o))return void bv(e,t,i,n,r);const a=vv(e.canvas.width,e.canvas.height),l=a.getContext("2d");bv(l,t,i,n,r),s&&Mv(l,t,i,s),o&&Pv(l,t,i,o,r),e.globalAlpha=n.opacity/255,e.drawImage(a,0,0)}(e,t,i,n.group,r),e.restore()):n.path&&(e.save(),function(e,t,i,n,r){e.setTransform(t),n.paint_order===$y.PAINT_ORDER_FILL_AND_STROKE?(Tv(e,i,n,r),Cv(e,i,n,r)):(Cv(e,i,n,r),Tv(e,i,n,r))}(e,t,i,n.path,r),e.restore())}function Tv(e,t,i,n){const r=i.fill;if(!r)return;const o=r.opacity/255;switch(e.save(),e.beginPath(),Lv(i,e),r.paint){case"rgb_color":e.fillStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Sv(e,i,o,n);break}case"radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Bv(e,i,o,n)}}e.fill(Ev(i)),e.restore()}function Ev(e){return e.rule===Gy.PATH_RULE_NON_ZERO?"nonzero":e.rule===Gy.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Cv(e,t,i,n){const r=i.stroke;if(!r)return;const o=Fv(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const s=r.opacity/255;switch(r.paint){case"rgb_color":e.strokeStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":e.strokeStyle=Sv(e,t.linear_gradients[r.linear_gradient_idx],s,n,!0);break;case"radial_gradient_idx":e.strokeStyle=Bv(e,t.radial_gradients[r.radial_gradient_idx],s,n,!0)}switch(r.linejoin){case Qy.LINE_JOIN_MITER_CLIP:case Qy.LINE_JOIN_MITER:e.lineJoin="miter";break;case Qy.LINE_JOIN_ROUND:e.lineJoin="round";break;case Qy.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(r.linecap){case Hy.LINE_CAP_BUTT:e.lineCap="butt";break;case Hy.LINE_CAP_ROUND:e.lineCap="round";break;case Hy.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(o)}function Sv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const{x1:o,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(o,s),u=new DOMPoint(a,l);if(r){const e=Rv(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return h}function Bv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const o=Rv(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(s,a),p=new DOMPoint(c,u),f=l,m=h;if(r){d=o.transformPoint(d),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e}const g=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)g.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return g}function Iv(e,t,i,n){const r=n.transform?Rv(n.transform).preMultiplySelf(t):t,o=vv(e.canvas.width,e.canvas.height),s=o.getContext("2d");for(const e of n.children)if(e.group)Iv(s,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(Fv(t),r),s.fill(i,Ev(t))}const a=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;a&&Mv(s,r,i,a),e.globalCompositeOperation="source-over",e.drawImage(o,0,0)}function Mv(e,t,i,n){const r=vv(e.canvas.width,e.canvas.height);Iv(r.getContext("2d"),t,i,n),e.globalCompositeOperation="destination-in",e.drawImage(r,0,0)}function Pv(e,t,i,n,r){if(0===n.children.length)return;const o=null!=n.mask_idx?i.masks[n.mask_idx]:null;o&&Pv(e,t,i,o,r);const s=e.canvas.width,a=e.canvas.height,l=vv(s,a),c=l.getContext("2d"),u=n.width,h=n.height,d=n.left,p=n.top,f=new Path2D,m=new Path2D;m.rect(d,p,u,h),f.addPath(m,t),c.clip(f);for(const e of n.children)wv(c,t,i,e,r);const g=c.getImageData(0,0,s,a),_=g.data;if(n.mask_type===Wy.MASK_TYPE_LUMINANCE)for(let e=0;e<_.length;e+=4)_[e+3]=_[e+3]/255*(.2126*_[e]+.7152*_[e+1]+.0722*_[e+2]);c.putImageData(g,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function Rv(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function Lv(e,t){const i=e.step;let n=e.diffs[0]*i,r=e.diffs[1]*i;t.moveTo(n,r);for(let o=0,s=2;ot[s])return null}else{const a=1/n[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>r&&(r=l),co)return null}return r}function Uv(e,t,i,n,r,o,s,a,l,c,u){const h=n-e,d=r-t,p=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,A=u[2]*f-u[0]*g,y=u[0]*m-u[1]*f,v=h*_+d*A+p*y;if(Math.abs(v)<1e-15)return null;const x=1/v,b=c[0]-e,w=c[1]-t,T=c[2]-i,E=(b*_+w*A+T*y)*x;if(E<0||E>1)return null;const C=w*p-T*d,S=T*h-b*p,B=b*d-w*h,I=(u[0]*C+u[1]*S+u[2]*B)*x;return I<0||E+I>1?null:(f*C+m*S+g*B)*x}function Nv(e,t,i){return(e-t)/(i-t)}function Vv(e,t,i,n,r,o,s,a,l){const c=1<{const o=n?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=a,r[2]=s,r[3]=l};let s=new Ov(n);const a=[];for(let t=0;t=1;n/=2){const e=i[i.length-1];s=new Ov(n);for(let t=0;t0;){const{idx:a,t:p,nodex:f,nodey:m,depth:g}=d.pop();if(this.leaves[a]){Vv(f,m,g,e,t,i,n,u,h);const a=1<=e[2])return p}continue}let _=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[_]=d),_++}}for(let e=0;e<_;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:g+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,n,r){if(1===e[n].isLeaf(t,i))return;this.childOffsets[r]||(this.childOffsets[r]=this.nodeCount);const o=n-1,s=e[o];let a=0,l=0;for(let e=0;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],n=Wv.getUnpackVector(t);let r=Math.floor((e+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Th({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function ox(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&i)>>8|(240&n)<<4|61440&n,e[t+1]=15&i|(3840&i)>>4|(15&n)<<8|(3840&n)<<4}return e;case"uint8":for(let t=0;t>6|(192&n)>>4|(192&r)>>2|192&o,e[t+1]=(48&i)>>4|(48&n)>>2|48&r|(48&o)<<2,e[t+2]=(12&i)>>2|12&n|(12&r)<<2|(12&o)<<4,e[t+3]=3&i|(3&n)<<2|(3&r)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}es(Wv,"DEMData"),es(jv,"DemMinMaxQuadTree",{omit:["dem"]});var sx=Uint8Array,ax=Uint16Array,lx=Int32Array,cx=new sx([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ux=new sx([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hx=new sx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dx=function(e,t){for(var i=new ax(31),n=0;n<31;++n)i[n]=t+=1<>1|(21845&Ax)<<1;_x[Ax]=((65280&(yx=(61680&(yx=(52428&yx)>>2|(13107&yx)<<2))>>4|(3855&yx)<<4))>>8|(255&yx)<<8)>>1}var vx=function(e,t,i){for(var n=e.length,r=0,o=new ax(t);r>l]=c;return s},xx=new sx(288);for(Ax=0;Ax<144;++Ax)xx[Ax]=8;for(Ax=144;Ax<256;++Ax)xx[Ax]=9;for(Ax=256;Ax<280;++Ax)xx[Ax]=7;for(Ax=280;Ax<288;++Ax)xx[Ax]=8;var bx=new sx(32);for(Ax=0;Ax<32;++Ax)bx[Ax]=5;var wx=vx(xx,9),Tx=vx(bx,5),Ex=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},Cx=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},Sx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Bx=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ix=function(e,t,i){var n=new Error(t||Bx[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Ix),!i)throw n;return n},Mx=new sx(0),Px="undefined"!=typeof TextDecoder&&new TextDecoder;try{Px.decode(Mx,{stream:!0})}catch(e){}const Rx={gzip_data:"gzip"};class Lx extends Error{constructor(e){super(e),this.name="MRTError"}}const Fx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},kx={uint32:1,uint16:2,uint8:4},Dx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Ox;class zx{constructor(e=5){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=e}getLayer(e){const t=this.layers[e];if(!t)throw new Lx(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Lx("File is not a valid MRT.");return i.getUint32(1,!0)}parseHeader(e){const t=new Uint8Array(e),i=this.getHeaderLength(e);if(t.length= ${i} but got buffer of length ${t.length}`);const n=new Ox(t.subarray(0,i)).readFields(qv,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Lx(`Invalid attempt to parse header ${n.z}/${n.x}/${n.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=n.x,this.y=n.y,this.z=n.z;for(const e of n.layers)this.layers[e.name]=new Ux(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let n of e.blockIndices){const r=i.dataIndex[n],o=r.firstByte-e.firstByte,s=r.lastByte-e.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:n,blockShape:[r.bands.length].concat(i.bandShape),buffer:i.buffer,codec:r.codec.codec,filters:r.filters.map(e=>e.filter)};i._blocksInProgress.add(n),t.push(a)}return new Nx(t,()=>{t.forEach(e=>i._blocksInProgress.delete(e.blockIndex))},(e,n)=>{if(t.forEach(e=>i._blocksInProgress.delete(e.blockIndex)),e)throw e;n.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e)})})}}class Ux{constructor({version:e,name:t,units:i,tileSize:n,pixelFormat:r,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new Lx(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Fx[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,kx[this.pixelFormat]],this._decodedBlocks=new kv(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return kx[this.pixelFormat]}get cacheSize(){return this._decodedBlocks.capacity}getBandList(){return this.dataIndex.map(({bands:e})=>e).flat()}processDecodedData(e){const t=e.blockIndex.toString();this._decodedBlocks.get(t)||this._decodedBlocks.put(t,e.data)}getBlockForBand(e){let t=0;switch(typeof e){case"string":for(const[i,n]of this.dataIndex.entries()){for(const[r,o]of n.bands.entries())if(o===e)return{bandIndex:t+r,blockIndex:i,blockBandIndex:r};t+=n.bands.length}break;case"number":for(const[i,n]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new Lx(`Number of blocks to decode (${r.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:n}}hasBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0}hasDataForBand(e){const{blockIndex:t}=this.getBlockForBand(e);return t>=0&&!!this._decodedBlocks.get(t.toString())}getBandView(e){const{blockIndex:t,blockBandIndex:i}=this.getBlockForBand(e);if(t<0)throw new Lx(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new Lx(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const r=this.dataIndex[t],o=this.bandShape.reduce((e,t)=>e*t,1),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:r.offset,scale:r.scale}}}zx.setPbf=function(e){Ox=e};class Nx{constructor(e,t,i){this.tasks=e,this._onCancel=t,this._onComplete=i,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(e,t){this._finalized||(this._onComplete(e,t),this._finalized=!0)}}zx.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:n,lastByte:r,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(n,r+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Lx(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ix(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[i++]);return i+(2&t)}(r=e))+8>r.length&&Ix(6,"invalid gzip data"),function(e,t,i){var n=e.length;if(!n||t.f&&!t.l)return i||new sx(0);var r=!i,o=r||2!=t.i,s=t.i;r&&(i=new sx(3*n));var a,l,c=function(e){var t=i.length;if(e>t){var n=new sx(Math.max(2*t,e));n.set(i),i=n}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,_=8*n;do{if(!p){u=Cx(e,h,1);var A=Cx(e,h+1,3);if(h+=3,!A){var y=e[(M=4+((h+7)/8|0))-4]|e[M-3]<<8,v=M+y;if(v>n){s&&Ix(0);break}o&&c(d+y),i.set(e.subarray(M,v),d),t.b=d+=y,t.p=h=8*v,t.f=u;continue}if(1==A)p=wx,f=Tx,m=9,g=5;else if(2==A){var x=Cx(e,h,31)+257,b=Cx(e,h+10,15)+4,w=x+Cx(e,h+5,31)+1;h+=14;for(var T=new sx(w),E=new sx(19),C=0;C>4)<16)T[C++]=M;else{var R=0,L=0;for(16==M?(L=3+Cx(e,h,3),h+=2,R=T[C-1]):17==M?(L=3+Cx(e,h,7),h+=3):18==M&&(L=11+Cx(e,h,127),h+=7);L--;)T[C++]=R}}var F=T.subarray(0,x),k=T.subarray(x);m=Ex(F),g=Ex(k),p=vx(F,m),f=vx(k,g)}else Ix(1);if(h>_){s&&Ix(0);break}}o&&c(d+131072);for(var D=(1<>4;if((h+=15&R)>_){s&&Ix(0);break}if(R||Ix(2),U<256)i[d++]=U;else{if(256==U){z=h,p=null;break}var N=U-254;U>264&&(N=Cx(e,h,(1<<(G=cx[C=U-257]))-1)+fx[C],h+=G);var V=f[Sx(e,h)&O],j=V>>4;if(V||Ix(3),h+=15&V,k=gx[j],j>3){var G=ux[j];k+=Sx(e,h)&(1<_){s&&Ix(0);break}o&&c(d+131072);var H=d+N;if(da.length)&&(l=a.length),new sx(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new sx(((i=r)[(n=i.length)-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0))));var i,n,r,o;const s=Rx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then(e=>new Uint8Array(e))}(u,c).then(e=>(function(e,t){e.readFields(tx,t)}(new Ox(e),h),new Dx[o](h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":nx(e,s);break;case"zigzag_filter":rx(e);break;case"bitshuffle_filter":ox(e,o);break;default:throw new Lx(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},es(Nx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),es(zx,"MapboxRasterTile"),es(Ux,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class Vx{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new kc(new wg(this.rawTileData)).layers,this.sourceLayerCoder=new Vx(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){const{tilespaceGeometry:i,transform:n,tileTransform:r,pixelPosMatrix:o,availableImages:s,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,n,r)=>gu(i.bufferedTilespaceGeometry,e-l,t-l,n+l,r+l));u.sort(Hx);let h=null;n.elevation&&u.length>0&&(h=Ey.create(n.elevation,this.tileID));const d={};let p;for(let t=0;t(f||(f=Bc(e,this.tileID.canonical,r)),t.queryIntersectsFeature(i,e,s,f,this.z,n,o,h,a)))}return d}loadMatchingFeature(e,t,i,n,r,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!Qe(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(s),g=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ")}`);this.promoteIdExpression=e.value}i=this.promoteIdExpression.evaluate({zoom:0},e)}else i=e.properties[n];"boolean"==typeof i&&(i=Number(i))}return i}}function Gx(e,t,i,n,r){return je(e,(e,o)=>{const s=t instanceof Ls?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,void 0,r):s})}function Hx(e,t){return t-e}es(jx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Qx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class $x{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 n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Qx[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new $x(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=Qx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 Zx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)Xx(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];Xx(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Zx(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;Wx(e,t,s,n,r,o),Zx(e,t,i,n,s-1,1-o),Zx(e,t,i,s+1,r,1-o)}function Wx(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Wx(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(qx(e,t,n,i),t[2*r+o]>s&&qx(e,t,n,r);as;)l--}t[2*n+o]===s?qx(e,t,n,l):(l++,qx(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function qx(e,t,i,n){Kx(e,i,n),Kx(t,2*i,2*n),Kx(t,2*i+1,2*n+1)}function Kx(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Xx(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}e.$=Yi,e.A=Oi,e.B=ta,e.C=2,e.D=Wp,e.E=ni,e.F=y_,e.G=__,e.H=Ki,e.I=ri,e.J=Us,e.K=qi,e.L=Ji,e.M=Ro,e.N=Io,e.O=Po,e.P=Te,e.Q=jo,e.R=kt,e.S=Ns,e.T=Mf,e.U=Go,e.V=Ay,e.W=$o,e.X=yr,e.Y=_r,e.Z=Ar,e._=on,e.a=function(e){return st.API_CDN_URL_REGEX.test(e)},e.a$=ma,e.a0=Xi,e.a1=ai,e.a2=Vs,e.a3=class extends Ay{},e.a4=Lo,e.a5=Mo,e.a6=zs,e.a7=function(e){const t=e.value;return t?Xi(t)?yy(t,!0)?[]:[new Ay(e.key,t,`invalid url "${t}"`)]:[new Ay(e.key,t,`string expected, "${qi(t)}" found`)]:[]},e.a8=Bs,e.a9=Os,e.aA=Fe,e.aB=h,e.aC=Y,e.aD=$l,e.aE=mu,e.aF=cc,e.aG=bc,e.aH=function(e,t){const i={};for(let n=0;n{n(e,i)},t):n(e,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i((i,n)=>{r.result=[i,n];for(const e of r.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,n)},t):e(i,n);setTimeout(()=>delete this.entries[e],3e3)})),()=>{r.result||(r.callbacks=r.callbacks.filter(e=>e!==n),r.callbacks.length||(r.cancel(),delete this.entries[e]))}}},e.aL=function(e,t,i){const n=JSON.stringify(e.request);return e.data&&(this.deduped.entries[n]={result:[null,e.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const n=Ut(e.request,(e,n,r)=>{e?t(e):n&&t(null,{vectorTile:i?void 0:new kc(new wg(n)),rawData:n,responseHeaders:new Map(r.entries())})});return()=>{n.cancel(),t()}},t)},e.aM=function(e){return e?{cacheControl:e.get("Cache-Control"),expires:e.get("Expires")}:{cacheControl:void 0,expires:void 0}},e.aN=function(e){St++,St>xt&&(e.getActor().send("enforceCacheSizeLimit",vt),St=0)},e.aO=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aP=Iu,e.aQ=ly,e.aR=fy,e.aS=rc,e.aT=sy,e.aU=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t{}}},e.aV=Pf,e.aW=zy,e.aX=Ve,e.aY=hA,e.aZ=dc,e.a_=pc,e.aa=Fs,e.ab=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return Ke(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i),azimuthal:di(e.azimuthal,t.azimuthal,i),polar:di(e.polar,t.polar,i)}}},e.ac=Es,e.ad=Qo,e.ae=vc,e.af=j,e.ag=T,e.ah=ke,e.ai=Ls,e.aj=th,e.ak=di,e.al=Nn,e.am=pi,e.an=Be,e.ao=li,e.ap=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=Ke([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i)}}},e.aq=function(e,t,i=0,n=!0){const r=new Te(i,i),o=e.sub(r),s=t.add(r),a=[o,new Te(s.x,o.y),s,new Te(o.x,s.y)];return n&&a.push(o.clone()),a},e.ar=function(e,t){const i=[];for(let n=0;n1)return!1;const i=t.getSource().maxzoom,n=1<1)return t;const r=n.getSource().maxzoom,o=1<{const a=this.getAtTileOffset(e,r,o,s),l=n.upVector(e.canonical,r.x,r.y);return R(l,l,a*n.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,n){if(this.isUsingMockSource())return!1;const r=Ey.create(this,e,n);return!!r&&(t.forEach(e=>{e[2]=this.exaggeration()*r.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,n=t.tileID,r=1<0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!nh(e,new rc(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!nh(e,new rc(e.center.lat,-90))]},e.cM=function(e,t){const{scale:i}=e.tileTransform,n=i*Nn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var n=t[1],r=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=n*s,e[2]=r*a,e[3]=o*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[n,n])},e.cN=Vf,e.cO=x,e.cP=Uf,e.cQ=function(e){const t=Uf(e,!0);return n([],[t[0],t[1],t[4],t[5]])},e.cR=p,e.cS=$c,e.cT=f,e.cU=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return eh(t,i,e.worldSize,n,r)},e.cV=I,e.cW=Ie,e.cX=Mu,e.cY=_u,e.cZ=Zl,e.c_=function(e,t,i){let n=0;for(let i=0;i<2;++i){const r=0;e[i]>r&&(n+=(e[i]-r)*(e[i]-r)),t[i]0?Math.acos(i/n)*Se:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Se+90:0;return o<0&&(o+=360),[n,o,r]},e.d4=E,e.d5=Ke,e.d6=yc,e.d7=S,e.d8=Jc,e.d9=B,e.dA=Cl,e.dB=class extends vl{constructor(e){super(e),this.current=Il}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}}},e.dC=Pe,e.dD=function(e,t,i){const n=th(i.zoom),r=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!o},e.dE=function(e){const t=e.pixelsPerMeter,i=t/hc(1,e.center.lat),n=c(new Float64Array(16));return d(n,n,[e.point.x,e.point.y,0]),p(n,n,[i,i,t]),Float32Array.from(n)},e.dF=Qu,e.dG=function(e){const t=mc-5;e=Fe(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Be(e))),3);return Math.round(i*(Xl.length-1))},e.dH=function(e,t,i,n){const r=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),c=1<0){const e=180/n;s(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},e.dI=Vu,e.dJ=function(e,t,i){const n=c(new Float64Array(16)),r=(t/(1<({u_matrix:new Bl(e),u_texsize:new wl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_image:new xl(e),u_units_to_pixels:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e),u_pattern_transition:new bl(e)}),e.dW=e=>({u_matrix:new Bl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_units_to_pixels:new wl(e),u_dash_image:new xl(e),u_gradient_image:new xl(e),u_image_height:new bl(e),u_texsize:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e)}),e.dX=e=>({u_camera_to_center_distance:new bl(e),u_extrude_scale:new Pl(e),u_device_pixel_ratio:new bl(e),u_matrix:new Bl(e),u_inv_rot_matrix:new Bl(e),u_merc_center:new wl(e),u_tile_id:new Tl(e),u_zoom_transition:new bl(e),u_up_dir:new Tl(e),u_emissive_strength:new bl(e)}),e.dY=Ra,e.dZ=fg,e.d_=class{constructor(e,t,i,n){this.context=e,this.format=n,this.size=i,this.texture=e.gl.createTexture();const[r,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Bf(this.format),If(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:n}=i;n.bindTexture(n.TEXTURE_3D,this.texture),e!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.da=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.db=Sf,e.dc=hm,e.dd=Jf,e.de=yy,e.df=function(e,t){return e.readFields(qy,{icons:[]},t)},e.dg=Xp,e.dh=S_,e.di=C_,e.dj=Ot,e.dk=ys,e.dl=At,e.dm=Jt,e.dn=He,e.dp=function(e){const t=e.indexOf(ea);return t>=0?e.slice(0,t):e},e.dq=function(e){return e.indexOf(ea)>=0},e.dr=function(e){const t=e.lastIndexOf(ea);return t>=0?e.slice(t+1):""},e.ds=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.dt=function(e,t,i,n){return"custom"===e.type?new my(e,t):new Vy[e.type](e,t,i,n)},e.du=Ge,e.dv=function(e){const t=e.indexOf(ea);return t>=0?e.slice(t+1):""},e.dw=class extends Oy{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},e.state)),this.target=t.target,this.namespace=t.namespace,t.properties&&(this.properties=t.properties),this.target&&("featuresetId"in this.target&&!this.target.importId||"layerId"in this.target)&&(this.source=e.source,this.sourceLayer=e.sourceLayer,this.layer=e.layer)}toJSON(){const e=super.toJSON();return e.target=this.target,e.namespace=this.namespace,e}},e.dx=xs,e.dy=zt,e.dz=function(e){return e({pluginStatus:_s,pluginURL:As}),xs.on("pluginStateChange",e),e},e.e=st,e.e$=function([e,t,i]){const n=Math.hypot(e,t,i),r=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/n);return new rc(Ie(r),Ie(o))},e.e0=(e,t,i,n,r,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Yu(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:gt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:ah,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=n,c.u_merc_center=r,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const u=e.transform,h=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:Xm(e,t,i,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:r,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:Km(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:h,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}},e.e4=(e,t,i,n,r,o,s,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07;return{u_matrix:Xm(e,t,i,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:Ym(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Km(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:l,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:p,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:c}},e.e5=Ne,e.e6=Eh,e.e7=fc,e.e8=Pu,e.e9=_p,e.eA=Uy,e.eB=Xf,e.eC=Zf,e.eD=[1,1,1],e.eE=Ey,e.eF=K,e.eG=function(e,t,i,n){var r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},e.eH=Kf,e.eI=Ia,e.eJ=ja,e.eK=function(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m,g){var _=new i(16);return _[0]=e,_[1]=t,_[2]=n,_[3]=r,_[4]=o,_[5]=s,_[6]=a,_[7]=l,_[8]=c,_[9]=u,_[10]=h,_[11]=d,_[12]=p,_[13]=f,_[14]=m,_[15]=g,_},e.eL=ic,e.eM=Va,e.eN=Na,e.eO=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Te(1/0,1/0),max:new Te(-1/0,-1/0)}}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[]}get updateTime(){return this._updateTime}getReplacementRegionsForTile(e,t=!1){const i=Gd(new Te(0,0),new Te(Nn,Nn),e),n=[];if(t&&!Vd(i,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Vd(i,t))continue;const r=Hd(t.min,t.max,e);n.push({min:r.min,max:r.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return n}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const n=e.cache.getTile(i).buckets[e.layer];n&&n.updateFootprints(i.toUnwrapped(),t)}return t},getOrder:()=>e.order,getClipMask:()=>e.clipMask,getClipScope:()=>e.clipScope})))}_addSource(e){const t=e.getFootprints();if(0===t.length)return;const i=e.getOrder(),n=e.getClipMask(),r=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Gd(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,order:i,clipMask:n,clipScope:r})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Ud(e.min,t.min)||Ud(e.max,t.max)||e.order-t.order||e.clipMask-t.clipMask||function(e,t){const i=(e,t)=>e+t;return e.length-t.length||e.reduce(i,"").localeCompare(t.reduce(i,""))}(e.clipScope,t.clipScope));let e=this._activeRegions.length!==this._prevRegions.length;if(!e){let t=0;for(;!e&&t!==this._activeRegions.length;){const i=this._activeRegions[t],n=this._prevRegions[t];e=i.priority!==n.priority||!Nd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Ee(i.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Dd&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,e.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,e.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,e.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,e.max.y));const e=e=>{const t=this._activeRegions;if(e>=t.length)return e;const i=t[e].priority;for(;e1){let t=0,i=e(t);for(;t!==i;){let n=t;const r=t;for(;n!==i;){const e=this._activeRegions[n];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.eP=Dd,e.eQ=class{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 pa,n=new Fa,r=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let n=e===o-1?e-2:0===e?e:e-1;return n+=i?24575:0,[n,t]};for(let e=0;e0?(_=2*Math.sqrt(g+1),e[3]=.25*_,e[0]=(d-f)/_,e[1]=(p-c)/_,e[2]=(l-u)/_):a>h&&a>m?(_=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/_,e[0]=.25*_,e[1]=(l+u)/_,e[2]=(p+c)/_):h>m?(_=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/_,e[0]=(l+u)/_,e[1]=.25*_,e[2]=(d+f)/_):(_=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/_,e[0]=(p+c)/_,e[1]=(d+f)/_,e[2]=.25*_),e},e.ez=function(e,i){var n=2*Math.acos(i[3]),r=Math.sin(n/2);return r>t?(e[0]=i[0]/r,e[1]=i[1]/r,e[2]=i[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.f0=J,e.f1=Gf,e.f2=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==Ye){const t=e.navigator?e.navigator.userAgent:null;Ye=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ye}(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/)))},e.f3=function(e,t){vt=e,xt=t},e.f4=nh,e.f5=ih,e.f6=function(e){const t=[0,0,0],i=c(new Float64Array(16));return h(i,e.pixelMatrix,e.globeMatrix),j(t,t,i),new Te(t[0],t[1])},e.f7=function(){const e=qp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release($p),qp=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()"))},e.f8=function(){Xp().acquire($p)},e.f9=bs,e.fA=Mc,e.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==vf){const i=new Uint32Array(e,0,7),[,,n,r,o,s]=i;t=i.byteLength+r+o+s+o,(n!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.")}return Cf(e,t)},e.fC=function(e,t){const i=hm(e);for(const e of i){for(const t of e.meshes)dm(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(fm(e.lights,t)))}return i},e.fD=Ry,e.fE=Xe,e.fF=Hp,e.fG=Ts,e.fH=ms,e.fI=function(e){Ct(),null!=wt&&wt.then(t=>{t.keys().then(i=>{for(let n=0;nZe(e.message))}).catch(e=>Ze(e.message))}).catch(e=>Ze(e.message))},e.fa=function(e,t,i=!1){if(_s===ms.deferred||_s===ms.loading||_s===ms.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");As=gt.resolveURL(e),_s=ms.deferred,gs=t,vs(),i||ws()},e.fb=function(e){nf=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setMeshoptUrl",nf)},e.fc=uf,e.fd=function(e){ef=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setDracoUrl",ef)},e.fe=cf,e.ff=Qp,e.fg=function(e){const t=Et();if(!t)return;const i=t.delete(yt);e&&i.then(()=>e()).catch(e)},e.fh=Zp,e.fi=es,e.fj=bh,e.fk=E_,e.fl=Vx,e.fm=jx,e.fn=Nm,e.fo=Oc,e.fp="hd_road_elevation",e.fq=tu,e.fr=je,e.fs=ld,e.ft=v_,e.fu=A_,e.fv=function(e,t,i,n,r,o,s,a=1,l,c,u){e.createArrays(),e.tilePixelRatio=Nn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};p.scaleFactor=a,p.textSizeScaleRange=h.get("text-size-scale-range"),p.iconSizeScaleRange=h.get("icon-size-scale-range");const[f,m]=p.textSizeScaleRange,[g,_]=p.iconSizeScaleRange;p.textScaleFactor=Fe(p.scaleFactor,f,m),p.iconScaleFactor=Fe(p.scaleFactor,g,_);const A=d["text-size"],y=d["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[A.possiblyEvaluate(new Es(t,{worldview:u}),o),A.possiblyEvaluate(new Es(i,{worldview:u}),o)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[y.possiblyEvaluate(new Es(t,{worldview:u}),o),y.possiblyEvaluate(new Es(i,{worldview:u}),o)]}p.layoutTextSize=A.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.layoutIconSize=y.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.textMaxSize=A.possiblyEvaluate(new Es(18,{worldview:u}),o);const v=h.get("symbol-placement"),x="map"===h.get("text-rotation-alignment")&&"point"!==v,b=h.get("text-size");let w=!1;const T=[];for(const s of e.features){const a=h.get("text-font").evaluate(s,{},o).join(","),f=b.evaluate(s,{},o)*p.textScaleFactor,m=p.layoutTextSize.evaluate(s,{},o)*p.textScaleFactor,g=p.layoutIconSize.evaluate(s,{},o)*p.iconScaleFactor,_={horizontal:{},vertical:void 0},A=s.text;let y,E=[0,0];if(A){const n=A.toString(),c=h.get("text-letter-spacing").evaluate(s,{},o)*mg,u=h.get("text-line-height").evaluate(s,{},o)*mg,d=as(n)?c:0,p=h.get("text-anchor").evaluate(s,{},o),g=h.get("text-variable-anchor");if(!g){const e=h.get("text-radial-offset").evaluate(s,{},o);if(e)E=Q_(p,[e*mg,j_]);else{const e=h.get("text-offset").evaluate(s,{},o);E=[e[0]*mg,e[1]*mg]}}let y=x?"center":h.get("text-justify").evaluate(s,{},o);const b="point"===v,w=b?h.get("text-max-width").evaluate(s,{},o)*mg:1/0,T=o=>{e.allowVerticalPlacement&&ss(n)&&(_.vertical=Gg(A,t,i,r,a,w,u,p,o,d,E,Ng.vertical,!0,m,f,l))};if(!x&&g){const e="auto"===y?g.map(e=>eA(e)):[y];let n=!1;for(let o=0;o=0||!ss(n)){const e=Gg(A,t,i,r,a,w,u,p,y,d,E,Ng.horizontal,!1,m,f,l);e&&(_.horizontal[y]=e)}T(b?"left":y)}}let C,S,B,I,M,P,R=!1;const L=h.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){const t=q_(s.icon,e.iconSizeData,d["icon-size"],o,e.zoom,s,l,p.iconScaleFactor,u);C=t.iconPrimary,B=t.iconSecondary;const i=C.toString();if(S=n.get(i),S&&(M=h.get("icon-offset").evaluate(s,{},o),P=h.get("icon-anchor").evaluate(s,{},o),y=e_(r.get(i),B?r.get(B.toString()):void 0,M,P),R=S.sdf,void 0===e.sdfIcons?e.sdfIcons=S.sdf:e.sdfIcons!==S.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(S.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),B){const e=B.toString();I=n.get(e)}}w=w||!(!s.icon||!s.icon.hasSecondary());const F=sA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!F&&F.iconsInText);const k=m*p.textScaleFactor/mg,{defaultShapedIcon:D,verticallyShapedIcon:O}=tA(e,y,h,s,o,_,k,M,L);"none"!==L&&y&&(i_(y)||n_(y))&&(Z_(0,S,C,y,D,L,c,n,r),Z_(0,I,B,y,D,L,c,n,r),O&&(Z_(0,S,C,y,O,L,c,n,r),Z_(0,I,B,y,O,L,c,n,r))),y=D;const{iconBBox:z,iconVerticalBBox:U}=$_(e,y,O,h,s,o,g,M,p,r,P);T.push({feature:s,shapedTextOrientations:_,shapedText:F,shapedIcon:y,iconPrimary:C,iconSecondary:B,iconOffset:M,iconAnchor:P,verticallyShapedIcon:O,layoutTextSize:m,layoutIconSize:g,textOffset:E,isSDFIcon:R,iconTextFit:L,iconCollisionBounds:z,iconVerticalCollisionBounds:U})}return{featureData:T,sizes:p,hasAnySecondaryIcon:w,textAlongLine:x,symbolPlacement:v}},e.fw=x_,e.fx=function(e,t,i,n,r,o,s,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of u){const{shapedIcon:i,verticallyShapedIcon:o,feature:u,shapedTextOrientations:m,shapedText:g,layoutTextSize:_,textOffset:A,isSDFIcon:y,iconPrimary:v,iconSecondary:x,iconTextFit:b,iconOffset:w,iconCollisionBounds:T,iconVerticalCollisionBounds:E}=t;X_(i,c.iconPositions,v,x),X_(o,c.iconPositions,v,x),J_(m,c.iconPositions),K_(v,x,c.iconPositions),(g||i)&&iA(e,u,m,i,o,l,d,_,0,A,y,n,r,s,a,h,b,w,p,f,T,E)}i&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray,d.textScaleFactor)},e.fy=kc,e.fz=Wv,e.g=function(e,t){return zt(Object.assign(e,{method:"GET"}),t)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return st.API_STYLE_REGEX.test(e)&&!lt(e)},e.j=at,e.k=Bt,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return zt(Object.assign(e,{type:"json"}),t)},e.n=Ht,e.o=gt,e.p=function(e,t){return zt(Object.assign(e,{method:"POST"}),t)},e.q=wh,e.r=mt,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=function(){return Kp||(Kp=new Zp),Kp},e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(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)},e.w=Ze,e.x=Dv,e.y=ei,e.z=Yt}),n(["./shared"],function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const n of e)t+=`${i(n)},`;return`${t}]`}let t="{";for(const n of Object.keys(e).sort())t+=`${n}:${i(e[n])},`;return`${t}}`}function n(t){let n="";for(const r of e.bw)n+=`/${i(t[r])}`;return n}class r{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,r,o){this._options=o;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.dt(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const r={};for(let o=0;othis._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}const o=1*e.fk;class s{constructor(t){const i={},n=[];for(const e in t){const r=t[e],s=i[e]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};n.push(a),s[e]=a}}const{w:r,h:s}=e.G(n),a=new e.fj({width:r||1,height:s||1});for(const n in t){const r=t[n];for(const t in r.glyphs){const s=r.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][t],c=s.metrics.localGlyph?o:1;e.fj.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}function a(e,t,i){e[t]?i&&(e[t].center=i):e[t]={floorIds:new Set,center:i||[0,0],floors:{}}}function l(e,t,i,n){for(const r of t)a(e,r),e[r].floors[i]=n,e[r].floorIds.add(i)}function c(e){return{id:e.properties.id.toString(),center:e.properties.center.toString().split(";").map(Number)}}function u(e){return{id:e.properties.id.toString(),isDefault:!!e.properties.is_default&&e.properties.is_default,connections:e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:e.properties.building_ids?new Set(e.properties.building_ids.toString().split(";")):new Set,name:e.properties.name.toString(),zIndex:e.properties.z_index}}function h(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function d(e){return h(e,["type","id","name"])&&"building"===e.properties.type}function p(e){return h(e,["type","id","name","z_index"])&&"floor"===e.properties.type}e.fi(s,"GlyphAtlas");class f{constructor(t){this.tileID=new e.aP(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.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor}parse(t,i,n,r,o,h){this.status="parsing",this.data=t,this.collisionBoxArray=new e.b2;const f=new e.fl(Object.keys(t.layers).sort()),g=new e.fm(this.tileID,this.promoteId);g.bucketLayerIDs=[];const _={},A=new e.fn(256,256),y={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:A,availableImages:n,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const i=this.indoor.indoorState.activeFloorsVisible,n=function(t,i,n){const r=function(t,i){if(!t)return e.w("No source layers defined in indoor specification"),i;if(0===t.size)return i;const n=t.difference(i);for(const t of n)e.w(`Missing source layer required in indoor specification: ${t}`);return i.intersection(i)}(i.sourceLayers,new Set(Object.keys(t.layers))),o=i.indoorState,s=function(t,i,n,r){const o=new Set,s=new Set,h=new Set,f=new Map,m={},g=e=>{const t=f.get(e)||new Set;for(const i of o)if((f.get(i)||new Set).has(e)||t.has(i))return!0;return!1};for(const n of i){const i=t.layers[n];if(i)for(let e=0;e=i.maxzoom)continue;if("none"===i.visibility)continue;m(t,this.zoom,y.brightness,n,this.worldview);const o=_[i.id]=i.createBucket({index:g.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:c,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:r,worldview:this.worldview});g.bucketLayerIDs.push(t.map(t=>e.B(t.id,t.scope)));let s=o.prepare?o.prepare():null;null!=s?(s=s.then(()=>o.populate(u,y,this.tileID.canonical,this.tileTransform)),v.push(s)):o.populate(u,y,this.tileID.canonical,this.tileTransform)}}const b=()=>{let i,r,a,l,c,u;A.trim();const d={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},p=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster)this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:y.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(r&&a&&l){const t=new s(r),i=new Map;for(const[t,n]of a.entries()){const{imagePosition:r}=e.ft(t,n,e.fu);i.set(t,r)}const h={};for(const o in _){const s=_[o];s instanceof e.b3&&(m(s.layers,this.zoom,y.brightness,n,this.worldview),h[o]=e.fv(s,r,t.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,c,this.worldview))}const d={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(o,a,c,()=>{d.iconsPending=!1,v(h,t,d)}),this.rasterizeIfNeeded(o,l,u,()=>{d.patternsPending=!1,v(h,t,d)})}},v=(t,i,r,o)=>{if(r.iconsPending||r.patternsPending)return;const s=new e.fw(a,l,this.lut);for(const i in _){const r=_[i];if(i in t)e.fx(r,t[i],this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,s);else if(r.hasPattern&&(r instanceof e.b9||r instanceof e.ba||r instanceof e.e9)){m(r.layers,this.zoom,y.brightness,n,this.worldview);const e=Object.fromEntries(s.patternPositions);r.addFeatures(y,this.tileID.canonical,e,n,this.tileTransform,this.brightness)}}this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:A,imageAtlas:s,brightness:y.brightness})};if(!this.extraShadowCaster){const t=e.fr(y.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{i||(i=e,r=t,p())},void 0,!1,d):r={};const n=Array.from(y.iconDependencies.keys()).map(t=>e.I.parse(t));n.length?o.send("getImages",{images:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{i||(i=e,a=new Map,c=this.updateImageMapAndGetImageTaskQueue(a,t,y.iconDependencies),p())},void 0,!1,d):(a=new Map,c=new Map);const s=Array.from(y.patternDependencies.keys()).map(t=>e.I.parse(t));s.length?o.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{i||(i=e,l=new Map,u=this.updateImageMapAndGetImageTaskQueue(l,t,y.patternDependencies),p())},void 0,!1,d):(l=new Map,u=new Map)}if(y.elevationFeatures&&y.elevationFeatures.length>0){const i=[];for(const t of Object.values(_))if(t instanceof e.ba){const e=t.getUnevaluatedPortalGraph();e&&i.push(e)}const n=e.fs.evaluate(i);for(const i of Object.values(_))if(i instanceof e.ba){const e=t.layers[f.decode(i.sourceLayerIndex)];i.setEvaluatedPortalGraph(n,e,this.tileID.canonical,y.availableImages,y.brightness)}}p()};v.length>0?Promise.allSettled(v).then(b).catch(h):b()}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor}rasterizeIfNeeded(e,t,i,n){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,i,n):n()}updateImageMapAndGetImageTaskQueue(e,t,i){const n=new Map;for(const r of t.keys()){const o=i.get(r)||[];for(const i of o){const r=i.toString(),o=t.get(i.id.toString());o.usvg?n.has(r)||(n.set(r,i),e.set(r,Object.assign({},o))):e.set(r,o)}}return n}rasterize(e,t,i,n){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:i},(e,i)=>{if(!e)for(const[e,n]of i.entries()){const i=Object.assign(t.get(e),{data:n});t.set(e,i)}n()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function m(t,i,n,r,o){const s=new e.ac(i,{brightness:n,worldview:o});for(const e of t)e.recalculate(s,r)}class g extends e.E{constructor(t,i,n,r,o,s,a){super(),this.actor=t,this.layerIndex=i,this.availableImages=n,this.availableModels=r,this.loadVectorData=s||e.aL,this.loading={},this.loaded={},this.deduped=new e.aK(t.scheduler),this.isSpriteLoaded=o,this.scheduler=t.scheduler,this.brightness=a}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[r]=new f(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[r];if(delete this.loading[r],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[r]=a),n(l);const h=c.rawData,d={},p=e.aM(c.responseHeaders);p&&p.expires&&(d.expires=p.expires),p&&p.cacheControl&&(d.cacheControl=p.cacheControl),a.vectorTile=c.vectorTile||new e.fy(new e.bs(h));const f=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,i)=>{if(e||!i)return n(e);const r={};if(s){const e=t(o);e.length>0&&(r.resourceTiming=JSON.parse(JSON.stringify(e)))}n(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},i,d,r))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):f()}),this.loaded=this.loaded||{},this.loaded[r]=a})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.updateParameters(e);const o=(e,i)=>{const n=r.reloadCallback;n&&(delete r.reloadCallback,r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n)),t(e,i)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&(r.vectorTile?r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o):o())}else t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class _{loadTile(t,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.fz(n,a,r,s<1))}reloadTile(e,t){t(null,null)}abortTile(e,t){t()}removeTile(e,t){t()}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 i=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),i}}e.br.setPbf(e.bs);class A{constructor(t){this._mrt=new e.br(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source}parse(t,i){const n=this._mrt;this.status="parsing",this._entireBuffer=t;try{n.parseHeader(t),this._isHeaderLoaded=!0;const r=[];for(const i in n.layers){const o=n.getLayer(i),s=o.getDataRange(o.getBandList()),a=n.createDecodingTask(s),l=t.slice(s.firstByte,s.lastByte+1),c=e.br.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));r.push(c)}Promise.allSettled(r).then(()=>i(null,n)).catch(e=>i(e))}catch(e){i(e)}}}class y{constructor(e){this.actor=e,this.loading={},this.loaded={}}loadTile(t,i){const n=t.uid,r=t.request,o=this.loading[n]=new A(t),{cancel:s}=e.bt(r,(e,t,r)=>{const s=!this.loading[n];if(delete this.loading[n],s||e||!t)return o.status="done",s||(this.loaded[n]=o),i(e);o.parse(t,(e,t)=>{if(e||!t)return i(e);i(null,t,r)}),this.loaded[n]=o});o.abort=s}reloadTile(e,t){t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=e.uid;this.loaded[i]&&delete this.loaded[i],t()}decodeRasterArray(t,i){e.br.performDecoding(t.buffer,t.task).then(e=>i(null,e)).catch(e=>i(e))}}const v=e.fA.prototype.toGeoJSON;class x{constructor(t){this._feature=t,this.extent=e.al,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 i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const n=[];for(const t of i)n.push(new e.P(t[0],t[1]));t.push(n)}return t}}toGeoJSON(e,t,i){return v.call(this,e,t,i)}}class b{constructor(t,i){this.name=t,this.extent=e.al,this.length=i.length,this._jsonFeatures=i}feature(e){return new x(this._jsonFeatures[e])}}class w{constructor(t){this.layers={},this.extent=e.al;for(const e of Object.keys(t))this.layers[e]=new b(e,t[e])}}const T=64/4096,E=128;class C{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let n=this.features.get(e);n&&this.updateCache(n,t),i.geometry?(n=B(i),this.updateCache(n,t),this.features.set(e,n)):this.features.delete(e),this.updateCache(n,t)}}updateCache(e,t){for(const{canonical:i,uid:n}of Object.values(t)){const{z:r,x:o,y:s}=i;S(e,Math.pow(2,r),o,s)&&delete t[n]}}getTile(e,t,i){const n=Math.pow(2,e),r=[];for(const e of this.features.values())S(e,n,t,i)&&r.push(R(e,n,t,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function S({minX:e,minY:t,maxX:i,maxY:n},r,o,s){return e<(o+1+T)/r&&t<(s+1+T)/r&&i>(o-T)/r&&n>(s-T)/r}function B(e){const{id:t,geometry:i,properties:n}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)I(o,a,s);else if("MultiPoint"===r)for(const e of o)I(e,a,s);else if("LineString"===r)s.type=2,M(o,a,s);else if("MultiLineString"===r)s.type=2,P(o,a,s);else if("Polygon"===r)s.type=3,P(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)P(e,a,s,!0)}return s}function I([t,i],n,r){const o=e.aF(t);let s=e.aJ(i);s=s<0?0:s>1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function M(e,t,i,n=!1,r=!1){const o=[];for(const t of e)I(t,o,i);t.push(o),n&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(m*((a-u)/f)),u=a):d>=a&&(p=h+Math.round(m*((a-u)/f)),d=a),h>=a&&p>=a||(h>=a?(u+=Math.round(f*((a-h)/m)),h=a):p>=a&&(d=u+Math.round(f*((a-h)/m)),p=a),l&&u===l[l.length-1][0]&&h===l[l.length-1][1]||(l=[[u,h]],o.push(l)),l.push([d,p])))))}}function F({name:t,features:i},n){n.writeStringField(1,t),n.writeVarintField(5,e.al);const r=new Map,o=new Map,s={keys:r,values:o,feature:null};for(const e of i)s.feature=e,n.writeMessage(2,k,s);for(const e of r.keys())n.writeStringField(3,e);for(const e of o.keys())n.writeMessage(4,N,e)}function k(e,t){const i=e.feature;void 0!==i.id&&Number.isSafeInteger(+i.id)&&t.writeVarintField(1,+i.id),i.tags&&t.writeMessage(2,D,e),t.writeVarintField(3,i.type),t.writeMessage(4,U,i)}function D({keys:e,values:t,feature:i},n){for(const r of Object.keys(i.tags)){let o=i.tags[r];if(null===o)continue;let s=e.get(r);void 0===s&&(s=e.size,e.set(r,s)),n.writeVarint(s);const a=typeof o;"string"!==a&&"boolean"!==a&&"number"!==a&&(o=JSON.stringify(o));let l=t.get(o);void 0===l&&(l=t.size,t.set(o,l)),n.writeVarint(l)}}function O(e,t){return(t<<3)+(7&e)}function z(e){return e<<1^e>>31}function U(e,t){const{geometry:i,type:n}=e;let r=0,o=0;if(1===n){t.writeVarint(O(1,i.length));for(const e of i){const i=e[0]-r,n=e[1]-o;t.writeVarint(z(i)),t.writeVarint(z(n)),r+=i,o+=n}}else for(const e of i){t.writeVarint(O(1,1));const i=e.length-(3===n?1:0);for(let n=0;ne},j=Math.fround||(G=new Float32Array(1),e=>(G[0]=+e,G[0]));var G;const H=3,Q=5,$=6;class Z{constructor(e){this.options=Object.assign(Object.create(V),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(K(i),X(o),K(r),X(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+Q]>1?W(l,t,this.clusterProps):this.points[l[t+H]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+Q]>1?W(o,i,this.clusterProps):this.points[o[i+H]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=q(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+H]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),u=X(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+H]:this.points[t[e+H]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+Q])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+Q];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+Q]>1){const n=this.clusterProps[e[t+$]];return i?Object.assign({},n):n}const n=this.points[e[t+H]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function W(e,t,i){return{type:"Feature",id:e[t+H],properties:q(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),J(e[t+1])]}};var n}function q(e,t,i){const n=e[t+Q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+$],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+H],point_count:n,point_count_abbreviated:r})}function K(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Y(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&Y(e,t,s,n),e[s+2]=r,i-s>3&&Y(e,s,i,n))}function ee(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function te(e,t,i,n){const r={id:e??null,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ie(r,i);else if("Polygon"===t)ie(r,i[0]);else if("MultiLineString"===t)for(const e of i)ie(r,e);else if("MultiPolygon"===t)for(const e of i)ie(r,e[0]);return r}function ie(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,Y(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function se(e,t,i,n){for(let r=0;r1?1:i}function ce(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)ue(e,u,i,n,r);else if("LineString"===o)he(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)pe(e,u,i,n,r,!1);else if("Polygon"===o)pe(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];pe(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(te(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(te(t.id,o,u,t.tags))}}return l.length?l:null}function ue(e,t,i,n,r){for(let o=0;o=i&&s<=n&&fe(t,e[o],e[o+1],e[o+2])}}function he(e,t,i,n,r,o,s){let a=de(e);const l=0===r?me:ge;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=de(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&fe(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&fe(a,a[0],a[1],a[2]),a.length&&t.push(a)}function de(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pe(e,t,i,n,r,o){for(const s of e)he(s,t,i,n,r,o,!1)}function fe(e,t,i,n){e.push(t,i,n)}function me(e,t,i,n,r,o){const s=(o-t)/(n-t);return fe(e,o,i+(r-i)*s,1),s}function ge(e,t,i,n,r,o){const s=(o-i)/(r-i);return fe(e,t+(n-t)*s,o,1),s}function _e(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=xe(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=ce(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=ce(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=ce(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=ce(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=ce(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=ce(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Ce(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ye(this.tiles[a],r):null):null}}function Ce(e,t,i){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,s=r.features.filter(e=>o(e));let a={_geojsonTileLayer:r.features};s.length>0&&(a={_geojsonTileLayer:r.features.filter(e=>!o(e)),hd_road_elevation:s});const l=new w(a),c=function(t){const i=new e.bs;for(const e of Object.keys(t))i.writeMessage(3,F,{name:e,features:t[e]});return i.finish()}(a).buffer;i(null,{vectorTile:l,rawData:c})}class Be extends g{constructor(e,t,i,n,r,o,s){super(e,t,i,n,r,Se,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new C}loadData(i,n){const r=i&&i.request,o=r&&r.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(i,(s,a)=>{if(s||!a)return n(s);if("object"!=typeof a)return n(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>t.value.evaluate({zoom:0},e))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new Z(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.U(s),l=e.U("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(a.features):i.dynamic?this._dynamicIndex:function(e,t){return new Ee(e,t)}(a,i.geojsonVtOptions)}catch(e){return n(e)}const s={};if(o){const e=t(r);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}n(null,s)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.m(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}},0)}}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 Ie{constructor(t,i,n){this.tileID=new e.aP(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=i,this.worldview=n}parse(t,i,n,r){this.status="parsing";const o=new e.aP(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),s=[],a=i.familiesBySource[n.source],l=new e.fm(o,n.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,e.fB(t).then(t=>{if(!t)return r(new Error("Could not parse tile"));const i=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const r in a)for(const h of a[r]){const r=h[0];l.bucketLayerIDs.push(h.map(t=>e.B(t.id,t.scope))),r.recalculate(u,[]);const a=e.fC(t,1/e.d6(n.tileID.canonical)),d=new e.fD(h,a,o,i,c,this.brightness,l,this.worldview);i||(d.needsUpload=!0),s.push(d),d.evaluate(r)}this.status="done",r(null,{buckets:s,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>r(new Error(e.message)))}}class Me{constructor(e,t,i,n,r,o,s,a){this.actor=e,this.layerIndex=t,this.availableImages=i,this.availableModels=n,this.brightness=s,this.loading={},this.loaded={},this.worldview=a}loadTile(t,i){const n=t.uid,r=this.loading[n]=new Ie(t,this.brightness,this.worldview);e.bt(t.request,(e,o)=>{const s=!this.loading[n];return delete this.loading[n],s||e?(r.status="done",s||(this.loaded[n]=r),i(e)):o&&0!==o.byteLength?void r.parse(o,this.layerIndex,t,(e,t)=>{r.status="done",this.loaded=this.loaded||{},this.loaded[n]=r,e||!t?i(e):i(null,t)}):(r.status="done",this.loaded[n]=r,i())})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.projection=e.projection,r.brightness=e.brightness;const o=(i,n)=>{r.reloadCallback&&(delete r.reloadCallback,this.loadTile(e,t)),t(i,n)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class Pe{constructor(t){this.self=t,this.actor=new e.fF(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cl({name:"mercator"}),this.workerSourceTypes={vector:g,geojson:Be,"raster-dem":_,"raster-array":y,"batched-model":Me},this.workerSources={},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.fG.isParsed())throw new Error("RTL text plugin already registered.");e.fG.setState({pluginStatus:e.fH.parsed,pluginURL:e.fG.getPluginURL()}),e.fG.applyArabicShaping=t.applyArabicShaping,e.fG.processBidirectionalText=t.processBidirectionalText,e.fG.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:n,isLoaded:r}=i;if(this.isSpriteLoaded[t][n]=r,this.workerSources[t]&&this.workerSources[t][n])for(const i in this.workerSources[t][n]){const o=this.workerSources[t][n][i];for(const t in o){const i=o[t];i instanceof g&&(i.isSpriteLoaded=r,i.fire(new e.z("isSpriteLoaded")))}}}setImages(e,t,i){this.availableImages[e]||(this.availableImages[e]={});const{scope:n,images:r}=t;if(this.availableImages[e][n]=r,this.workerSources[e]&&this.workerSources[e][n]){for(const t in this.workerSources[e][n]){const i=this.workerSources[e][n][t];for(const e in i)i[e].availableImages=r}i()}else i()}setModels(e,{scope:t,models:i},n){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const n in this.workerSources[e][t]){const r=this.workerSources[e][t][n];for(const e in r)r[e].availableModels=i}n()}else n()}setProjection(t,i){this.projections[t]=e.cl(i)}setBrightness(e,t,i){this.brightness=t,i()}setWorldview(e,t,i){this.worldview=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){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 n=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,n){if(e.fG.isParsed())n(null,!0);else if(e.fG.isParsing())this.rtlPluginParsingListeners.push(n);else try{e.fG.setState(i);const t=e.fG.getPluginURL();!e.fG.isLoaded()||e.fG.isParsed()||e.fG.isParsing()||null==t||(e.fG.setState({pluginStatus:e.fH.parsing,pluginURL:e.fG.getPluginURL()}),this.self.importScripts(t),e.fG.isParsed()?n(null,!0):this.rtlPluginParsingListeners.push(n))}catch(e){n(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let i=this.availableModels[e][t];return i||(i={}),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new r,i.scope=t),i}getWorkerSource(e,t,i,n){const r=this.workerSources;return r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][t]||(r[e][n][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),r[e][n][t][i]||(r[e][n][t][i]=new this.workerSourceTypes[t]({send:(t,i,n,r,o,s)=>this.actor.send(t,i,n,e,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(e,n),this.getAvailableImages(e,n),this.getAvailableModels(e,n),this.isSpriteLoaded[e][n],void 0,this.brightness,this.worldview)),r[e][n][t][i]}rasterizeImagesWorker(e,t,i){const n=new Map;for(const[i,{image:r,imageVariant:o}]of t.tasks.entries()){const s=this.imageRasterizer.rasterize(o,r,t.scope,e);n.set(i,s)}i(void 0,n)}removeRasterizedImages(e,t,i){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),i()}enforceCacheSizeLimit(t,i){e.fI(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return e.fE(self)&&(self.worker=new Pe(self)),Pe}),n(["./shared"],function(e){var t="3.16.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},n={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function r(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var o,s={},a=function(){if(o)return s;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(i);try{t=new Worker(n),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(n),e}()?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===i[n=t&&t.failIfMajorPerformanceCaveat]&&(i[n]=function(t){var i,n=function(t){var i=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",n)}(t);if(!n)return!1;try{i=n.createShader(n.VERTEX_SHADER)}catch(e){return!1}return!(!i||n.isContextLost())&&(n.shaderSource(i,"void main() {}"),n.compileShader(i),!0===n.getShaderParameter(i,n.COMPILE_STATUS))}(n)),i[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var n}o=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const n=document.createElement(e);return null!=t&&(n.className=t),i&&i.appendChild(n),n}function c(e,t,i){const n=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))n.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(n),n}const u="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,h=u&&void 0!==u.userSelect?"userSelect":"WebkitUserSelect";let d;function p(){u&&h&&(d=u[h],u[h]="none")}function f(){u&&h&&(u[h]=d)}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0)}function g(){window.addEventListener("click",m,!0),window.setTimeout(()=>{window.removeEventListener("click",m,!0)},0)}function _(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function A(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;rthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,n){if(!e.h(i))return i;const r=E(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||n)}normalizeGlyphsURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/models/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeSourceURL(t,i,n,r){if(!e.h(t))return t;const o=E(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),n&&o.params.push(`language=${n}`),r&&o.params.push(`worldview=${r}`),this._makeAPIURL(o,this._customAccessToken||i)}normalizeIconsetURL(t,i){const n=E(t);return e.h(t)?(n.path=`/styles/v1${n.path}/iconset.pbf`,this._makeAPIURL(n,this._customAccessToken||i)):C(n)}normalizeSpriteURL(t,i,n,r){const o=E(t);return e.h(t)?(o.path=`/styles/v1${o.path}/sprite${i}${n}`,this._makeAPIURL(o,this._customAccessToken||r)):(o.path+=`${i}${n}`,C(o))}normalizeTileURL(t,i,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.h(t))return t;const r=E(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||n&&"raster"!==r.authority&&512===n?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.e.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.e.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${e.e.TILE_URL_VERSION}${r.path}`);const o=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,o)}canonicalizeTileURL(t,i){const n=E(t);if(!n.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!n.path.match(/\.[\w]+$/))return t;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+=`raster/${n.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:n.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${n.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${n.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=n.params;return i&&(o=o.filter(e=>!e.match(/^access_token=/))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,i){const n=!!i&&e.h(i),r=[];for(const i of t.tiles||[])e.j(i)?r.push(this.canonicalizeTileURL(i,n)):r.push(i);return r}_makeAPIURL(t,i){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=E(e.e.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return C(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),C(t)}}const T=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function E(e){const t=e.match(T);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 C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const S="mapbox.eventData";function B(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}class I{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=B(e.e.ACCESS_TOKEN);let n="";return n=i&&i.u?e.f(i.u):e.e.ACCESS_TOKEN||"",t?`${S}.${t}:${n}`:`${S}:${n}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(n);t&&(this.anonId=t);const o=localStorage.getItem(r);o&&(this.anonIdTimestamp=Number(o));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString())}catch(t){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(t,i,n,r){if(!e.e.EVENTS_URL)return;const o=E(e.e.EVENTS_URL);o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:C(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const M=new class extends I{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(t,i){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(t=>e.h(t)||e.j(t))&&this.queueRequest(Date.now(),i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=B(e.e.ACCESS_TOKEN),r=n?n.u:e.e.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),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:t,skuId:x,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)},i):this.processRequests()}},P=M.postTurnstileEvent.bind(M),R=new class extends I{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.EVENTS_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:n,timestamp:r}=this.queue.shift();n&&this.success[n]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):n&&(this.success[n]=!0)},i))}remove(){this.errorCb=null}},L=R.postMapLoadEvent.bind(R),F=new class extends I{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:n,style:r,importedStyles:o}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const s=this.getMapInstanceId(n),a={mapInstanceId:s,eventId:this.getEventId(s),style:r};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},k=F.postStyleLoadEvent.bind(F),D=new class extends I{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(t){if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),O=D.postMetricsEvent.bind(D),z=new class extends I{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(n){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:o,performanceData:s}=this.queue.shift(),a=function(n){const o=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const n of e[i]){const e=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,n.startTime),t[r]=Math.max(t[r]||-1/0,n.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(o)}return t}(function(e,t){const i={};if(e)for(const n of e){const e=t(n);void 0===i[e]&&(i[e]=[]),i[e].push(n)}return i}(o,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,u=c?c.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in a)d(h.counters,e,a[e]);if(n.interactionRange[0]!==1/0&&n.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",n.interactionRange[0]),d(h.counters,"interactionRangeMax",n.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&d(h.counters,e,t.startTime)}return d(h.counters,"visibilityHidden",n.visibilityHidden),d(h.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(o)),d(h.attributes,"terrainEnabled",n.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",n.fogEnabled?"true":"false"),d(h.attributes,"projection",n.projection),d(h.attributes,"zoom",n.zoom),d(h.metadata,"devicePixelRatio",l),d(h.metadata,"connectionEffectiveType",u),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",n.width/l),d(h.metadata,"mapHeight",n.height/l),d(h.metadata,"webglRenderer",n.renderer),d(h.metadata,"webglVendor",n.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(o,a,()=>{},n)}},U=z.postPerformanceEvent.bind(z),N=new class extends I{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,n,r){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const o=E(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${i||""}`),o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={url:C(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.SESSION_PATH&&e.e.API_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}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)}remove(){this.errorCb=null}},V=N.getSessionAPI.bind(N),j=new Set;function G(e,t){t?j.add(e):j.delete(e)}class H{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}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(e){return this._updatedImages[e]?Array.from(this._updatedImages[e].values()):[]}updateImage(t,i){this._updatedImages[i]=this._updatedImages[i]||new Set,this._updatedImages[i].add(e.I.toString(t)),this.setDirty()}resetUpdatedImages(e){this._updatedImages[e]&&this._updatedImages[e].clear()}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Q(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class $ extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=new Map,this.loaded=new Map,this.requestors=[],this.patterns=new Map,this.patternsInFlight=new Set,this.atlasImage=new Map,this.atlasTexture=new Map,this.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.r()&&(this.imageRasterizerDispatcher=new e.D(e.t(),this,"Image Rasterizer Worker",1))}addScope(t){this.loaded.set(t,!1),this.imageProviders.set(t,new Map),this.images.set(t,new Map),this.updatedImages.set(t,new Set),this.callbackDispatchedThisFrame.set(t,new Set),this.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({width:1,height:1}))}removeScope(e){this.loaded.delete(e),this.imageProviders.delete(e),this.images.delete(e),this.updatedImages.delete(e),this.callbackDispatchedThisFrame.delete(e),this.patterns.delete(e),this.atlasImage.delete(e);const t=this.atlasTexture.get(e);t&&(t.destroy(),this.atlasTexture.delete(e))}addImageProvider(e,t){this.imageProviders.has(t)||this.imageProviders.set(t,new Map),this.imageProviders.get(t).set(e.id,e)}removeImageProvider(e,t){this.imageProviders.has(t)&&this.imageProviders.get(t).delete(e)}getPendingImageProviders(){const e=[];for(const t of this.imageProviders.values())for(const i of t.values())i.hasPendingRequests()&&e.push(i);return e}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.x),this._imageRasterizer}isLoaded(){for(const e of this.loaded.keys())if(!this.loaded.get(e))return!1;return!0}setLoaded(e,t){if(this.loaded.get(t)!==e&&(this.loaded.set(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.get(t).get(e.toString())}addImage(e,t,i){this._validate(e,i)&&this.images.get(t).set(e.toString(),i)}_validate(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]e.I.from(t))}getImages(e,t,i){const n=[],r=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){n.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i))}if(0===n.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of n)l.has(e.toString())||(s=!1);a||s?this._notify(n,t,i):this.requestors.push({ids:n,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:n,scope:r}=e;for(const[e,t]of n.entries()){const n=this.getImage(t.id,r);n&&i.set(e,{image:n,imageVariant:t})}this._rasterizeImages(r,i,t)}_rasterizeImages(t,i,n){if(e.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},n);else{const e=new Map;for(const[n,{image:r,imageVariant:o}]of i.entries())e.set(n,this.imageRasterizer.rasterize(o,r,t,0));n(void 0,e)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,n){const r=this.images.get(i),o=new Map;for(const i of t){if(!r.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.z("styleimagemissing",{id:i.name}))}const t=r.get(i.toString());if(!t){e.w(`Image "${i.name}" 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.`);continue}const n={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(n,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),o.set(e.I.toString(i),n)}n(null,o)}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(t,i,n){const r=t.toString(),o=this.patterns.get(i),s=o.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version}else{if(a.usvg&&!a.data){const o=this.getPatternInFlightId(r,i);if(this.patternsInFlight.has(o))return null;this.patternsInFlight.add(o);const s=new e.A(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(s,i,a,n,t)),null}this.storePattern(t,i,a)}return this._updatePatternAtlas(i,n),o.get(r).position}getPatternInFlightId(t,i){return e.B(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,n,r){const o=e.toString(),s=r?r.get(o):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,n),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(t,i,n){const r={w:n.data.width+2*e.C,h:n.data.height+2*e.C,x:0,y:0},o=new e.F(r,n,e.C);this.patterns.get(i).set(t.toString(),{bin:r,position:o})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(t,i){const n=t.gl;let r=this.atlasTexture.get(i);r?this.dirty&&(r.update(this.atlasImage.get(i)),this.dirty=!1):(r=new e.T(t,this.atlasImage.get(i),n.RGBA8),this.atlasTexture.set(i,r)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const n=this.patterns.get(t),r=Array.from(n.values()).map(({bin:e})=>e),{w:o,h:s}=e.G(r),a=this.atlasImage.get(t);a.resize({width:o||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:o}]of n.entries()){let n=o.padding;const s=r.x+n,c=r.y+n,u=l.get(t).data,h=u.width,d=u.height;n=n>1?n-1:n,e.q.copy(u,a,{x:0,y:0},{x:s,y:c},{width:h,height:d},i),e.q.copy(u,a,{x:0,y:d-n},{x:s,y:c-n},{width:h,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s,y:c+d},{width:h,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:h-n,y:d-n},{x:s-n,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:d-n},{x:s+h,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c+d},{width:n,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c+d},{width:n,height:n},i)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const n of e){if(this.callbackDispatchedThisFrame.get(t).has(n.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(n.toString());const e=i.get(n.toString());Q(e)&&this.updateImage(n,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Z(t){const i=t.value,n=t.valueSpec,r=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||me;if(!Array.isArray(i))return[new e.V(s,i,`array expected, ${e.K(i)} found`)];if(n.length&&i.length!==n.length)return[new e.V(s,i,`array length ${n.length} expected, length ${i.length} found`)];if(n["min-length"]&&i.lengtho)return[new e.V(i,n,`${n} is greater than the maximum value ${o}`)]}return[]}function q(t){const i=t.key,n=t.value;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];const r=t.valueSpec,o=e.J(n.type);let s,a,l,c={};const u="categorical"!==o&&void 0===n.property,h=!u,d=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.H(i[0][0])}(n),p=ge({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat(Z({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),Array.isArray(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return me({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&u&&p.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||n.stops||p.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&r.expression&&!e.M(r)&&p.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!e.N(r)?p.push(new e.V(t.key,t.value,"property functions not supported")):u&&!e.O(r)&&p.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!d||void 0!==n.property||p.push(new e.V(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const n=t.value,o=t.key;if(!Array.isArray(n))return[new e.V(o,n,`array expected, ${e.K(n)} found`)];if(2!==n.length)return[new e.V(o,n,`array length 2 expected, length ${n.length} found`)];if(d){if(!e.H(n[0]))return[new e.V(o,n,`object expected, ${e.K(n[0])} found`)];const r=n[0];if(void 0===r.zoom)return[new e.V(o,n,"object stop key must have zoom")];if(void 0===r.value)return[new e.V(o,n,"object stop key must have value")];const s=e.J(r.zoom);if("number"!=typeof s)return[new e.V(o,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return[new e.V(o,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(ge({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:m}}))}else i=i.concat(m({key:`${o}[0]`,value:n[0],style:t.style,styleSpec:t.styleSpec},n));return e.Q(e.S(n[1]))?i.concat([new e.V(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(me({key:`${o}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const n=e.K(t.value),l=e.J(t.value),u=null!==t.value?t.value:i;if(s){if(n!==s)return[new e.V(t.key,u,`${n} stop domain type must match previous stop domain type ${s}`)]}else s=n;if("number"!==n&&"string"!==n&&"boolean"!==n&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==n&&"categorical"!==o){let i=`number expected, ${n} found`;return e.N(r)&&void 0===o&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,i)]}return"categorical"!==o||"number"!==n||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===n&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew e.V(`${t.key}${i.key}`,t.value,i.message));const n=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new e.V(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!e.Z(n))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return X(n,t);if("appearance"===t.expressionContext)return J(n,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(n,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(n))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function X(t,i){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.delete(e);if(0===n.size)return[];const r=[];return t instanceof e._&&n.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)]:(t.eachChild(e=>{r.push(...X(e,i))}),r)}function J(t,i){const n=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.add(e);if(0===n.size)return[];const r=[];return t instanceof e._&&!n.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{r.push(...J(e,i))}),r)}function Y(t){const i=t.key,n=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),o}function ee(t){return e.a2(e.S(t.value))?K(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):te(t)}function te(t){const i=t.value,n=t.key;if(!Array.isArray(i))return[new e.V(n,i,`array expected, ${e.K(i)} found`)];if(i.length<1)return[new e.V(n,i,"filter array must have at least 1 element")];const r=t.styleSpec;let o=Y({key:`${n}[0]`,value:i[0],valueSpec:r.filter_operator});switch(e.J(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.J(i[1])&&o.push(new e.V(n,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&o.push(new e.V(n,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(e.a0(i[1])||o.push(new e.V(`${n}[1]`,i[1],`string expected, ${e.K(i[1])} found`)));for(let t=2;t{t in n&&i.push(new e.V(r,n[t],`"${t}" is prohibited for ref layers`))}),o.layers.forEach(i=>{e.J(i.id)===l&&(t=i)}),t?t.ref?i.push(new e.V(r,n.ref,"ref cannot reference another ref layer")):a=e.J(t.type):"string"==typeof l&&i.push(new e.V(r,n.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(n.source)if(e.a0(n.source)){const t=o.sources&&o.sources[n.source],s=t&&e.J(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==s||n["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&n.paint&&(n.paint["line-gradient"]||n.paint["line-trim-offset"])&&"geojson"===s&&!t.lineMetrics?i.push(new e.V(r,n,`layer "${n.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(r,n.source,`layer "${n.id}" requires a 'raster-array' source.`)):i.push(new e.V(r,n.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(r,n,`layer "${n.id}" must specify a "source-layer"`)):i.push(new e.V(r,n.source,`source "${n.source}" not found`))}else i.push(new e.V(`${r}.source`,n.source,'"source" must be a string'));else i.push(new e.V(r,n,'missing required property "source"'));return i=i.concat(ge({key:r,value:n,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>me({key:`${r}.type`,value:n.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"}),filter:e=>ee(Object.assign({layerType:a},e)),layout:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>re(Object.assign({layerType:a},e))}}),paint:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ne(Object.assign({layerType:a,layer:n},e))}}),appearances(t){const i=Z({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:n,layerType:r}=t,o=e.J(t.value),s=e.J(o.name),a=e.J(o.condition),l=ge({key:i,value:o,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...K({key:t.key,value:t.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:n,layerType:r},t)),properties:t=>function(t){const i=[],{styleSpec:n,layer:r,layerType:o}=t,s=n[`paint_${o}`],a=n[`layout_${o}`],l=t.object[t.objectKey];for(const n in l){const c=n in s?"paint":n in a?"layout":void 0;if(!c){i.push(new e.V(t.key,n,`unknown property "${n}" for layer type "${o}"`));continue}const u=Object.assign({},t,{key:`${t.key}.${n}`,object:l,objectKey:n,layer:r,layerType:o,value:l[n],valueSpec:"paint"===c?s[n]:a[n]});i.push(...ie(u,c))}return i}(Object.assign({layer:n,layerType:r},t))}});return"hidden"!==s&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:n},t))}),r=Array.isArray(t.value)?t.value:[],o=new Set;return r.forEach((r,s)=>{const a=e.J(r.name);if(a)if(o.has(a)){const r=e.J(n.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`))}else o.add(a)}),i}}})),i}function se({key:t,value:i}){return e.a0(i)?[]:[new e.V(t,i,`string expected, ${e.K(i)} found`)]}const ae={promoteId:function t({key:i,value:n}){if(e.a0(n))return se({key:i,value:n});if(Array.isArray(n)){const t=[],r=e.S(n),o=e.U(r);return"error"===o.result&&o.value.forEach(n=>{t.push(new e.V(`${i}${n.key}`,null,`${n.message}`))}),e.X(o.value.expression,["zoom","heatmap-density","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])||t.push(new e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!e.H(n))return[new e.V(i,n,`string, expression or object expected, "${e.K(n)}" found`)];const r=[];for(const e in n)r.push(...t({key:`${i}.${e}`,value:n[e]}));return r}};function le(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];if(!("type"in i))return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new e.a3(n,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(ge({key:n,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ae})),a;case"geojson":if(a=ge({key:n,value:i,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:ae}),"cluster"in i&&"clusterProperties"in i){if(!e.H(i.clusterProperties))return[new e.V(`${n}.clusterProperties`,i,`object expected, ${e.K(i)} found`)];for(const t in i.clusterProperties){const r=i.clusterProperties[t];if(!Array.isArray(r))return[new e.V(`${n}.clusterProperties.${t}`,r,"array expected")];const[o,s]=r,l="string"==typeof o?[o,["accumulated"],["get",t]]:o;a.push(...K({key:`${n}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...K({key:`${n}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}))}}return a;case"video":return ge({key:n,value:i,valueSpec:r.source_video,style:o,styleSpec:r});case"image":return ge({key:n,value:i,valueSpec:r.source_image,style:o,styleSpec:r});case"canvas":return[new e.V(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Y({key:`${n}.type`,value:i.type,valueSpec:{values:ce(r)}})}}function ce(e){return e.source.reduce((t,i)=>{const n=e[i];return"enum"===n.type.type&&(t=t.concat(Object.keys(n.type.values||{}))),t},[])}function ue(t){const i=t.value,n=t.styleSpec,r=n.light,o=t.style;if(void 0===i)return[];if(!e.H(i))return[new e.V("light",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&r[l[1]]?me({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:n}):a&&r[a[1]]&&r[a[1]].transition?me({key:t,value:i[t],valueSpec:n.transition,style:o,styleSpec:n}):r[t]?me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function he(t){const i=t.value;if(!i)return[];const n=t.key;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];let r=[];const o=t.styleSpec,s=o["light-3d"],a=t.style,l=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V(n,i,`missing property "${t}"`)]),r;if(!e.a0(i.type))return r=r.concat([new e.V(`${n}.type`,i.type,"string expected")]),r;if(l)for(let o=0;o[],array:Z,boolean:function(t){const i=t.value,n=t.key;return e.$(i)?[]:[new e.V(n,i,`boolean expected, ${e.K(i)} found`)]},number:W,color:function({key:t,value:i}){return e.a0(i)?null===e.a1.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.K(i)} found`)]},enum:Y,filter:ee,function:q,layer:oe,object:ge,source:le,model:e.a7,light:ue,"light-3d":he,terrain:de,fog:pe,string:se,formatted:function(e){return 0===se(e).length?[]:K(e)},resolvedImage:function(e){return 0===se(e).length?[]:K(e)},projection:function(t){const i=t.value,n=t.styleSpec,r=n.projection,o=t.style;if(e.H(i)){let e=[];for(const t in i)e=e.concat(me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}));return e}return e.a0(i)?[]:[new e.V("projection",i,`object or string expected, ${e.K(i)} found`)]},import:function(t){const i=t.key,{value:n,styleSpec:r}=t;if(!e.H(n))return[new e.V(i,n,"import must be an object")];const{data:o,...s}=n;Object.defineProperty(s,"__line__",{value:n.__line__,enumerable:!1});let a=ge(Object.assign({},t,{value:s,valueSpec:r.import}));return""===e.J(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),o&&(a=a.concat(Ae(o,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,"object expected")];if(!i.type)return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];if(a=a.concat(ge({key:n,value:i,valueSpec:r[`iconset_${s}`],style:o,styleSpec:r})),function(e,t){return!("source"!==e||!t.source)}(s,i)){const t=o.sources&&o.sources[i.source],r=t&&e.J(t.type);t?"raster-array"!==r&&a.push(new e.V(n,i.source,`iconset cannot be used with a source of type ${String(r)}, it only be used with a "raster-array" source type`)):a.push(new e.V(n,i.source,`source "${i.source}" not found`))}return a}};function me(t,i=!1){const n=t.value,r=t.valueSpec,o=t.styleSpec;if(r.expression){if(e.a4(e.J(n)))return q(t);if(e.Q(e.S(n)))return K(t)}if(r.type&&fe[r.type]){const e=fe[r.type](t);return!0===i&&e.length>0&&Array.isArray(t.value)?K(t):e}return ge(Object.assign({},t,{valueSpec:r.type?o[r.type]:r}))}function ge(t){const i=t.key,n=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];let l=[];for(const t in n){const c=t.split(".")[0];let u;o[c]?u=o[c]:r[c]?u=me:o["*"]?u=o["*"]:r["*"]&&(u=me),u?l=l.concat(u({key:(i?`${i}.`:i)+t,value:n[t],valueSpec:r[c]||r["*"],style:s,styleSpec:a,object:n,objectKey:t},n)):l.push(new e.a3(i,n[t],`unknown property "${t}"`))}for(const t in r){if(o[t])continue;const s=r[t];s.required&&void 0===s.default&&void 0===n[t]&&l.push(new e.V(i,n,`missing required property "${t}"`))}return l}function _e({key:t,value:i}){const n=se({key:t,value:i});if(n.length)return n;const r=i;return-1===r.indexOf("{fontstack}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),n}function Ae(t,i=e.a6,n={}){return ge({key:n.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:_e}})}function ye(t,i=e.a6){return Re(Ae(t,i))}const ve=e=>Re(le(e)),xe=e=>Re(ue(e)),be=e=>Re(he(e)),we=e=>Re(de(e)),Te=e=>Re(pe(e)),Ee=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.snow;if(void 0===i)return[];if(!e.H(i))return[new e.V("snow",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Ce=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.rain;if(void 0===i)return[];if(!e.H(i))return[new e.V("rain",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Se=e=>Re(oe(e)),Be=e=>Re(ee(e)),Ie=e=>Re(ne(e)),Me=e=>Re(re(e)),Pe=t=>Re(e.a7(t));function Re(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Le(t,i){let n=!1;if(i&&i.length)for(const r of i)r instanceof e.a3?e.w(r.message):(t.fire(new e.y(new Error(r.message))),n=!0);return n}const Fe=e.a6.light;let ke;class De extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a8(ke||(ke=new e.a9({anchor:new e.aa(Fe.anchor),position:new e.ab(Fe.position),color:new e.aa(Fe.color),intensity:new e.aa(Fe.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(xe,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(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}const Oe=e.a6.terrain;let ze=class extends e.E{constructor(t,i,n,r,o){super(),this.scope=n,this._transitionable=new e.a8(new e.a9({source:new e.aa(Oe.source),exaggeration:new e.aa(Oe.exaggeration)}),n,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i,this.worldview=o}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(t){return this._transitioning.possiblyEvaluate(new e.ac(t,{worldview:this.worldview})).get("exaggeration")}getAttenuationRange(){if(!this.isZoomDependent())return null;const t=this._transitionable._values.exaggeration;if(!t)return null;const i=t.value.expression;if(!i)return null;let n=-1,r=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.ac(t,{worldview:this.worldview})),o>.01?(n=t,r=-1):r=t;return o<.01&&n>0&&r>n?[n,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ad}};const Ue=45,Ne=65,Ve=.05;function je(t,i,n,r){const o=e.ah(Ue,Ne,n),[s,a]=Ge(t,r);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function Ge(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function He(t,i,n,r,o){const s=e.af([],[i,n,r],o.mercatorFogMatrix);return je(t,e.ag(s),o.pitch,o._fov)}function Qe(t,i,n,r,o,s,a){const l=[[n,r,0],[o,r,0],[o,s,0],[n,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const n=e.af([],t,i),r=e.ag(n);c=Math.min(c,r),u=Math.max(u,r)}return[je(t,c,a.pitch,a._fov),je(t,u,a.pitch,a._fov)]}const $e=e.a6.fog;class Ze extends e.E{constructor(t,i,n,r){super();const o=new e.a9({range:new e.aa($e.range),color:new e.aa($e.color),"color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.aa($e["high-color"]),"high-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.aa($e["space-color"]),"space-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.aa($e["horizon-blend"]),"star-intensity":new e.aa($e["star-intensity"]),"vertical-range":new e.aa($e["vertical-range"])});this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ai(o),this.scope=n}get state(){const t=this._transform,i="globe"===t.projection.name,n=e.aj(t.zoom),r=this.properties.get("range"),o=[.5,3];return{range:i?[e.ak(o[0],r[0],n),e.ak(o[1],r[1],n)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Te,e,i))return;const n=Object.assign({},e);for(const e of Object.keys($e))void 0===n[e]&&(n[e]=$e[e].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,t)}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return("globe"===this._transform.projection.name?1:e.ah(Ue,Ne,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,n){const r=e.ae.fromLngLat(i),o=n.elevation?n.elevation.getAtPointOrZero(r):0;return He(t,r.x,r.y,o,n)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Qe(this.state,i,0,0,e.al,e.al,this._transform)}getOpacityForBounds(e,t,i,n,r){return this._transform.projection.supportsFog?Qe(this.state,e,t,i,n,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Ge(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const n of i){const i=t.points[n];let r;if(i[2]>=0)r=i;else{const o=t.points[n-4];r=e.am(o,i,o[2]/(o[2]-i[2]))}if(He(this.state,r[0],r[1],0,this._transform)>=Ve)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let We,qe,Ke,Xe,Je=class extends e.E{constructor(t,i,n,r){super();const o=We||(We=new e.a9({density:new e.aa(e.a6.snow.density),intensity:new e.aa(e.a6.snow.intensity),color:new e.aa(e.a6.snow.color),opacity:new e.aa(e.a6.snow.opacity),vignette:new e.aa(e.a6.snow.vignette),"vignette-color":new e.aa(e.a6.snow["vignette-color"]),"center-thinning":new e.aa(e.a6.snow["center-thinning"]),direction:new e.aa(e.a6.snow.direction),"flake-size":new e.aa(e.a6.snow["flake-size"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ee,t,n))return;const r=Object.assign({},t),o=e.a6.snow;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},Ye=class extends e.E{constructor(t,i,n,r){super();const o=qe||(qe=new e.a9({density:new e.aa(e.a6.rain.density),intensity:new e.aa(e.a6.rain.intensity),color:new e.aa(e.a6.rain.color),opacity:new e.aa(e.a6.rain.opacity),vignette:new e.aa(e.a6.rain.vignette),"vignette-color":new e.aa(e.a6.rain["vignette-color"]),"center-thinning":new e.aa(e.a6.rain["center-thinning"]),direction:new e.aa(e.a6.rain.direction),"droplet-size":new e.aa(e.a6.rain["droplet-size"]),"distortion-strength":new e.aa(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ce,t,n))return;const r=Object.assign({},t),o=e.a6.rain;for(const e of Object.keys(o))void 0===r[e]&&(r[e]=o[e].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,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)}_validate(t,i,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};class et extends e.E{constructor(t,i,n,r){super(),this.scope=n,this._options=t,this.properties=new e.ai(i),this._transitionable=new e.a8(i,n,new Map(r)),this._transitionable.setTransitionOrValue(t.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")}}class tt{constructor(e,t,i){this.screenBounds=e,this.cameraPoint=i.getCameraPoint(),this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=t,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,i)}static createFromScreenPoints(t,i){let n,r;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);n=[o],r=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]),a=o.add(s)._div(2);n=[o,s],r=e.aq(o,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a)}return new tt(n,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.aq(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.ar(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.x))){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o}return r}containsTile(t,i,n,r=0){const o=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map(i=>e.as(t.tileTransform,i,a));if(!e.at(l,0,0,e.al,e.al))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.au(t.tileTransform,i,a)),u=c.map(t=>new e.P(t[0],t[1])),h=i.getFreeCameraOptions().position||new e.ae(0,0,0),d=e.au(t.tileTransform,h,a),p=c.map(t=>{const i=e.av(t,t,d);return e.aw(i,i),new e.ax(d,i)}),f=e.ay(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.az(l),m.min.x=e.aA(m.min.x,0,e.al),m.min.y=e.aA(m.min.y,0,e.al),m.max.x=e.aA(m.max.x,0,e.al),m.max.y=e.aA(m.max.y,0,e.al),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=rt(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=rt(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.aB([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aD,0,1],o=[0,e.aD,0,1],s=[0,0,0,1];e.aC(r,r,n),e.aC(o,o,n),e.aC(s,s,n);const a=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.aE(t,a)&&r[3]1?it(t.slice(0,d),i):[],m=dnew e.P(nt(t.x),t.y)),m=m.map(t=>new e.P(nt(t.x),t.y));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.ak(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,p);let A;return A=c?[new e.P(0,_),new e.P(0,0),new e.P(1,0),new e.P(1,_)]:[new e.P(1,_),new e.P(1,1),new e.P(0,1),new e.P(0,_)],g.push(...A),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map(t=>new e.ae(t.x,t.y)),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,o=0;for(let e=0;er&&(r=t[e].x,o=e);for(let e=0;e.5&&(r.x{e.x-=1}),{polygon:t,unwrapped:n}}(it(t,i).map(t=>new e.P(nt(t.x),t.y)),i);return{polygon:r.polygon.map(t=>new e.ae(t.x,t.y)),unwrapped:r.unwrapped}}}function it(t,i){return e.aG(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function nt(e){return e<0?1+e%1:e%1}function rt(e){return 100*e|0}function ot(t,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){if(t.url&&r.tiles&&t.tiles&&delete t.tiles,r.variants){if(!Array.isArray(r.variants))return o(new Error("variants must be an array"));for(const e of r.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return o(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){r=Object.assign(r,e);break}}}const n=e.aH(Object.assign({},r,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);n.tiles=i.canonicalizeTileset(n,t.url),o(null,n)}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const n=Object.values(e.language||{});if(0===n.length)return null;const r=Object.values(e.worldview||{});if(0===r.length)return null;const o=n.every(e=>e===t),s=r.every(e=>e===i);return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,n,r);return a?e.o.frame(()=>s(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,n,r),e.R.Source),s):e.o.frame(()=>{const{data:e,...i}=t;s(null,i)})}function st(t,i){const n=Math.pow(2,i.z),r=Math.floor(e.aF(t.getWest())*n),o=Math.floor(e.aJ(t.getNorth())*n),s=Math.ceil(e.aF(t.getEast())*n),a=Math.ceil(e.aJ(t.getSouth())*n);return i.x>=r&&i.x=o&&i.ythis.maxzoom||e.z{if(this._tileJSONRequest=null,this._loaded=!0,r)i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r));else if(o){if(Object.assign(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers){this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of o.vector_layers)this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id)}this.tileBounds=at.fromTileJSON(o),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}t&&t(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 t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}loadTile(t,i){const n=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(n),o=this.map._requestManager.transformRequest(r,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:o,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,tessellationStep:this.map._tessellationStep,scaleFactor:this.map.getScaleFactor(),worldview:this.map.getWorldview()||this.worldviewDefault,indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&e.h(n)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aL.call({deduped:this._deduped},l,(i,n)=>{if(i||!n)c.call(this,i);else{const i=e.aM(n.responseHeaders);l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0)}},!0);t.request={cancel:i}}function c(n,r){return delete t.request,t.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.aN(this.dispatcher),i(null,r),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.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,t){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 ct extends e.E{constructor(t,i,n,r){super(),this.id=t,this.dispatcher=n,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=Object.assign({type:"raster"},i),Object.assign(this,e.aH(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,null,i,(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(Object.assign(this,n),n.raster_layers&&(this.rasterLayers=n.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=at.fromTileJSON(n),P(n.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(e){this.cancelTileJSONRequest()}serialize(){return Object.assign({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.o.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(r,e.R.Tile),(n,r,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n)return t.state="errored",i(n);if(!r)return i(null);const s=e.aM(o);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(r,this.map.painter),t.state="loaded",e.aN(this.dispatcher),i(null)})}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),i&&i()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function ut([t,i],n,r,{scaled:o=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:u}=n;if(!isFinite(l)||!isFinite(c)||!isFinite(u))throw new Error("Invalid MRT header");const h=2**u,d=h*e.aF(t),p=h*e.aJ(i);return function([e,t],i,{scaled:n=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:o,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>o+s||t<-s||t>o+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${s}`);const u=(t+s)*(o+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[u])return null;let h=[];h=n?[]:new i.data.constructor(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n){if("AbortError"===n.name)return;return t.state="errored",i(n)}if(this.map._refreshExpiredTiles&&r){const i=e.aM(o);t.setExpiryData(i)}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!r)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=r}i(null)};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",o,s.bind(this),void 0,!0)}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,t){const i=e.texturePerLayer;if(e.flushAllQueues(),i.size){e.destroy(!0);for(const e of i.values())this.map.painter.saveTileTexture(e)}else e.destroy()}prepareTile(t,i,n,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,n,r,(i,r)=>{if(i)return t.state="errored",this.fire(new e.y(i)),void this.triggerRepaint(t);r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(n,r,this.map.painter),t.state="loaded",this.triggerRepaint(t))}))}getInitialBand(e){if(!this.rasterLayers)return 0;const t=this.rasterLayers.find(({id:t})=>t===e),i=t&&t.fields,n=i&&i.bands&&i.bands;return n?n[0]:0}getTextureDescriptor(t,i,n){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let o=null;i instanceof e.aQ?o=i.paint.get("raster-array-band"):i instanceof e.aR&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(r);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,s);if(t.updateNeeded(i.id,s)&&!n)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const n=new Map;for(const r of t)for(const t of i){const[i,o]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(o)||!s.hasDataForBand(o))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(o),u=l+2*c,h={data:new e.q({width:u,height:u},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};n.set(t,h)}return n}queryRasterArrayValueByBandId(t,i,n){const r=i._mrt;return new Promise(o=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(n.layerName&&l!==n.layerName)continue;const u={};s[l]=u;for(const{bands:h}of c.dataIndex)for(const d of h)n.bands&&!n.bands.includes(d)||(a.add(e.B(l,d)),i.fetchBand(l,null,d,i=>{e.o.frame(()=>{u[d]=i?null:ut([t.lng,t.lat],r,c.getBandView(d)),a.delete(e.B(l,d)),0===a.size&&o(s)})},!1))}0===a.size&&o(s)})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,n,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!n)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&n){const i=e.aM(r);t.setExpiryData(i)}t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,n)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise((n,r)=>{this._loadTileForQuery(t,(o,s)=>{o?r(o):n(s?this.queryRasterArrayValueByBandId(e,t,i):null)})})}queryRasterArrayValue(t,i){const n=e.aS.convert(t),r=this.findLoadedParent(n);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(n,r,i):this.queryRasterArrayValueByAllBands(n,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ae.fromLngLat(t,this.map.transform.tileSize),n=this.maxzoom+1,r=1<0&&(l[new e.aP(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(i.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const t=e.B(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){const n=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,o=r?{image:r.image.clone()}:null,s=this._partialReload,a={type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,lut:o,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};t.request=this.actor.send(n,a,(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aT{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aU(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,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(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.y(new e.V(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}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 t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA8),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aT,model:e.aW,"batched-model":class extends e.E{constructor(e,t,i,n){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(n)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,i,n,(r,o)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r))):o&&(Object.assign(this,o),o.bounds&&(this.tileBounds=new at(o.bounds,this.minzoom,this.maxzoom)),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,o.bind(this),void 0,!0);function o(e,n){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadModelData(n,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aT{constructor(t,i,n,r){super(t,i,n,r),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 e.y(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new e.V(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.y(new e.V(`sources.${t}`,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 e.y(new e.V(`sources.${t}`,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 HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.y(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(e){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?!t&&!this._playing||this.texture instanceof e.aV||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA8,{premultiply:!0}),this._prepareData(i)}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 e.E{constructor(t,i,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,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 e.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new at(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aH(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:n,z:r}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:r},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i))}),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:n}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:n})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t&&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 t=e.B(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},pt=function(t,i,n,r){const o=new dt[i.type](t,i,n,r);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.aX(["load","abort","unload","serialize","prepare"],o),o};function ft(e,t,i=""){return`${i}:${t.id||""}:${t.layer.id}:${function(e){if("layerId"in e)return`layer:${e.layerId}`;{const{featuresetId:t,importId:i}=e;return`featureset:${t}${i?`:import:${i}`:""}`}}(e.target)}`}function mt(e,t,i,n=""){if(e.uniqueFeatureID){const r=ft(e,t,n);if(i.has(r))return!0;i.add(r)}return!1}function gt(e,t,i,n,r=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,r);s.sort(yt);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,n,o,r);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,n);Object.keys(i).length&&a.push({wrappedTileID:0,queryResults:i})}}return 0===a.length?{}:function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(a)}function _t(e,t,i,n,r,o){const s={},a=n.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(yt);for(const e of l){const n=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in n){const i=s[t]=s[t]||[],r=n[t];r.sort((t,i)=>{const n=e.featureSortOrder;if(n){const e=n.indexOf(t.featureIndex);return n.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e)}}return s}function At(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;et.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.fqid]=n}}return i}const xt=32,bt=33,wt=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,n=0,r=0,o=0,s=0,a=0;for(1&t?r=o=s=xt:i=n=a=xt;(t>>=1)>1;){const e=i+r>>1,l=n+o>>1;1&t?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=e,a=l}const l=4*e;wt[l+0]=i,wt[l+1]=n,wt[l+2]=r,wt[l+3]=o}const Tt=new Uint16Array(2178),Et=new Uint8Array(1089),Ct=new Uint16Array(1089);function St(e){return 0===e?-.03125:32===e?.03125:0}const Bt={type:2,extent:e.al,loadGeometry:()=>[[new e.P(0,0),new e.P(e.al+1,0),new e.P(e.al+1,e.al+1),new e.P(0,e.al+1),new e.P(0,0)]]};class It{constructor(t,i,n,r,o,s){this.tileID=t,this.uid=e.b1(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=s,this._hasAppearances=null}registerFadeDuration(t){const i=t+this.timeAdded;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return!0;return!1}updateBuckets(t,i){if(!this.latestFeatureIndex)return;if(!t.style)return;const n=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages(),o=t.style.getBrightness();for(const s in this.buckets){if(!t.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",u=n[c],h=t.style.getLayerSourceCache(l);let d={};h&&(d=h._state.getState(c,void 0));const p=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},f=Object.keys(d).length>0&&!i;if(a.hasAppearances=a.layers.some(e=>e.appearances&&e.appearances.length>0),(f&&0!==a.stateDependentLayers.length||i)&&a.update(d,u,r,p,f?a.stateDependentLayers:a.layers,i,o),f&&0!==a.stateDependentLayers.length||i||a.hasAppearances){const e={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview};a.updateAppearances(this.tileID.canonical,d,r,e)}(a instanceof e.b9||a instanceof e.ba)&&t._terrain&&t._terrain.enabled&&h&&a.uploadPending()&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const m=t&&t.style&&t.style.getOwnLayer(s);m&&(this.queryPadding=Math.max(this.queryPadding,m.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=wt[t+0],n=wt[t+1],r=wt[t+2],o=wt[t+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*bt+i,h=o*bt+r,d=a*bt+s,p=Math.hypot((Tt[2*u+0]+Tt[2*h+0])/2-Tt[2*d+0],(Tt[2*u+1]+Tt[2*h+1])/2-Tt[2*d+1])>=16;Et[d]=Et[d]||(p?1:0),e<1022&&(Et[d]=Et[d]||Et[(n+c>>1)*bt+(i+l>>1)]||Et[(o+c>>1)*bt+(r+l>>1)])}const o=new e.a$,s=new e.b0;let a=0;function l(t,i){const n=i*bt+t;return 0===Ct[n]&&(o.emplaceBack(Tt[2*n+0],Tt[2*n+1],t*e.al/xt,i*e.al/xt),Ct[n]=++a),Ct[n]-1}function c(e,t,i,n,r,o){const a=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-o)>1&&Et[u*bt+a])c(r,o,e,t,a,u),c(i,n,r,o,a,u);else{const a=l(e,t),c=l(i,n),u=l(r,o);s.emplaceBack(a,c,u)}}return c(0,0,xt,xt,xt,0),c(xt,xt,0,0,0,xt),{vertices:o,indices:s}}(this.tileID.canonical,i);r=t.vertices,o=t.indices}else{r=new e.a$,o=new e.b0;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const t=e.bg(r.int16.subarray(0,4*r.length),void 0,4);for(let e=0;e0&&(l=e.bk(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,s,l,a)}_globePoint(t,i,n,r,o,s,a){let l=e.bl(t,i,n);if(s){const o=1<.5?d=-1:h<-.5&&(d=1);let p=(t/e.al+n.x)/o+d,f=(i/e.al+n.y)/o;p=(p-c)*r._pixelsPerMercatorPixel+c,f=(f-u)*r._pixelsPerMercatorPixel+u;const m=[p*r.worldSize,f*r.worldSize,0];e.af(m,m,s),l=e.bm(l,m,a)}return e.af(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,n,r,o,s){const a=new e.bc,l=new e.bd,c=new e.bn,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;uh*e+t;for(let e=0;e{if(e)i(e);else try{const e=n.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));n.parseHeader(r),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(n.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);r.byteLength>=s&&(this.entireBuffer=r),i(null,this.entireBuffer||r,o)}catch(e){i(e)}}),this.request}fetchBandForRender(e,t,i,n){this.fetchBand(e,t,i,r=>{if(r)return void n(r);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);n(null,o?o.img:null)})}fetchBand(t,i,n,r,o=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.B(String(n),e.B(this.tileID.key,t));let u=this._taskQueue.get(c);u?u.add(r):(u=new Set,u.add(r),this._taskQueue.set(c,u));const h=(e,t)=>{l.complete(e,t),e?r(e):(u.values().forEach(e=>e(null,t)),this._taskQueue.delete(c))},d=(e,t)=>{if(e)return r(e);const n=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},h,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{n&&n.cancel(),l.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e)}};let p;try{p=s.getLayer(t)}catch(e){if("reloading"===this.state)return;throw e}if(!p)return void r(new Error(`Unknown sourceLayer "${t}"`));if(p.hasDataForBand(n))return u.values().forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=p.getDataRange([n]);if(l=s.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),n=e.bt(t,d);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{n.cancel(),l.cancel()}),this._fetchQueuePerLayer.has(i)||this._fetchQueuePerLayer.set(i,e)}}}updateNeeded(e,t){return(!this.textureDescriptorPerLayer.get(e)||this.textureDescriptorPerLayer.get(e).band!==t||this.refreshedUponExpiration)&&"errored"!==this.state}updateTextureDescriptor(t,i,n){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(n)||!r.hasDataForBand(n))return;const{bytes:o,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(n),u=s+2*a,h=new e.q({width:u,height:u},o),d=this.texturePerLayer.get(i);d&&d instanceof e.T&&d.update(h,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:n,img:h,buffer:a,offset:l,tileSize:s,format:r.pixelFormat,mix:[c,256*c,65536*c,16777216*c]})}destroy(t=!1){if(super.destroy(t),delete this._mrt,!t)for(const t of this.texturePerLayer.values())t&&t instanceof e.T&&t.destroy();this.texturePerLayer.clear(),this.textureDescriptorPerLayer.clear(),this.fbo&&(this.fbo.destroy(),delete this.fbo),delete this.request,delete this.requestParams,this._isHeaderLoaded=!1}}class Pt{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Rt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const n=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},Object.assign(this.stateChanges[e][n],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])i[t]||(this.deletedStates[e][n][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},n=this.stateChanges[e]||{},r=this.deletedStates[e];if(null===r)return{};if(void 0!==t){const e=String(t),o=Object.assign({},i[e],n[e]);if(r){const e=r[t];if(null===e)return{};for(const t in e)delete o[t]}return o}const o=Object.assign({},i,n);if(r)for(const e in r)delete o[e];return o}initializeTileState(e,t){e.refreshFeatureState(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]={}),Object.assign(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]||{},Object.assign(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const i in e)e[i].refreshFeatureState(t)}}class Lt extends e.E{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 Pt(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Rt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===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)if(!this._tiles[e].loaded())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,this.map?this.map.painter:void 0),i.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Ft).map(e=>e.key)}getRenderableIds(t,i){const n=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&n.push(this._tiles[e]);return t?n.sort((t,i)=>{const n=t.tileID,r=i.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),s=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(Ft).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(t,i,n,r,o){if(r){if(t.state="errored",404!==r.status)this._source.fire(new e.y(r,{tile:t}));else{if(this._source.fire(new e.z("data",{dataType:"source",sourceDataType:"error",sourceId:this._source.id,tile:t})),!(t.tileID.key in this._loadedParentTiles))return;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)}return}t.timeAdded=e.o.now(),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null);let s=new Map;o&&o.responseHeaders&&(s=o.responseHeaders),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!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]){n[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),n=this._getLoadedTile(t);if(n)return n}}_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,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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(t,i,n,r,o){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;const c=this.map&&this.map.painter?this.map.painter._terrain:null;if(c&&c.sourceCache===this&&c.attenuationRange()){const e=c.attenuationRange()[0],t=Math.floor(e)-Math.log2(c.getDemUpscale());l>t&&(l=t)}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aP(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const r=t.clone();r.tileCoverLift=this.tileCoverLift,a=r.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aP(1,0,1,0,0)),a.push(new e.aP(1,0,1,1,0)),a.push(new e.aP(1,0,1,0,1)),a.push(new e.aP(1,0,1,1,1)))}else if(a=t.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.hasTile){const e=this._source.hasTile.bind(this._source);a=a.filter(t=>e(t))}}else a=[];if(a.length>0&&"globe"!==this.transform.projection.name&&!this.usedForTerrain&&!kt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),l=Math.min(e,this._source.maxzoom);if(s){const e=t.extendTileCover(a,l);for(const t of e)a.push(t)}else if(o){const e=t.extendTileCoverToNearPlane(a,this.transform.getFrustum(l),l);for(const t of e)a.push(t)}else if(this.castsShadows&&r){const e=t.extendTileCover(a,l,r);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t)}}const u=this._updateRetainedTiles(a);if(kt(this._source.type)&&0!==a.length){const t={},i={},n=Object.keys(u);for(const r of n){const n=u[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.o.now())continue;const s=this.findLoadedParent(n,Math.max(n.overscaledZ-Lt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[r]=n}const r=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(u[e]||!t.hasData())continue;let n=t.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&i[n.key]){u[e]=t.tileID;break}}}for(const e in t)u[e]||(this._coveredTiles[e]=!0,u[e]=t[e])}for(const e in u)this._tiles[e].clearFadeHold();const h=e.bu(this._tiles,u);for(const e of h){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={},n=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,o=Math.max(r-Lt.maxOverzooming,this._source.minzoom),s=Math.max(r+Lt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let r=e.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&r&&(e=this._addTile(o)),e&&(t[o.key]=o,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return!0!==i.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,"reloading"),i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const n=Boolean(i);if(!n){const e=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Mt(t,n,this.transform.tileZoom,e,this._isRaster):new It(t,n,this.transform.tileZoom,e,this._isRaster,this._source.worldview),this._loadTile(i,this._tileLoaded.bind(this,i,t.key,i.state))}return i.uses++,this._tiles[t.key]=i,n||this._source.fire(new e.z("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_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||"empty"===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(t,i,n){const r=[],o=this.transform;if(!o)return r;const s="globe"===o.projection.name,a=e.aF(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(n&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,0))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(const e of u){const n=t.containsTile(c,o,i,e);n&&r.push(n)}}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),n="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=n?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(kt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.o.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 n=this._tiles[e];n&&n.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(t,i){if(!this._sourceLoaded){const e=()=>{this._sourceLoaded&&(this._source.off("data",e),this._preloadTiles(t,i))};return void this._source.on("data",e)}const n=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,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)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(n.values());e.bv(a,(e,t)=>{const i=new It(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)})},i)}}function Ft(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function kt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Dt(e,t){const i=1<0:"building"===i.type?n=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(n=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!n&&t.visible,t.visible=n}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,n=this.style.getLayerSourceCache(i);let r=1;"fill-extrusion"===i.type?r=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(r=e.visible?i.paint.get("building-vertical-scale"):0);let o=n?n.getTile(t):null;if(!o&&n)for(const e in n._tiles){const i=n._tiles[e];if(t.canonical.isChildOf(i.tileID.canonical)){o=i;break}}this.currentBuildingBuckets.push({bucket:o?o.getBucket(i):null,tileID:o?o.tileID:t,verticalScale:r})}e.hasAnyZOffset=!1;let i=!1;for(let n=0;n{e in i&&(n[e]=i[e])}),n}function Ut(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Jt{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return!r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,n,r){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!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(e,t,i,n,r){return this._query(e,t,i,n,!1,r)}hitTest(e,t,i,n,r){return this._query(e,t,i,n,!0,r)}hitTestCircle(e,t,i,n){return this._queryCircle(e,t,i,!0,n)}_queryCell(e,t,i,n,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&n>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],e,t,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=r[u],t=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const e=this.bboxes;for(const t of u)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 h=this.circleCells[r];if(null!==h){const e=this.circles;for(const t of h)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,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const Yt={unknown:0,flipRequired:1,flipNotRequired:2},ei=Math.tan(85*Math.PI/180);function ti(t,i,n,r,o,s,a){const l=e.bB();if(n)if("globe"===s.name){const t=e.bC(o,i);e.aB(l,l,t)}else{const t=e.bD([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.bA(l,l,o.angle)}else e.aB(l,o.labelPlaneMatrix,t);return l}function ii(e,t,i,n,r,o,s){const a=ti(e,t,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ni(t,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=ti(t,i,n,r,o,s,a);return e.bk(l,l),e.aB(l,t,l),l}{const i=e.by(t),n=e.bz([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],e.aB(i,i,n),r||e.bA(i,i,-o.angle),i}}return o.glCoordMatrix}function ri(t,i,n,r){const o=[t,i,n,1];n?e.aC(o,o,r):mi(o,o,r);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function oi(e,t){return Math.min(.5+e/t*.5,1.5)}function si(e,t){const i=e[0]/e[3],n=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&n>=-t[1]&&n<=t[1]}function ai(t,i,n,r,o,s,a,l,c,u,h=1){const d=n.transform,p=r?t.textSizeData:t.iconSizeData,f=e.bJ(p,n.transform.zoom,h),m="globe"===d.projection.name,g=[256/n.width*2+1,256/n.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let A=null;m&&(A=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;rMath.abs(n)?{useVertical:!0}:t===e.bK.vertical?r>0?{needsFlipping:!0}:null:i!==Yt.unknown&&function(e,t){return 0===e||Math.abs(t/e)>ei}(n,r)?i===Yt.flipRequired?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function ui(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:S,writingMode:B,flipState:I}=t,M=T+t.lineLength,P=t=>{if(h){const[i,n,r]=t.up,o=u.length;e.bM(h,o+0,i,n,r),e.bM(h,o+1,i,n,r),e.bM(h,o+2,i,n,r),e.bM(h,o+3,i,n,r)}const[i,n,r]=t.point;e.bN(u,i,n,r,t.angle)};if(C>1){const e=li(x,l,b,w,n,d,p,t,c,s,f,g,!1,_,A,y,v);if(!e)return{notEnoughRoom:!0};if(r&&!n){let[i,n,r]=e.first.point,[o,s,l]=e.last.point;[i,n]=ri(i,n,r,a),[o,s]=ri(o,s,l,a);const c=ci(B,I,(o-i)*m,s-n);if(t.flipState=c&&c.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:di(p,r,i,1,o,void 0,_,A.canonical),l=ci(B,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,l)return l}const i=pi(x*l.getoffsetX(E),b,w,n,d,p,S,T,M,c,s,f,g,!1,!1,_,A,y,v);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function hi(e,t,i,n,r){const{x:o,y:s,z:a}=n.projectTilePoint(e.x,e.y,t);if(!r)return ri(o,s,a,i);const[l,c,u]=r.getElevation(e,r.elevation,r.elevationFeature);return ri(o+l,s+c,a+u,i)}function di(t,i,n,r,o,s,a,l){const c=hi(t.sub(i)._unit()._add(t),l,o,a,s);return e.av(c,n,c),e.aw(c,c),e.bG(c,n,c,r)}function pi(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y){const v=r?t-i:t+i;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+a+(x>0?0:1)|0,T=o,E=o,C=0,S=0;const B=Math.abs(v),I=[],M=[];let P=s,R=P,L=e.bE([]);const F=()=>di(R,P,E,B-C+1,h,p,g,_.canonical);for(;C+S<=B;){if(w+=x,w=c)return null;if(E=T,R=P,I.push(E),f&&M.push(R),P=new e.P(u.getx(w),u.gety(w)),T=d[w],!T){const e=hi(P,_.canonical,h,g,p);T=e[3]>0?d[w]=e:F()}C+=S;const t=e.av([],T,E),i=e.bF(E,T);if(n&&i>0&&S>0&&e.bI(L,t)/(S*i)0,y),w=c*b.perspectiveRatio,T=(n.x1*i+a.x-n.padding)*w+b.point.x,E=(n.y1*i+a.y-n.padding)*w+b.point.y,C=(n.x2*i+a.x+n.padding)*w+b.point.x,S=(n.y2*i+a.y+n.padding)*w+b.point.y,B=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(T,E,C,S)||!l&&this.grid.hitTest(T,E,C,S,h)||B?{box:[],offscreen:!1,occluded:b.occluded}:{box:[T,E,C,S],offscreen:this.isOffscreen(T,E,C,S),occluded:!1}}placeCollisionCircles(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=[],A=this.transform.elevation,y=t.getProjection(),v="road"===t.elevationType,x=!!A||v,b=e.bU.getAtTileOffsetFunc(g,this.transform.center.lat,this.transform.worldSize,y),w=new e.P(n.tileAnchorX,n.tileAnchorY),T=new e.P(n.tileAnchorX,n.tileAnchorY);let{x:E,y:C,z:S}=y.projectTilePoint(T.x,T.y,g.canonical),B=null;if(x){const e=v?t.getElevationFeatureForText(r):null;B={getElevation:b,elevation:A,elevationFeature:e};const[i,n,o]=b(w,A,e);E+=i,C+=n,S+=o}const I="globe"===y.name,M=this.projectAndGetPerspectiveRatio(l,E,C,S,g,I||!!A||this.transform.pitch>0,y),{perspectiveRatio:P}=M,R=(d?a/P:a*P)/e.bX,L=ri(E,C,S,c),F=n.lineOffsetX*R,k=n.lineOffsetY*R,D=e.an(t.layers[0].layout.get("text-max-angle")),O=Math.cos(D),z=M.signedDistanceFromCamera>0?li(R,s,F,k,v&&1===n.flipState,L,T,n,o,c,{},x&&!d?B:null,d&&x,y,g,d,O):null;let U=!1,N=!1,V=!0;if(z&&!M.occluded){const t=.5*f*P+m,n=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Xt,{first:s,last:a}=z,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(x&&!I&&(i=b(ne[3]<=0)&&(c=[]));let g=[];if(c.length>0){let t=1/0,i=-1/0,o=1/0,s=-1/0;for(const e of c)t=Math.min(t,e[0]),o=Math.min(o,e[1]),i=Math.max(i,e[0]),s=Math.max(s,e[1]);i>=n.x&&t<=r.x&&s>=n.y&&o<=r.y&&(g=[c.map(t=>new e.P(t[0],t[1]))],(tr.x||or.y)&&(g=e.bV(g,n.x,n.y,r.x,r.y)))}for(const e of g){o.reset(e,.25*t);let n=0;n=o.length<=.5*t?1:Math.ceil(o.paddedLength/d)+1;for(let e=0;e0){if(e.aC(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return e.af(l,l,a),je(t,e.ag(l),s.pitch,s._fov)}(this.fogState,i,n,r,o.toUnwrapped(),this.transform);c=t>.9}}else mi(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+gi,(-l[1]/u+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,i,n){return i=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ti(t,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=e.c0(t),l=-(s-.5)*i,c=-(a-.5)*n,u=e.c1(t,r);return new e.P(l+u[0]*o,c+u[1]*o)}function Ei(t,i,n,r,o){const s=new e.P(t,i);return n&&s._rotate(r?o:-o),s}class Ci{constructor(e,t,i,n,r,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new _i(this.transform,r),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new wi(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,n,r,o=1){const s=n.getBucket(i),a=n.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,u=n.collisionBoxArray,h=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),d=n.tileSize/e.al,p=n.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(m=n.tileID,g=s.getProjection(),_=this.transform,g.name===this.projection?_.calculateProjMatrix(m.toUnwrapped()):Wt(_,g,m));var m,g,_;const A="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(n),w=ii(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);let T=null;const E=s.getProjection().createInversionMatrix(this.transform,n.tileID.canonical);if(A){const t=ni(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);T=e.aB([],this.transform.labelPlaneMatrix,t)}let C=null;v&&n.latestFeatureIndex&&(C={unwrappedTileID:p,dynamicFilter:v,dynamicFilterNeedsFeature:x}),this.retainedQueryData[s.bucketInstanceId]=new bi(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,n.tileID);const[S,B]=s.layers[0].layout.get("text-size-scale-range"),I=e.aA(o,S,B),[M,P]=l.get("icon-size-scale-range"),R=e.aA(o,M,P),L={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:E,mercatorCenter:[e.aF(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:C,scale:h,textPixelRatio:d,holdingForFade:n.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bJ(s.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bJ(s.iconSizeData,this.transform.zoom,R),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:n.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:L})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const{textOffset0:x,textOffset1:b,crossTileID:w}=f,T=[x,b],E=Ti(e,o,s,T,a),C=this.collisionIndex.placeCollisionBox(g,a,t,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate);if(A){const e=g.getSymbolInstanceIconSize(v,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,A,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(C.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[w]&&this.prevPlacement.placements[w]&&this.prevPlacement.placements[w].text&&(t=this.prevPlacement.variableOffsets[w].anchor),this.variableOffsets[w]={textOffset:T,width:o,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(g,e,f,_),g.allowVerticalPlacement&&(this.markUsedOrientation(g,_,f),this.placedOrientations[w]=_),{shift:E,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,n,r,o=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:g,collisionBoxArray:_,partiallyEvaluatedTextSize:A,partiallyEvaluatedIconSize:y,collisionGroup:v,latestFeatureIndex:x}=t.parameters,b=a.get("text-optional"),w=a.get("icon-optional"),T=a.get("text-allow-overlap"),E=a.get("icon-allow-overlap"),C="map"===a.get("text-rotation-alignment"),S="map"===a.get("icon-rotation-alignment"),B="map"===a.get("text-pitch-alignment"),I=l.get("symbol-z-offset"),M="sea"===a.get("symbol-elevation-reference"),P=a.get("symbol-placement"),[R,L]=a.get("text-size-scale-range"),[F,k]=a.get("icon-size-scale-range"),D=e.aA(o,R,L),O=e.aA(o,F,k),z=a.get("text-variable-anchor"),U=C&&"point"!==P,N=S&&"point"!==P,V=z&&s.hasTextData(),j=s.hasIconTextFit()&&V&&s.hasIconData();this.transform.setProjection(s.projection);const G=V||U,H=N||j;let Q=T&&(E||!s.hasIconData()||w),$=E&&(T||!s.hasTextData()||b);const Z=!I.isConstant();!s.collisionArrays&&_&&s.deserializeCollisionBoxes(_),n&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,_,D,O);const W=(t,r,o)=>{const{crossTileID:l,numVerticalGlyphVertices:_}=t;let S=null;if(d&&d.dynamicFilterNeedsFeature||Z){const e=this.retainedQueryData[s.bucketInstanceId];S=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:s.worldview},S,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[l]=new vi(!1,!1,!1,!0),void i.add(l);const P=I.evaluate(S,{});if(i.has(l))return;if(g)return void(this.placements[l]=new vi(!1,!1,!1));let R=!1,L=!1,F=!0,k=!1,D=!1,O=null,U={box:null,offscreen:null,occluded:null},N={box:null},V=null,j=null,W=null,q=0,K=0,X=0;o.textFeatureIndex?q=o.textFeatureIndex:t.useRuntimeCollisionCircles&&(q=t.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);const J=s.elevationFeatures?s.elevationFeatures[t.elevationFeatureIndex]:void 0,Y=i=>{i.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const n=this.transform.elevation;i.elevation=M?P:P+e.bU.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),n,J),i.elevation+=t.zOffset},ee=o.textBox;if(ee){Y(ee);const i=i=>{let n=e.bK.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,n=e,this.markUsedOrientation(s,n,t))}return n},n=(t,i)=>{if(s.allowVerticalPlacement&&_>0&&o.verticalTextBox){for(const n of s.writingModes)if(n===e.bK.vertical?(U=i(),N=U):U=t(),U&&U.box&&U.box.length)break}else U=t()};if(z){let a=z;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor))}const u=(e,i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),l=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,h=t.hasIconTextFit&&!E?i:null;h&&Y(h);let d={box:[],offscreen:!1,occluded:!1};const g=T?2*a.length:a.length;for(let i=0;i=a.length,t,r,s,n,h,A,y);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){R=!0,O=g.shift;break}}return d};n(()=>u(ee,o.iconBox,e.bK.horizontal),()=>{const t=o.verticalTextBox;return t&&Y(t),s.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&_>0&&t?u(t,o.verticalIconBox,e.bK.vertical):{box:null,offscreen:null,occluded:null}}),U&&(R=U.box,F=U.offscreen,k=U.occluded);const h=i(!(!U||!U.box));if(!R&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(s,e.anchor,t,h))}}else{const a=(i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(s,o,i,f,m,G,new e.P(0,0),T,p,c,v.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(s,n,t),this.placedOrientations[l]=n),a};n(()=>a(ee,e.bK.horizontal),()=>{const t=o.verticalTextBox;return s.allowVerticalPlacement&&_>0&&t?(Y(t),a(t,e.bK.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(U&&U.box&&U.box.length))}}if(V=U,R=V&&V.box&&V.box.length>0,F=V&&V.offscreen,k=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,r=s.text.placedSymbolArray.get(i),o=e.bL(s.textSizeData,A,r),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,T,r,i,s.lineVertexArray,s.glyphOffsetArray,o,c,u,h,n,B,v.predicate,t.collisionCircleDiameter*o/e.bX,l,this.retainedQueryData[s.bucketInstanceId].tileID),R=T||j.circles.length>0&&!j.collisionDetected,F=F&&j.offscreen,k=j.occluded}if(o.iconFeatureIndex&&(X=o.iconFeatureIndex),o.iconBox){const i=i=>{Y(i);const n=t.hasIconTextFit&&O?Ei(O.x,O.y,C,B,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,f,m,H,n,E,p,c,v.predicate)};N&&N.box&&N.box.length&&o.verticalIconBox?(W=i(o.verticalIconBox),L=W.box.length>0):(W=i(o.iconBox),L=W.box.length>0),F=F&&W.offscreen,D=W.occluded}const te=b||0===t.numHorizontalGlyphVertices&&0===_,ie=w||0===t.numIconVertices;if(te||ie?ie?te||(L=L&&R):R=L&&R:L=R=L&&R,R&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),s.bucketInstanceId,N&&N.box&&K?K:q,v.ID),L&&W&&this.collisionIndex.insertCollisionBox(W.box,a.get("icon-ignore-placement"),s.bucketInstanceId,X,v.ID),j&&(R&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,q,v.ID),n)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new xi);for(let e=0;e=0;--e){const i=t[e];W(s.symbolInstances.get(i),i,s.collisionArrays[i])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,n){const r=i===e.bK.horizontal||i===e.bK.horizontalOnly?i:0,o=i===e.bK.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new yi(o,n,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new yi(null,n,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new yi(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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,i,n){const r=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,o,o.collisionBoxArray,i,n,o.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,o.tileID),"road"===t.elevationType&&t.updateRoadElevation(o.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(t,i,n,r,o,s,a,l){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const c=t.layers[0].layout,u=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),d=new yi(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),g="map"===c.get("text-rotation-alignment"),_="map"===c.get("text-pitch-alignment"),A=u.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),v=!A.isConstant(),x=new yi(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const b=(e,t,i)=>{for(let n=0;n0||p>0,L=T>0,F=this.placedOrientations[f],k=F===e.bK.vertical,D=F===e.bK.horizontal||F===e.bK.horizontalOnly;!R&&!L||P.isHidden()||w++;let O=!1;if((R||L)&&s)for(const i of t.activeReplacements){if(e.bY(i,o,e.bZ.Symbol,l))continue;if(i.min.x>E||E>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.b_(E,C,a.canonical,i.footprintTileId.canonical);if(O=e.b$(t,i.footprint),O)break}if(R){const e=O?Di:ki(P.text);b(t.text,u,k?Di:e),b(t.text,p,D?Di:e);const i=P.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||k?1:0;n>=0&&(a.get(n).hidden=l),r>=0&&(a.get(r).hidden=l),o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=i||D?1:0);const h=this.variableOffsets[f];h&&this.markUsedJustification(t,h.anchor,c,F);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(L){const e=O?Di:ki(P.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=c,r=t.icon.placedSymbolArray,o=P.icon.isHidden()?1:0;i>=0&&(b(t.icon,T,k?Di:e),r.get(i).hidden=o),n>=0&&(b(t.icon,c.numVerticalIconVertices,D?Di:e),r.get(n).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let n=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(n=Ti(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&n._rotate(_?this.transform.angle:-this.transform.angle)):r=!1}h&&(r=!P.clipped),i.textBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||k,I,y,n.x,n.y),i.verticalTextBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||D,I,y,n.x,n.y)}const o=r&&Boolean(!D&&i.verticalIconBox);i.iconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0),i.verticalIconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,!o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0)}}}if(t.fullyClipped=0===w,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Si(e,t,i,n,r,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0)}const Bi=Math.pow(2,25),Ii=Math.pow(2,24),Mi=Math.pow(2,17),Pi=Math.pow(2,16),Ri=Math.pow(2,9),Li=Math.pow(2,8),Fi=Math.pow(2,1);function ki(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*Bi+t*Ii+i*Mi+t*Pi+i*Ri+t*Li+i*Fi+t}const Di=0;class Oi{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,n,r,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.o.now()-s;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,i=t.layout.get("symbol-z-elevate"),l=void 0!==t.layout.get("symbol-sort-key").constantOr(1),c=t.layout.get("symbol-z-order"),u="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),h=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=u&&h,p=this._inProgressLayer=this._inProgressLayer||new Oi(t),f=e.B(s.source,s.scope);if(p.continuePlacement(i||d?r[f]:n[f],this.placement,this._showCollisionBoxes,s,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.al/2;class Ni{constructor(t,i,n){this.tileID=t,this.bucketInstanceId=n,this.index=new e.c3(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.al,o=t.canonical.y*e.al;for(let e=0;ee-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!n.has(t)){n.add(t),i.crossTileID=t;break}}}}}class Vi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ji{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hi=771;class Qi{constructor(e,t,i,n){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=n}}Qi.Replace=[1,0,1,0],Qi.disabled=new Qi(Qi.Replace,e.ao.transparent,[!1,!1,!1,!1]),Qi.unblended=new Qi(Qi.Replace,e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlended=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlendedNonPremultiplied=new Qi([770,Hi,770,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.multiply=new Qi([774,0,774,0],e.ao.transparent,[!0,!0,!0,!0]),Qi.additive=new Qi([1,1,1,1],e.ao.transparent,[!0,!0,!0,!0]);class $i{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}$i.ReadOnly=!1,$i.ReadWrite=!0,$i.disabled=new $i(519,$i.ReadOnly,[0,1]);const Zi=7680;class Wi{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Wi.disabled=new Wi({func:519,mask:0},0,0,Zi,Zi,Zi);const qi=1029,Ki=2305;class Xi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function Ji(t,i){const n=e.c9(t,3);e.cb(t,i),e.cf(t,3,n)}function Yi(t,i){const n=e.c6([]);return e.c7(n,n,-i),e.c8(n,n,-t),n}function en(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.ag(n)>=1e-15){const t=e.aw([],n);e.c4(r,t,e.bI(r,t)),i[0]=r[0],i[1]=r[1]}const o=e.bH([],i,t);if(e.c5(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Yi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Xi.disabled=new Xi(!1,qi,Ki),Xi.backCCW=new Xi(!0,qi,Ki),Xi.backCW=new Xi(!0,qi,2304),Xi.frontCW=new Xi(!0,1028,2304),Xi.frontCCW=new Xi(!0,1028,Ki);class tn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ae?t:new e.ae(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bS(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,n){if(this.orientation=null,!this.position)return;const r=this.position,o=n||(this._elevation?this._elevation.getAtPointOrZero(e.ae.fromLngLat(t)):0),s=e.ae.fromLngLat(t,o),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=en(a,i)}setPitchBearing(t,i){this.orientation=Yi(e.an(t),e.an(-i))}}class nn{constructor(t,i){this._transform=e.bz([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.ae(t[0],t[1],t[2])}get position(){const t=e.c9(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.cf(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.c6([]),t&&Ji(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=Yi(e,t),Ji(this._transform,this._orientation)}forward(){const t=e.c9(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.c9(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.c9(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.bk(n,this.getWorldToCamera(t,i)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,n){const r=this.position;e.c4(r,r,-t);const o=new Float64Array(16);return e.bp(o,[n,n,n]),e.bq(o,o,r),o[10]*=i,o}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return e.ca(r,this._orientation),e.c4(o,o,-t),e.cb(n,r),e.bq(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const o=new Float64Array(16);return e.cc(o,t,i,n,r),o}getCameraToClipOrthographic(t,i,n,r,o,s){const a=new Float64Array(16);return e.cd(a,t,i,n,r,o,s),a}getDistanceToElevation(t,i=!1){const n=0===t?0:e.ce(t,i?e.a_(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new nn([...this.position],[...this.orientation])}}const rn={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class on{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.ak(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.ak(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.ak(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.ak(t.right,i.right,n)),this}getCenter(t,i){const n=e.aA((this.left+t-this.right)/2,0,t),r=e.aA((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new on(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const sn=15;class an{constructor(t,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=n??0,this._maxPitch=r??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aS(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 on,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new nn,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._tileCoverLift=0,this.freezeTileCoverage=!1,this._horizonShift=.1,this._orthographicProjectionAtLowPitch=!1,this._allowWorldUnderZoom=!1}clone(){const e=new an(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection(),this.maxBounds);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._allowWorldUnderZoom=this._allowWorldUnderZoom,e}get isOrthographic(){return"globe"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch0&&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(){if(void 0===this._centerAltitudeValidForExaggeration)return;const e=Math.max(0,(this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize);this._seaLevelZoom=this._zoomFromMercatorZ(e)}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;s{const l=e.cX(i,t,n,o,s);a.has(l)||(r.push(new e.aP(t,i,n,o,s)),a.add(l))};for(let e=0;e0,f=a.y+10,g=r.wrap-(p?0:1),_=r.wrap+(d?0:1),A=p?a.x-1:h-1,y=d?a.x+1:0;if(o)n[0]<0?(l(c,_,a.z,y,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))):n[0]>0?(l(c,g,a.z,A,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))):n[1]<0&&f?l(c,u,a.z,a.x,a.y+1):m&&l(c,u,a.z,a.x,a.y-1);else{const e=r.visibleQuadrants;1&e&&(l(c,g,a.z,A,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))),2&e&&(l(c,_,a.z,y,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))),4&e&&(l(c,g,a.z,A,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1))),8&e&&(l(c,_,a.z,y,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)))}}const c=[];for(const e of r)r.some(t=>e.isChildOf(t))||c.push(e);if(r=c.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-n[0],i=e.canonical.y+.5-n[1];return t*t+i*i{const l=e.cX(i,t,n,s,a);o.has(l)||(r.push(new e.aP(t,i,n,s,a)),o.add(l))},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),n),l=1<{const r=Math.floor(t[0]),o=Math.floor(t[1]),d=(t[0]-r)*e.al,p=(t[1]-o)*e.al,f=Math.floor(i[0]),m=Math.floor(i[1]),g=(i[0]-f)*e.al,_=(i[1]-m)*e.al;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){u.x=d-t*e.al,h.x=g-(i-f)*e.al;for(let t=-1;t<=1;t++){const r=o+t;u.y=p-t*e.al,h.y=_-(r-m)*e.al,e.cY(u,h,c)&&s(a,0,n,i,r)}}}},p=i.points,f=p[e.cu],m=p[e.cv],g=this._projectToGround(f,p[e.cw]),_=this._projectToGround(m,p[e.cx]);return d(f,g),d(m,_),r}_projectToGround(t,i){return e.cy(e.cz(),t,i,t[2]/(t[2]-i[2]))}coveringTiles(t){let i=this.coveringZoomLevel(t);const n=i,r=this.elevation&&this.elevation.exaggeration(),o=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,n=new e.ae(t.x+i,t.y,t.z),r=new e.ae(t.x,t.y+i,t.z),o=t.toLngLat(),s=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/i},E=t=>{const i=x,n=b;return{aabb:e.cE(this,c,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let S=[];const B=i,I=t.reparseOverscaled?n:i,M=(g-this._centerAltitude)*m,P=e=>{if(!this._elevation||!e.tileID||!s)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=L(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=(e,t)=>{if(.707*t{if(t.zoom=.9)return!0}else if(o&&(a=t.aabb.distanceZ(_)*m),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=T(new e.ae((t.x+.5)/i,(t.y+.5)/i));c=n>.85?1:n}if(!s&&!h){const e=Math.sqrt(i*i+r*r+a*a);let n=(1<0;){const n=C.pop(),r=n.x,a=n.y;let l=n.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<>1),d={aabb:s?n.aabb.quadrant(t):e.cE(this,c,n.zoom+1,i,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:u,wrap:n.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};o&&!h&&(d.tileID=new e.aP(n.zoom+1===B?I:n.zoom+1,n.wrap,n.zoom+1,i,u),P(d)),C.push(d)}else{const o=n.zoom===B?I:n.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let i=A?n.aabb.intersectsPrecise(p):n.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.cC(n.zoom,r,a);i=e.cD(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(n.aabb.center))s=15;else for(let e=0;e<4;e++)0!==n.aabb.quadrant(e).intersects(p)&&(s|=1<{const o=[0,0,0,1],s=[e.al,e.al,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aC(o,o,a),e.aC(s,s,a);const l=e.cF([],o,s),c=e.cG([],o,s),u=e.c_(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(r.tileID)),o||(o={min:b,max:x});const s=e.cH(this.rotation),a=[s[0]*e.al,s[1]*e.al,o.max];e.af(a,a,i),h=(1-a[1])*this.height*.5e.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.log2(e)}project(t){const i=e.aA(t.lat,-e.cI,e.cI),n=this.projection.project(t.lng,i);return new e.P(n.x*this.worldSize,n.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/e.ce(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-o.x)/e,r=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);n=e.x-t.x,r=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.ae(s.x-n,s.y-r))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e,t){return this.projection.locationPoint(this,e,t)}locationPoint3D(e,t){return this.projection.locationPoint(this,e,t,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e,t){return this.coordinateLocation(this.pointCoordinate3D(e,t))}locationCoordinate(t,i){const n=i?e.ce(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ae(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aC(r,r,this.pixelMatrixInverse),e.aC(o,o,this.pixelMatrixInverse);const s=o[3];e.cJ(r,r,1/r[3]),e.cJ(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.aC(i,i,this.pixelMatrixInverse),e.aC(n,n,this.pixelMatrixInverse),e.cJ(i,i,1/i[3]),e.cJ(n,n,1/n[3]),i[2]=e.ce(i[2],this._center.lat)*this.worldSize,n[2]=e.ce(n[2],this._center.lat)*this.worldSize,e.cJ(i,i,1/this.worldSize),e.cJ(n,n,1/this.worldSize),new e.ax([i[0],i[1],i[2]],e.aw([],e.av([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,o=e.ce(i[2],this._center.lat),s=e.ce(n[2],this._center.lat);return new e.ae(e.ak(i[0],n[0],r)/this.worldSize,e.ak(i[1],n[1],r)/this.worldSize,e.ak(o,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.ae(n[0],n[1],n[2]);let r=0,o=this.horizonLineFromTop();if(t.y>o)return this.pointCoordinate(t,i);const s=.02*o,a=t.clone();for(let t=0;t<10&&o-r>s;t++){a.y=e.ak(r,o,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(o=a.y,n=t):r=a.y}return n?new e.ae(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.cK)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.aC(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,n)),l=this.pointLocation3D(new e.P(i,n));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,n,r,o)=>{const s=(t+n)/2,a=(i+r)/2,l=new e.P(s,a),{lng:g,lat:_}=this.pointLocation3D(l),A=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(op)&&(m(t,i,s,a,o+1),m(s,a,n,r,o+1))};if(m(i,t,r,t,1),m(r,t,r,n,1),m(r,n,i,n,1),m(i,n,i,t,1),"globe"===this.projection.name){const[t,i]=e.cL(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.aI(new e.aS(c,h),new e.aS(u,d))}_getBoundsRectangular(t,i){const{top:n,left:r}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(r,n),l=new e.P(s,n),c=new e.P(s,o),u=new e.P(r,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.ae((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.ae(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.ae((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.ae(-p.y/m(p,d)+p.x,0)),(new e.aI).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_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(t){this.maxBounds=t,this.minLat=-e.cI,this.maxLat=e.cI,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(a=h-c),h-ut&&(s=t-l),t-e{for(let o=0;o<16;o++)t[o]=e.ak(i[o],n[o],r)})(a,a,l,e.c$(this.pitch>=sn?1:this.pitch/sn))}else a=l;const c=e.cO([],l,s);let u=e.cO([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.bz([]);e.bq(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aB(i,i,e.cP(this)),e.bq(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aB(u,u,i),e.aB(c,c,i),this.inverseAdjustmentMatrix=e.cQ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cR([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.bk(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cO([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.bk([],a);this.frustumCorners=e.cS.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.bz(d),e.cR(d,d,[1,-1,1]),e.cT(d,d,this._pitch),e.bA(d,d,this.angle);const p=e.cc(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.by(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.aB(d,p,d);const m=this.point,g=m.x,_=m.y,A=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=g-Math.round(g)+v*A+x*y,w=_-Math.round(_)+v*y+x*A,T=new Float64Array(u);if(e.bq(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=e.bB(),e.cR(u,u,[this.width/2,-this.height/2,1]),e.bq(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.bB(),e.cR(u,u,[1,-1,1]),e.bq(u,u,[-1,-1,0]),e.cR(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.aB(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.bk(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cU(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.af(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.c4(o,o,r),e.c4(n,n,-1),e.cV(n,n,o);const s=e.bB();e.bq(s,s,n),e.cR(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,e/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(o=Math.min((i-n)/r,1)),this._camera.position=e.bG([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=e.ce(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.an(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);e.bG(t,t,i,a),this._pitch=e.aA(n,e.an(this.minPitch),e.an(this.maxPitch)),this.angle=e.bS(r,-Math.PI,Math.PI),this._setZoom(e.aA(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ae(t[0],t[1],t[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,this._maxZoom)+4;return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(Math.max(0,e)*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,n=e.cK,r=0,o=1/0;for(;n-i>1e-6&&n>i;){const e=i+.5*(n-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cW(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.ag(e.av([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,n],r){const o=[t,i,n,1];e.aC(o,o,r);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,n=this.worldSize){const r=e.cN(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,n,r);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=e.ak(1,s,e.c$(this.pitch>=sn?1:this.pitch/sn))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aB(t,t,this.globeMatrix),t}getFrustum(t){return e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const ln=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const n=t.transform,r=Math.max(Math.abs(n._zoom-(t.minCutoffZoom-1)),1),o=n.isLODDisabled(!1)?e.ah(60,45,n.pitch):e.ah(30,15,n.pitch),s=n._farZ-n._nearZ,a=i*n.height,l=((1-(c=o))*n.cameraToCenterDistance+c*(n._farZ+a))*r;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(l-n._nearZ)/s,(l-a-n._nearZ)/s]}}},cn={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class un{constructor(e,t){this.aabb=e,this.lastCascade=t}}class hn{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 un(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,n){const r=e.d8.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),r)break}}return o+1}}class dn{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new hn,this._depthMode=new $i(e.context.gl.LEQUAL,$i.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._forceDisable=!1,this.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),e.tp.registerParameter(cn,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(cn,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(cn,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const n=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=n.style.order.reduce((e,i)=>{const r=n.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=n.context,s=cn.shadowMapResolution,a=cn.shadowMapResolution;if(0===this._cascades.length||cn.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.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]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let i=0;i=0)return{};const o=function(t,i,n){const r=n/(1<0&&(e.d7(o[1],o[1],[r[0]*s,0,0]),e.d7(o[2],o[2],[r[0]*s,0,0])),r[1]<0?(e.d7(o[0],o[0],[0,r[1]*s,0]),e.d7(o[1],o[1],[0,r[1]*s,0])):r[1]>0&&(e.d7(o[2],o[2],[0,r[1]*s,0]),e.d7(o[3],o[3],[0,r[1]*s,0]));const a={};return a.vertices=o,a.planes=[pn(o[1],o[0],o[4]),pn(o[2],o[1],o[5]),pn(o[3],o[2],o[6]),pn(o[0],o[3],o[7])],a}addShadowReceiver(t,i,n){this._receivers.add(t,e.d8.fromTileIdAndHeight(t,i,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function pn(t,i,n){const r=e.av([],n,i),o=e.av([],t,i),s=e.bH([],r,o),a=e.ag(s);return 0===a?[0,0,1,0]:(e.c4(s,s,1/a),[s[0],s[1],s[2],-e.bI(s,i)])}function fn(t){const i=t.properties.get("direction"),n=e.d3(i.x,i.y,i.z);n[2]=e.aA(n[2],0,75);const r=e.d5([n[0],n[1],n[2]]);return e.d4(r.x,r.y,r.z)}function mn(t,i,n){const r="none"===i.properties.get("color-use-theme"),o=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===n.properties.get("color-use-theme"),u=n.properties.get("color"),h=n.properties.get("intensity"),d=Math.max(e.bI([0,0,1],l),0),p=[0,0,0];e.c4(p,u.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),h);const f=[0,0,0];return e.c4(f,o.toPremultipliedRenderColor(r?null:t.getLut(n.scope)).toArray01Linear().slice(0,3),d*s),e.da([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function gn(t,i,n,r,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=r-n,m=r+n;let g,_;p>f/m?(g=r,_=r*d):(g=.5*m*(1+p),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*p+m*m*p*p));const A=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),v=[0,0,-g*u];e.af(v,v,y);let x=_*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?A:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,n,r);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.cO(s,o,i);const u=new Float64Array(16);e.bk(u,s);const h=e.cA.fromInvProjectionMatrix(u,c,a,!0);for(const i of h.points){const n=((w=i)[0]/=l,w[1]/=l,w[2]=e.ce(w[2],t._center.lat),w);x=Math.max(x,e.c5(e.d9([],v,n)))}}var w;x*=o/(o-1);const T=Math.acos(i[2]),E=Math.atan2(-i[0],-i[1]),C=new nn;C.position=v,C.setPitchBearing(T,E);const S=C.getWorldToCamera(c,A),B=x*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*B),M=C.getCameraToClipOrthographic(-B,B,-B,B,I,(B+s*A)/i[2]),P=new Float64Array(16);e.aB(P,M,S);const R=e.d4(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),L=.5*o,F=[0,0,0];e.af(F,R,P),e.c4(F,F,L);const k=[Math.floor(F[0]),Math.floor(F[1]),Math.floor(F[2])],D=[0,0,0];e.av(D,F,k),e.c4(D,D,-1/L);const O=new Float64Array(16);return e.bz(O),e.bq(O,O,D),e.aB(P,O,P),[P,B]}class _n extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,i){return e.db(this.requestManager.transformRequest(i,e.R.Model).url).then(n=>{if(!n)return;const r=e.dc(n),o=new e.dd(t,i,void 0,void 0,r);return o.computeBoundsAndApplyParent(),o}).catch(n=>{if(n&&404===n.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${n.message}`)))})}load(t,i,n={forceReload:!1}){this.models[i]||(this.models[i]={});const r=Object.keys(t),o=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!n.forceReload||(this.modelByURL[r]={modelId:e,scope:i},o.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(o).then(t=>{for(let e=0;e{this.fire(new e.y(new Error(`Could not load models: ${t.message}`)))})}isLoaded(){for(const e in this.numModelsLoading)if(this.numModelsLoading[e]>0)return!1;return!0}hasModel(e,t,i={exactIdMatch:!1}){return!!(i.exactIdMatch?this.getModel(e,t):this.getModelByURL(this.modelUris[t][e]))}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}getModelByURL(e){if(!e)return null;const t=this.modelByURL[e];return t?this.models[t.scope][t.modelId].model:null}hasModelBeenAdded(e,t){return this.models[t]&&void 0!==this.models[t][e]}getModelURIs(e){return this.modelUris[e]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===n)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(n)){const{scope:e,modelId:t}=this.modelByURL[n];this.models[e][t].numReferences++}else this.modelUris[i][e]=n,this.load({[e]:this.modelUris[i][e]},i)}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n={};for(const r of t)this.hasModel(r,i,{exactIdMatch:!0})||this.hasURLBeenRequested(r)?this.models[i][r].numReferences++:this.modelUris[i][r]&&!this.hasURLBeenRequested(r)?n[r]=this.modelUris[i][r]:!this.hasURLBeenRequested(r)&&e.de(r,!1)&&(this.modelUris[i][r]=this.requestManager.normalizeModelURL(r),n[r]=this.modelUris[i][r]);this.load(n,i)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,n=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||n)){const n=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[n];const r=this.models[t][e].model;if(!r)return;delete this.models[t][e],r.destroy()}}destroy(){for(const e of Object.keys(this.models))for(const t of Object.keys(this.models[e])){const i=this.models[e][t].model;delete this.models[e][t],i&&i.destroy()}this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}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].model&&this.models[t][i].model.upload(e.context)}}const An=e.a6.colorTheme,yn=new e.a9({data:new e.aa(An.data)});function vn(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:n,top:r,width:o,height:s}=t.metadata.content_area,a=n*i,l=r*i;return[a,l,a+o*i,l+s*i]}function xn(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class bn{constructor(e,t,i){this.id=e,this.scope=t,this.sourceCache=i,this.pendingRequests=new Set,this.missingRequests=new Set}addPendingRequest(e){this.missingRequests.has(e.name)||this.pendingRequests.has(e.name)||this.pendingRequests.add(e.name)}hasPendingRequests(){return this.pendingRequests.size>0}resolvePendingRequests(){const t=new Map;if(!this.sourceCache.loaded())return t;const i=this.sourceCache.getVisibleCoordinates();if(0===i.length)return t;const n=this.sourceCache.getSource();if(!(n instanceof ht))return t;const r=i.map(e=>this.sourceCache.getTile(e)),o=n.getImages(r,Array.from(this.pendingRequests));for(const[i,n]of o)t.set(e.I.from({name:i,iconsetId:this.id}),n),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const wn=(e,t)=>Le(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Tn=e.aH(Nt,["addLayer","removeLayer","setLights","setPaintProperty","setLayoutProperty","setLayerProperty","setSlot","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setSnow","setRain","setProjection","setCamera","addImport","removeImport","updateImport","addIconset","removeIconset"]),En=e.aH(Nt,["setCenter","setZoom","setBearing","setPitch"]),Cn=new Set(["background","sky","slot","custom"]),Sn={version:8,layers:[],sources:{}},Bn={duration:300,delay:0};class In extends e.E{constructor(t,i={}){super(),this.map=t,this.scope=i.scope||"",this.globalId=null,this.fragments=[],this.importDepth=i.importDepth||0,this.importsCache=i.importsCache||new Map,this.resolvedImports=i.resolvedImports||new Set,this.transition=Object.assign({},Bn),this._buildingIndex=new Ot(this),this.crossTileSymbolIndex=new Gi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new H,this.dispatcher=i.dispatcher?i.dispatcher:new e.D(e.dg(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new $(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.dh(t._requestManager,i.localFontFamily?e.di.all:i.localIdeographFontFamily?e.di.ideographs:e.di.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new _n(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.dj());const n=this;this._rtlTextPluginCallback=In.registerForPluginStateChange(t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.dk(t),i&&i.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||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)}})}load(e){return e?("string"==typeof e?this.loadURL(e):this.loadJSON(e),this):this}_getGlobalId(t){if(!t)return null;if("string"==typeof t){if(e.h(t))return t;const i=e.dl(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.dm(JSON.stringify(t))}`}_diffStyle(t,i,n){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,n))}catch(e){t(e,!1)}};if("string"==typeof t){const n=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(n,e.R.Style);e.m(o,(t,n)=>{t?this.fire(new e.y(t)):n&&r(n,i)})}else"object"==typeof t&&r(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.h(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const r=this.importsCache.get(t);if(r)return this._load(r,n);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(o,(i,r)=>{if(this._request=null,i)this.fire(new e.y(i));else if(r)return this.importsCache.set(t,r),this._load(r,n)})}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Sn,!1)}_loadImports(t,i,n){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise(e=>{t.once("style.import.load",e),t.once("error",e)}).then(()=>this.mergeAll());if(r.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(n){const e=this.fragments.findIndex(({id:e})=>e===n);this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(r)}getImportGlobalIds(e=this,t=new Set){for(const i of e.fragments)i.style.globalId&&t.add(i.style.globalId),this.getImportGlobalIds(i.style,t);return[...t.values()]}_createFragmentStyle(t){const i=this.scope?e.B(t.id,this.scope):t.id;let n;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(n=Object.assign({},t.config,r));const o=new In(this.map,{scope:i,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:n,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Sn,{imports:[{id:"basemap",data:t,url:""}]},t.center?{center:t.center}:{},t.bearing?{bearing:t.bearing}:{},t.pitch?{pitch:t.pitch}:{},t.zoom?{zoom:t.zoom}:{},t.light?{light:t.light}:{});return this._importedAsBasemap=!0,void this._load(e,i)}if(this.updateConfig(this._config,t.schema),i&&wn(this,ye(t)))return;this._loaded=!0,this.stylesheet=e.dn(t);const n=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});if(t.iconsets)for(const e in t.iconsets)this.addIconset(e,t.iconsets[e]);t.sprite?this._loadIconset(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const n=Ut(this.stylesheet.layers);if(this._order=n.map(e=>e.id),this.stylesheet.light&&e.w("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 De(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new De(this.stylesheet.light)),this._layers={};for(const t of n){const i=e.dt(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const n=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&i.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(r,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.snow&&this._createSnow(this.stylesheet.snow),this.stylesheet.rain&&this._createRain(this.stylesheet.rain),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.z("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))}).catch(t=>{this.fire(new e.y(new Error("Failed to load imports",t))),this.fire(new e.z(o?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const r=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(r){const t=this._evaluateColorThemeData(r);this._loadColorTheme(t).then(()=>{n()}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()})}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances}mergeAll(){let e,t,i,n,r,o,s,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(h=>{if(h.stylesheet){if(null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);n=this._prioritizeTerrain(n,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(r=h.fog),h.stylesheet.snow&&null!=h.snow&&(o=h.snow),h.stylesheet.rain&&null!=h.rain&&(s=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=o,this.rain=s,this._styleColorThemeForScope=u,null===n?delete this.terrain:this.terrain=n,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Bn,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const n=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:n?e:null:null!=t&&(!e||n||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 t={},i={},n={};this.forEachFragmentStyle(r=>{for(const i in r._sourceCaches){const n=e.B(i,r.scope);t[n]=r._sourceCaches[i]}for(const t in r._otherSourceCaches){const n=e.B(t,r.scope);i[n]=r._otherSourceCaches[t]}for(const t in r._symbolSourceCaches){const i=e.B(t,r.scope);n[i]=r._symbolSourceCaches[t]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=n}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const n=i,r=e.B(n.sourceId,t.scope);this._mergedIndoor[r]=new Set(n.sourceLayers||[])}})}mergeLayers(){const t={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const o=n._layers[r];if("slot"===o.type){const i=e.dp(r);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}}),this._mergedOrder=[];let r=-1;const o=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.dp(s.id);t[i]&&o(t[i]),this._mergedSlots.push(i)}else{const t=e.B(s.id,s.scope);this._mergedOrder.push(t),n[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0)}};if(o(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i])}this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,n){const r=Object.assign({},i);for(const e of Object.keys(An))void 0===r[e]&&(r[e]=An[e].default);const o=new e.a8(yn,t,new Map(n));return o.setTransitionOrValue(r,n),o.untransitioned().possiblyEvaluate(new e.ac(0,{worldview:void 0}))}(this.scope,t,this.options).get("data"):null}_loadColorTheme(t){this._styleColorTheme.lutLoading=!0,this._styleColorTheme.lutLoadingCorrelationID+=1;const i=this._styleColorTheme.lutLoadingCorrelationID;return new Promise((n,r)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void n();let s=t;s.startsWith(o)||(s=o+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void n();this._styleColorTheme.lutLoading=!1;const{width:o,height:s,data:c}=e.o.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)return void r(new Error("The width of the image must be equal to the height squared."));this.getImage(a)&&this.removeImage(a),this.addImage(a,{data:new e.q({width:o,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const u=this.imageManager.getImage(a,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},n()):r(new Error("Missing LUT image."))}})}getLut(e){const t=this._styleColorThemeForScope[e];return t?t.lut:null}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.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,n){let r,o,s;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,s||(s=e,r=t,u())}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,s||(s=e,o=t,u())});function u(){if(s)n(s);else if(r&&o){const t=e.o.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=r[n],f=new e.q({width:o,height:s});e.q.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[n]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==c&&c,stretchX:h,stretchY:d,content:p,usvg:!1,version:0}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i){const t=new Map;for(const n in i)t.set(e.I.from(n),i[n]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const n=this.getOwnSourceCache(i.source);if(!n)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=n.getSource();if("raster-array"!==r.type)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const o=new bn(t,this.scope,n);this.imageManager.addImageProvider(o,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(t){if(!e.h(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var n,r;this._spriteRequest=(r=(n,r)=>{if(this._spriteRequest=null,n)i?this._loadSprite(t):this.fire(new e.y(n));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.bt((n=this.map._requestManager).transformRequest(n.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void r(t);const n={},o=e.df(new e.bs(i));for(const t of o.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:vn(t),stretchX:t.metadata?xn(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?xn(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};n[t.name]=i}r(null,n)}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.y(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${t.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.imageManager.hasPatternsInFlight())return!1;if(!this.modelManager.isLoaded())return!1;if(this._styleColorTheme.lutLoading)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()}hasSnowTransition(){return!!this.snow&&this.snow.hasTransition()}hasRainTransition(){return!!this.rain&&this.rain.hasTransition()}hasTransitions(){if(this.hasLightTransitions())return!0;if(this.hasFogTransition())return!0;if(this.hasSnowTransition())return!0;if(this.hasRainTransition())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}_getOrder(e){return e?this.order:this._mergedOrder}isLayerDraped(e){return!!this.terrain&&e.isDraped(this.getLayerSourceCache(e))}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}_checkLayer(t){const i=this.getOwnLayer(t);if(i)return i;this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style.`)))}_checkSource(t){const i=this.getOwnSource(t);if(i)return i;this.fire(new e.y(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let n=e.minzoom||0;n<(e.maxzoom||25.5);n++){const n=e.getProgramIds();if(n)for(const r of n){const n=e.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);n&&(i.style=this,this.fog&&(i._fogVisible=!0,n.overrideFog=!0,i.getOrCreateProgram(r,n)),i._fogVisible=!1,n.overrideFog=!1,i.getOrCreateProgram(r,n),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(n.overrideRtt=!0,i.getOrCreateProgram(r,n)))}}}update(t){if(!this._loaded)return;this.ambientLight&&this.ambientLight.recalculate(t),this.directionalLight&&this.directionalLight.recalculate(t);const i=this.calculateLightsBrightness();t.brightness=i||0,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const n=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:n}=e[t];(i||n)&&(this._updateWorkerLayers(t,i,n),r=!0)}this.updateSourceCaches(),this._updateTilesForChangedImages(),this.updateLayers(t),this.light&&this.light.updateTransitions(t),this.ambientLight&&this.ambientLight.updateTransitions(t),this.directionalLight&&this.directionalLight.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this.snow&&this.snow.updateTransitions(t),this.rain&&this.rain.updateTransitions(t),this._changes.reset()}const o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(i,t)}):this.precompilePrograms(i,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&r&&this.mergeLayers();const s=this.imageManager.getPendingImageProviders();for(const e of s)e.sourceCache.used=!0;for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light&&this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.snow&&this.snow.recalculate(t),this.rain&&this.rain.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),this.imageManager.clearUpdatedImages(this.scope),n&&this.fire(new e.z("data",{dataType:"style"}))}updateImageProviders(){const e=this.imageManager.getPendingImageProviders();for(const t of e){const e=t.resolvePendingRequests(),i=this.getFragmentStyle(t.scope);i&&i.addImages(e)}}_updateTilesForChangedImages(){const e={};for(const t in this._mergedSourceCaches){const i=this._mergedSourceCaches[t].getSource().scope;e[i]=e[i]||this._changes.getUpdatedImages(i),0!==e[i].length&&this._mergedSourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e[i])}for(const t in e)this._changes.resetUpdatedImages(t)}_updateWorkerLayers(e,t,i){const n=this.getFragmentStyle(e);n&&this.dispatcher.broadcast("updateLayers",{layers:t?n._serializeLayers(t):[],scope:e,removedIds:i||[],options:n.options})}setState(t,i){if(this._checkLoaded(),wn(this,ye(t)))return!1;(t=e.dn(t)).layers=Ut(t.layers);const n=function(t,i){if(!t)return[{command:Nt.setStyle,args:[i]}];let n=[];try{if(!e.bx(t.version,i.version))return[{command:Nt.setStyle,args:[i]}];if(e.bx(t.center,i.center)||n.push({command:Nt.setCenter,args:[i.center]}),e.bx(t.zoom,i.zoom)||n.push({command:Nt.setZoom,args:[i.zoom]}),e.bx(t.bearing,i.bearing)||n.push({command:Nt.setBearing,args:[i.bearing]}),e.bx(t.pitch,i.pitch)||n.push({command:Nt.setPitch,args:[i.pitch]}),e.bx(t.sprite,i.sprite)||n.push({command:Nt.setSprite,args:[i.sprite]}),e.bx(t.glyphs,i.glyphs)||n.push({command:Nt.setGlyphs,args:[i.glyphs]}),e.bx(t.imports,i.imports)||function(t=[],i=[],n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&r[e.source]?n.push({command:Nt.removeLayer,args:[e.id]}):s.push(e)});let a=t.terrain;a&&r[a.source]&&(n.push({command:Nt.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),e.bx(a,i.terrain)||n.push({command:Nt.setTerrain,args:[i.terrain]}),function(t,i,n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice(),c=Object.create(null);let u,h,d,p,f,m,g;for(u=0,h=0;u!(e.command in En));if(0===n.length)return!1;const r=n.filter(e=>!(e.command in Tn));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const o=[];return n.forEach(e=>{o.push(this[e.command](...e.args))}),i&&Promise.all(o).then(i).catch(i),this.stylesheet=t,this.mergeAll(),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}_updateWorkerImages(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(0===t.size)return this;for(const[i,n]of t.entries()){if(this.getImage(i))return this.fire(new e.y(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,n),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.y(new Error(`An image with the name "${t.name}" already exists.`))):(this.imageManager.addImage(t,this.scope,i),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this)}updateImage(t,i,n=!1){this.imageManager.updateImage(t,this.scope,i),n&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})))}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModelURLs(t){return this.modelManager.addModelURLs(t,this.scope),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(t,i,n={}){return this._checkLoaded(),this._validate(Pe,`models.${t}`,i,null,n)||(this.modelManager.addModel(t,i,this.scope),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope,!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,n={}){if(this._checkLoaded(),void 0!==this.getOwnSource(t))throw new Error(`There is already a source with ID "${t}".`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(ve,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=pt(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const o=t=>{const i=(t?"symbol:":"other:")+r.id,n=e.B(i,this.scope),o=this._sourceCaches[i]=new Lt(n,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),n.isInitialLoad||(this.mergeSources(),this._changes.setDirty())}removeSource(t){this._checkLoaded();const i=this.getOwnSource(t);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.scope===this.scope&&this.terrain.get().source===t)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));if(this.stylesheet.iconsets){const i=Object.entries(this.stylesheet.iconsets).find(([e,i])=>"source"===i.type&&i.source===t);if(i)return this.fire(new e.y(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const n=this.getOwnSourceCaches(t);for(const t of n){const i=e.dp(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.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}areTilesLoaded(){const e=this._mergedSourceCaches;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}setLights(t){if(this._checkLoaded(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const n of t){if(this._validate(be,"lights",n))return;switch(n.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(n),e.updateTransitions(i)}else this.ambientLight=new et(n,Ke||(Ke=new e.a9({color:new e.aa(e.a6.properties_light_ambient.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(n),e.updateTransitions(i)}else this.directionalLight=new et(n,Xe||(Xe=new e.a9({direction:new e.ap(e.a6.properties_light_directional.direction),color:new e.aa(e.a6.properties_light_directional.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_directional.intensity),"cast-shadows":new e.aa(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.aa(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.aa(e.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const n=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ac(this.z||0,n);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const n=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=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.d3(s.x,s.y,s.z)[2]/90,l=n(r)*o*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity"),h=n(c)*u;return Number(((l+h)/2).toFixed(6))}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(t){if(null==t||""===t&&this.isRootStyle())return this;if(e.dq(t)){const i=e.dr(t),n=this.fragments.find(({id:e})=>e===i);if(!n)return;const r=e.dp(t);return n.style.getFragmentStyle(r)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i={},n=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const r in t){const o=this._featuresetSelectors[r]=[];for(const s of t[r].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const o=n(t.source,t.sourceLayer);if(o in i&&i[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${r}'s selector is not associated to the same source, skip this selector`);continue}i[o]=s.featureNamespace}let t;if(s.properties)for(const i in s.properties){const n=e.U(s.properties[i]);"success"===n.result&&(t=t||{},t[i]=n.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._uniqueFeatureID})}}}getFeaturesetDescriptors(e){const t=this.getFragmentStyle(e);if(!t||!t.stylesheet.featuresets)return[];const i=[];for(const e in t.stylesheet.featuresets)i.push({featuresetId:e,importId:t.scope?t.scope:void 0});return i}getFeaturesetLayers(t,i){const n=this.getFragmentStyle(i),r=n.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const o=[];for(const e of r[t].selectors){const t=n.getOwnLayer(e.layer);t&&o.push(t)}return o}getConfigProperty(t,i){const n=this.getFragmentStyle(t);if(!n)return null;const r=e.B(i,n.scope),o=n.options.get(r),s=o?o.value||o.default:null;return s?s.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const n=e.B(t,i);return this._mergedIndoor[n]}setIndoorData(e,t){this.map.indoor.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,n){const r=this.getFragmentStyle(t);if(!r)return;const o=r.stylesheet.schema;if(!o||!o[i])return;const s=e.U(n);if("success"!==s.result)return void wn(this,s.value);const a=s.value.expression,l=e.B(i,r.scope),c=r.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[i],g=e.U(o[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,Object.assign({},c,{value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m})),this.updateConfigDependencies(i)):this.fire(new e.y(new Error(`No schema defined for the config option "${i}" in the "${t}" fragment.`)))}getConfig(t){const i=this.getFragmentStyle(t);if(!i)return null;const n=i.stylesheet.schema;if(!n)return null;const r={};for(const t in n){const n=e.B(t,i.scope),o=i.options.get(n),s=o?o.value||o.default:null;r[t]=s?s.serialize():null}return r}setConfig(e,t){const i=this.getFragmentStyle(e);i&&(i.updateConfig(t,i.stylesheet.schema),this.updateConfigDependencies())}getSchema(e){const t=this.getFragmentStyle(e);return t?t.stylesheet.schema:null}setSchema(e,t){const i=this.getFragmentStyle(e);i&&(i.stylesheet.schema=t,i.updateConfig(i._config,t),this.updateConfigDependencies())}updateConfig(t,i){if(this._config=t,t||i)if(i)for(const n in i){let r,o;const s=e.U(i[n].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[n]){const i=e.U(t[n]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[n];if(r){const t=e.B(n,this.scope);this.options.set(t,{default:r,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.y(new Error(`No schema defined for config option "${n}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty())}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.snow&&this.snow.updateConfig(this.options),this.rain&&this.rain.updateConfig(this.options),this.forEachFragmentStyle(e=>{const t=e._styleColorTheme.colorThemeOverride?e._styleColorTheme.colorThemeOverride:e._styleColorTheme.colorTheme;if(t){const i=e._evaluateColorThemeData(t);(!e._styleColorTheme.lut&&""!==i||e._styleColorTheme.lut&&i!==e._styleColorTheme.lut.data)&&e.setColorTheme(t)}}),this._changes.setDirty()}addLayer(t,i,n={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.y(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(wn(this,e.ds(t)))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.dn(t),t=Object.assign(t,{source:r})),this._validate(Se,`layers.${r}`,t,{arrayIndex:-1},n))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=e.B(o.source,o.scope);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?a=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const l=this.getOwnLayerSourceCache(o),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&o.canCastShadows()&&c&&(l.castsShadows=!0);const u=this._changes.getRemovedLayer(o);if(u&&o.source&&l&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.B(o.source,o.scope);u.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const n=this._checkLayer(t);if(!n)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),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],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const n=this.getOwnLayerSourceCache(t);if(n&&n.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}n.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 n=this._checkLayer(e);n&&(n.minzoom===t&&n.maxzoom===i||(null!=t&&(n.minzoom=t),null!=i&&(n.maxzoom=i),this._updateLayer(n)))}getSlots(){return this._checkLoaded(),this._mergedSlots}setSlot(e,t){this._checkLoaded();const i=this._checkLayer(e);i&&i.slot!==t&&(i.slot=t,this._updateLayer(i))}setFilter(t,i,n={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bx(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Be,`layers.${r.id}.filter`,i,{layerType:r.type},n)||(r.filter=e.dn(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.dn(i.filter)}setLayoutProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.bx(o.getLayoutProperty(i),n)){if(null!=n&&(!r||!1!==r.validate)&&wn(o,Me.call(ye,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,n),0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),this._updateLayer(o)}}setLayerProperty(e,t,i,n={}){this._checkLoaded();const r=this._checkLayer(e);r&&("appearances"===t?(r.setAppearances(i),this._changes.setDirty()):r.isPaintProperty(t)?this.setPaintProperty(e,t,i,n):this.setLayoutProperty(e,t,i,n))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(e.bx(o.getPaintProperty(i),n))return;if(null!=n&&(!r||!1!==r.validate)&&wn(o,Ie.call(ye,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6})))return;const s=o.setPaintProperty(i,n);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),s&&this._updateLayer(o),this._changes.updatePaintProperties(o)}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.setFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.setFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=t.sourceLayer,o=this._checkSource(n);if(!o)return;const s=o.type;if("geojson"===s&&r)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.setFeatureState(r,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.removeFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.removeFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=this._checkSource(n);if(!r)return;const o=r.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:n,importId:r}=t.target,o=this.getFragmentStyle(r),s=o.getFeaturesetLayers(n);for(const{source:n,sourceLayer:r}of s){const s=o.getFeatureState({id:t.id,source:n,sourceLayer:r});if(s&&!i)i=s;else if(!e.bx(i,s))return void this.fire(new e.y(new Error("The same feature id exists in multiple sources in the featureset, but their feature states are not consistent through the sources.")))}}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);i=this.getFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer})}return i}const i=t.source,n=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.du({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,imports:this._serializeImports(),schema:this.stylesheet.schema,camera:this.stylesheet.camera,light:this.stylesheet.light,lights:this.stylesheet.lights,terrain:i,fog:this.stylesheet.fog,snow:this.stylesheet.snow,rain:this.stylesheet.rain,center:this.stylesheet.center,"color-theme":this.stylesheet["color-theme"],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)}_updateFilteredLayers(e){for(const t of Object.values(this._mergedLayers))e(t)&&this._updateLayer(t)}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),n=e.B(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[n]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(n,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,n={},r=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){n[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t)}}}r.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=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&n[t.layer.id]{if(Cn.has(e.type))return;const t=this.getOwnLayerSourceCache(e),i=o[t.id]=o[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};e.is3D(!!this.terrain)&&(i.has3DLayers=!0),i.layers[e.fqid]=i.layers[e.fqid]||{styleLayer:e,targets:[]},i.layers[e.fqid].targets.push({filter:r})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.y(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i)}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,o,n),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dv(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,n){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Be,"queryRenderedFeatures.filter",i.filter,null,i),r=e.b5(i.filter));const o="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:o,filter:r}));else{const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:o,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:o,filter:r,target:e})}}const a=this.queryRenderedTargets(t,s,n),l=[],c=new Set;for(const t of a)for(const i of t.variants[o])mt(i,t,c)||l.push(new e.dw(t,i));return l}queryRenderedTargets(t,i,n){const r={},o=(e,t,i,n)=>{const o=r[t.id]=r[t.id]||{sourceCache:t,layers:{},has3DLayers:!1};if(o.layers[e.fqid]=o.layers[e.fqid]||{styleLayer:e,targets:[]},e.is3D(!!this.terrain)&&(o.has3DLayers=!0),!n)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push(Object.assign({},i,{namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID}))};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:n}=t.target,r=this.getFragmentStyle(n);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!Cn.has(i.type)&&o(i,r.getOwnLayerSourceCache(i),t,e)}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Cn.has(i.type))continue;o(i,this.getLayerSourceCache(i),t)}const s=this._queryRenderedFeatures(t,r,n);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,t,i){const n=[],r=!!this.map._showQueryGeometry,o=tt.createFromScreenPoints(e,i);for(const e in t){const s=gt(o,t[e],this._availableImages,i,r);Object.keys(s).length&&n.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=_t(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&n.push(i)}return n}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Be,"querySourceFeatures.filter",i,null,t);let n=[];const r=this.getOwnSourceCaches(e);for(const e of r)n=n.concat(At(e,t));return n}addSourceType(e,t,i){return In.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(In.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(t,i,n={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e.bx(t[i],r[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(t,i,n),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.hasCanvasFingerprintNoise(),this.disableElevatedTerrain&&e.w("Terrain and hillshade are disabled because of Canvas2D limitations when fingerprinting protection is enabled (e.g. in private browsing mode)."))}setTerrain(t,i=1){if(this._checkLoaded(),!t)return this.terrainSetForDrapingOnly()||(delete this.terrain,this.map.transform.projection.requiresDraping&&this.setTerrainForDraping()),0===i&&delete this.terrain,null===t?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let n=t;const r=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.dn(n),n=Object.assign(n,{source:t})}const t=Object.assign({},n),i={};if(this.terrain&&r){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(we,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,r=i.get();for(const t of Object.keys(e.a6.terrain))!n.hasOwnProperty(t)&&e.a6.terrain[t].default&&(n[t]=e.a6.terrain[t].default);for(const n in t)if(!e.bx(t[n],r[n])){i.set(t,this.options),this.stylesheet.terrain=t;const n=this._getTransitionParameters({duration:0});i.updateTransitions(n),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Ze(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createSnow(e){const t=this.snow=new Je(e,this.map.transform,this.scope,this.options);this.stylesheet.snow=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i)}_createRain(e){const t=this.rain=new Ye(e,this.map.transform,this.scope,this.options);this.stylesheet.rain=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(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.fog=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createFog(t);this._markersNeedUpdate=!0}getSnow(){return this.snow?this.snow.get():null}setSnow(t){if(this._checkLoaded(),!t)return delete this.snow,void delete this.stylesheet.snow;if(this.snow){const i=this.snow;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.snow=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createSnow(t);this._markersNeedUpdate=!0}getRain(){return this.rain?this.rain.get():null}setRain(t){if(this._checkLoaded(),!t)return delete this.rain,void delete this.stylesheet.rain;if(this.rain){const i=this.rain;if(!e.bx(i.get(),t)){i.set(t,this.options),this.stylesheet.rain=i.get();const e=this._getTransitionParameters({duration:0});i.updateTransitions(e)}}else this._createRain(t);this._markersNeedUpdate=!0}_reloadColorTheme(){const t=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()},i=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(!i)return this._styleColorTheme.lut=null,void t();const n=this._evaluateColorThemeData(i);this._loadColorTheme(n).then(()=>{this.fire(new e.z("colorthemeset")),t()}).catch(t=>{e.w(`Couldn't set color theme: ${t}`)})}setColorTheme(t){this._checkLoaded(),this._styleColorTheme.colorThemeOverride&&e.w("Note: setColorTheme is called on a style with a color-theme override, the passed color-theme won't be visible."),this._styleColorTheme.colorTheme=t,this._reloadColorTheme()}setImportColorTheme(e,t){const i=this.getFragmentStyle(e);i&&(i._styleColorTheme.colorThemeOverride=t,i._reloadColorTheme())}_getTransitionParameters(t){return{now:e.o.now(),transition:Object.assign(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i of this._mergedOrder)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 ze(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const n=this._getTransitionParameters({duration:0});i.updateTransitions(n)}_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(t,i,n,r,o={}){if(o&&!1===o.validate)return!1;const s=Object.assign({},this.serialize());return wn(this,t.call(ye,Object.assign({key:i,style:s,value:n,styleSpec:e.a6},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dx.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.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.modelManager.setEventedParent(null),this.modelManager.destroy(),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()}clearLayers(){for(const e in this._mergedLayers){const t=this._mergedLayers[e];t._clear&&t._clear()}}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()}reloadModels(){this.modelManager.reloadModels(""),this.forEachFragmentStyle(e=>{e.modelManager.reloadModels(e.scope)})}updateSources(e){let t;this.directionalLight&&(t=fn(this.directionalLight));const i=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];t.hasElevation()&&!i.has(t.source)&&i.add(t.source)}for(const n in this._mergedSourceCaches){const r=this._mergedSourceCaches[n],o=i.has(r._source.id);r.update(e,void 0,void 0,t,o)}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,n,r,o,s,a=!1){let l=!1,c=!1;const u={},h={};for(const t of this._mergedOrder){const n=this._mergedLayers[t];if("symbol"!==n.type)continue;const r=e.B(n.source,n.scope);let o=u[r];if(!o){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),o=u[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const s=this.crossTileSymbolIndex.addLayer(n,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.z("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),i.zoom))&&(this.pauseablePlacement=new zi(i,this._mergedOrder,a,n,r,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,u,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;te===t.id))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return n.push(t),this._loadImports([t],!0);const r=n.findIndex(({id:e})=>e===i);return-1===r&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=n.slice(0,r).concat(t).concat(n.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(t);return-1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==n[r].url&&this.setImportUrl(t,i.url),e.bx(i.config,n[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.bx(i.data,n[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const n=this.getImportIndex(e);if(-1===n)return this;const r=this.getImportIndex(t);if(-1===r)return this;const o=i[n],s=this.fragments[n];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,r).concat(o).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);if(-1===n)return this;i[n].url=t;const r=this.fragments[n];return r.style=this._createFragmentStyle(i[n]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),n=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete n[i].data,this.setImportUrl(e,n[i].url))}setImportConfig(e,t,i){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const o=this.fragments[n];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.style.updateConfig(t,s),this.updateConfigDependencies(),this}removeImport(e){this._checkLoaded();const t=this.stylesheet.imports||[],i=this.getImportIndex(e);-1!==i&&(t.splice(i,1),this.fragments[i].style._remove(),this.fragments.splice(i,1),this._reloadImports())}getImportIndex(t){const i=(this.stylesheet.imports||[]).findIndex(e=>e.id===t);return-1===i&&this.fire(new e.y(new Error(`Import '${t}' does not exist in the map's style and cannot be updated.`))),i}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(t,i){const n=e.B(t,i);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(t){const i=e.B(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);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)}}getGlyphsUrl(){return this.stylesheet.glyphs}setGlyphsUrl(e){this.stylesheet.glyphs=e,this.glyphManager.setURL(e)}getImages(t,i,n){this.imageManager.getImages(i.images,i.scope,n),this._updateTilesForChangedImages();const r=t=>{if(t){const n=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,n)}},o=e.B(i.source,i.scope);r(this._mergedOtherSourceCaches[o]),r(this._mergedSymbolSourceCaches[o]),i.images.some(e=>e.iconsetId)&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,n){return e.dy(i,n)}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(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(new Error(`There is no source with ID '${t}'`))),!1):i.every(e=>e.loaded())}has3DLayers(){return this._has3DLayers}hasSymbolLayers(){return this._hasSymbolLayers}hasCircleLayers(){return this._hasCircleLayers}isLayerClipped(e,t){if(!this._clipLayerPresent&&"fill-extrusion"!==e.type&&"building"!==e.type)return!1;const i="fill-extrusion"===e.type&&("building"===e.sourceLayer||"procedural_buildings"===e.sourceLayer),n="building"===e.type;if(e.is3D(!!this.terrain)){if(i||n||t&&"batched-model"===t.type)return!0;if("model"===e.type)return!0}else if("symbol"===e.type)return!0;return!1}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(e=>{e.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}In.getSourceType=function(e){return dt[e]},In.setSourceType=function(e,t){dt[e]=t},In.registerForPluginStateChange=e.dz;class Mn extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},e.aX(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=e,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(e){this._activeFloorsVisible=e,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(e){for(const[t,i]of Object.entries(e.buildings))if(this._buildings[t])for(const e of i.floorIds)this._buildings[t].floors[e]||(this._buildings[t].floors[e]=i.floors[e]);else this._buildings[t]=i;for(const t of e.activeFloors)this._activeFloors.add(t);this._updateIndoorSelector()}getIndoorTileOptions(e,t){const i=this._style.getIndoorSourceLayers(e,t);return i&&this._indoorState?{sourceLayers:i,indoorState:this._indoorState}:null}_updateUI(t,i,n){const r=function(t,i,n,r){let o=null,s=Number.MAX_SAFE_INTEGER;if(r<16)return null;for(const[r,a]of Object.entries(t)){const t=a.center;if(t){const a=i.distanceTo(e.aS.convert(t));a({id:e,name:n.floors[e].name,zIndex:n.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex);this.fire(new e.z("selector-update",{selectedFloorId:r,activeFloorsVisible:this._activeFloorsVisible,floors:o}))}_updateActiveFloors(){const e=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:e,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var Pn="\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;float linearDepth=(depth-near)/(far-near);return clamp((linearDepth-cutoffStart)/(cutoffEnd-cutoffStart),0.0,1.0);}\n#endif",Rn="\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 vec3 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\n#endif\nvec4 applyCutout(vec4 color,float height) {\n#ifdef INDICATOR_CUTOUT\nfloat verticalFadeRange=u_indicator_cutout_centers.z*0.25;float holeMinOpacity=mix(1.0,u_indicator_cutout_params.x,smoothstep(u_indicator_cutout_centers.z,u_indicator_cutout_centers.z+verticalFadeRange,height));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\nvec4 textureLodCustom(sampler2D image,highp vec2 pos,highp vec2 lod_coord) {highp vec2 size=vec2(textureSize(image,0));highp vec2 dx=dFdx(lod_coord.xy*size);highp vec2 dy=dFdy(lod_coord.xy*size);highp float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));highp float lod=0.5*log2(delta_max_sqr);return textureLod(image,pos,lod);}vec4 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Ln="\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 vec2 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 (units_to_pixels*pos+offset)/pattern_size;}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) {return get_pattern_pos(pixel_coord_upper,pixel_coord_lower,pattern_size,vec2(tile_units_to_pixels),pos);}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);}\n#ifndef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_id) attrib\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_id) attrib\n#define DECLARE_MATERIAL_TABLE_INFO\n#endif",Fn="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;}",kn="\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;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\nvec4 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; }\n#endif\n#ifdef DEPTH_OCCLUSION\nuniform highp sampler2D u_depth;uniform highp vec2 u_depth_size_inv;uniform highp vec2 u_depth_range_unpack;uniform highp float u_occluder_half_size;uniform highp float u_occlusion_depth_offset;\n#ifdef DEPTH_D24\nfloat unpack_depth(float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}vec4 unpack_depth4(vec4 depth) {return depth*u_depth_range_unpack.x+vec4(u_depth_range_unpack.y);}\n#else\nhighp float unpack_depth_rgba(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;}\n#endif\nbool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\n#ifdef DEPTH_D24\nfloat depth=unpack_depth(texture(u_depth,(coord.xy+1.0)*0.5).r);\n#else\nfloat depth=unpack_depth_rgba(texture(u_depth,(coord.xy+1.0)*0.5));\n#endif\nreturn coord.z+u_occlusion_depth_offset > depth;}highp vec4 getCornerDepths(vec2 coord) {highp vec3 df=vec3(u_occluder_half_size*u_depth_size_inv,0.0);highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef DEPTH_D24\nhighp vec4 depth=vec4(\ntexture(u_depth,uv-df.xz).r,texture(u_depth,uv+df.xz).r,texture(u_depth,uv-df.zy).r,texture(u_depth,uv+df.zy).r\n);depth=unpack_depth4(depth);\n#else\nhighp vec4 depth=vec4(\nunpack_depth_rgba(texture(u_depth,uv-df.xz)),unpack_depth_rgba(texture(u_depth,uv+df.xz)),unpack_depth_rgba(texture(u_depth,uv-df.zy)),unpack_depth_rgba(texture(u_depth,uv+df.zy))\n);\n#endif\nreturn depth;}highp float occlusionFadeMultiSample(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;highp vec2 uv=0.5*coord.xy+0.5;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nint NX=3;int NY=4;highp vec2 df=u_occluder_half_size*u_depth_size_inv;highp vec2 oneStep=2.0*u_occluder_half_size*u_depth_size_inv/vec2(NX-1,NY-1);highp float res=0.0;for (int y=0; y < NY;++y) {for (int x=0; x < NX;++x) {\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depth,uv-df+vec2(float(x)*oneStep.x,float(y)*oneStep.y)));\n#endif\nres+=1.0-clamp(300.0*(coord.z+u_occlusion_depth_offset-depth),0.0,1.0);}}res=clamp(2.0*res/float(NX*NY)-0.5,0.0,1.0);return res;}highp float occlusionFade(vec4 frag) {highp vec3 coord=frag.xyz/frag.w;\n#ifdef CLIP_ZERO_TO_ONE\ncoord.z=-1.0+2.0*coord.z; \n#endif\nhighp vec4 depth=getCornerDepths(coord.xy);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z+u_occlusion_depth_offset)-depth),0.0,1.0));}\n#else\nbool isOccluded(vec4 frag) { return false; }highp float occlusionFade(vec4 frag) { return 1.0; }highp float occlusionFadeMultiSample(vec4 frag) { return 1.0; }\n#endif//DEPTH_OCCLUSION",Dn="#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",On="#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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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) {return color;}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif",zn="#ifdef RASTER_ARRAY\nuniform highp sampler2D u_image0;uniform sampler2D u_image1;const vec4 NODATA=vec4(1);ivec4 _raTexLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}vec2 _raTexLinearMix(highp vec2 fxy,highp vec4 colorMix,highp float colorOffset,highp vec4 t00,highp vec4 t10,highp vec4 t01,highp 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(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image0,c.yz,0),texelFetch(u_image0,c.xz,0),texelFetch(u_image0,c.yw,0),texelFetch(u_image0,c.xw,0)\n);}vec2 raTexture2D_image1_linear(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec2 fxy;ivec4 c=_raTexLinearCoord(texCoord,texResolution,fxy);return _raTexLinearMix(fxy,colorMix,colorOffset,texelFetch(u_image1,c.yz,0),texelFetch(u_image1,c.xz,0),texelFetch(u_image1,c.yw,0),texelFetch(u_image1,c.xw,0)\n);}vec2 raTexture2D_image0_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image0,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}vec2 raTexture2D_image1_nearest(highp vec2 texCoord,highp vec2 texResolution,highp vec4 colorMix,highp float colorOffset) {vec4 t=texelFetch(u_image1,ivec2(texCoord*texResolution),0);return t==NODATA ? vec2(0) : vec2(colorOffset+dot(t,colorMix),1);}\n#endif",Un="#ifdef RASTER_ARRAY\nuniform sampler2D u_velocity;uniform mediump vec2 u_velocity_res;uniform mediump float u_max_speed;const vec4 NO_DATA=vec4(1);const vec2 INVALID_VELOCITY=vec2(-1);uniform highp vec2 u_uv_offset;uniform highp float u_data_offset;uniform highp vec2 u_data_scale;ivec4 rasterArrayLinearCoord(highp vec2 texCoord,highp vec2 texResolution,out highp vec2 fxy) {texCoord=texCoord*texResolution-0.5;fxy=fract(texCoord);texCoord-=fxy;return ivec4(texCoord.xxyy+vec2(1.5,0.5).xyxy);}highp vec2 lookup_velocity(highp vec2 uv) {uv=u_uv_offset.x+u_uv_offset.y*uv;highp vec2 fxy;ivec4 c=rasterArrayLinearCoord(uv,u_velocity_res,fxy);highp vec4 tl=texelFetch(u_velocity,c.yz,0);highp vec4 tr=texelFetch(u_velocity,c.xz,0);highp vec4 bl=texelFetch(u_velocity,c.yw,0);highp vec4 br=texelFetch(u_velocity,c.xw,0);if (tl==NO_DATA) {return INVALID_VELOCITY;}if (tr==NO_DATA) {return INVALID_VELOCITY;}if (bl==NO_DATA) {return INVALID_VELOCITY;}if (br==NO_DATA) {return INVALID_VELOCITY;}highp vec4 t=mix(mix(bl,br,fxy.x),mix(tl,tr,fxy.x),fxy.y);highp vec2 velocity=u_data_offset+vec2(dot(t.rg,u_data_scale),dot(t.ba,u_data_scale));velocity.y=-velocity.y;velocity/=max(u_max_speed,length(velocity));return velocity;}\n#endif\nuniform highp float u_particle_pos_scale;uniform highp vec2 u_particle_pos_offset;highp vec4 pack_pos_to_rgba(highp vec2 p) {highp vec2 v=(p+u_particle_pos_offset)/u_particle_pos_scale;highp vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}highp vec2 unpack_pos_from_rgba(highp vec4 v) {v=floor(v*255.0+0.5)/255.0;highp vec2 p=vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));return u_particle_pos_scale*p-u_particle_pos_offset;}",Nn="#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) {vec3 transformed_normal=vec3(-normal.xy,normal.z);float NDotL=dot(normalize(transformed_normal),u_shadow_direction);float dotScale=min(1.0-NDotL,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",Vn="#ifdef RENDER_SHADOWS\nprecision highp sampler2DShadow;uniform sampler2DShadow u_shadowmap_0;uniform sampler2DShadow u_shadowmap_1;uniform 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;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z*0.5+0.5-bias);\n#endif\nreturn texture(shadowmap,coord);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {light_view_pos0.xyz/=light_view_pos0.w;\n#ifdef SHADOWS_SINGLE_CASCADE\nvec2 abs_bounds=abs(light_view_pos0.xy);if (abs_bounds.x >=1.0 || abs_bounds.y >=1.0) {return 0.0;}return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);\n#else\nlight_view_pos1.xyz/=light_view_pos1.w;vec4 abs_bounds=abs(vec4(light_view_pos0.xy,light_view_pos1.xy));if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {return shadow_sample(u_shadowmap_0,light_view_pos0.xyz,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}float occlusion1=shadow_sample(u_shadowmap_1,light_view_pos1.xyz,bias);return clamp(mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth)),0.0,1.0);\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_opacity(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,float shadow_opacity) {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)*shadow_opacity;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));}highp vec2 compute_receiver_plane_depth_bias(highp vec3 pos_dx,highp vec3 pos_dy)\n{highp vec2 biasUV=vec2(\npos_dy.y*pos_dx.z-pos_dx.y*pos_dy.z,pos_dx.x*pos_dy.z-pos_dy.x*pos_dx.z);biasUV*=1.0/((pos_dx.x*pos_dy.y)-(pos_dx.y*pos_dy.x));return biasUV;}float shadowed_light_factor_plane_bias(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {highp vec3 light_view_pos0_xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;highp vec3 light_view_pos0_ddx=dFdx(light_view_pos0_xyz);highp vec3 light_view_pos0_ddy=dFdy(light_view_pos0_xyz);highp vec2 plane_depth_bias=compute_receiver_plane_depth_bias(light_view_pos0_ddx,light_view_pos0_ddy);highp float bias=dot(vec2(u_shadow_texel_size,u_shadow_texel_size),plane_depth_bias)+0.0001;float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return 1.0-(u_shadow_intensity*occlusion);}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 jn=[];Wn(Pn,jn),Wn(Ln,jn),Wn(Rn,jn);const Gn={"_prelude_fog.vertex.glsl":Dn,"_prelude_terrain.vertex.glsl":kn,"_prelude_shadow.vertex.glsl":Nn,"_prelude_material_table.vertex.glsl":"#ifdef HAS_SHADER_STORAGE_BLOCK_material_buffer\n#define MATERIAL_TABLE_DEBUG 0\nuniform int u_material_offset;uniform int u_vertex_offset;layout(std140,binding=0)readonly buffer material_buffer{uvec4 material_data[];};struct MaterialInfo{uint dataOffset;\n#if MATERIAL_TABLE_DEBUG\nvec4 colorDebug;\n#endif\n};uint read_buf_no_offset(uint iDword) {return material_data[iDword/4u][iDword % 4u];}uint read_buf(uint iDword) {iDword+=uint(u_material_offset/4);return read_buf_no_offset(iDword);}float read_buf_float(uint iDword){return uintBitsToFloat(read_buf(iDword));}uint read_buf_uint8(uint iDword,uint iUint8){uint dwordOffset=iDword+(iUint8/4u);uint byteOffset=iUint8 & 3u;uint bitOffset=8u*byteOffset;uint mask=0xffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint read_buf_uint16(uint iDword,uint iUint16){uint dwordOffset=iDword+(iUint16 >> 1u);uint bitOffset=(iUint16 & 1u)*16u;uint mask=0xffffu << bitOffset;uint dwordVal=read_buf(dwordOffset);return (dwordVal & mask) >> bitOffset;}uint nrDwordsForVertexIdEntries(uint nrMaterialLookupEntries) {return nrMaterialLookupEntries;}uint nrDwordsForMaterialIdEntries(uint nrMaterialLookupEntries) {return (nrMaterialLookupEntries*2u+3u)/4u;}uint findRangeBinarySearch(uint vertexId,uint numRanges,uint dwordOffset) {uint left=0u;uint right=numRanges-1u;for (uint i=0u; i < 16u; i++) { \nif (left > right) {break;}uint mid=(left+right)/2u;uint start=read_buf(dwordOffset+mid);uint nextStart=(mid+1u < numRanges) ? read_buf(dwordOffset+mid+1u) : 0xffffffffu;if (vertexId >=start && vertexId < nextStart) {return mid;} else if (vertexId < start) {if (mid==0u) {break;}right=mid-1u;} else {left=mid+1u;}}return 0u; \n}uint readVertexId(uint dwordOffset,uint iMaterialLookupEntry) {return read_buf(dwordOffset+iMaterialLookupEntry);}uint findRange(uint vertexId,uint numRanges,uint dwordOffset) {uint iRange;if(numRanges <=64u){uint vertexBegin;for(iRange=0u; iRange < numRanges;++iRange) {vertexBegin=readVertexId(dwordOffset,iRange);if(vertexBegin > vertexId) {break;}}iRange=iRange==0u? 0u : iRange-1u;} else { \niRange=findRangeBinarySearch(vertexId,numRanges,dwordOffset);}return iRange;}MaterialInfo read_material_info(uint vertex_id) {MaterialInfo info;\n#if MATERIAL_TABLE_DEBUG\nconst vec4 red=vec4(1.0,0.0,0.0,1.0);const vec4 orange=vec4(1.0,0.5,0.0,1.0);const vec4 yellow=vec4(1.0,1.0,0.0,1.0);const vec4 green=vec4(0.0,1.0,0.0,1.0);const vec4 indigo=vec4(0.294,0.0,0.510,1.0);const vec4 blue=vec4(0.0,0.0,1.0,1.0);const vec4 purple=vec4(0.5,0.0,0.5,1.0);const vec4 pink=vec4(1.0,0.0,1.0,1.0);info.colorDebug=green;\n#endif\nuint offset=0u;\n#if MATERIAL_TABLE_DEBUG\nbool keepFinding=true;uint magic=read_buf(offset);if(magic !=0xCAFEBABEu) {info.colorDebug=red;keepFinding=false;return info;}\n#endif\noffset++;\n#if MATERIAL_TABLE_DEBUG\nuint nrMaterials=read_buf(offset);uint nrVertices=read_buf(offset+1u);if(keepFinding && vertex_id >=nrVertices) {info.colorDebug=red;keepFinding=false;}\n#endif\noffset+=2u;uint nrMaterialLookupEntries=read_buf(offset++);uint perMaterialEntrySizeDwords=read_buf(offset++);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding && perMaterialEntrySizeDwords !=1u) {info.colorDebug=red;keepFinding=false;}\n#endif\nuint iMaterialLookup=findRange(vertex_id,nrMaterialLookupEntries,offset);\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding)\n{uint vertexBeginCheck=readVertexId(offset,iMaterialLookup);if(vertexBeginCheck > vertex_id) {info.colorDebug=red;keepFinding=false;}if(iMaterialLookup < nrMaterialLookupEntries-1u) {uint vertexEndCheck=readVertexId(offset,iMaterialLookup+1u);if(vertexEndCheck <=vertex_id) {info.colorDebug=red;keepFinding=false;}}}\n#endif\noffset+=nrDwordsForVertexIdEntries(nrMaterialLookupEntries);uint materialId=iMaterialLookup;\n#if MATERIAL_TABLE_DEBUG\nif(keepFinding) {if(materialId >=nrMaterialLookupEntries) {info.colorDebug=red;}}\n#endif\ninfo.dataOffset=offset+materialId*perMaterialEntrySizeDwords;return info;}uint get_data_location(const MaterialInfo matInfo,uint attribOffsetBytes)\n{uint attribFieldOffsetDwords=attribOffsetBytes/4u;return matInfo.dataOffset+attribFieldOffsetDwords;}vec4 read_material_vec4(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec4(read_buf_float(loc),read_buf_float(loc+1u),read_buf_float(loc+2u),read_buf_float(loc+3u));}vec2 read_material_vec2(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return vec2(read_buf_float(loc),read_buf_float(loc+1u));}float read_material_float(const MaterialInfo matInfo,uint attribOffsetBytes){uint loc=get_data_location(matInfo,attribOffsetBytes);return read_buf_float(loc);}\n#define GET_ATTRIBUTE_float(attrib,matInfo,attrib_offset) read_material_float(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec4(attrib,matInfo,attrib_offset) read_material_vec4(matInfo,attrib_offset)\n#define GET_ATTRIBUTE_vec2(attrib,matInfo,attrib_offset) read_material_vec2(matInfo,attrib_offset)\n#define DECLARE_MATERIAL_TABLE_INFO MaterialInfo materialInfo=read_material_info(uint(gl_VertexID));\n#define DECLARE_MATERIAL_TABLE_INFO_DEBUG(dbgColor) MaterialInfo materialInfo=read_material_info(uint(gl_VertexID)); dbgColor=materialInfo.colorDebug;\n#endif","_prelude_fog.fragment.glsl":On,"_prelude_shadow.fragment.glsl":Vn,"_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":zn,"_prelude_raster_particle.glsl":Un},Hn={};qn("",kn),qn(On,Dn),qn(Vn,Nn),qn(zn,""),qn(Un,"");const Qn=qn(Rn,Ln),$n=Pn;var Zn={background:qn('#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:qn('#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 highp vec2 v_pos;void main() {highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=textureLodCustom(u_image,pos,v_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 vec2 u_pattern_units_to_pixels;in vec2 a_pos;out highp 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_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nconst float window_depth=0.5;const float ao_radius=0.2;in vec4 v_color;in highp vec3 v_normal;in highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nin lowp float v_faux_facade;in highp float v_faux_facade_ed;in highp vec2 v_faux_facade_window;in highp vec2 v_faux_facade_floor;in highp vec2 v_faux_facade_range;in highp float v_aspect;in highp vec3 v_tbn_0;in highp vec3 v_tbn_1;in highp vec3 v_tbn_2;in highp vec4 v_faux_color_emissive;uniform float u_faux_facade_ao_intensity;\n#endif\n#ifdef RENDER_SHADOWS\nin highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef FLOOD_LIGHT\nin highp float v_flood_radius;in float v_has_flood_light;\n#endif\nuniform lowp float u_opacity;uniform vec3 u_camera_pos;uniform highp float u_tile_to_meter;uniform float u_facade_emissive_chance;uniform vec3 u_flood_light_color;uniform float u_flood_light_intensity;vec3 linearTosRGB(in vec3 color) {return pow(color,vec3(1./2.2));}\n#ifdef BUILDING_FAUX_FACADE\nfloat hash12(in vec2 p) {vec3 p3 =fract(vec3(p.xyx)*0.1031);p3+=dot(p3,p3.yzx+33.33);return fract((p3.x+p3.y)*p3.z);}float min3(in vec3 v) {return min(min(v.x,v.y),v.z);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {vec2 p=q;mask=step(v_faux_facade_range.x,p.y)*step(p.y,v_faux_facade_range.y);p.y=p.y-v_faux_facade_range.x;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;vec2 m=step(edge.xy,uv)*step(uv,edge.zw);mask*=m.x*m.y;uv-=vec2(0.5);uv*=vec2(0.5)/(vec2(0.5)-edge.xy);uv+=vec2(0.5);return uv;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));vec3 t=(planes-ray_o)/ray_d;return min3(t);}float get_emissive(in vec2 id) {if (u_facade_emissive_chance > 0.0) {return (step(hash12(id),u_facade_emissive_chance)+0.05)*v_faux_color_emissive.a;}return 0.0;}vec3 get_shade_info(in vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;vec3 abs_v=abs(v_normalized);bool x_major=abs_v.x >=abs_v.y && abs_v.x >=abs_v.z;bool y_major=abs_v.y >=abs_v.x && abs_v.y >=abs_v.z;bool z_major=abs_v.z >=abs_v.x && abs_v.z >=abs_v.y;\n#if 0\nif (x_major) {out_color=v.x > 0.0 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,1.0);} else if (y_major) {out_color=v.y > 0.0 ? vec3(0.0,1.0,0.0) : vec3(1.0,0.0,1.0);} else if (z_major) {out_color=v.z > 0.0 ? vec3(0.0,0.0,1.0) : vec3(1.0,1.0,0.0);}out_emissive=1.0;\n#else\nif (x_major) {out_normal=sign(v.x)*tbn[0];} else if (y_major) {out_normal=vec3(0.0,0.0,-sign(v.y));} else if (z_major) {out_color=v_faux_color_emissive.rgb;out_emissive=v.z <=0.0 ? get_emissive(id) : out_emissive;}float ao=1.0;if (u_faux_facade_ao_intensity > 0.0) {vec4 ao_range=v_faux_facade_window.xxyy*0.5-vec4(0,ao_radius,0,ao_radius);vec2 ao_range_z=vec2(window_depth*0.5)-vec2(0.0,ao_radius);if (x_major || y_major) {ao*=smoothstep(-ao_range_z.x,-ao_range_z.y,v.z);} else if (z_major) {ao*=smoothstep(-ao_range.x,-ao_range.y,v.x)*(1.0-smoothstep(ao_range.y,ao_range.x,v.x));ao*=smoothstep(-ao_range.z,-ao_range.w,v.y)*(1.0-smoothstep(ao_range.w,ao_range.z,v.y));}ao=mix(1.0,min(1.0,ao+0.25),u_faux_facade_ao_intensity);}out_color*=ao;\n#endif\nreturn out_color;}\n#endif\nvec3 apply_lighting_linear(in vec3 color,in vec3 normal,in 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 color*(ambient_contrib+directional_contrib);}void main() {vec3 normal=normalize(v_normal);vec3 base_color=v_color.rgb;float emissive=v_color.a;\n#ifdef BUILDING_FAUX_FACADE\nif (v_faux_facade > 0.0) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;vec3 normalized=hit/r;vec3 out_normal=normal;float out_emissive=emissive;vec3 room_color=get_shade_info(hit,normalized,base_color,id,tbn,out_normal,out_emissive);base_color=mix(base_color,room_color,mask);normal=mix(normal,out_normal,mask);emissive=mix(emissive,out_emissive,mask);}\n#endif\nvec4 color=vec4(base_color,1.0);vec3 xy_flipped_normal=vec3(-normal.xy,normal.z);float shadowed_lighting_factor=0.0;\n#ifdef RENDER_SHADOWS\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nshadowed_lighting_factor=dot(normal,u_lighting_directional_dir);\n#endif\ncolor.rgb=apply_lighting_linear(color.rgb,xy_flipped_normal,shadowed_lighting_factor);color.rgb=linearTosRGB(color.rgb);\n#ifdef FLOOD_LIGHT\nfloat flood_radiance=(1.0-min(v_pos.z/v_flood_radius,1.0))*u_flood_light_intensity*v_has_flood_light;color.rgb=mix(color.rgb,u_flood_light_color,flood_radiance);\n#endif\ncolor.rgb=mix(color.rgb,linearTosRGB(base_color.rgb),emissive);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,v_pos.z));\n#endif\ncolor*=u_opacity;\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\n#endif\nglFragColor=color; \n#ifdef DEBUG_SHOW_NORMALS\ncolor.rgb=xy_flipped_normal*0.5+vec3(0.5,0.5,0.5);color.a=1.0;glFragColor=color;\n#endif\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;in vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out vec4 v_color;out vec3 v_normal;out highp vec3 v_pos;\n#ifdef BUILDING_FAUX_FACADE\nout lowp float v_faux_facade;out highp float v_faux_facade_ed;out highp vec2 v_faux_facade_window;out highp vec2 v_faux_facade_floor;out highp vec2 v_faux_facade_range;out highp float v_aspect;out highp vec3 v_tbn_0;out highp vec3 v_tbn_1;out highp vec3 v_tbn_2;out highp vec4 v_faux_color_emissive;\n#endif\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_shadows;\n#endif\n#ifdef FLOOD_LIGHT\nout highp float v_flood_radius;out float v_has_flood_light;\n#endif\nconst float MAX_UINT_16=65535.0;const float MAX_INT_16=32767.0;const float MAX_UINT_8=255.0;const float TWO_POW_8=256.0;const float FLOOD_LIGHT_MAX_RADIUS_METER=2048.0;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\n#ifdef BUILDING_FAUX_FACADE\nmat3 get_tbn(in vec3 normal) {const vec3 bitangent=vec3(0.0,0.0,1.0);vec3 tangent=normalize(vec3(normal.y,-normal.x,0.0));return mat3(tangent,bitangent,normal);}\n#endif\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(a_flood_light_wall_radius_1i16/MAX_INT_16*FLOOD_LIGHT_MAX_RADIUS_METER);v_has_flood_light=step(0.0,v_flood_radius);\n#endif\nvec4 color_emissive=decode_color(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_faux_facade_data.y-TWO_POW_8*window_x_perc;vec2 window_perc=vec2(window_x_perc,window_y_perc)/MAX_UINT_8;v_faux_facade_floor=(a_faux_facade_data.zw/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_faux_facade_window=window_perc*v_faux_facade_floor;v_faux_facade_range=(a_faux_facade_vertical_range/MAX_UINT_16*EXTENT)*u_tile_to_meter;v_aspect=v_faux_facade_window.x/v_faux_facade_window.y;mat3 tbn=get_tbn(normalize(v_normal));v_tbn_0=tbn[0];v_tbn_1=tbn[1];v_tbn_2=tbn[2];v_faux_color_emissive=decode_color(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_cutoff_opacity=cutoff_opacity(u_cutoff_params,ground.z);hidden=float(v_cutoff_opacity==0.0);v_pos.z*=v_cutoff_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shadow_pos=v_pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset_model(v_normal);shadow_pos+=offset*shadow_normal_offset_multiplier0();\n#endif\nv_pos_light_view_0=u_light_matrix_0*vec4(shadow_pos,1.0);v_pos_light_view_1=u_light_matrix_1*vec4(shadow_pos,1.0);v_depth_shadows=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);}'),buildingBloom:qn("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float emission=v_color_emissive.a;float opacity=1.0;\n#ifdef HAS_ATTRIBUTE_a_bloom_attenuation\nfloat distance=length(vec2(1.3*max(0.0,abs(bloom_attenuation.x)-bloom_attenuation.z),bloom_attenuation.y));distance+= mix(0.5,0.0,clamp(emission-1.0,0.0,1.0));opacity*=saturate(1.0-distance*distance);\n#endif\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 part_color_emissive\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\nout vec4 v_color_emissive;uniform mat4 u_matrix;vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\n#ifdef HAS_ATTRIBUTE_a_part_color_emissive\nvec4 color_emissive=decode_color(part_color_emissive);float part_emissive=color_emissive.a*5.0;v_color_emissive=vec4(sRGBToLinear(color_emissive.rgb),part_emissive);\n#else\nv_color_emissive=vec4(1.0);\n#endif\ngl_Position=u_matrix*vec4(a_pos_3f,1.0);}"),buildingDepth:qn("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;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:qn('#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 blur_positive=blur < 0.0 ? 0.0 : 1.0;lowp float antialiasblur=v_data.z;float extrude_length=length(extrude)+antialiasblur*(1.0-blur_positive);float antialiased_blur=-max(abs(blur),antialiasblur);float antialiase_blur_opacity=smoothstep(0.0,antialiasblur,extrude_length-1.0);float opacity_t=blur_positive==1.0 ? \nsmoothstep(0.0,-antialiased_blur,1.0-extrude_length) : \nsmoothstep(antialiased_blur,0.0,extrude_length-1.0)-antialiase_blur_opacity;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\n#ifdef ELEVATED_ROADS\nin float a_circle_z_offset;\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() {\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\n#ifdef ELEVATED_ROADS\nworld_center.z+=a_circle_z_offset+ELEVATION_BIAS;\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:qn("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:qn('#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() {\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:qn("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:qn("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 vec2 a_elevation_from_sea;in float a_size_scale;in vec2 a_padding;in float a_auto_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform float u_zoom_transition;\n#endif\nout float v_placed;out float v_notUsed;void main() {float feature_elevation=a_elevation_from_sea.x+a_auto_z_offset;float terrain_elevation=(a_elevation_from_sea.y==1.0 ? 0.0 : elevation(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_anchor_pos)*(feature_elevation+terrain_elevation);\n#ifdef PROJECTION_GLOBE_VIEW\n#ifndef PROJECTED_POS_ON_VIEWPORT\nvec3 globe_pos=proj_pos;vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,a_anchor_pos,u_tile_id,u_merc_center);proj_pos=mix_globe_mercator(globe_pos,mercator_pos,u_zoom_transition);\n#endif\n#endif\nvec4 projectedPoint=u_matrix*vec4(proj_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:qn("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:qn("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}'),elevatedStructuresDepth:qn("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform float u_depth_bias;void main() {gl_Position=u_matrix*vec4(a_pos,a_height,1);gl_Position.z=gl_Position.z+u_depth_bias;}"),elevatedStructuresDepthReconstruct:qn("#ifdef DEPTH_RECONSTRUCTION\nin float v_height;\n#endif\nvoid main() {\n#ifdef DEPTH_RECONSTRUCTION\nif (v_height >=0.0)\ndiscard;\n#else\n#ifdef FEATURE_CUTOUT\napply_feature_cutout(vec4(0.0,0.0,0.0,1.0),gl_FragCoord);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 a_pos;in float a_height;uniform mat4 u_matrix;uniform vec3 u_camera_pos;uniform highp float u_depth_bias;uniform lowp float u_height_scale;uniform lowp float u_reset_depth;\n#ifdef DEPTH_RECONSTRUCTION\nout float v_height;\n#endif\nvoid main() {vec3 vpos=vec3(a_pos,a_height*u_height_scale);\n#ifdef DEPTH_RECONSTRUCTION\nif (u_camera_pos.z > vpos.z) {vpos-=(u_camera_pos-vpos)*(vpos.z/(u_camera_pos.z-vpos.z));}v_height=a_height;\n#endif\ngl_Position=u_matrix*vec4(vpos,1);gl_Position.z=u_reset_depth==1.0 ? gl_Position.w : gl_Position.z+u_depth_bias;}"),elevatedStructures:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin vec3 v_normal;in float v_height;\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\nvec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}vec3 compute_view_dependent_emissive_color(float ndotl,float emissive_strength,vec3 color)\n{color=sRGBToLinear(color);color=color*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);color=linearTosRGB(color.rgb);return color;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;\n#ifdef LIGHTING_3D_MODE\nvec3 normal=normalize(v_normal);vec3 transformed_normal=vec3(-normal.xy,normal.z);float ndotl=calculate_NdotL(transformed_normal);float emissive_strength=u_emissive_strength;emissive_strength=0.0;vec3 emissive_color=compute_view_dependent_emissive_color(ndotl,emissive_strength,color.xyz);\n#ifdef RENDER_SHADOWS\nfloat shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\n#else\ncolor=apply_lighting(color,transformed_normal);\n#endif\ncolor=mix(color,emissive_color,emissive_strength);if (v_height < 0.0) {float penetration=max(v_height+7.5,0.0);float occlusion=1.0-1.0/PI*acos(1.0-penetration/4.0);color=color*(1.0-pow(occlusion,2.0)*0.3);}\n#endif\n#ifdef FOG\ncolor=fog_apply(color,v_fog_pos);\n#endif\nvec4 out_color=vec4(color,1.0);\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_height);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 a_pos_normal_3;uniform mat4 u_matrix;out vec3 v_normal;out float v_height;\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#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nv_normal=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(a_pos,a_height);gl_Position=u_matrix*vec4(pos,1);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=pos;vec3 shd_pos1=pos;\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(-v_normal.xy,v_normal.z));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fill:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\nvoid 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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nout_color*=opacity;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\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#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nuniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp float z_offset\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);\n#ifdef FLIP_Y\nv_pos=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillOutlinePattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nuniform float u_emissive_strength;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nout highp vec2 v_pos;out highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);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);\n#ifdef FLIP_Y\nv_pos_world=(vec2(gl_Position.x,-gl_Position.y)/gl_Position.w+1.0)/2.0*u_world;\n#else\nv_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#endif\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin highp vec2 v_pos;uniform float u_emissive_strength;\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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"\n#include "_prelude_shadow.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;\n#ifdef ELEVATED_ROADS\nin float a_road_z_offset;out highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\nout highp vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define highp float z_offset\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;v_road_z_offset=z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_pos,z_offset,1),AWAY,hidden);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef RENDER_SHADOWS\nvec3 shd_pos0=vec3(a_pos,z_offset);vec3 shd_pos1=vec3(a_pos,z_offset);\n#ifdef NORMAL_OFFSET\nvec3 offset=shadow_normal_offset(vec3(0.0,0.0,1.0));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\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),fillExtrusion:qn('#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;\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\nin float v_height;\n#pragma mapbox: define highp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp float emissive_strength\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,1.0/gl_FragCoord.w);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;\n#ifdef RENDER_CUTOFF\nshadowed_lighting_factor=shadowed_light_factor_normal_opacity(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w,v_cutoff_opacity);if (v_cutoff_opacity==0.0) {discard;}\n#else\nshadowed_lighting_factor=shadowed_light_factor_normal(normal,v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);\n#endif\ncolor.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,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 INDICATOR_CUTOUT\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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#include "_prelude_material_table.vertex.glsl"\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;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\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;\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;vec3 linearTosRGB(vec3 color) {return pow(color,vec3(1./2.2));}vec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}\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\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp float emissive_strength\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\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\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp float emissive_strength\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);float attr_height=height;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=0.0;vec3 pos;\n#ifdef TERRAIN\nbool is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_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 cutoff=1.0;vec3 scaled_pos=pos;\n#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);\n#ifdef CLIP_ZERO_TO_ONE\ncutoff=cutoff_opacity(u_cutoff_params,ground.z*2.0-ground.w);\n#else\ncutoff=cutoff_opacity(u_cutoff_params,ground.z);\n#endif\nif (centroid_pos.y !=0.0 && centroid_pos.x !=0.0) {vec3 g=floor(ground_pos);vec3 mod_=centroid_random-g*8.0;float seed=min(1.0,0.1*(min(3.5,max(mod_.x+mod_.y,0.2*attr_height))*0.35+mod_.z));if (cutoff < 0.8-seed) {cutoff=0.0;}}float cutoff_scale=cutoff;v_cutoff_opacity=cutoff;scaled_pos.z=mix(c_ele,h,cutoff_scale);\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (cutoff==0.0 && centroid_pos.x !=0.0) || (color.a==0.0));\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\ngl_Position=mix(u_matrix*vec4(scaled_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);\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);float ndotl=calculate_NdotL(normal);v_flat.rgb=sRGBToLinear(color.rgb);v_flat.rgb=v_flat.rgb*(ndotl+(1.0-min(ndotl*57.29,1.0))*emissive_strength);v_flat=vec4(linearTosRGB(v_flat.rgb),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}'),fillExtrusionDepth:qn("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_material_table.vertex.glsl"\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_width_scale;uniform float u_vertical_scale;\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nin vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp float line_width\n#pragma mapbox: define highp vec4 color\nout highp float v_depth;void main() {DECLARE_MATERIAL_TABLE_INFO\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp float line_width\n#pragma mapbox: initialize highp vec4 color\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 is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;float ele=elevation(pos_nx.xy);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);float h=t > 0.0 ? max(h_base,h_height) : h_base;pos=vec3(pos_nx.xy,h);\n#else\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.0));gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\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\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\nin highp 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#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\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#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;highp vec2 imagecoord=mod(v_pos,1.0);highp vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);highp vec2 lod_pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,v_pos);vec4 out_color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl/u_texsize,pattern_b_br/u_texsize,imagecoord);vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);out_color=out_color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\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,height);\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"\n#include "_prelude_material_table.vertex.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 float u_width_scale;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 RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\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\n#ifdef TERRAIN\nuniform int u_height_type;uniform int u_base_type;\n#endif\nout highp 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 highp vec4 color\n#pragma mapbox: define mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define highp float pixel_ratio\n#pragma mapbox: define highp float line_width\nvoid main() {DECLARE_MATERIAL_TABLE_INFO\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 mediump vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\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 is_flat_height=centroid_pos.x !=0.0 && u_height_type==1;bool is_flat_base=centroid_pos.x !=0.0 && u_base_type==1;ele=elevation(pos_nx.xy);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos)) : ele;float h_height=is_flat_height ? max(c_ele+height,ele+base+2.0) : ele+height;float h_base=is_flat_base ? max(c_ele+base,ele+base) : ele+(base==0.0 ?-5.0 : base);h=t > 0.0 ? max(h_base,h_height) : h_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\n#ifdef RENDER_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_join_normal_inside.z*wall_offset*0.5;\n#endif\nfloat hidden=float((centroid_pos.x==0.0 && centroid_pos.y==1.0) || (color.a==0.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:qn('#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;\n#ifdef FOG\nin float v_fog_opacity;\n#endif\nvoid main() {float light=shadowed_light_factor_plane_bias(v_pos_light_view_0,v_pos_light_view_1,1.0/gl_FragCoord.w);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,1.0/gl_FragCoord.w));\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),0.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;\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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:qn("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;\n#endif\nHANDLE_WIREFRAME_DEBUG;\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 float u_dynamic_offset;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;fl_ground_radius=abs(flood_light_ground_radius);float direction=flood_light_ground_radius < 0.0 ?-1.0 : 1.0;float 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=direction*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(u_dynamic_offset,angular_offset,top);vec2 perp=vec2(v.y,-v.x);vec2 extrusion_perp=direction*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:qn("precision highp float;uniform highp 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:qn('#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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\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\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\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=(u_width_scale*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).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_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 trim_alpha=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=1.0-transition_factor;}\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*u_width_scale)+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) {float 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=mix(border_color*trim_alpha,out_color,smoothAlpha);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\nout_color.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\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,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nin highp vec3 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;uniform float u_width_scale;uniform highp float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\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#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\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 highp float v_depth;\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 a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\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;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);halfwidth=(u_width_scale*(left==1.0 ? a_z_offset_width.y : a_z_offset_width.z))/2.0;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-1.0*offset*u_width_scale;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);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#endif\n#ifndef RENDER_TO_TEXTURE\nfloat epsilon=0.0001;float extrude_length_without_perspective=max(length(dist),epsilon);float extrude_length_with_perspective=max(length(projected_extrude_xy/gl_Position.w*u_units_to_pixels),epsilon);v_gamma_scale=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2];\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=vec3(a_uv_x,a_split_index*texel_height-half_texel_height,line_progress);\n#else\nv_uv=vec3(a_uv_x,0.0,line_progress);\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*u_floor_width_scale),(-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#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),linePattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;uniform highp vec2 u_texsize;uniform highp float u_tile_units_to_pixels;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;uniform sampler2D u_image;\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nuniform float u_pattern_transition;\n#endif\nin vec2 v_normal;in vec2 v_width2;in highp float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef LINE_JOIN_NONE\nin vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;highp float pattern_size=display_size.x/u_tile_units_to_pixels;float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(u_width_scale*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);highp float pattern_x=v_linesofar/pattern_size*aspect;highp float x=mod(pattern_x,1.0);highp float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;highp vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));highp vec2 lod_pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(pattern_x,y));vec4 color=textureLodCustom(u_image,pos,lod_pos);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\n#ifdef LINE_PATTERN_TRANSITION\nvec2 pattern_b_tl=pattern_b.xy;vec2 pattern_b_br=pattern_b.zw;highp vec2 pos_b=mix(pattern_b_tl*texel_size-texel_size,pattern_b_br*texel_size+texel_size,vec2(x,y));vec4 color_b=textureLodCustom(u_image,pos_b,lod_pos);color=color*(1.0-u_pattern_transition)+color_b*u_pattern_transition;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=v_uv[2];if (trim_end > trim_start) {highp float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/max(u_trim_fade_range[0],1.0e-9)));highp float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/max(u_trim_fade_range[1],1.0e-9)));highp float transition_factor=min(start_transition,end_transition);color=mix(color,color.a*u_trim_color,transition_factor);}\n#endif\n#ifdef LINE_JOIN_NONE\nhighp float pattern_len=pattern_size/aspect;highp float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);highp float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;highp float visible_end=floor((v_pattern_data.y-segment_phase)/pattern_len)*pattern_len+segment_phase;visible_end+=step(pattern_len*0.5,v_pattern_data.y-visible_end)*pattern_len;if (v_pattern_data.x < visible_start || v_pattern_data.x >=visible_end) {color=vec4(0.0);}\n#endif\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting_with_emission_ground(color,u_emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef ELEVATED_ROADS\ncolor.rgb*=mix(v_road_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#else\ncolor.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ncolor*=(alpha*opacity);if (u_alpha_discard_threshold !=0.0) {if (color.a < u_alpha_discard_threshold) {discard;}}\n#ifdef INDICATOR_CUTOUT\ncolor=applyCutout(color,v_z_offset);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nin highp vec3 a_packed;\n#endif\nin highp float a_linesofar;\n#ifdef LINE_JOIN_NONE\nin highp vec3 a_pattern_data;out vec2 v_pattern_data;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#endif\nuniform mat4 u_matrix;uniform float u_tile_units_to_pixels;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform float u_device_pixel_ratio;uniform float u_width_scale;uniform float u_floor_width_scale;\n#ifdef ELEVATED\nuniform lowp float u_zbias_factor;uniform lowp float u_tile_to_meter;float sample_elevation(vec2 apos) {\n#ifdef ELEVATION_REFERENCE_SEA\nreturn 0.0;\n#else\nreturn elevation(apos);\n#endif\n}\n#endif\nout vec2 v_normal;out vec2 v_width2;out highp float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef RENDER_LINE_TRIM_OFFSET\nout highp vec3 v_uv;\n#endif\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\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 highp float v_depth;\n#endif\n#pragma mapbox: define mediump float blur\n#pragma mapbox: define mediump float opacity\n#pragma mapbox: define mediump float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define mediump float floorwidth\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize mediump float blur\n#pragma mapbox: initialize mediump float opacity\n#pragma mapbox: initialize mediump float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize mediump float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\nfloat a_z_offset;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\na_z_offset=a_z_offset_width.x;\n#endif\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);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=(u_width_scale*width)/2.0;offset=-1.0*offset*u_width_scale;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);vec2 dist=outset*a_extrude*scale;float u=0.5*a_direction;float t=1.0-abs(u);vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float hidden=float(opacity==0.0);vec2 extrude=dist*u_pixels_to_tile_units;vec4 projected_extrude=u_matrix*vec4(extrude,0.0,0.0);vec2 projected_extrude_xy=projected_extrude.xy;\n#ifdef ELEVATED_ROADS\nv_road_z_offset=a_z_offset;gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,a_z_offset,1.0)+projected_extrude;\n#else\n#ifdef ELEVATED\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 offset_pos=pos+offsetTile;float ele=0.0;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_z_offset;ele=sample_elevation(offset_pos)+line_height;projected_extrude=vec4(0);\n#else\n#ifdef CROSS_SLOPE_HORIZONTAL\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,max(ele1,ele2));ele=ele_max+a_z_offset;\n#else\nfloat ele0=sample_elevation(offset_pos);float ele1=max(sample_elevation(offset_pos+extrude),sample_elevation(offset_pos+extrude/2.0));float ele2=max(sample_elevation(offset_pos-extrude),sample_elevation(offset_pos-extrude/2.0));float ele_max=max(ele0,0.5*(ele1+ele2));ele=ele_max-ele0+ele1+a_z_offset;\n#endif\n#endif\ngl_Position=u_matrix*vec4(offset_pos,ele,1.0)+projected_extrude;float z=clamp(gl_Position.z/gl_Position.w,0.5,1.0);float zbias=max(0.00005,(pow(z,0.8)-z)*u_zbias_factor*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);gl_Position=mix(gl_Position,AWAY,hidden);\n#else\ngl_Position=mix(u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude,AWAY,hidden);\n#endif\n#endif\n#ifdef ELEVATED_ROADS\n#ifdef RENDER_SHADOWS\nvec3 shd_pos=vec3(pos+(offset2+dist)*u_pixels_to_tile_units,a_z_offset);vec3 shd_pos0=shd_pos;vec3 shd_pos1=shd_pos;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#endif\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=mix(extrude_length_without_perspective/extrude_length_with_perspective,1.0,step(0.01,blur));\n#else\nv_gamma_scale=1.0;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float a_uv_x=a_packed[0];highp float line_progress=a_packed[2];v_uv=vec3(a_uv_x,0.0,line_progress);\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=(floorwidth*u_floor_width_scale);\n#ifdef LINE_JOIN_NONE\nv_width=(floorwidth*u_floor_width_scale)+ANTIALIASING;mediump float pixels_to_tile_units=1.0/u_tile_units_to_pixels;mediump float pixel_ratio_inverse=1.0/pixel_ratio;mediump float aspect=v_width/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(pattern.z-pattern.x)*pixel_ratio_inverse*pixels_to_tile_units*aspect*32.0;highp float subt=floor(a_pattern_data.z/subt_multiple)*subt_multiple;float offset_sign=(fract(a_pattern_data.x)-0.5)*4.0;float line_progress_offset=offset_sign*v_width*0.5*pixels_to_tile_units;v_linesofar=(a_pattern_data.z-subt)+a_linesofar+line_progress_offset;v_pattern_data=vec2(a_pattern_data.x+line_progress_offset,a_pattern_data.y);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=a_z_offset;\n#endif\n}'),raster:qn('#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;uniform highp float u_zoom_transition;in vec2 v_pos0;in vec2 v_pos1;in float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nin float v_split_fade;\n#endif\nuniform 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 highp 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;\n#ifdef GLOBE_POLES\ncolor.a*=1.0-smoothstep(0.0,0.05,u_zoom_transition);\n#endif\nvec3 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 PROJECTION_GLOBE_VIEW\nglFragColor*=mix(1.0,1.0-smoothstep(0.0,0.05,u_zoom_transition),smoothstep(0.8,0.9,v_split_fade));\n#endif\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 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#else\nin vec2 a_pos;in vec2 a_texture_pos;\n#endif\nout vec2 v_pos0;out vec2 v_pos1;out float v_depth;\n#ifdef PROJECTION_GLOBE_VIEW\nout float v_split_fade;\n#endif\nvoid 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\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\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);vec3 globe_pos=latLngToECEF(latLng.xy);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=0.0;if (u_zoom_transition > 0.0) {vec2 merc_pos=vec2(mercatorX,mercatorY);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;float opposite_merc_center=mod(u_merc_center.x+0.5,1.0);float dist_from_poles=(abs(mercatorY-0.5)*2.0);float range=0.1;v_split_fade=abs(opposite_merc_center-mercatorX);v_split_fade=clamp(1.0-v_split_fade,0.0,1.0);v_split_fade=max(smoothstep(1.0-range,1.0,dist_from_poles),max(smoothstep(1.0-range,1.0,v_split_fade),smoothstep(1.0-range,1.0,1.0-v_split_fade)));}float tiles=u_grid_matrix[0][2];if (tiles > 0.0) {float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvY=mercatorY*tiles-idy;float uvX=mercatorX*tiles-idx;uv=vec2(uvX,uvY);}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition)*w,w);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\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\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}'),rasterParticle:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_fade_t;uniform float u_opacity;uniform highp float u_raster_elevation;in vec2 v_pos0;in vec2 v_pos1;uniform sampler2D u_image0;uniform sampler2D u_image1;void main() {vec4 color0,color1,color;color0=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);color.a*=u_opacity;vec3 out_color=color.rgb;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(vec4(out_color,1.0),1.0).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 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 float u_raster_elevation;uniform float u_zoom_transition;uniform vec2 u_merc_center;\n#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\nin vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {float w=1.0;vec2 uv;\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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]);float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];float uvX=mercatorX*tiles-idx;float uvY=mercatorY*tiles-idy;uv=vec2(uvX,uvY);vec3 globe_pos=latLngToECEF(latLng.xy);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) {vec2 merc_pos=vec2(mercatorX,mercatorY);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)*w,w);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\nuv=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:qn("uniform sampler2D u_color_ramp;in float v_particle_speed;void main() {glFragColor=texture(u_color_ramp,vec2(v_particle_speed,0.5));}",'#include "_prelude_raster_particle.glsl"\nin float a_index;uniform sampler2D u_particle_texture;uniform float u_particle_texture_side_len;uniform vec2 u_tile_offset;out float v_particle_speed;void main() {ivec2 pixel_coord=ivec2(\nmod(a_index,u_particle_texture_side_len),a_index/u_particle_texture_side_len);vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);vec2 pos=unpack_pos_from_rgba(pixel)+u_tile_offset;vec2 tex_coord=fract(pos);vec2 velocity=lookup_velocity(tex_coord);if (velocity==INVALID_VELOCITY) {gl_Position=AWAY;v_particle_speed=0.0;} else {gl_Position=vec4(2.0*pos-1.0,0,1);v_particle_speed=length(velocity);}gl_PointSize=1.0;}'),rasterParticleTexture:qn("uniform sampler2D u_texture;uniform float u_opacity;in vec2 v_tex_pos;void main() {vec4 color=texture(u_texture,v_tex_pos);glFragColor=vec4(floor(255.0*color*u_opacity)/255.0);}","in vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:qn('#include "_prelude_raster_particle.glsl"\nuniform sampler2D u_particle_texture;uniform mediump float u_particle_texture_side_len;uniform mediump float u_speed_factor;uniform highp float u_reset_rate;uniform highp float u_rand_seed;in highp vec2 v_tex_coord;vec2 linearstep(vec2 edge0,vec2 edge1,vec2 x) {return clamp((x-edge0)/(edge1-edge0),vec2(0),vec2(1));}const highp vec3 rand_constants=vec3(12.9898,78.233,4375.85453);highp float rand(const highp vec2 co) {highp float t=dot(rand_constants.xy,co);return fract(sin(t)*(rand_constants.z+t));}void main() {ivec2 pixel_coord=ivec2(v_tex_coord*u_particle_texture_side_len);highp vec4 pixel=texelFetch(u_particle_texture,pixel_coord,0);highp vec2 pos=unpack_pos_from_rgba(pixel);highp vec2 velocity=lookup_velocity(clamp(pos,0.0,1.0));highp vec2 dp=velocity==INVALID_VELOCITY ? vec2(0) : velocity*u_speed_factor;pos=pos+dp;highp vec2 seed=(pos+v_tex_coord)*u_rand_seed;highp vec2 random_pos=vec2(rand(seed+1.3),rand(seed+2.1));highp vec2 persist_rate=pow(\nlinearstep(vec2(-u_particle_pos_offset),vec2(0),pos)*linearstep(vec2(1.0+u_particle_pos_offset),vec2(1),pos),vec2(4)\n);highp vec2 per_frame_persist=pow(persist_rate,abs(dp)/u_particle_pos_offset);highp float drop_rate=1.0-per_frame_persist.x*per_frame_persist.y;drop_rate=any(greaterThanEqual(abs(pos-0.5),vec2(0.5+u_particle_pos_offset))) ? 1.0 : drop_rate;highp float drop=step(1.0-drop_rate-u_reset_rate,rand(seed));highp vec2 next_pos=mix(pos,random_pos,drop);glFragColor=pack_pos_to_rgba(next_pos);}',"in vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:qn('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.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_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\n#ifdef ICON_TRANSITION\nuniform float u_icon_transition;\n#endif\n#ifdef COLOR_ADJUSTMENT\nuniform mat4 u_color_adj_mat;\n#endif\n#ifdef INDICATOR_CUTOUT\nin highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nin highp float v_z_offset;\n#endif\n#endif\nin vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nin vec2 v_tex_b;\n#endif\nin float v_draw_halo;in vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nin float is_sdf;in vec2 v_tex_a_icon;\n#endif\n#ifdef RENDER_SHADOWS\nuniform vec3 u_ground_shadow_factor;in highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in highp float v_depth;\n#endif\n#ifdef APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\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\nvec4 out_color;float fade_opacity=v_gamma_scale_size_fade_opacity[2];\n#ifdef RENDER_TEXT_AND_SYMBOL\nif (is_sdf==ICON) {vec2 tex_icon=v_tex_a_icon;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;}\n#endif\n#ifdef RENDER_SDF\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_gamma_scale_size_fade_opacity.x;float size=v_gamma_scale_size_fade_opacity.y;float fontScale=u_is_text ? size/24.0 : size;out_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) {out_color=halo_color;gamma=(halo_blur*u_scale_factor*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width*u_scale_factor/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,v_tex_a).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);out_color*=alpha;\n#else\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);\n#else\nout_color=texture(u_texture,v_tex_a);\n#endif\n#ifdef APPLY_LUT_ON_GPU\nout_color=applyLUT(u_lutTexture,out_color);\n#endif\n#ifdef COLOR_ADJUSTMENT\nout_color=u_color_adj_mat*out_color;\n#endif\n#endif\nout_color*=opacity*fade_opacity;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\n#ifdef RENDER_SHADOWS\nfloat light=shadowed_light_factor(v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#ifdef TERRAIN\nout_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#else\nout_color.rgb*=mix(v_z_offset !=0.0 ? u_ground_shadow_factor : vec3(1.0),vec3(1.0),light);\n#endif\n#endif\n#endif\n#ifdef INDICATOR_CUTOUT\nout_color=applyCutout(out_color,v_z_offset);\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_terrain.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\n#define APPEARANCE_ICON 1.0\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_auto_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\n#ifdef OCCLUSION_QUERIES\nin float a_occlusion_query_opacity;\n#endif\n#ifdef ELEVATED_ROADS\nin vec3 a_x_axis;in vec3 a_y_axis;uniform float u_normal_scale;\n#endif\n#ifdef INDICATOR_CUTOUT\nout highp float v_z_offset;\n#else\n#ifdef RENDER_SHADOWS\nout highp float v_z_offset;\n#endif\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_inv_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_elevation_from_sea;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 vec2 v_tex_a;\n#ifdef ICON_TRANSITION\nout vec2 v_tex_b;\n#endif\nout float v_draw_halo;out vec3 v_gamma_scale_size_fade_opacity;\n#ifdef RENDER_TEXT_AND_SYMBOL\nout float is_sdf;out vec2 v_tex_a_icon;\n#endif\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 highp float v_depth;\n#endif\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\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\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\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\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 a_size_max= floor(a_size[1]*0.5);float a_apperance_icon=a_size[1]-2.0*a_size_max;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 (a_apperance_icon==APPEARANCE_ICON) {size=a_size_max/128.0;} else if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size_max,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=u_elevation_from_sea ? z_offset : z_offset+elevation(tile_anchor);\n#ifdef Z_OFFSET\ne+=a_auto_z_offset;\n#endif\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;vec3 world_pos_globe;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos_globe=a_globe_anchor+h;world_pos=mix_globe_mercator(world_pos_globe,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;vec2 a;\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);vec4 projected_point_globe=u_matrix*vec4(world_pos_globe,1);a=projected_point_globe.xy/projected_point_globe.w;\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);a=projected_point.xy/projected_point.w;\n#endif\nvec2 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\n#ifdef PROJECTED_POS_ON_VIEWPORT\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xyz+h,1.0);\n#else\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz,mercator_pos,u_zoom_transition)+h;projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0); \n#endif\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\n#ifdef Z_OFFSET\nz+=u_pitch_with_map ? a_auto_z_offset+z_offset : 0.0;\n#else\nz+=u_pitch_with_map ? z_offset : 0.0;\n#endif\nfloat occlusion_fade=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 out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));\n#ifdef DEPTH_OCCLUSION\nfloat depth_occlusion=occlusionFadeMultiSample(projected_point);float depth_occlusion_multplier=mix(occlusion_opacity,1.0,depth_occlusion);out_fade_opacity*=depth_occlusion_multplier;\n#endif\n#ifdef OCCLUSION_QUERIES\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\n#endif\n#ifdef Z_TEST_OCCLUSION\nout_fade_opacity*=occlusion_opacity;\n#endif\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);vec3 pos;\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);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\n#ifdef ELEVATED_ROADS\nvec3 xAxis=vec3(a_x_axis.xy,a_x_axis.z*u_normal_scale);vec3 yAxis=vec3(a_y_axis.xy,a_y_axis.z*u_normal_scale);pos=projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y;\n#else\npos=vec3(projected_pos.xy/projected_pos.w+offset,z);\n#endif\n#endif\ngl_Position=mix(u_coord_matrix*vec4(pos,1.0),AWAY,hidden);float gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_gamma_scale_size_fade_opacity=vec3(gamma_scale,size,out_fade_opacity);v_tex_a=a_tex/u_texsize;\n#ifdef RENDER_TEXT_AND_SYMBOL\nis_sdf=a_size[0]-2.0*a_size_min;v_tex_a_icon=a_tex/u_texsize_icon;\n#endif\n#ifdef ICON_TRANSITION\nv_tex_b=a_texb/u_texsize;\n#endif\n#ifdef RENDER_SHADOWS\nvec4 shd_pos=u_inv_matrix*vec4(pos,1.0);vec3 shd_pos0=shd_pos.xyz;vec3 shd_pos1=shd_pos.xyz;\n#ifdef NORMAL_OFFSET\nvec3 shd_pos_offset=shadow_normal_offset(vec3(0.0,0.0,1.0));shd_pos0+=shd_pos_offset*shadow_normal_offset_multiplier0();shd_pos1+=shd_pos_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\n#ifdef INDICATOR_CUTOUT\nv_z_offset=e;\n#else\n#ifdef RENDER_SHADOWS\nv_z_offset=e;\n#endif\n#endif\n}'),terrainRaster:qn('#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;\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,1.0/gl_FragCoord.w);\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,1.0/gl_FragCoord.w,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,1.0/gl_FragCoord.w);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;\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.);\n#endif\n}'),terrainDepth:qn("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:qn('#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+=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}',Fn),skyboxGradient:qn('#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;glFragColor=color;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\n}',Fn),skyboxCapture:qn("\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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform float u_far_z_cutoff;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\nhighp vec2 uv=gl_FragCoord.xy/u_viewport;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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 norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;highp float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);highp 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(clamp(raster.rgb,vec3(0),vec3(1))*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\ncolor*=1.0-step(u_far_z_cutoff,1.0/gl_FragCoord.w);glFragColor=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:qn('#include "_prelude_fog.fragment.glsl"\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_atmosphere_fog_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_atmosphere_fog_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_atmosphere_fog_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;glFragColor=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:qn('#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 highp vec4 v_pos_light_view_0;in highp vec4 v_pos_light_view_1;in float v_depth_shadows;\n#endif\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nuniform vec4 u_occlusionTextureTransform;\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 APPLY_LUT_ON_GPU\nuniform highp sampler3D u_lutTexture;\n#endif\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\nin highp float v_depth;uniform highp sampler2D u_depthTexture;uniform highp vec2 u_inv_depth_size;uniform highp vec2 u_depth_range_unpack;\n#ifdef DEPTH_D24\nhighp float unpack_depth(highp float depth) {return depth*u_depth_range_unpack.x+u_depth_range_unpack.y;}\n#else\nhighp float unpack_depth_rgba(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;}\n#endif\nbool isOccluded() {highp vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\n#ifdef FLIP_Y\ncoord.y=1.0-coord.y;\n#endif\n#ifdef DEPTH_D24\nhighp float depth=unpack_depth(texture(u_depthTexture,coord).r);\n#else\nhighp float depth=unpack_depth_rgba(texture(u_depthTexture,coord));\n#endif\nreturn 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\nif(u_baseTextureIsAlpha) {if (texColor.r < 0.5) {discard;}} else {texColor.rgb=sRGBToLinear(texColor.rgb);albedo*=texColor;}\n#endif\nvec4 color=vec4(mix(albedo.rgb,v_color_mix.rgb,v_color_mix.a),albedo.a);\n#ifdef APPLY_LUT_ON_GPU\ncolor=applyLUT(u_lutTexture,color);\n#endif\nreturn color;}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;\n#ifdef FLIP_Y\nT=-T;B=-B;\n#endif\nhighp 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#ifdef FLIP_Y\nn=normalize(cross(fdx,fdy));\n#else\nn=normalize(cross(fdx,fdy))*-1.0;\n#endif\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 baseColor=getBaseColor().rgb;vec3 diffuse=getDiffuseShadedColor(baseColor,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(mix(diffuse,baseColor,u_emissive_strength),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)\n#ifdef OCCLUSION_TEXTURE_TRANSFORM\nvec2 uv=uv_2f.xy*u_occlusionTextureTransform.zw+u_occlusionTextureTransform.xy;\n#else\nvec2 uv=uv_2f;\n#endif\nao=(texture(u_occlusionTexture,uv).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\n#ifdef APPLY_LUT_ON_GPU\nfloat emissiveFactorLength=max(length(u_emissiveFactor.rgb),0.001);emissive.rgb=sRGBToLinear(applyLUT(u_lutTexture,linearTosRGB(emissive.rgb/emissiveFactorLength).rbg))*emissiveFactorLength;\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);vec3 color_mix=v_color_mix.rgb;\n#ifdef APPLY_LUT_ON_GPU\ncolor_mix=applyLUT(u_lutTexture,color_mix);\n#endif\ncolor=mix(color,color_mix,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,v_position_height.w);\n#endif\n#ifdef FEATURE_CUTOUT\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord);\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_node_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 highp vec4 v_pos_light_view_0;out highp 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 hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);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#ifdef CLIP_ZERO_TO_ONE\nv_depth=-1.0+2.0*v_depth; \n#endif\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\nvec4 shadow_pos=u_node_matrix*vec4(local_pos,1.0);\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.xyz+=offset*shadow_normal_offset_multiplier0();\n#else\nvec3 offset=shadow_normal_offset_model(normal_3f);shadow_pos.xyz+=offset*shadow_normal_offset_multiplier0();\n#endif\n#endif\n#endif\nv_pos_light_view_0=u_light_matrix_0*shadow_pos;v_pos_light_view_1=u_light_matrix_1*shadow_pos;v_depth_shadows=gl_Position.w;\n#endif\n}'),modelDepth:qn("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 hidden=float(pos_a.x > EXTENT);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=mix(u_matrix*pos,AWAY,hidden);\n#else\ngl_Position=u_matrix*vec4(a_pos_3f,1);\n#endif\nv_depth=gl_Position.z/gl_Position.w;}"),stars:qn("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);}"),snowParticle:qn("in highp vec2 uv;in highp float alphaMultiplier;uniform vec4 u_particleColor;uniform vec2 u_simpleShapeParameters;void main() {float t=clamp((length(uv)-u_simpleShapeParameters.x)/(1.0-u_simpleShapeParameters.x),0.0,1.0);float alpha=1.0-pow(t,pow(10.0,u_simpleShapeParameters.y));alpha*=alphaMultiplier;alpha*=u_particleColor.a;vec3 color=u_particleColor.rgb*alpha;glFragColor=vec4(color,alpha) ;HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_snowParticleData;in highp vec4 a_snowParticleDataHorizontalOscillation;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform vec2 u_screenSize;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity;uniform vec3 u_direction;uniform float u_horizontalOscillationRadius; \nuniform float u_horizontalOscillationRate; \nuniform float u_billboardSize;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;out highp vec2 uv;out highp float alphaMultiplier;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos.xyz*=halfBoxSize;pos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_snowParticleData.z;float coneAngleHeadingRad=a_snowParticleData.w*radians(360.0);vec3 localZ=normalize(u_direction);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 direction;direction.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);direction.z=cos(coneAnglePichRad);direction=normalize(direction);vec3 simPosLocal=vec3(0,0,0);float velocityScale=(1.0+3.0*a_snowParticleData.y)*u_velocity;simPosLocal+=direction*velocityScale*u_time;float horizontalOscillationRadius=u_horizontalOscillationRadius*a_snowParticleDataHorizontalOscillation.x;float horizontalOscillationAngle=u_horizontalOscillationRate*u_time*(-1.0+2.0*a_snowParticleDataHorizontalOscillation.y);simPosLocal.xy+=horizontalOscillationRadius*vec2(cos(horizontalOscillationAngle),sin(horizontalOscillationAngle));vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);float clipZ=-u_cam_pos.z+pos.z;vec4 posView=u_modelview*vec4(pos,1.0);float size=u_billboardSize;alphaMultiplier=1.0;vec4 posScreen=u_projection*posView;posScreen/=posScreen.w;posScreen.xy=vec2(0.5)+posScreen.xy*0.5;posScreen.xy*=u_screenSize;vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=u_screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-posScreen.xy)/(0.5*u_screenSize));screenDist+=a_snowParticleData.x*u_thinningParticleOffset;float scaleFactorMode=0.0;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);if (a_snowParticleData.x < u_thinningAffectedRatio) {scaleFactorMode=1.0-thinningFadeRatio;alphaMultiplier=thinningFadeRatio;}}vec4 posScreen1=u_projection*vec4(posView.x-size,posView.yzw);posScreen1/=posScreen1.w;vec4 posScreen2=u_projection*vec4(posView.x+size,posView.yzw);posScreen2/=posScreen2.w;posScreen1.xy=vec2(0.5)+posScreen1.xy*0.5;posScreen1.xy*=u_screenSize;posScreen2.xy=vec2(0.5)+posScreen2.xy*0.5;posScreen2.xy*=u_screenSize;float screenLength=length(posScreen1.xy-posScreen2.xy);float screenEpsilon=3.0;float scaleFactor=1.0;if (screenLength < screenEpsilon) {scaleFactor=screenEpsilon/max(screenLength,0.01);scaleFactor=mix(scaleFactor,1.0,scaleFactorMode);}float screenEpsilon2=15.0;if (screenLength > screenEpsilon2) {scaleFactor=screenEpsilon2/max(screenLength,0.01);}size*=scaleFactor;vec2 right=size*vec2(1,0);vec2 up=size*vec2(0,1);posView.xy+=right*a_uv.x;posView.xy+=up*a_uv.y;uv=a_uv;gl_Position=u_projection*posView;}"),rainParticle:qn("in highp vec2 uv;in highp float particleRandomValue;uniform sampler2D u_texScreen;uniform float u_distortionStrength;uniform vec4 u_color;uniform vec2 u_thinningCenterPos;uniform vec3 u_thinningShape;uniform float u_thinningAffectedRatio;uniform float u_thinningParticleOffset;uniform float u_shapeDirectionalPower;uniform float u_mode;void main() {vec2 st=uv*0.5+vec2(0.5);vec2 uvm=uv;uvm.y=-1.0+2.0*pow(st.y,u_shapeDirectionalPower);float shape=clamp(1.0-length(uvm),0.0,1.0);float alpha=abs(shape)*u_color.a;vec2 screenSize=vec2(textureSize(u_texScreen,0));vec2 thinningCenterPos=u_thinningCenterPos.xy;thinningCenterPos.y=screenSize.y-thinningCenterPos.y;float screenDist=length((thinningCenterPos-gl_FragCoord.xy)/(0.5*screenSize));screenDist+=(0.5+0.5*particleRandomValue)*u_thinningParticleOffset;float thinningShapeDist=u_thinningShape.x+u_thinningShape.y;float thinningAlpha=1.0;if (screenDist < thinningShapeDist) {float thinningFadeRatio=clamp((screenDist-u_thinningShape.x)/u_thinningShape.y,0.0,1.0);thinningFadeRatio=pow(thinningFadeRatio,u_thinningShape.z);thinningAlpha*=thinningFadeRatio;}vec2 offsetXY=normalize(uvm)*abs(shape);vec2 stScreen=(gl_FragCoord.xy+offsetXY*u_distortionStrength*thinningAlpha)/screenSize;vec3 colorScreen=texture(u_texScreen,stScreen).rgb;alpha*=thinningAlpha;glFragColor=mix(vec4(colorScreen,1.0),vec4(u_color.rgb*alpha,alpha),u_mode);HANDLE_WIREFRAME_DEBUG;}","\nin highp vec3 a_pos_3f;in highp vec2 a_uv;in highp vec4 a_rainParticleData;uniform mat4 u_modelview;uniform mat4 u_projection;uniform vec3 u_cam_pos;uniform float u_time;uniform float u_boxSize;uniform float u_velocityConeAperture; \nuniform float u_velocity; \nuniform vec2 u_rainDropletSize;uniform vec3 u_rainDirection;out highp vec2 uv;out highp float particleRandomValue;void main() {vec3 pos=a_pos_3f;float halfBoxSize=0.5*u_boxSize;pos*=halfBoxSize; \npos+=u_cam_pos;float velocityConeApertureRad=radians(u_velocityConeAperture*0.5);float coneAnglePichRad=velocityConeApertureRad*a_rainParticleData.z;float coneAngleHeadingRad=a_rainParticleData.w*radians(360.0);vec3 localZ=normalize(u_rainDirection);vec3 localX=normalize(cross(localZ,vec3(1,0,0)));vec3 localY=normalize(cross(localZ,localX));vec3 directionLocal;directionLocal.x=cos(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.y=sin(coneAngleHeadingRad)*sin(coneAnglePichRad);directionLocal.z=cos(coneAnglePichRad);directionLocal=normalize(directionLocal);vec3 directionWorld=localX*directionLocal.x+localY*directionLocal.y+localZ*directionLocal.z;float velocityScale=(1.0+3.0*a_rainParticleData.y)*u_velocity;vec3 simPosLocal=vec3(0,0,0);simPosLocal+=directionLocal*velocityScale*u_time;vec3 simPos=localX*simPosLocal.x+\nlocalY*simPosLocal.y+localZ*simPosLocal.z;pos+=simPos;pos=fract((pos+vec3(halfBoxSize))/vec3(u_boxSize))*u_boxSize-vec3(halfBoxSize);vec4 posView=u_modelview*vec4(pos,1.0);vec3 directionView=normalize((u_modelview*vec4(directionWorld,0.0)).xyz);vec3 side=cross(directionView,normalize(posView.xyz));posView.xyz+=side*a_uv.x*u_rainDropletSize.x;posView.xyz+=directionView*a_uv.y*u_rainDropletSize.y;uv=a_uv;particleRandomValue=a_rainParticleData.x;gl_Position=u_projection*posView;}"),vignette:qn("uniform vec3 u_vignetteShape;uniform vec4 u_vignetteColor;in vec2 st;void main() {float screenDist=length(st);float alpha=clamp((screenDist-u_vignetteShape.x)/u_vignetteShape.y,0.0,1.0);alpha=pow(alpha,u_vignetteShape.z)*u_vignetteColor.a;vec3 color=u_vignetteColor.rgb;glFragColor=vec4(color*alpha,alpha) ;}","in vec2 a_pos_2f;out vec2 st;void main() {st=a_pos_2f;gl_Position=vec4(a_pos_2f,0,1);}"),occlusion:qn("uniform vec4 u_color;void main() {glFragColor=u_color;}",'#include "_prelude_terrain.vertex.glsl"\nin highp vec2 a_offset_xy;uniform highp vec3 u_anchorPos;uniform mat4 u_matrix;uniform vec2 u_screenSizePx;uniform vec2 u_occluderSizePx;void main() {vec3 world_pos=u_anchorPos;\n#ifdef TERRAIN\nfloat e=elevation(world_pos.xy);world_pos.z+=e;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1.0);projected_point.xy+=projected_point.w*a_offset_xy*0.5*u_occluderSizePx/u_screenSizePx;gl_Position=projected_point;}')};function Wn(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 qn(e,t){const i=/#include\s+"([^"]+)"/g,n=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,r={},o=[],s=[];if(e=e.replace(i,(e,t)=>(s.push(t),"")),(t=t.replace(i,(e,t)=>(o.push(t),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let a=[...jn];Wn(e,a),Wn(t,a);for(const e of[...o,...s])Gn[e]||console.error(`Undefined include: ${e}`),Hn[e]||(Hn[e]=[],Wn(Gn[e],Hn[e])),a=[...a,...Hn[e]];return{fragmentSource:e=e.replace(n,(e,t,i,n,o)=>(r[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(n,(e,t,i,n,o)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,a="float"===n?"vec2":n,l=`GET_ATTRIBUTE_${a}(a_${o}, materialInfo, ${s})`,c=o.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${i} ${n} a_${o};\n#endif\n`:r[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif\nout ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o}) \n #ifdef ${s}\n ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} a_${o};\n out ${i} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${o} = a_${o};\n#endif\n`:void 0:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif \n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\n#ifdef INSTANCED_ARRAYS\nin vec4 a_${o}0;\nin vec4 a_${o}1;\nin vec4 a_${o}2;\nin vec4 a_${o}3;\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${i} ${n} ${o} = a_${o};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = ${l};\n #else\n ${i} ${n} ${o} = a_${o};\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${i} ${n} ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`}),usedDefines:a,vertexIncludes:o,fragmentIncludes:s}}class Kn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,n,r,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!l&&e{const o=n.paint.get("hillshade-shadow-color"),s="none"===n.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=n.paint.get("hillshade-highlight-color"),l="none"===n.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=n.paint.get("hillshade-accent-color"),u="none"===n.paint.get("hillshade-accent-color-use-theme").constantOr("default"),h=n.paint.get("hillshade-emissive-strength");let d=e.an(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),n=e.d3(i.x,i.y,i.z);d=e.an(n[1])}const p=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:Xn(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),d],u_shadow:o.toPremultipliedRenderColor(s?null:n.lut),u_highlight:a.toPremultipliedRenderColor(l?null:n.lut),u_emissive_strength:h,u_accent:c.toPremultipliedRenderColor(u?null:n.lut)}})(t,n,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(n);d.draw(t,c.TRIANGLES,o,s,a,Xi.disabled,p,r.id,f,m,g)}function Yn(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(r,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function er(t,i,n){const r=t.context,o=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(o.TEXTURE1),Yn(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;r.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:a,height:a,data:null},o.RGBA8);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.disabled,((t,i)=>{const n=i.stride,r=e.bB();return e.cd(r,0,e.al,-e.al,0,0,1),e.bq(r,r,[0,-e.al,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ}})(i.tileID,s),n.id,c,u,h),i.needsHillshadePrepare=!1}class tr{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 ir extends tr{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}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 nr extends tr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class rr extends tr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class or extends tr{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 sr extends tr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class ar extends tr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class lr extends tr{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 cr extends tr{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 ur extends tr{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 hr extends tr{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 dr extends tr{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 pr extends tr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class fr extends tr{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 mr extends tr{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 gr extends tr{getDefault(){return e.ao.transparent.toNonPremultipliedRenderColor(null)}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 _r extends tr{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 Ar extends tr{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 yr extends tr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class vr extends tr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let xr=class extends tr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class br extends tr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class wr extends tr{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 Tr extends tr{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 Er extends tr{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 Cr extends tr{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 Sr extends tr{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 Br extends tr{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ir extends tr{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Mr extends tr{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 Pr extends tr{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 Rr extends tr{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 Lr extends tr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Fr extends Lr{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 kr extends Lr{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 Dr extends Lr{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 Or extends kr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const zr=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Ur=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,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:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function Nr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Vr=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,r){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:n,phase:0,duration:r,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()}},jr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Gr(e,t,i){if(0===t)return 0;const n=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*n}function Hr(e,t){const i=1<({u_matrix:e});function $r(t,i,n,r,o){if(o>0){const s=e.o.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.aA(h?a:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:a<1}:{opacity:d,mix:0,isFading:a<1}}return{opacity:1,mix:0,isFading:!1}}class Zr extends Lt{constructor(e){const t=pt("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",t,!1),t.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Wr extends Lt{constructor(e){const t=pt("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,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 n=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 It(i,this._source.tileSize*i.overscaleFactor(),e.tileZoom,void 0,void 0,this._source.worldview);t.state="loaded",this._tiles[i.key]=t}return t},{});for(const e in this._tiles)e in n||(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 qr extends e.aP{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 Kr extends e.bU{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(){const t=new e.bc,i=new e.b0,n=131;t.reserve(17161),i.reserve(33800);const r=e.al/128,o=e.al+r/2,s=o+r;for(let i=-r;io||i<0||i>o?24575:0,s=e.aA(Math.round(n),0,e.al),a=e.aA(Math.round(i),0,e.al);t.emplaceBack(s+r,a)}const a=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+1,r+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]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(n,e.be.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.bf.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.bf.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Wr(i.map),this.orthoMatrix=e.bB(),e.cd(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.al,0,e.al,0,1);const a=s.gl;this._overlapStencilMode=new Wi({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Zr(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=r.get("source"),c=o?this._mockSourceCache:t.getSourceCache(l,a);if(!c)return void e.w(`Couldn't find terrain source "${l}".`);if(this.sourceCache=c,this._attenuationRange=t.terrain.getAttenuationRange(),this._exaggeration=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{this.sourceCache.used&&e.w(`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 t=this.getScaledDemTileSize();this.sourceCache.update(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,u(),this._initializing=!0),u(),i.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom}else this._disable()}calculateExaggeration(t){if(this._attenuationRange&&t.zoom>=Math.ceil(this._attenuationRange[1]))return this._style.terrain.getExaggeration(t.zoom);const i=this._previousCameraAltitude,n=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=n;const r=null!=i?n-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.getExaggeration(o);let a=o-this._previousZoom;const l=this._previousUpdateTimestamp;let c=o;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(o-c)>.5&&(a=.5*(o-c+a)),a*r<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.ak(this._exaggeration,u,d)}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}attenuationRange(){return this._attenuationRange}getDemUpscale(){return this.proxySourceCache.getSource().tileSize/128}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){"source"===e.dataType&&e.coord?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._emptyDEMTextureDirty=!0,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.pool.forEach(e=>e.fb.destroy()),this.pool=[],this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy()}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.enabled?this._exaggeration:0}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.ae.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(n.x,n.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const n=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map(e=>new qr(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1;const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[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 n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Yn(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const n=i.dem.tree.minimums[0];return n>0&&e++,t+n},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.dK({width:1,height:1},new Float32Array([n]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(t,r,i.R32F,{premultiply:!1}),o}setupElevationDraw(t,i,n){const r=this.painter.context,o=r.gl,s={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0};s.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;c=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,r.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,r.activeTexture.set(o.TEXTURE2),h&&(s.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(n&&n.useDepthForOcclusion,i,s),n&&n.useMeterToDem&&a){const t=(1<{if(c===i)return;const n=[jr[i],"PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:n,overrideFog:r}),c=i},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=e.dE(u),g=[e.aF(u.center.lng),e.aJ(u.center.lat)],_=t.globeSharedBuffers,A=[u.width*e.o.devicePixelRatio,u.height*e.o.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=Gr(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const x=a.TRIANGLES;for(const c of r){const r=n.getTile(c),b=Wi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Nr(w,T)&&Vr.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Vr.getMorphValuesForProxy(c.key),C=E?1:0;E&&Object.assign(v,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dC(E.phase)}});const S=e.dF(c.canonical),B=e.dG(S.getCenter().lat),I=e.dH(c.canonical,S,B,u.worldSize/u._pixelsPerMercatorPixel),M=e.bj(e.dI(c.canonical)),P=Ur(u.expandedFarZProjMatrix,y,m,M,e.aj(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,h,u._farZ,I);if(d(c,C),l&&(i.setupElevationDraw(r,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),_)){const[e,i,n]=_.getGridBuffers(B,0!==h);l.draw(t,x,f,b,p,Xi.backCCW,P,"globe_raster",e,i,n)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of r){const{x:r,y:c,z:h}=o.canonical,d=0===c,m=c===(1<e.draw(t,a.TRIANGLES,f,Wi.disabled,p,Xi.disabled,Ur(u.expandedFarZProjMatrix,_,_,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,0,u._farZ),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&E(l,y),m&&t.renderDefaultSouthPole&&(_=e.cR(e.bB(),_,[1,-1,1]),E(l,x))}}}}(t,i,n,r,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=ln(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(jr[e]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),u&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),u.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=t.transform,g=Gr(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(_=mn(t.style,e,i))}{c=-1;const A=a.TRIANGLES,[y,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),x=Wi.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];Nr(b,w)&&Vr.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=Vr.getMorphValuesForProxy(c.key),E=T?1:0;let C;T&&(C={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.dC(T.phase)}});const S=zr(c.projMatrix,Hr(c.canonical,m.renderWorldCopies)?g/10:g,_);if(d(E),!l)continue;i.setupElevationDraw(r,l,C);const B=c.toUnwrapped();u&&u.setupShadows(B,l),t.uploadCommonUniforms(s,l,B,null,h),l.draw(t,A,f,x,p,Xi.backCCW,S,"terrain_raster",i.gridBuffer,y,v)}}}}(i,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?r.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;n.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(n.clear({color:e.ao.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,n=t;for(let r=0;ri}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 n=this._visibleDemTiles.filter(e=>e.dem).map(n=>{const r=n.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:n[0],height:n[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(n[0],n[1],!0,null);return o.colorAttachment.set(r.texture),o.depthAttachment=new Or(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return"hillshade"===t.type||"custom"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()})}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof lt){t=!0;break}if(!t)return;const i={};for(let t=0;te>t.end)||e.w("fill-extrusion with flood lighting and/or ground ambient occlusion should be moved to be on top of all draped layers.")}this._drapedRenderBatches=n}_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=0;r--){const o=i[r];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],r=this.proxyToSource[o.key];let s=0;for(const e in r){const t=r[e],o=i[e];if(!o||o.length!==t.length||t.some((t,i)=>t!==o[i]||n[e]&&n[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 r=[...this._drapedRenderBatches];r.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of r)for(const n of i){if(t.proxyCachedFBO[n.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[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.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&&(r.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):Wi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,n=this.painter.context,r=n.gl;i._tileClippingMaskIDs={},n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=i.getOrCreateProgram("clippingMask");for(const n of e){const e=i._tileClippingMaskIDs[n.key]=--t;o.draw(i,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(n.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const n=[t.x,t.y,1,1];e.aC(n,n,i.pixelMatrixInverse),e.cJ(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=e.ce(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=e.d9([],n.slice(0,3),s);e.aw(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.bG(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(t,i,n){if(t.getSource()instanceof e.aT)return this._setupProxiedCoordsForImageSource(t,i,n);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,n){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(e.min.x=Math.min(e.min.x,t.x-l.x),e.min.y=Math.min(e.min.y,t.y-l.y),e.max.x=Math.max(e.max.x,t.x-l.x),e.max.y=Math.max(e.max.y,t.y-l.y),e),{min:new e.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,i)=>{const n=t.wrap+t.canonical.x/(1<s+c.max.x||r+oa+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let o,s,a;r=e.bB();const l=i.tileID.wrap-t.wrap<0?(o=e.al>>n,s=o*((i.tileID.canonical.x<=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}s.key!==t.key&&(c.push(s.key),n=i.getTile(s))}const u=e=>{c.forEach(t=>{r[t]=e}),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=s.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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 Xr(t,i,n){const r=function(t,i,n){const r=e.bI(i,t),o=e.bI(n,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(r+1,1));return s(.92,1,Math.asin(e.aA(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.c4(o,n.slice(0,3),r);const s=[0,0,0];e.c4(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.d7(a,o,s),e.da(a)}const Jr=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Yr=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","elevatedStructures","model","symbol"];class eo{static cacheKey(e,t,i,n){let r=`${t}${n?n.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,n,r,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...s];let l=r?r.defines():[];l=l.concat(s.map(e=>`#define ${e}`));const c="#version 300 es\n";let u=c+l.concat("precision mediump float;",$n,Qn.fragmentSource).join("\n");for(const e of n.fragmentIncludes)u+=`\n${Gn[e]}`;u+=`\n${n.fragmentSource}`;let h=c+l.concat("precision highp float;",$n,Qn.vertexSource).join("\n");for(const e of n.vertexIncludes)h+=`\n${Gn[e]}`;this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&-1!==n.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(h+="\nuniform int u_instanceID;\n"),h+=`\n${n.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(h=h.replaceAll("gl_InstanceID","u_instanceID"));const d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,u),a.compileShader(d),a.attachShader(this.program,d);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,h),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(d),this.fixedUniforms=o(t),this.binderUniforms=r?r.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.cg(t)}))(t)),(s.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.cg(t),u_dem_prev:new e.cg(t),u_dem_tl:new e.cj(t),u_dem_scale:new e.ci(t),u_dem_tl_prev:new e.cj(t),u_dem_scale_prev:new e.ci(t),u_dem_size:new e.ci(t),u_dem_lerp:new e.ci(t),u_exaggeration:new e.ci(t),u_depth:new e.cg(t),u_depth_size_inv:new e.cj(t),u_depth_range_unpack:new e.cj(t),u_occluder_half_size:new e.ci(t),u_occlusion_depth_offset:new e.ci(t),u_meter_to_dem:new e.ci(t),u_label_plane_matrix_inv:new e.ck(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.ch(t),u_tile_tr_up:new e.ch(t),u_tile_br_up:new e.ch(t),u_tile_bl_up:new e.ch(t),u_tile_up_scale:new e.ci(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.ck(t),u_fog_range:new e.cj(t),u_fog_color:new e.d2(t),u_fog_horizon_blend:new e.ci(t),u_fog_vertical_limit:new e.cj(t),u_fog_temporal_offset:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_globe_transition:new e.ci(t),u_is_globe:new e.cg(t),u_viewport:new e.cj(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.d2(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.ch(t),u_lighting_directional_dir:new e.ch(t),u_lighting_directional_color:new e.ch(t),u_ground_radiance:new e.ch(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.ck(t),u_light_matrix_1:new e.ck(t),u_fade_range:new e.cj(t),u_shadow_normal_offset:new e.ch(t),u_shadow_intensity:new e.ci(t),u_shadow_texel_size:new e.ci(t),u_shadow_map_resolution:new e.ci(t),u_shadow_direction:new e.ch(t),u_shadow_bias:new e.ch(t),u_shadowmap_0:new e.cg(t),u_shadowmap_1:new e.cg(t)}))(t)))}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}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(t,i,n,r,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!Jr.includes(this.name))||!(!h.layers3D||!Yr.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(g.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const n in t[e])i[e][n]&&i[e][n].set(i.program,n,t[e][n].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,a,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),f.bind(),d.setColorMode(new Qi([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.ao.transparent,[!0,!0,!0,!1])),d.setDepthMode(new $i(i.func===p.LESS?p.LEQUAL:i.func,$i.ReadOnly,i.range)),d.setStencilMode(Wi.disabled);const A=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=u||1;for(let t=0;t1?p.drawElementsInstanced(p.LINES,A,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,A,p.UNSIGNED_SHORT,y);o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(n),d.setColorMode(r)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const n of Object.keys(i))if(!i[n].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${n} not set but required by ${t} being defined`)}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=e.context,_=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(n),g.setColorMode(r),g.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const A={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new Kn)).bind(g,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i1?_.drawElementsInstanced(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2,m):c?_.drawElements(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2):_.drawArrays(t,o.vertexOffset,o.vertexLength);t===_.TRIANGLES&&c&&this._drawDebugWireframe(e,i,n,r,c,o,h,d,p,m)}}}function to(t,i,n=0){const r=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=o*(i.tileID.canonical.x+i.tileID.wrap*r),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ay(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:n}}const io={terrain:0,flat:1},no=e.bB(),ro=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A)=>{const y=i.style.light,v=y.properties.get("position"),x=[v.x,v.y,v.z],b=e.dN();"viewport"===y.properties.get("anchor")&&(e.dO(b,-i.transform.angle),e.dP(x,x,b));const w=y.properties.get("color").toPremultipliedRenderColor(null),T=i.transform,E={u_matrix:t,u_lightpos:x,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:no,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:io[u],u_base_type:io[h],u_ao:o,u_edge_radius:s,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:_,u_ground_shadow_factor:A};return"globe"===T.projection.name&&(E.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:n,u_height_type:io[r],u_base_type:io[o]}),so=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_)=>{const A=ro(e,t,i,n,r,o,s,a,c,u,h,d,p,f,m,g,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(A,to(t,l,_),y)},ao=(e,t,i,n,r,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:n?1:0,u_meter_to_tile:r,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:u,u_dynamic_offset:1}),lo=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),co=(e,t,i,n,r,o=0)=>Object.assign(lo(e,t,r),to(i,n,o)),uo=(e,t,i,n)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:n}),ho=(e,t,i,n,r,o,s=0)=>Object.assign(co(e,t,i,n,o,s),{u_world:r}),po=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),fo=(e,t,i,n,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:n,u_reset_depth:r}),mo=(e,t,i,n,r,o,s,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:n,u_camera_pos:r,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l}),go=e=>({u_matrix:e}),_o=e=>({u_matrix:e}),Ao=(t,i,n,r,o,s,a,l)=>{const c=e.al/s.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:n.getCameraToCenterDistance(l),u_extrude_scale:[n.pixelsToGLUnits[0]/c,n.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:o}},yo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),vo=e.bB(),xo=(t,i,n,r,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.dQ(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ay(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:vo,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=r,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.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:e.dS(d.paint.get("raster-saturation")),u_contrast_factor:e.dR(d.paint.get("raster-contrast")),u_spin_weights:Eo(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:bo(e.dT,g,A),u_colorization_offset:wo(e.dT,_,A),u_color_ramp:m,u_texture_offset:[v/(y+2*v),y/(y+2*v)],u_texture_res:[y+2*v,y+2*v],u_emissive_strength:x});function Eo(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]}const Co=.05,So=(e,t,i,n,r,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:r,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Bo=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:n,u_color_ramp:o,u_velocity_res:r,u_max_speed:s,u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Co,Co]}),Io=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:n,u_max_speed:r,u_speed_factor:o,u_reset_rate:s,u_rand_seed:Math.random(),u_uv_offset:a,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[Co,Co]}),Mo=e.bB(),Po=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T)=>{const E=o.transform,C={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:E.getCameraToCenterDistance(y),u_rotate_symbol:+n,u_aspect_ratio:E.width/E.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:h,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Mo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Mo,u_up_vector:[0,-1,0],u_color_adj_mat:b,u_icon_transition:w||0,u_gamma_scale:r?o.transform.getCameraToCenterDistance(y)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:T||1,u_ground_shadow_factor:v,u_inv_matrix:e.bk(e.bB(),a),u_normal_scale:x,u_lutTexture:rn.LUT};return"globe"===y.name&&(C.u_tile_id=[f.canonical.x,f.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:n}),Lo=(t,i,n,r,o,s,a,l,c)=>Object.assign(function(t,i,n,r,o,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),u=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(s.tileID.canonical.x+s.tileID.wrap*c),d=u*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[a,l],u_pattern_size:n.displaySize,u_pattern_units_to_pixels:o?[r.transform.width,-1*r.transform.height]:[1/e.ay(s,1,r.transform.tileZoom),1/e.ay(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:n}),Fo=new Float32Array(e.bz([])),ko=(t,i,n,r,o,s,a,l,c,u,h,d,p,f=[0,0,0],m,g,_)=>{const A=o.style.light,y=A.properties.get("position"),v=[-y.x,-y.y,y.z],x=e.dN();"viewport"===A.properties.get("anchor")&&(e.dO(x,-o.transform.angle),e.dP(v,v,x));const b="MASK"===h.alphaMode,w=A.properties.get("color").toNonPremultipliedRenderColor(null),T=p.paint.get("model-ambient-occlusion-intensity"),E=p.paint.get("model-color").constantOr(e.ao.white).toNonPremultipliedRenderColor(null);return E.a=p.paint.get("model-color-mix-intensity").constantOr(0),_&&(E.r=_[0],E.g=_[1],E.b=_[2],E.a=_[3]),g&&(E.r=g.color.r,E.g=g.color.g,E.b=g.color.b,E.a=g.colorMix,d=g.emissionStrength,s=g.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:n,u_node_matrix:r||Fo,u_lightpos:v,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+b,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:rn.BaseColor,u_metallicRoughnessTexture:rn.MetallicRoughness,u_normalTexture:rn.Normal,u_occlusionTexture:rn.Occlusion,u_emissionTexture:rn.Emission,u_lutTexture:rn.LUT,u_color_mix:E.toArray01(),u_aoIntensity:T,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Do=(e,t=Fo,i=Fo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Oo={fillExtrusion:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_opacity:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_flood_light_color:new e.ch(t),u_vertical_scale:new e.ci(t),u_flood_light_intensity:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillExtrusionDepth:t=>({u_matrix:new e.ck(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_vertical_scale:new e.ci(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t)}),fillExtrusionPattern:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_height_factor:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_opacity:new e.ci(t),u_pattern_transition:new e.ci(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.ck(t),u_opacity:new e.ci(t),u_ao_pass:new e.ci(t),u_meter_to_tile:new e.ci(t),u_ao:new e.cj(t),u_flood_light_intensity:new e.ci(t),u_flood_light_color:new e.ch(t),u_attenuation:new e.ci(t),u_edge_radius:new e.ci(t),u_fb:new e.cg(t),u_fb_size:new e.ci(t),u_dynamic_offset:new e.ci(t)}),fill:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),fillOutline:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_ground_shadow_factor:new e.ch(t)}),fillOutlinePattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),building:t=>({u_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_opacity:new e.ci(t),u_faux_facade_ao_intensity:new e.ci(t),u_camera_pos:new e.ch(t),u_tile_to_meter:new e.ci(t),u_facade_emissive_chance:new e.ci(t),u_flood_light_color:new e.ch(t),u_flood_light_intensity:new e.ci(t)}),buildingBloom:t=>({u_matrix:new e.ck(t)}),buildingDepth:t=>({u_matrix:new e.ck(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.ck(t),u_depth_bias:new e.ci(t)}),elevatedStructures:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.ck(t),u_camera_pos:new e.ch(t),u_depth_bias:new e.ci(t),u_height_scale:new e.ci(t),u_reset_depth:new e.ci(t)}),circle:e.dX,collisionBox:t=>({u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_extrude_scale:new e.cj(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t)}),collisionCircle:t=>({u_matrix:new e.ck(t),u_inv_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_viewport_size:new e.cj(t)}),debug:t=>({u_color:new e.dA(t),u_matrix:new e.ck(t),u_overlay:new e.cg(t),u_overlay_scale:new e.ci(t)}),clippingMask:t=>({u_matrix:new e.ck(t)}),heatmap:t=>({u_extrude_scale:new e.ci(t),u_intensity:new e.ci(t),u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_up_dir:new e.ch(t)}),heatmapTexture:t=>({u_image:new e.cg(t),u_color_ramp:new e.cg(t),u_opacity:new e.ci(t)}),hillshade:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_latrange:new e.cj(t),u_light:new e.cj(t),u_shadow:new e.dA(t),u_highlight:new e.dA(t),u_emissive_strength:new e.ci(t),u_accent:new e.dA(t)}),hillshadePrepare:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_dimension:new e.cj(t),u_zoom:new e.ci(t)}),line:e.dW,linePattern:e.dV,raster:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_brightness_low:new e.ci(t),u_brightness_high:new e.ci(t),u_saturation_factor:new e.ci(t),u_contrast_factor:new e.ci(t),u_spin_weights:new e.ch(t),u_perspective_transform:new e.cj(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t),u_colorization_mix:new e.d2(t),u_colorization_offset:new e.ci(t),u_color_ramp:new e.cg(t),u_texture_offset:new e.cj(t),u_texture_res:new e.cj(t),u_emissive_strength:new e.ci(t)}),rasterParticle:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t)}),rasterParticleTexture:t=>({u_texture:new e.cg(t),u_opacity:new e.ci(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_tile_offset:new e.cj(t),u_velocity:new e.cg(t),u_color_ramp:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_velocity:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_speed_factor:new e.ci(t),u_reset_rate:new e.ci(t),u_rand_seed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),symbol:t=>({u_is_size_zoom_constant:new e.cg(t),u_is_size_feature_constant:new e.cg(t),u_size_t:new e.ci(t),u_size:new e.ci(t),u_camera_to_center_distance:new e.ci(t),u_rotate_symbol:new e.cg(t),u_aspect_ratio:new e.ci(t),u_fade_change:new e.ci(t),u_matrix:new e.ck(t),u_label_plane_matrix:new e.ck(t),u_coord_matrix:new e.ck(t),u_is_text:new e.cg(t),u_elevation_from_sea:new e.cg(t),u_pitch_with_map:new e.cg(t),u_texsize:new e.cj(t),u_texsize_icon:new e.cj(t),u_texture:new e.cg(t),u_texture_icon:new e.cg(t),u_gamma_scale:new e.ci(t),u_device_pixel_ratio:new e.ci(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_camera_forward:new e.ch(t),u_tile_matrix:new e.ck(t),u_up_vector:new e.ch(t),u_ecef_origin:new e.ch(t),u_is_halo:new e.cg(t),u_icon_transition:new e.ci(t),u_color_adj_mat:new e.ck(t),u_scale_factor:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_inv_matrix:new e.ck(t),u_normal_scale:new e.ci(t),u_lutTexture:new e.cg(t)}),background:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_color:new e.dA(t)}),backgroundPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_image:new e.cg(t),u_pattern_tl:new e.cj(t),u_pattern_br:new e.cj(t),u_texsize:new e.cj(t),u_pattern_size:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_pattern_units_to_pixels:new e.cj(t)}),terrainRaster:t=>({u_matrix:new e.ck(t),u_image0:new e.cg(t),u_skirt_height:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),skybox:t=>({u_matrix:new e.ck(t),u_sun_direction:new e.ch(t),u_cubemap:new e.cg(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxGradient:t=>({u_matrix:new e.ck(t),u_color_ramp:new e.cg(t),u_center_direction:new e.ch(t),u_radius:new e.ci(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dB(t),u_sun_direction:new e.ch(t),u_sun_intensity:new e.ci(t),u_color_tint_r:new e.d2(t),u_color_tint_m:new e.d2(t),u_luminance:new e.ci(t)}),globeRaster:t=>({u_proj_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_image0:new e.cg(t),u_grid_matrix:new e.dB(t),u_skirt_height:new e.ci(t),u_far_z_cutoff:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_viewport:new e.cj(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_horizon:new e.ci(t),u_transition:new e.ci(t),u_fadeout_range:new e.ci(t),u_atmosphere_fog_color:new e.d2(t),u_high_color:new e.d2(t),u_space_color:new e.d2(t),u_temporal_offset:new e.ci(t),u_horizon_angle:new e.ci(t)}),model:t=>({u_matrix:new e.ck(t),u_lighting_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_node_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_camera_pos:new e.ch(t),u_opacity:new e.ci(t),u_baseColorFactor:new e.d2(t),u_emissiveFactor:new e.d2(t),u_metallicFactor:new e.ci(t),u_roughnessFactor:new e.ci(t),u_baseTextureIsAlpha:new e.cg(t),u_alphaMask:new e.cg(t),u_alphaCutoff:new e.ci(t),u_baseColorTexture:new e.cg(t),u_metallicRoughnessTexture:new e.cg(t),u_normalTexture:new e.cg(t),u_occlusionTexture:new e.cg(t),u_emissionTexture:new e.cg(t),u_lutTexture:new e.cg(t),u_color_mix:new e.d2(t),u_aoIntensity:new e.ci(t),u_emissive_strength:new e.ci(t),u_occlusionTextureTransform:new e.d2(t)}),modelDepth:t=>({u_matrix:new e.ck(t),u_instance:new e.ck(t),u_node_matrix:new e.ck(t)}),groundShadow:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),stars:t=>({u_matrix:new e.ck(t),u_up:new e.ch(t),u_right:new e.ch(t),u_intensity_multiplier:new e.ci(t)}),snowParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_horizontalOscillationRadius:new e.ci(t),u_horizontalOscillationRate:new e.ci(t),u_boxSize:new e.ci(t),u_billboardSize:new e.ci(t),u_simpleShapeParameters:new e.cj(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_particleColor:new e.d2(t),u_direction:new e.ch(t)}),rainParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_texScreen:new e.cg(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_boxSize:new e.ci(t),u_rainDropletSize:new e.cj(t),u_distortionStrength:new e.ci(t),u_rainDirection:new e.ch(t),u_color:new e.d2(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_shapeDirectionalPower:new e.ci(t),u_shapeNormalPower:new e.ci(t),u_mode:new e.ci(t)}),vignette:t=>({u_vignetteShape:new e.ch(t),u_vignetteColor:new e.d2(t)}),occlusion:t=>({u_matrix:new e.ck(t),u_anchorPos:new e.ch(t),u_screenSizePx:new e.cj(t),u_occluderSizePx:new e.cj(t),u_color:new e.d2(t)})};class zo{constructor(e,t,i,n){this.id=zo.uniqueIdxCounter,zo.uniqueIdxCounter++,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||n||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=zo.uniqueIdxCounter,zo.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)}}zo.uniqueIdxCounter=0;const Uo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class No{constructor(e,t,i,n,r,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,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||r||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;i0&&e.vertexAttribDivisor(r,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Vo{constructor(e,t,i,n,r){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();n&&(this.colorAttachment=new Fr(e,o)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new kr(e,o):new Dr(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 jo{constructor(e,t){this.gl=e,this.clearColor=new ir(this),this.clearDepth=new nr(this),this.clearStencil=new rr(this),this.colorMask=new or(this),this.depthMask=new sr(this),this.stencilMask=new ar(this),this.stencilFunc=new lr(this),this.stencilOp=new cr(this),this.stencilTest=new ur(this),this.depthRange=new hr(this),this.depthTest=new dr(this),this.depthFunc=new pr(this),this.blend=new fr(this),this.blendFunc=new mr(this),this.blendColor=new gr(this),this.blendEquation=new _r(this),this.cullFace=new Ar(this),this.cullFaceSide=new yr(this),this.frontFace=new vr(this),this.program=new xr(this),this.activeTexture=new br(this),this.viewport=new wr(this),this.bindFramebuffer=new Tr(this),this.bindRenderbuffer=new Er(this),this.bindTexture=new Cr(this),this.bindVertexBuffer=new Sr(this),this.bindElementBuffer=new Br(this),this.bindVertexArrayOES=new Ir(this),this.pixelStoreUnpack=new Mr(this),this.pixelStoreUnpackPremultiplyAlpha=new Pr(this),this.pixelStoreUnpackFlipY=new Rr(this),this.options=t?Object.assign({},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.forceManualRenderingForInstanceIDShaders=t&&!!t.forceManualRenderingForInstanceIDShaders||this.renderer&&-1!==this.renderer.indexOf("PowerVR"),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),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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 zo(this,e,t,i)}createVertexBuffer(e,t,i,n,r){return new No(this,e,t,i,n,r)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,n){return new Vo(this,e,t,i,n)}clear({color:e,depth:t,stencil:i,colorMask:n}){const r=this.gl;let o=0;e&&(o|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(n||[!0,!0,!0,!0])),void 0!==t&&(o|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.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(t){e.bx(t.blendFunction,Qi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor),t.blendEquation?this.blendEquation.set(t.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(t.mask)}unbindVAO(){this.bindVertexArrayOES.set(null)}}let Go;function Ho(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=[e.aF(u.center.lng),e.aJ(u.center.lat)],d=n.layout.get("symbol-placement"),p=n.layout.get("text-variable-anchor"),f="map"===n.layout.get("icon-rotation-alignment"),m="map"===n.layout.get("text-rotation-alignment"),g="point"!==d,_=[];let A=0,y=0;for(let l=0;l0){const t=e.bB(),i=L;e.cO(t,x.placementInvProjMatrix,u.glCoordMatrix),e.cO(t,t,x.placementViewportMatrix),_.push({circleArray:k,circleOffset:y,transform:i,invTransform:t,projection:x.getProjection()}),A+=k.length/4,y=A}if(!F)continue;t.terrain&&t.terrain.setupElevationDraw(v,R);const D=M?[d.canonical.x,d.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:C,y:S,z:B,angle:L})}else fi(b,d)}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(i=mn(t.style,e,n))}return i},Q=e=>{C.depthOcclusionForSymbolsAndCircles&&(n.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},$=i=>{n.lut&&!w&&(n.lut.texture||(n.lut.texture=new e.d_(t.context,n.lut.image,[n.lut.image.height,n.lut.image.height,n.lut.image.height],T.gl.RGBA8)),T.activeTexture.set(T.gl.TEXTURE0+rn.LUT),n.lut.texture&&n.lut.texture.bind(T.gl.LINEAR,T.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},Z=()=>{const i=S&&"point"!==n.layout.get("symbol-placement"),a=[];Q(a),$(a);const c=i||V,h="road"===s.elevationType,_=t.shadowRenderer,w=h&&I&&!!_&&_.enabled,T=H(w),B=h&&I&&!t.terrain?F:L,M=n.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),M>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),0===A&&0===y&&0===v&&1===x||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),w&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&I&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS");const P=s.icon.programConfigurations.get(n.id),R=t.getOrCreateProgram("symbol",{config:P,defines:a}),D=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],z=s.iconSizeData,N=e.bJ(z,C.zoom),Z=I||!C.isOrthographic,W=ti(f,r.tileID.canonical,I,S,C,s.getProjection(),m),q=ni(f,r.tileID.canonical,I,S,C,s.getProjection(),m),K=t.translatePosMatrix(q,r,l,u,!0),X=t.translatePosMatrix(f,r,l,u),J=c?Qo:W,Y=S&&!I&&!i;let ee=U;!O&&!C.mercatorFromTransition||S||(ee=$o(C));const te=d?ee:U,ie=n.getColorAdjustmentMatrix(A,y,v,x),ne=Po(z.kind,N,Y,I,t,X,J,K,b,!1,D,[0,0],0,o,p,k,j,te,s.getProjection(),T,G,ie,M,null),re=r.imageAtlasTexture?r.imageAtlasTexture:null,oe=1!==n.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,se=s.sdfIcons||t.options.rotating||t.options.zooming||oe||Z?E.LINEAR:E.NEAREST,ae=s.sdfIcons&&0!==n.paint.get("icon-halo-width").constantOr(1),le=t.terrain&&I&&i?e.bk(e.bB(),W):Qo;if(i&&s.icon){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),a=ii(f,r.tileID.canonical,I,S,C,s.getProjection(),m),l=n.layout.get("icon-size-scale-range"),c=e.aA(t.scaleFactor,l[0],l[1]);ai(s,f,t,!1,a,q,I,g,i,o,c)}return{program:R,buffers:s.icon,uniformValues:ne,atlasTexture:re,atlasTextureIcon:null,atlasInterpolation:se,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:ae,depthMode:B,tile:r,renderWithShadows:w,labelPlaneMatrixInv:le}},W=()=>{const i=B&&"point"!==n.layout.get("symbol-placement"),a=[],l=i||D||V,u="road"===s.elevationType,g=t.shadowRenderer,A=u&&M&&!!g&&g.enabled,y=H(A),v=u&&M&&!t.terrain?F:L;t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||u&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),A&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),u&&M&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Q(a);const x=s.text.programConfigurations.get(n.id),w=t.getOrCreateProgram("symbol",{config:x,defines:a});let T,S=[0,0],I=null;const P=s.textSizeData;s.iconsInText&&(S=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],I=r.imageAtlasTexture?r.imageAtlasTexture:null,T=M||!C.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?E.LINEAR:E.NEAREST);const R=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],z=n.layout.get("text-size-scale-range"),N=e.aA(t.scaleFactor,z[0],z[1]),$=e.bJ(P,C.zoom,N),Z=ti(f,r.tileID.canonical,M,B,C,s.getProjection(),m),W=ni(f,r.tileID.canonical,M,B,C,s.getProjection(),m),q=t.translatePosMatrix(W,r,c,h,!0),K=t.translatePosMatrix(f,r,c,h),X=l?Qo:Z,J=B&&!M&&!i;let Y=U;!O&&!C.mercatorFromTransition||B||(Y=$o(C));const ee=Po(P.kind,$,J,M,t,K,X,q,b,!0,R,S,0,o,p,k,j,d?Y:U,s.getProjection(),y,G,null,null,N),te=r.glyphAtlasTexture?r.glyphAtlasTexture:null,ie=E.LINEAR,ne=0!==n.paint.get("text-halo-width").constantOr(1),re=t.terrain&&M&&i?e.bk(e.bB(),Z):Qo;if(i&&s.text){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),n=ii(f,r.tileID.canonical,M,B,C,s.getProjection(),m);ai(s,f,t,!0,n,W,M,_,i,o,N)}return{program:w,buffers:s.text,uniformValues:ee,atlasTexture:te,atlasTextureIcon:I,atlasInterpolation:ie,atlasInterpolationIcon:T,isSDF:!0,hasHalo:ne,depthMode:v,tile:r,renderWithShadows:A,labelPlaneMatrixInv:re}},q=s.icon.segments.get().length,K=s.text.segments.get().length,X=q&&!a.onlyText?Z():null,J=K&&!a.onlyIcons?W():null,Y=n.paint.get("icon-opacity").constantOr(1),ee=n.paint.get("text-opacity").constantOr(1);if(P&&s.canOverlap){R=!0;const t=Y&&!a.onlyText?s.icon.segments.get():[],i=ee&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)z.push({segments:new e.bf([i]),sortKey:i.sortKey,state:X});for(const t of i)z.push({segments:new e.bf([t]),sortKey:t.sortKey,state:J})}else a.onlyText||z.push({segments:Y?s.icon.segments:new e.bf([]),sortKey:0,state:X}),a.onlyIcons||z.push({segments:ee?s.text.segments:new e.bf([]),sortKey:0,state:J})}R&&z.sort((e,t)=>e.sortKey-t.sortKey);for(const e of z){const i=e.state;if(i)if(t.terrain?t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(C.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.CLAMP_TO_EDGE,!0)),i.renderWithShadows&&t.shadowRenderer.setupShadows(i.tile.tileID.toUnwrapped(),i.program,"vector-tile"),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,2),r.u_is_halo=0}else{if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,1)),r.u_is_halo=0}Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,i.uniformValues,1)}}}function Ko(e,t,i,n,r,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];r.draw(n,n.context.gl.TRIANGLES,o,s,a,Xi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),u,c)}function Xo(t,i){const n=1<=sn?1:t.pitch/sn))),2*i}(t.transform),u=t.transform.getFreeCameraOptions().position,h="elevatedStructuresDepthReconstruct",d=t.getOrCreateProgram(h,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(h);for(const e of r){const r=i.getTile(e),h=r.getBucket(n);if(!h)continue;const f=h.elevatedStructures;if(!f)continue;const m=h.elevationBufferData.heightRange,g=Xo(e.toUnwrapped(),u),_=t.translatePosMatrix(e.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));let A,y,v,x;if("initialize"===o){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=d}else if("reset"===o){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;A=fo(_,g,0,0,1),y=l,v=f.maskSegments,x=d}else if("geometry"===o){if(0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=p}x.draw(t,s.TRIANGLES,y,Wi.disabled,Qi.disabled,Xi.disabled,A,n.id,f.vertexBuffer,f.indexBuffer,v,n.paint,t.transform.zoom)}}function Yo(t,i,n){const{painter:r,sourceCache:o,layer:s,coords:a,colorMode:l,elevationType:c,terrainEnabled:u,pass:h}=t,d=r.context.gl,p=s.paint.get("fill-pattern"),f=s.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=c;"road"!==c||i&&!u||(g="none");const _="road"===g,A=t.painter.shadowRenderer,y=_&&!!A&&A.enabled,v=new $i(r.context.gl.LEQUAL,$i.ReadOnly,r.depthRangeFor3D);let x=[0,0,0];if(y){const e=r.style.directionalLight,t=r.style.ambientLight;e&&t&&(x=mn(r.style,e,t))}const b=p&&p.constantOr(1),w=(t,h)=>{let p,g,w,T,E;h?(p=b&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",w=d.LINES):(p=b?"fillPattern":"fill",w=d.TRIANGLES);for(const C of a){const a=o.getTile(C);if(b&&!a.patternsLoaded())continue;const S=a.getBucket(s);if(!S)continue;const B=i?S.elevationBufferData:S.bufferData;if(B.isEmpty())continue;r.prepareDrawTile();const I=B.programConfigurations.get(s.id),M=r.isTileAffectedByFog(C),P=[],R=[];_&&(P.push("ELEVATED_ROADS"),R.push(B.elevatedLayoutVertexBuffer)),y&&P.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),b&&(r.context.activeTexture.set(d.TEXTURE0),a.imageAtlasTexture&&a.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),I.updatePaintBuffers());let L=!1;if(m&&a.imageAtlas){const t=a.imageAtlas,i=e.e2.from(m),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),o=t.patternPositions.get(n),s=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;L=!!o&&!!s,o&&I.setConstantPatternPositions(o,s)}f>0&&(L||I.getPatternTransitionVertexBuffer("fill-pattern"))&&P.push("FILL_PATTERN_TRANSITION");const F=r.getOrCreateProgram(p,{config:I,overrideFog:M,defines:P}),k=r.translatePosMatrix(C.projMatrix,a,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));y&&A.setupShadows(a.tileID.toUnwrapped(),F,"vector-tile");const D=s.paint.get("fill-emissive-strength");if(h){T=B.lineIndexBuffer,E=B.lineSegments;const e=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[d.drawingBufferWidth,d.drawingBufferHeight];g="fillOutlinePattern"===p&&b?ho(k,D,r,a,e,x,f):uo(k,D,e,x)}else T=B.indexBuffer,E=B.triangleSegments,g=b?co(k,D,r,a,x,f):lo(k,D,x);r.uploadCommonUniforms(r.context,F,C.toUnwrapped());let O=t;("road"===c&&!u||"offset"===c)&&(O=v),F.draw(r,w,O,n||r.stencilModeForClipping(C),l,Xi.disabled,g,s.id,B.layoutVertexBuffer,T,E,s.paint,r.transform.zoom,I,R)}};r.renderPass===h&&w(r.depthModeForSublayer(1,"opaque"===r.renderPass?$i.ReadWrite:$i.ReadOnly),!1),"none"===g&&"translucent"===r.renderPass&&s.paint.get("fill-antialias")&&w(r.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,$i.ReadOnly),!0)}function es(t,i,n,r,o,s,a,l){n.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=n.paint.get("fill-extrusion-pattern"),p=n.paint.get("fill-extrusion-pattern-cross-fade"),f=d.constantOr(null),m=d.constantOr(1),g=n.paint.get("fill-extrusion-opacity"),_=t.style.enable3dLights(),A=n.paint.get(_&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],v=n.layout.get("fill-extrusion-edge-radius"),x=v>0&&!n.paint.get("fill-extrusion-rounded-roof"),b=x?0:v,w="globe"===h.projection.name?e.ea():0,T="globe"===h.projection.name,E=T?e.aj(h.zoom):0,C=[e.aF(h.center.lng),e.aJ(h.center.lat)],S="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),B=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(S?null:n.lut).toArray01().slice(0,3),I=n.paint.get("fill-extrusion-flood-light-intensity"),M=n.paint.get("fill-extrusion-vertical-scale"),P=0!==n.paint.get("fill-extrusion-line-width").constantOr(1),R=n.paint.get("fill-extrusion-height-alignment"),L=n.paint.get("fill-extrusion-base-alignment"),F=ln(t,n.paint.get("fill-extrusion-cutoff-fade-range")),k=[];let D;T&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),x&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),I>0&&k.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),P&&k.push("RENDER_WALL_MODE");const O="shadow"===t.renderPass,z=t.shadowRenderer,U=O&&!!z,N=O?Xi.disabled:Xi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let V=[0,0,0];if(z){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(V=mn(t.style,e,i)),O||(k.push("RENDER_SHADOWS","DEPTH_TEXTURE"),z.useNormalOffset&&k.push("NORMAL_OFFSET")),D=k.concat(["SHADOWS_SINGLE_CASCADE"])}const j=U?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",G=n.getLayerRenderingStats();for(const d of r){const r=i.getTile(d),_=r.getBucket(n);if(!_||_.projection.name!==h.projection.name)continue;let A=!1;z&&(A=0===z.getMaxCascadeForTile(d.toUnwrapped()));const v=t.isTileAffectedByFog(d),x=_.programConfigurations.get(n.id);let S=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.e2.from(f),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),o=i.getSecondary(),s=t.patternPositions.get(n),a=o?t.patternPositions.get(o.scaleSelf(e.o.devicePixelRatio).toString()):null;S=!!s&&!!a,s&&x.setConstantPatternPositions(s,a)}p>0&&(S||x.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const U=t.getOrCreateProgram(j,{config:x,defines:A?D:k,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(r,U,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=U.getAttributeLocation(u,"a_centroid_pos");-1!==e&&u.vertexAttrib2f(e,0,0)}!O&&z&&z.setupShadows(r.tileID.toUnwrapped(),U,"vector-tile"),m&&(t.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),x.updatePaintBuffers());const H=n.paint.get("fill-extrusion-vertical-gradient"),Q=1/_.tileToMeter;let $;if(O&&z){if(as(r.tileID,_.maxHeight,t))continue;const e=z.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());$=oo(e,b,Q,M,R,L)}else{const e=t.translatePosMatrix(d.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,d.canonical);$=m?so(e,t,H,g,y,b,Q,d,r,w,R,L,E,C,i,B,M,p):ro(e,t,H,g,y,b,Q,d,w,R,L,E,C,i,B,M,I,V)}t.uploadCommonUniforms(c,U,d.toUnwrapped(),null,F);let Z=_.segments;if("mercator"===h.projection.name&&!O&&(Z=_.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!Z.get().length))continue;if(G)if(O)for(const e of Z.get())G.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of Z.get())G.numRenderedVerticesInTransparentPass+=e.primitiveLength;const W=[];(t.terrain||l)&&W.push(_.centroidVertexBuffer),T&&W.push(_.layoutVertexExtBuffer),P&&W.push(_.wallVertexBuffer),U.draw(t,c.gl.TRIANGLES,o,s,a,N,$,n.id,_.layoutVertexBuffer,_.indexBuffer,Z,n.paint,t.transform.zoom,x,W)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class ts{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function is(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i.context,b=x.gl,w=i.transform,T=i.transform.zoom,E=[],C=t.translate,S=t.translateAnchor,B=t.edgeRadius,I=ln(i,t.cutoffFadeRange);"clear"===h?(E.push("CLEAR_SUBPASS"),v&&(E.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),v.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),A&&E.push("HAS_CENTROID"),I.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=(e,t,n,o,h)=>{let y=E;null!=t.groundRadiusBuffer&&(y=E.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),w=i.isTileAffectedByFog(e),C=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:w}),S=ao(i,o,d,u,h,[p,f*h],m,g,_,T>=17?0:B*h,v?v.size[0]:0),M=[];A&&M.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&M.push(t.groundRadiusBuffer),i.uploadCommonUniforms(x,C,e.toUnwrapped(),null,I),C.draw(i,x.gl.TRIANGLES,s,a,l,c,S,r.id,t.vertexBuffer,t.indexBuffer,n,r.paint,T,b,M)};for(const t of o){const o=n.getTile(t),s=o.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,o,C,S),n=a.getDefaultSegment();M(t,a,n,e,l)}if(y)for(let s=0;s<4;s++){const a=e.e8[s](t),c=n.getTile(a);if(!c)continue;const u=c.getBucket(r);if(!u||u.projection.name!==w.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.al,0,0],p=1):1===s?(d=[e.al,0,0],p=0):2===s?(d=[0,-e.al,0],p=3):(d=[0,e.al,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.bq(m,t.projMatrix,d),M(t,h,f,i.translatePosMatrix(m,o,C,S),l)}}}function ns(t,i,n,r,o,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(n):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=t=>new e.P(Math.ceil((t+e.ec)*e.ed),0),u=e=>{const t=i.getSource().minzoom,n=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(h[0]=Math.min(t.min.y,i.min.y),h[1]=Math.max(t.max.y,i.max.y),h[2]=e.al-i.min.x>t.max.x?i.min.x-e.al:t.max.x,h),p=(t,i)=>(h[0]=Math.min(t.min.x,i.min.x),h[1]=Math.max(t.max.x,i.max.x),h[2]=e.al-i.min.y>t.max.y?i.min.y-e.al:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,r,o,a,c,u)=>{if(!s)return 0;const h=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=u<0?e.al+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&u<0||0!==r&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(n,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const o=e.e8[t](n),l=u(o);if(!(l&&l instanceof e.e9))continue;const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;if(s&&h&&h.dem&&r.borderDEMTileTimestamp[t]!==h.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=h.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==r.canonical.z,A=l.borderFeatureIndices[d];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(p)for(const e of A)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}for(const n of i){const i=r.featuresOnBorder[n],s=r.centroidData[i.centroidDataIndex],u=i.borders[t];let p;for(;yu[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&yu[1]-3)&&(v++,++y!==A.length);)p=l.featuresOnBorder[A[y]];p=l.featuresOnBorder[A[n]];let x=!1;if(v>=1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(v=1,x=!0,y=n+1)}else if(0===v){r.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&x&&(((g=s).flags|(_=b).flags)&e.eb?(g.flags|=e.eb,_.flags|=e.eb):(g.flags&=~e.eb,_.flags&=~e.eb));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)y=n,s.centroidXY=b.centroidXY=new e.P(0,0);else if(h&&h.dem&&!w){const i=f[t](s,b),n=t%2?e.al-1:0,r=m(i[0],Math.min(e.al-1,i[1]),n,h,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(r)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else r.showCentroid(i)}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}var g,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const rs=[1,0,0],os=[0,1,0],ss=[0,0,1];function as(t,i,n){const r=n.transform,o=n.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=r.tileSize*o._cascades[n.currentShadowCascade].scale;let l=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[rs,os,ss,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===r.projection.name,p=r.scaleZoom(a),f=e.cA.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ls(t){const{painter:i,source:n,layer:r,coords:o}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,u=i.shadowRenderer,h=e.ee(i.transform.center.lat,i.transform.zoom),d=ln(i,r.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF")),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const p of o){const o=n.getTile(p),f=o.getBucket(r);if(!f)continue;u&&0===u.getMaxCascadeForTile(p.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(r.id);let g,_,A,y=i.translatePosMatrix(p.expandedProjMatrix,o,[0,0],"map");if(y=e.cR(e.bB(),y,[1,1,t.verticalScale]),l&&u){if(as(o.tileID,f.maxHeight*h,i))continue;let n=u.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());n=e.cR(e.bB(),n,[1,1,t.verticalScale]),A=_o(n),g=_=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1})}else if(c)g=_=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),A=go(y);else{const n=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.cR(n,n,[1,1,t.verticalScale]);const r=e.bB();e.cR(r,n,[1,-1,1/h]),e.bk(r,r),e.ef(r,r);const o=i.transform.getFreeCameraOptions().position,a=1<{if(c){const o=e.entranceBloom;n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,Xi.disabled,A,r.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,r.paint,i.transform.zoom,m,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{const o=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,l?Xi.disabled:Xi.backCW,A,r.id,e.layoutVertexBuffer,e.indexBuffer,o,r.paint,i.transform.zoom,m,s)}};i.uploadCommonUniforms(a,_,p.toUnwrapped(),null,d),f.buildingWithoutFacade&&v(f.buildingWithoutFacade,_),f.buildingWithFacade&&(g!==_&&i.uploadCommonUniforms(a,g,p.toUnwrapped(),null,d),v(f.buildingWithFacade,g))}}function cs(t,i,n,r,o,s,a,l,c,u,h,d,p){const f=t.context.gl,m=t.depthModeForSublayer(1,$i.ReadOnly,f.LEQUAL,!0),g=.1*(1-(_=h))+3*_;var _;const A=t._showOverdrawInspector,y=d,v=new ts;A||is(v,t,i,n,r,m,new Wi({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),new Qi([f.ONE,f.ONE,f.ONE,f.ONE],e.ao.transparent,[!1,!1,!1,!0],f.MIN),Xi.disabled,o,"sdf",s,a,l,c,u,g,y,!1);{const h=A?Wi.disabled:new Wi({func:f.EQUAL,mask:255},255,255,f.KEEP,f.DECR,f.DECR),d=A?t.colorModeForRenderPass():new Qi([f.ONE_MINUS_DST_ALPHA,f.DST_ALPHA,f.ONE,f.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(v,t,i,n,r,m,h,d,Xi.disabled,o,"color",s,a,l,c,u,g,y,!1)}}function us(t){return[t[0]*e.eg,t[1]*e.eg,t[2]*e.eg,0]}function hs(t,i,n,r,o,s,a,l,c){const u=r.getSource(),h=n.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=r.getTile(i)),u instanceof e.aT?(p=u.texture,f=e.dJ(0,0,n.transform)):d&&i&&(p=d.texture,f=e.dJ(i.canonical.z,i.canonical.x,n.transform)),!p||!f)return;t||(f=e.cR(e.bB(),f,[1,-1,1]));const m=n.context,g=m.gl,_="nearest"===o.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,A=n.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const v=new $i(g.LEQUAL,$i.ReadWrite,n.depthRangeFor3D),x=Float32Array.from(n.transform.expandedFarZProjMatrix),b=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0))));n.terrain&&n.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),p.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),p.bind(_,g.CLAMP_TO_EDGE),"useMipmap"in p&&m.extTextureFilterAnisotropic&&n.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,T,E,C]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),S=o.paint.get("raster-elevation");let B;t?(B=w,n.renderDefaultNorthPole=0!==S):(B=T,n.renderDefaultSouthPole=0!==S);const I=us(a.mix),M=((e,t,i,n,r,o,s,a,l,c,u,h,d)=>To(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],n,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(x,b,f,e.aj(n.transform.zoom),0,o,0,S,0,I,a.offset,a.range,s),P=n.getOrCreateProgram("raster",{defines:y});n.uploadCommonUniforms(m,P,null),P.draw(n,g.TRIANGLES,v,c,A,l,M,o.id,B,E,C)}function ds(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),n=i-t,r=.2*e.height,o=t+r;return[t,i,(o-r-t)/n,(o-t)/n]}function ps(e,t,i,n){if(e)return t instanceof ht&&e instanceof Mt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:us(n.mix),offset:n.offset,buffer:0,tileSize:1}}var fs=e.eh([{name:"a_index",type:"Int16",components:1}]);class ms{constructor(t,i,n,r){const o={width:n[0],height:n[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,r),this.lastInvalidatedAt=0}updateParticleTexture(t,i){if(this.particleTextureDimension===i.width)return;(this.particleTexture0||this.particleTexture1||this.particleIndexBuffer||this.particleSegment)&&(this.particleTexture0.destroy(),this.particleTexture1.destroy(),this.particleIndexBuffer.destroy(),this.particleSegment.destroy());const n=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.ei;o.reserve(r);for(let e=0;e0){const t=e.bi(n.canonical,c),i=e.ek(t);p=e.aB(new Float32Array(16),c.globeMatrix,i),e.aB(p,c.projMatrix,p)}const f=e.bB();f[12]+=2*o/(e.o.devicePixelRatio*c.width),f[13]+=2*s/(e.o.devicePixelRatio*c.height),e.aB(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),g=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=$i.disabled,A=Wi.disabled,y=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const x=g._tileDebugBuffer||t.debugBuffer,b=g._tileDebugIndexBuffer||t.debugIndexBuffer,w=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,A,y,Xi.disabled,yo(p,r.toPremultipliedRenderColor(null)),v,x,b,w,null,null,null,[g._globeTileDebugBorderBuffer]),a){const e=g.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(r+=` => ${n.overscaledZ}`),r+=` ${g.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,r)}const T=i.getTile(n).tileSize,E=512/Math.min(T,512)*(n.overscaledZ/c.zoom)*.5,C=g._tileDebugTextBuffer||t.debugBuffer,S=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,B=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,A,Qi.alphaBlended,Xi.disabled,yo(p,e.ao.transparent.toPremultipliedRenderColor(null),E),v,C,S,B,null,null,null,[g._globeTileDebugTextBuffer])}function Es(e,t,i,n){Ss(e,0,t+i/2,e.transform.width,i,n)}function Cs(e,t,i,n){Ss(e,t-i/2,0,i,e.transform.height,n)}function Ss(t,i,n,r,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,n*e.o.devicePixelRatio,r*e.o.devicePixelRatio,o*e.o.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Bs=e.eh([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Is}=Bs;function Ms(e,t,i,n){e.emplaceBack(t,i,n)}class Ps{constructor(t){this.vertexArray=new e.el,this.indices=new e.b0,Ms(this.vertexArray,-1,-1,1),Ms(this.vertexArray,1,-1,1),Ms(this.vertexArray,-1,1,1),Ms(this.vertexArray,1,1,1),Ms(this.vertexArray,-1,-1,-1),Ms(this.vertexArray,1,-1,-1),Ms(this.vertexArray,-1,1,-1),Ms(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=t.createVertexBuffer(this.vertexArray,Is),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.bf.simpleSegment(0,0,36,12)}}function Rs(t,i,n,r,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.en(e.dN(),r),o,u,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Ls=e.eh([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Fs{constructor(t){const i=new e.eo;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new e.b0;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Ls.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.bf.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const ks=e.eh([{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 Ds{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Os{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Qi([1,0,1,0],e.ao.transparent,[!1,!1,!1,!0]),this.params=new Ds,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Fs(i);const t=this.params.sizeRange,n=this.params.intensityRange,r=function(t){const i=e.eq(30),n=[];for(let r=0;r{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,n,r,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:n,u_horizon:r,u_transition:o,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,g,u,d,f,A,x);t.uploadCommonUniforms(n,l);const h=this.atmosphereBuffer;h&&l.draw(t,r.TRIANGLES,s,Wi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",h.vertexBuffer,h.indexBuffer,h.segments)};b(!1),b(!0)}drawStars(t,i){const n=e.aA(i.properties.get("star-intensity"),0,1);if(0===n)return;const r=t.context,o=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.c6([]);e.c8(l,l,-s._pitch),e.c7(l,l,-s.angle),e.c8(l,l,e.an(s._center.lat)),e.es(l,l,-e.an(s._center.lng));const c=e.cb(new Float32Array(16),l),u=e.aB([],s.starsProjMatrix,c),h=e.en([],c),d=e.et([],h),p=[0,1,0];e.dP(p,p,d),e.c4(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.dP(f,f,d),e.c4(f,f,this.params.sizeMultiplier);const m=(g=p,_=f,A=n,{u_matrix:Float32Array.from(u),u_up:g,u_right:_,u_intensity_multiplier:A});var g,_,A;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,this.colorModeAlphaBlendedWriteRGB,Xi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class zs{constructor(){this.visibleTiles=[]}updateBorders(t,i){const n=[],r=[],o=t._getRenderableCoordinates(!1,!0);for(const e of o){const o=t.getTile(e);if(!o.hasData())continue;const s=o.getBucket(i);s&&(s.isEmpty()||(n.push(e.key),r.push({bucket:s,tileID:e.canonical})))}let s=n.length!==this.visibleTiles.length;if(!s){n.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of r){const i=new Array,n=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?n.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.eu,!1),r.updateFootprintHiddenFlags(n,e.eu,!0)}}}function Us(t,i){const n=[...t],r=i.cameraWorldSizeForFog/i.worldSize,o=e.bz([]);return e.cR(o,o,[r,r,1]),e.aB(n,o,n),e.aB(n,i.worldToFogMatrix,n),n}function Ns(t,i,n,r,o){const s=n.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=s;function p(e,i,n){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+n),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:n,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,n,r)}}p(l,"HAS_TEXTURE_u_baseColorTexture",rn.BaseColor),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",rn.MetallicRoughness),p(u,"HAS_TEXTURE_u_normalTexture",rn.Normal),p(h,"HAS_TEXTURE_u_occlusionTexture",rn.Occlusion),p(d,"HAS_TEXTURE_u_emissionTexture",rn.Emission),o&&(o.texture||(o.texture=new e.d_(r.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+rn.LUT),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),n.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(n.texcoordBuffer)),n.colorBuffer&&(t.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(n.colorBuffer)),n.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(n.normalBuffer)),n.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(n.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Vs(t,i,n,r,o,s){const a=n.paint.get("model-opacity").constantOr(1),l=i.context,c=new $i(i.context.gl.LEQUAL,t.isLightMesh?$i.ReadOnly:$i.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aB([],r.zScaleMatrix,t.nodeModelMatrix),e.aB(m,r.negCameraPosMatrix,m);const g=e.bk([],m);e.ef(g,g);const _="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=n.paint.get("model-emissive-strength").constantOr(0),y=ko(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(g),null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,A,n,void 0,void 0,t.materialOverride,t.modelColor),v={defines:[]},x=[],b=i.shadowRenderer;b&&(b.useNormalOffset=!1),Ns(v.defines,x,h,i,_?null:n.lut);let w=null;if(f){const e=Us(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,i=h.aabb.max,[n,r]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);v.overrideFog=n>=Ve||r>=Ve}}const T=ln(i,n.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Xi.disabled:Xi.backCCW,y,n.id,h.vertexBuffer,h.indexBuffer,h.segments,n.paint,i.transform.zoom,void 0,x)}function js(e,t,i){return"vector"===e.type?t.scope:i?"basemap":""}function Gs(t,i,n,r,o,s,a,l,c){const u=t.transform,h=!!i.isGeometryBloom&&i.isGeometryBloom;if(h&&"shadow"===t.renderPass)return;const d="globe"===u.projection.name?e.eC(n,u):[...n];e.aB(d,d,i.globalMatrix);const p=e.aB([],r,d);if(i.meshes)for(const t of i.meshes){const i=l.get(t.material.name);if(i&&i.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c});continue}const n=e.af([],t.centroid,p);!u.isOrthographic&&n[2]<=0||s.push({mesh:t,depth:n[2],modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c})}if(i.children)for(const e of i.children)Gs(t,e,n,r,o,s,a,l,c)}function Hs(e,t,i,n){const r=i.shadowRenderer;if(!r)return;const o=r.getShadowPassDepthMode(),s=r.getShadowPassColorMode(),a=r.calculateShadowPassMatrixFromMatrix(t),l=Do(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Wi.disabled,s,Xi.disabled,l,n.id,e.vertexBuffer,e.indexBuffer,e.segments,n.paint,i.transform.zoom,void 0,void 0)}function Qs(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};o.set(s,l)}}function $s(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};o.set(s,l)}}function Zs(e,t,i,n,r,o){if(1===i)for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,e.colorModeForRenderPass());else{for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,Qi.disabled);for(const i of r)Vs(i,e,t,o[i.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}const s=Qi.additive;for(const i of n)Vs(i,e,t,o[i.modelIndex],Wi.disabled,i.isLightMesh?s:e.colorModeForRenderPass())}function Ws(t,i,n){const r=i.updateZoomBasedPaintProperties(),o=function(t,i,n){let r,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(n);o&&o.dem?r=e.eE.create(i,n,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.aA(r.x,s,a)-r.x,d=e.aA(r.y,l,c)-r.y,p=e.ce(u,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Xs(e,t,i,n,r,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new $i(a.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let g,_,A;const y=!d&&n.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const v=ln(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)g=e.getOrCreateProgram("modelDepth",{defines:f}),_=Do(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),A=c.getShadowPassColorMode();else{Ns(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),g=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const n=p.material,l=n.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);_=ko(o.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,u,l.baseColorFactor,n.emissiveFactor,l.metallicFactor,l.roughnessFactor,n,d,t,r),c&&(s.shadowUniformsInitialized?g.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),g,"model-tile"),s.shadowUniformsInitialized=!0)),A=v.shouldRenderCutoff||u<1||"OPAQUE"!==n.alphaMode?Qi.alphaBlended:Qi.unblended}e.uploadCommonUniforms(a,g,o.toUnwrapped(),null,v);const x=p.material.doubleSided?Xi.disabled:Xi.backCCW;if(y)m.push(n.instancedDataBuffer),g.draw(e,a.gl.TRIANGLES,u,Wi.disabled,A,x,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,n.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let r=0;rc[1]?a:c,s[0]=n.max[0],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c,s[1]=n.min[1],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c;const u=e.aA(r[0],0,1),h=100*i.pixelsPerMeter*e.aA(r[1],0,1),d=e.aA(r[2],0,1),p=e.eG(e.eF(),l,c,u),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===h)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/h,_=(e,t,i)=>(1-i)*e+i*t,A=e.aA(_(1,d,g),d,1);return _(1,A,e.aA((i.pitch-20)/20,0,1))}class ia{}class na{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,n){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=n.gl,o=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.eI;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class ra{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}const oa=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class sa{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class aa{constructor(e,t){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...t,"Reveal"],"revealStart",{min:0,max:17,step:.05}),e.registerParameter(this,[...t,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}const la=e.eh([{type:"Float32",name:"a_pos_2f",components:2}]);class ca{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const n=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eJ,n=new e.b0;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,la.members),this.vignetteIdx=t.context.createIndexBuffer(n)}const r=e.bf.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,n);const e={u_vignetteShape:(o={vignetteShape:[i.start,i.range,Math.pow(10,i.fadePower)],vignetteColor:[i.color.r,i.color.g,i.color.b,i.color.a*i.strength]}).vignetteShape,u_vignetteColor:o.vignetteColor};n.draw(t,t.context.gl.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r)}var o}}class ua{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const n=t.getFreeCameraOptions().position,r=n.toAltitude(),o=n.toLngLat(),s=e.an(o.lng),a=e.an(o.lat),l=t.pixelsPerMeter/i,c=s*e.eL,u=e.eL*Math.log(Math.tan(Math.PI/4+a/2));if(void 0===this._offsetXPrev)this._offsetXPrev=0,this._offsetYPrev=0,this._elevationPrev=0,this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0;else{const e=-this._offsetYPrev+u,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=u,this._elevationPrev=r}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ha(e,t){return[-(e[0]-Math.floor(e[0]/t)*t),-(e[1]-Math.floor(e[1]/t)*t),-(e[2]-Math.floor(e[2]/t)*t)]}function da(t){const i=e.eq(1323123451230),n=[];for(let r=0;rn)return;const r=pa(0,1,i.revealStart,i.revealStart+i.revealRange,n);if(!this.particlesVx||!this.particlesIdx)return;const o=structuredClone(this._params);let s=[-o.direction.x,o.direction.y,-100];e.aw(s,s);const a=structuredClone(this._vignetteParams);a.strength*=r,o.overrideStyleParameters||(o.intensity=t.style.rain.state.density,o.timeFactor=t.style.rain.state.intensity,o.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),o.screenThinning.intensity=t.style.rain.state.centerThinning,o.dropletSizeX=t.style.rain.state.dropletSize[0],o.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],o.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,o.timeFactor),c=t.context,u=c.gl,h=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},u.RGBA8)),o.distortionStrength>0&&(c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),u.copyTexSubImage2D(u.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const d=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,d),c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE);const p=[o.color.r,o.color.g,o.color.b,o.color.a],f=(i,n)=>{const r=ha(this._movement.getPosition(),i),a=o.dropletSizeX,c=o.dropletSizeX*o.dropletSizeYScale,f=t.width/2,m=t.height/2,g=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),A=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(v={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:r,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:o.distortionStrength,rainDirection:s,color:p,screenSize:[h.width,h.height],thinningCenterPos:[f,m],thinningShape:[g,_,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:A,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:n?0:1},{u_modelview:Float32Array.from(v.modelview),u_projection:Float32Array.from(v.projection),u_time:v.time,u_cam_pos:v.camPos,u_texScreen:0,u_velocityConeAperture:v.velocityConeAperture,u_velocity:v.velocity,u_boxSize:v.boxSize,u_rainDropletSize:v.rainDropletSize,u_distortionStrength:v.distortionStrength,u_rainDirection:v.rainDirection,u_color:v.color,u_screenSize:v.screenSize,u_thinningCenterPos:v.thinningCenterPos,u_thinningShape:v.thinningShape,u_thinningAffectedRatio:v.thinningAffectedRatio,u_thinningParticleOffset:v.thinningParticleOffset,u_shapeDirectionalPower:v.shapeDirectionalPower,u_shapeNormalPower:v.shapeNormalPower,u_mode:v.mode});var v;const x=Math.round(o.intensity*this.particlesCount),b=e.bf.simpleSegment(0,0,4*x,2*x);d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,b)};o.distortionStrength>0&&f(o.boxSize,!0),f(o.boxSize,!1),this._vignette.draw(t,a)}}const ga=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_snowParticleData",components:4},{type:"Float32",name:"a_snowParticleDataHorizontalOscillation",components:2}]);class _a extends fa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,intensity:.85,timeFactor:.75,velocityConeAperture:70,velocity:40,horizontalOscillationRadius:4,horizontalOscillationRate:1.5,boxSize:2e3,billboardSize:2,shapeFadeStart:.27,shapeFadePower:.21,screenThinning:{intensity:.4,start:.15,range:1.4,fadePower:.24,affectedRatio:1,particleOffset:-.2},color:{r:1,g:1,b:1,a:1},direction:{x:-50,y:-35}},this._revealParams=new aa(e.tp,["Precipitation","Snow"]),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=da(this.particlesCount),n=new e.eN,r=new e.b0;let o=0;const s=e.eq(1323123451230);for(let e=0;es)return;const a=pa(0,1,o.revealStart,o.revealStart+o.revealRange,s);r.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),n=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,r.strength=1,r.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,u=c.gl,h=t.transform,d=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,d),((i,r,o)=>{const s=ha(this._movement.getPosition(),i),a=h.width/2,c=h.height/2,p=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),f=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),m=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),g=(_={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:i,billboardSize:1*o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[h.width,h.height],thinningCenterPos:[a,c],thinningShape:[p,f,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:m,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:n},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const A=Math.round(o.intensity*this.particlesCount),y=e.bf.simpleSegment(0,0,4*A,2*A);this.particlesVx&&this.particlesIdx&&d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,y)})(i.boxSize,0,i),this._vignette.draw(t,r)}}const Aa={symbol:function(t,i,n,r,o){if("translucent"!==t.renderPass)return;const s=Wi.disabled,a=t.colorModeForRenderPass(),l=n.layout.get("text-variable-anchor"),c=n.layout.get("text-size-scale-range"),u=e.aA(t.scaleFactor,c[0],c[1]);l&&function(t,i,n,r,o,s,a,l){const c=i.transform,u="map"===o,h="map"===s;for(const i of t){const t=r.getTile(i),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.bJ(o.textSizeData,c.zoom,l),d=Kt(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=ti(d,t.tileID.canonical,h,u,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();s&&Wo(o,u,h,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,m)}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o,u);const h=0!==n.paint.get("icon-opacity").constantOr(1),d=0!==n.paint.get("text-opacity").constantOr(1);void 0!==n.layout.get("symbol-sort-key").constantOr(1)&&(h||d)?qo(t,i,n,r,s,a):(h&&qo(t,i,n,r,s,a,{onlyIcons:!0}),d&&qo(t,i,n,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Ho(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Ho(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1),c=n.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=n.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,$i.ReadOnly),g=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D),_="none"===f||p?m:g,A=Wi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),v="globe"===d.projection.name,x=[e.aF(d.center.lng),e.aJ(d.center.lat)],b=[];for(let o=0;oe.sortKey-t.sortKey);const w={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of b){const{programConfiguration:i,program:r,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,p=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,w),t.uploadCommonUniforms(u,r,c.tileID.toUnwrapped()),r.draw(t,h.TRIANGLES,_,A,y,Xi.disabled,l,n.id,o,a,p,n.paint,d.zoom,i,s)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=Wi.disabled,l=new Qi([s.ONE,s.ONE,s.ONE,s.ONE],e.ao.transparent,[!0,!0,!0,!0]);!function(e,t,i,n){const r=e.gl,o=t.width*n,s=t.height*n;e.activeTexture.set(r.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=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,n,r,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,r,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(e,0,t,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,n,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.ao.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Xi.frontCCW:Xi.disabled,p=[e.aF(c.center.lng),e.aJ(c.center.lat)];for(let e=0;e({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,i),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))},line:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=n.paint.get("line-emissive-strength"),l=n.paint.get("line-occlusion-opacity"),c=n.layout.get("line-elevation-reference"),u="meters"===n.layout.get("line-width-unit"),h="sea"===c,d=!(!t.terrain||!t.terrain.enabled),p=t.context,f=p.gl;if(n.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const m=n.layout.get("line-cross-slope"),g=void 0!==m,_=m<1,A=t.colorModeForDrapableLayerRenderPass(a),y=t.terrain&&t.terrain.renderingToTexture,v=y?1:e.o.devicePixelRatio,x=n.paint.get("line-dasharray"),b=x.constantOr(1),w=n.layout.get("line-cap"),T=x.constantOr(null),E=w.constantOr(null),C=n.paint.get("line-pattern"),S=C.constantOr(1),B=n.paint.get("line-pattern-cross-fade"),I=C.constantOr(null),M=n.paint.get("line-opacity").constantOr(1);let P=!S&&1!==M||t.depthOcclusion&&l>0&&l<1;const R=n.paint.get("line-gradient"),L=S?"linePattern":"line",F=e.e1(n);let k;if(y&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&t.depthOcclusion){const t=n.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?k=t.value:e.w(`Occlusion opacity for layer ${n.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==s.value.kind&&!1===s.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH");const D=(r,o,s,a,c,d)=>{for(const m of r){const r=i.getTile(m);if(S&&!r.patternsLoaded())continue;const g=r.getBucket(n);if(!g)continue;if("none"!==g.elevationType&&!c||"none"===g.elevationType&&c)continue;t.prepareDrawTile();const _=[...o],x=t.shadowRenderer,w="road"===g.elevationType&&!!x&&x.enabled;let C=[0,0,0];if(w){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(C=mn(t.style,e,i)),_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const F=g.programConfigurations.get(n.id);let D=!1;if(I&&r.imageAtlas){const t=e.e2.from(I),i=t.getPrimary().scaleSelf(v).toString(),n=r.imageAtlas.patternPositions.get(i),o=t.getSecondary(),s=o?r.imageAtlas.patternPositions.get(o.scaleSelf(v).toString()):null;D=!!n&&!!s,n&&F.setConstantPatternPositions(n,s)}B>0&&(D||F.getPatternTransitionVertexBuffer("line-pattern"))&&_.push("LINE_PATTERN_TRANSITION");const O=t.isTileAffectedByFog(m),z=t.getOrCreateProgram(L,{config:F,defines:_,overrideFog:O});if(!S&&T&&E&&r.lineAtlas){const e=r.lineAtlas.getDash(T,E);e&&F.setConstantPatternPositions(e)}w&&x.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile");let[U,N]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;U!==N&&(0===U&&(U-=e),1===N&&(N+=e))}const V=y?m.projMatrix:null,j=u?1/g.tileToMeter/e.ay(r,1,t.transform.zoom):1,G=u?1/g.tileToMeter/e.ay(r,1,Math.floor(t.transform.zoom)):1,H=S?e.e3(t,r,n,V,v,j,G,[U,N],C,B):e.e4(t,r,n,V,g.lineClipsArray.length,v,j,G,[U,N],C);if(R){const r=g.gradients[n.id];let o=r.texture;if(n.gradientVersion!==r.version){let s=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=m.canonical.z===n?Math.ceil(1<{null!=k&&(k.value=M*l),z.draw(t,f.TRIANGLES,s,e,A,Xi.disabled,H,n.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,n.paint,t.transform.zoom,F,[g.layoutVertexBuffer2,g.patternVertexBuffer,g.zOffsetVertexBuffer]),null!=k&&(k.value=M)};if(P&&!c){const e=t.stencilModeForClipping(m).ref;0===e&&y&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};H.u_alpha_discard_threshold=.8,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.INVERT)),H.u_alpha_discard_threshold=0,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.KEEP))}else H.u_alpha_discard_threshold=P&&c&&d?.8:0,Q(c?a:t.stencilModeForClipping(m))}};let O=t.depthModeForSublayer(0,$i.ReadOnly);const z=new $i(t.depthOcclusion?f.GREATER:f.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);if(n.hasNonElevatedBuckets){const i=!y&&t.terrain;0!==l&&i?e.w(`Occlusion opacity for layer ${n.id} is supported on terrain only if the layer has line-z-offset enabled.`):i?e.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${n.id}.`):D(r,F,O,Wi.disabled,!1,!0)}if(n.hasElevatedBuckets){"hd-road-markup"===c?d||(O=z,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),O=z,g&&F.push(_?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),h&&F.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Wi.disabled;t.forceTerrainMode=!0,D(r,F,O,e,!0,!0),P&&D(r,F,O,e,!0,!1),t.forceTerrainMode=!1}P&&(t.resetStencilClippingMasks(),y&&p.clear({stencil:0})),0===l||t.depthOcclusion||y||t.layersWithOcclusionOpacity.push(t.currentLayer)},fill:function(t,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=n.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.ao.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let h="none";"none"!==n.layout.get("fill-elevation-reference")?h="road":0!==n.paint.get("fill-z-offset").constantOr(1)&&(h="offset");const d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:n,coords:r,colorMode:l,elevationType:h,terrainEnabled:d,pass:u};if("shadow"!==t.renderPass)if("offset"!==h){if(Yo(p,!1),"road"===h){const e=!d&&"translucent"===t.renderPass;e&&Jo(t,i,n,r,"geometry"),Yo(p,!0,Wi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r,colorMode:o}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=mn(t.style,e,i))}const h=e=>{for(const h of r){const r=i.getTile(h),d=r.getBucket(n);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(n.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(n.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const g=t.isTileAffectedByFog(h),_=[];l&&_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const A=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:g,defines:_}),y=t.translatePosMatrix(h.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),A,"vector-tile");const v=po(y,u);t.uploadCommonUniforms(t.context,A,h.toUnwrapped()),A.draw(t,s.TRIANGLES,c,Wi.disabled,o,Xi.backCCW,v,n.id,p.vertexBuffer,p.indexBuffer,f,n.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(p)}}else Yo(p,!1,t.stencilModeFor3D());else t.shadowRenderer&&"road"===h&&!d&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r}=e,o=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(n);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(n.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p={u_matrix:d,u_depth_bias:0};h.draw(t,o.TRIANGLES,s.getShadowPassDepthMode(),Wi.disabled,s.getShadowPassColorMode(),Xi.disabled,p,n.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,n.paint,t.transform.zoom,c)}}(p)},"fill-extrusion":function(t,i,n,r){const o=n.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.style.isLayerClipped(n,i.getSource()),h=t.style.order.indexOf(n.fqid);if(u&&function(e,t,i,n,r){for(const o of n){const n=t.getTile(o).getBucket(i);n&&(n.updateReplacement(o,e.replacementSource,r),n.uploadCentroid(e.context))}}(t,i,n,r,h),l||u)for(const e of r){const r=i.getTile(e).getBucket(n);r&&ns(t.context,i,e,r,n,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ad)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();es(t,i,n,r,a,Wi.disabled,c,u)}else if("translucent"===t.renderPass){const h=!n.paint.get("fill-extrusion-pattern").constantOr(1),d=n.paint.get("fill-extrusion-color").constantOr(e.ao.white);if(!c&&0!==d.a){const e=new $i(t.context.gl.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);1===o&&h?es(t,i,n,r,e,Wi.disabled,Qi.unblended,u):(es(t,i,n,r,e,Wi.disabled,Qi.disabled,u),es(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=n.paint.get("fill-extrusion-opacity"),h=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=n.paint.get("fill-extrusion-flood-light-intensity"),f="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:n.lut).toArray01().slice(0,3),g=h>0&&d>0,_=p>0,A=(e,t,i)=>(1-i)*e+i*t,y=new ts;y.translate=n.paint.get("fill-extrusion-translate"),y.translateAnchor=n.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=n.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=n.paint.get("fill-extrusion-cutoff-fade-range");const v=s=>{const l=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!0),c=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=A(.1,3,c),g=t._showOverdrawInspector;if(!g){const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,l,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,f,u,!1)}{const c=g?Wi.disabled:new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=g?t.colorModeForRenderPass():new Qi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,l,c,_,Xi.disabled,s,"color",o,h,d,p,m,f,u,!1)}};if(c){const c=(s,l,c)=>{const f=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!1),g=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=A(.1,3,g);{const c=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0]);is(y,t,i,n,r,f,Wi.disabled,c,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l)}{const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,f,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,g=new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),A=new Qi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,f,g,A,Xi.disabled,s,"color",o,h,d,p,m,_,u,l)}{const g=new Qi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.ao.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);is(y,t,i,n,r,f,Wi.disabled,g,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l,c)}};if(g||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],n=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===n)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.q({width:t,height:n}),a.RGBA8)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,n)}g&&c(!0,!1,i),_&&c(!1,!0,i)}}else g&&v(!0),_&&v(!1),(g||_)&&t.resetStencilClippingMasks()}}},building:function(e,t,i,n){e.currentLayer0&&o>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;(!e.shadowRenderer||u<1)&&(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,n,r,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(r&&o.updateReplacement(s,e.replacementSource,n),o.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,n),function(e,t,i,n){for(const r of n){const n=t.getTile(r).getBucket(i);n&&n.needsEvaluation()&&n.uploadUpdatedColorBuffer(e.context)}}(e,t,i,n),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=e.shadowRenderer,o=[],s=r.getShadowPassDepthMode();ls({painter:e,source:t,layer:i,coords:n,defines:o,blendMode:r.getShadowPassColorMode(),depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),g="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),_=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:i.lut).toArray01().slice(0,3),A=i.paint.get("building-flood-light-ground-attenuation"),y=m>0,v=new $i(e.context.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D);a<1&&ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:Qi.disabled,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_,depthOnly:!0});const x=e.colorModeForRenderPass();ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:x,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_}),l&&cs(e,t,i,n,!0,a,r,o,m,_,s,h),y&&cs(e,t,i,n,!1,a,r,o,m,_,A,h)}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],o=new $i(e.context.gl.LEQUAL,$i.ReadOnly,e.depthRangeFor3D);ls({painter:e,source:t,layer:i,coords:n,defines:r,blendMode:Qi.alphaBlended,depthMode:o,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},hillshade:function(e,t,i,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},n]:e.stencilConfigForOverlap(n);for(const n of a){const r=t.getTile(n);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)er(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,$i.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):s[n.overscaledZ];Jn(e,n,r,i,t,c,l)}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,n,r,o,s){if("translucent"!==t.renderPass)return;if(0===n.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==n.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=i.getSource(),p=function(t,i,n,r){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let u=i.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?r.NEAREST:r.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=r.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),n.activeTexture.set(r.TEXTURE2),i.updateColorRamp(u);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(n,i.colorRamp,r.RGBA8)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,n,u,h);if(d instanceof e.aT&&!r.length&&!a)return;const f=n.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),g=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,A="nearest"===n.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.aT&&!r.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Wi.disabled;return void hs(!!d.onNorthPole,null,t,i,n,f,p,Xi.disabled,e)}if(!r.length)return;const[y,v]=d instanceof e.aT||g?[{},r]:t.stencilConfigForOverlap(r),x=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(r,o,v)=>{for(const b of r){const r=b.toUnwrapped(),w=i.getTile(b);if(g&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const T=ps(w,d,n,p);if(!T||!T.texture)continue;const{texture:E,mix:C,offset:S,tileSize:B,buffer:I}=T;let M,P;g?(M=$i.disabled,P=b.projMatrix):l?(M=new $i(h.LEQUAL,$i.ReadWrite,t.depthRangeFor3D),P=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,_)):(M=t.depthModeForSublayer(b.overscaledZ-x,1===n.paint.get("raster-opacity")?$i.ReadWrite:$i.ReadOnly,h.LESS),P=t.transform.calculateProjMatrix(r,_));const R=t.terrain&&g?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:n.paint.get("raster-fade-duration");w.registerFadeDuration(L);const F=i.findLoadedParent(b,0),k=$r(w,F,i,t.transform,L);let D,O;!k.isFading&&w.refreshedUponExpiration&&(w.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),E.bind(A,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),F?(F.texture&&F.texture.bind(A,h.CLAMP_TO_EDGE),D=Math.pow(2,F.tileID.overscaledZ-w.tileID.overscaledZ),O=[w.tileID.canonical.x*D%1,w.tileID.canonical.y*D%1]):E.bind(A,h.CLAMP_TO_EDGE),"useMipmap"in E&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const z=t.transform;let U;const N=l?ds(z):[0,0,0,0];let V,j,G,H,Q,$=0;if(c&&d instanceof e.aT&&d.coordinates.length>3)V=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0)))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=d.elevatedGlobePerspectiveTransform,Q=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.dF(b.canonical);$=e.dG(t.getCenter().lat),V=Float32Array.from(e.bj(e.dI(b.canonical))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=[0,0],Q=Float32Array.from(e.dH(b.canonical,t,$,z.worldSize/z._pixelsPerMercatorPixel))}else U=d instanceof e.aT?d.perspectiveTransform:[0,0],V=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),H=[0,0],Q=new Float32Array(9);const Z=To(P,V,j,G,Q,O||[0,0],e.aj(t.transform.zoom),H,N,D||1,k,n,U,l?n.paint.get("raster-elevation"):0,2,C,S,p.range,B,I,f),W=t.isTileAffectedByFog(b),q=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:W});if(t.uploadCommonUniforms(u,q,r),d instanceof e.aT){const i=d.elevatedGlobeVertexBuffer,r=d.elevatedGlobeIndexBuffer;if(g||!a)d.boundsBuffer&&d.boundsSegments&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,Xi.disabled,Z,n.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&r){const s=z.zoom<=e.cZ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(z.center.lng);s&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,o,Z,n.id,i,r,s)}}else if(c){M=new $i(h.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,r,s]=e.getGridBuffers($,!1);q.draw(t,h.TRIANGLES,M,v||R,t.colorModeForRenderPass(),o,Z,n.id,i,r,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(w);q.draw(t,h.TRIANGLES,M,R,m,Xi.disabled,Z,n.id,e,i,r)}}if(!(d instanceof e.aT)&&c)for(const e of r){const r=e.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},r=1/1.1;for(let e=0;ee.e8[t](r));f.push(r);const m=r.canonical.x,g=r.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<e.tileID)),f&&(u.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,n.scope)),c){const i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0}),r=new Float32Array(e.bz([])),u=new e.aP(0,0,0,0,0),d=f?Lo(r,l,a,t,0,n.scope,m,c,{tileID:u,tileSize:p}):Ro(r,l,a,o.toPremultipliedRenderColor(s?null:n.lut));i.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,d,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}else for(const e of b){const g=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(v,{overrideFog:g}),w=e.toUnwrapped(),T=r?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):x?x[e.key]:new It(e,p,d.zoom,t),C=f?Lo(T,l,a,t,0,n.scope,m,c,{tileID:e,tileSize:p}):Ro(T,l,a,o.toPremultipliedRenderColor(s?null:n.lut));t.uploadCommonUniforms(u,b,w);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:B,tileBoundsSegments:I}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,C,n.id,S,B,I)}},sky:function(t,i,n){const r=t._atmosphere?e.aj(t.transform.zoom):1,o=n.paint.get("sky-opacity")*r;if(0===o)return;const s=t.context,a=n.paint.get("sky-type"),l=new $i(s.gl.LEQUAL,$i.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i){const n=t.context,r=n.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=n.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ps(n),i.skyboxTexture=n.gl.createTexture(),r.bindTexture(r.TEXTURE_CUBE_MAP,i.skyboxTexture),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,r.LINEAR);for(let e=0;e<6;++e)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,r.RGBA,32,32,0,r.RGBA,r.UNSIGNED_BYTE,null)}n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.bz(l),e.em(l,l,.5*-Math.PI),Rs(t,i,a,l,s,0),e.bz(l),e.em(l,l,.5*Math.PI),Rs(t,i,a,l,s,1),e.bz(l),e.cT(l,l,.5*-Math.PI),Rs(t,i,a,l,s,2),e.bz(l),e.cT(l,l,.5*Math.PI),Rs(t,i,a,l,s,3),e.bz(l),Rs(t,i,a,l,s,4),e.bz(l),e.em(l,l,Math.PI),Rs(t,i,a,l,s,5),n.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,n,r){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,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,n,r);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Wi.disabled,e.colorModeForRenderPass(),Xi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,n,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ps(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.an(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,n,Wi.disabled,t.colorModeForRenderPass(),Xi.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,l,o,c)},custom:function(t,i,n,r){const o=t.context,s=n.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&n.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const n=t.transform.pointMerc;i.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.aj(t.transform.zoom),[n.x,n.y],t.transform.pixelsPerMeterRatio)}else i.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,n={x:i.x+r[0].wrap*(s.wrapTileId?0:1<{u&&(u.useNormalOffset=!0,h||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,n,r,o){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;n.modelManager=c;const u=t.shadowRenderer;if(!n._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=n._unevaluatedLayout._values["model-id"],d=Object.assign({},n.layout.get("model-id").parameters),p=t.style.order.indexOf(n.fqid);for(const f of r){const r=i.getTile(f).getBucket(n);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,o),r.modelsRequested=!0),a)d.zoom=f.overscaledZ;else{const e=Ks(f,s);d.zoom=e}const g=h.possiblyEvaluate(d);if(Ws(t,r,f),qs.shadowUniformsInitialized=!1,qs.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(qs.tileMatrix.set(i),qs.shadowTileMatrix=Float32Array.from(u.calculateShadowPassMatrixFromMatrix(i)),qs.aabb.min=[0,0,0],qs.aabb.max[0]=qs.aabb.max[1]=e.al,qs.aabb.max[2]=0,Ys(r,qs,t,n.scope))continue}const _=1<0&&t.style.isLayerClipped(n,i.getSource())&&r.updateReplacement(f,t.replacementSource,p,o)&&(r.uploaded=!1,r.upload(t.context));let y=0;const v=new Array,x=new Array,b=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const u=c.getModel(i,o);if(u||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),u&&u.uploaded)if(a){const i=e.c4([],[l.x,l.y,l.z],t.transform.worldSize);e.ev(i,i);for(let n=0;n0&&n.elevationUpdate(e.terrain,r,s,i.source),n.needsReEvaluation(e,o,i)&&n.evaluate(i))}})(t,i,n,r),function(){let c,h,E;b?(c=r.length-1,h=-1,E=-1):(c=0,h=r.length,E=1);const C=new Float64Array(16),S=e.cz(),B=new e.P(0,0);for(let I=c;I!==h;I+=E){const c=r[I],h=i.getTile(c).getBucket(n);if(!h||!h.uploaded)continue;let E=!1;l&&(E=0===l.getMaxCascadeForTile(c.toUnwrapped()));const M=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),P=h.modelTraits;!y&&b&&(e.bk(C,M),e.af(S,u,C),B.x=S[0],B.y=S[1]);const R=[];h.setFilter(n.filter);for(const i of h.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const n=i.node;let r=0;t.terrain&&n.elevation&&(r=n.elevation*t.terrain.exaggeration());const o=(()=>{const t=i.aabb;return A.min=[...t.min],A.max=[...t.max],A.min[2]+=r,A.max[2]+=r,e.af(A.min,A.min,M),e.af(A.max,A.max,M),A})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===o.intersects(v))continue;if(!y&&b){const t=1/6;i.cameraCollisionOpacity=u[0]>o.min[0]&&u[0]o.min[1]&&u[1]!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of R){const r=i.nodeInfo,c=r.node;let u=e.aB([],f,i.tileModelMatrix);e.aB(u,d,u);const h=e.bk([],u);e.ef(h,h),e.cR(h,h,Js),u=e.aB(u,u,c.globalMatrix);const p="light-beam"===t.renderPass,m="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=P&e.eH.HasMapboxMeshFeatures,v=A?0:r.evaluatedRMEA[0][2];for(let e=0;e=Ve||r>=Ve}}const S=d.material;let B;S.occlusionTexture&&S.occlusionTexture.offsetScale&&(B=S.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const I=t.getOrCreateProgram("model",b);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,I,l.useNormalOffset),t.uploadCommonUniforms(o,I,null,C);const M=S.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const P=ko(new Float32Array(x),new Float32Array(u),new Float32Array(h),new Float32Array(c.globalMatrix),t,i.opacity,M.baseColorFactor,S.emissiveFactor,M.metallicFactor,M.roughnessFactor,S,v,n,[0,0,0],B);!f&&(r.hasTranslucentParts||i.opacity<1)&&I.draw(t,o.gl.TRIANGLES,g,Wi.disabled,Qi.disabled,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w),I.draw(t,o.gl.TRIANGLES,f?_:g,Wi.disabled,f||i.opacity<1||r.hasTranslucentParts?Qi.alphaBlended:Qi.unblended,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w)}}}}()}(t,i,n,r),void d();if("model"!==p.type)return;const f=p.getModels(),m=[],g=t.transform.getFreeCameraOptions().position,_=e.c4([],[g.x,g.y,g.z],t.transform.worldSize);e.ev(_,_);const A=[],y=[];let v=0;for(const r of f){const o=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=n.paint.get("model-rotation").evaluate(s,o),u=n.paint.get("model-scale").evaluate(s,o),h=n.paint.get("model-translation").evaluate(s,o);Qs(n,r.id,o,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),$s(n,r.id,o,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,u,h,l,a,!1);const d=e.bz([]),p=e.ee(r.position.lat,t.transform.zoom),f=e.bp([],[1,1,1/p]);e.bq(d,d,_),m.push({zScaleMatrix:f,negCameraPosMatrix:d});for(const e of r.nodes)Gs(t,e,r.matrix,t.transform.expandedFarZProjMatrix,v,A,y,r.materialOverrides);v++}if(A.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass)Zs(t,n,o,A,y,m),d();else{for(const e of y)Hs(e.mesh,e.nodeModelMatrix,t,n);for(const e of A)Hs(e.mesh,e.nodeModelMatrix,t,n);d()}}},ya={line:function(e,t,i){if(e.hasElevatedBuckets=!1,e.hasNonElevatedBuckets=!1,void 0!==e._unevaluatedLayout.getValue("line-elevation-reference")||void 0!==e._unevaluatedLayout.getValue("line-z-offset")){if(t){const i=t.getVisibleCoordinates();for(const n of i){const i=t.getTile(n).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0},model:function(e,t,i){const n=t.getSource();if(!n.loaded())return;if("vector"===n.type||"geojson"===n.type){const t=js(n,e,i.style._importedAsBasemap);return void(i.modelManager&&i.modelManager.upload(i,t))}if("batched-model"===n.type)return;if("model"!==n.type)return;const r=n.getModels();for(const e of r)e.upload(i.context)},raster:function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)},"raster-particle":function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-particle-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)}},va={fill:Jo},xa={fill:function(e,t,i,n){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,o=new $i(r.LEQUAL,$i.ReadOnly,e.depthRangeFor3D),s=new Wi({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of n){const n=t.getTile(c),u=n.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||0===h.depthSegments.segments[0].primitiveLength)continue;const d=Xo(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=fo(p,d,0,1,0);l.draw(e,r.TRIANGLES,o,s,Qi.disabled,Xi.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class ba{constructor(t,i,n,r,o,s){this.context=new jo(t,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of a)this._debugParams.enabledLayers[e]=!0;o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of a)o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new ra(o),this.setup(),this.numSublayers=Lt.maxUnderzooming+Lt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eO,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new dn(this),this._wireframeDebugCache=new na,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const l=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,l,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.worldview=s}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 Kr(this,e));const n=this._terrain;this.transform.elevation=i?n:null,n.update(e,this.transform,t),this.transform.elevation&&!n.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,n]=t.getFovAdjustedRange(this.transform._fov);if(i>n)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled||this._forceTerrainMode?this._terrain:null}get forceTerrainMode(){return this._forceTerrainMode}set forceTerrainMode(e){e&&!this._terrain&&(this._terrain=new Kr(this,this.style)),this._forceTerrainMode=e}get shadowRenderer(){return this._shadowRenderer&&this._shadowRenderer.enabled?this._shadowRenderer:null}get wireframeDebugCache(){return this._wireframeDebugCache}resize(t,i){if(this.width=t*e.o.devicePixelRatio,this.height=i*e.o.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 t=this.context,i=new e.bc;i.emplaceBack(0,0),i.emplaceBack(e.al,0),i.emplaceBack(0,e.al),i.emplaceBack(e.al,e.al),this.tileExtentBuffer=t.createVertexBuffer(i,e.be.members),this.tileExtentSegments=e.bf.simpleSegment(0,0,4,2);const n=new e.bc;n.emplaceBack(0,0),n.emplaceBack(e.al,0),n.emplaceBack(0,e.al),n.emplaceBack(e.al,e.al),this.debugBuffer=t.createVertexBuffer(n,e.be.members),this.debugSegments=e.bf.simpleSegment(0,0,4,5);const r=new e.bc;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.be.members),this.viewportSegments=e.bf.simpleSegment(0,0,4,2);const o=new e.a$;o.emplaceBack(0,0,0,0),o.emplaceBack(e.al,0,e.al,0),o.emplaceBack(0,e.al,0,e.al),o.emplaceBack(e.al,e.al,e.al,e.al),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.bh.members),this.mercatorBoundsSegments=e.bf.simpleSegment(0,0,4,2);const s=new e.b0;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.bd;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.T(t,new e.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bB();const l=this.context.gl;this.stencilClearMode=new Wi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(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,$i.disabled,this.stencilClearMode,Qi.disabled,Xi.disabled,Qr(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 n=this.context,r=n.gl;this.nextStencilID+i.length>256&&this.clearStencil(),n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),n=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},n,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(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 Wi({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 Wi({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),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Qi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ao(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,n=!1){if(this.depthOcclusion)return new $i(this.context.gl.GREATER,$i.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!n)return $i.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new $i(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((e,t)=>e+t/this._fpsHistory.length,0))}render(t,i){const n=e.o.now();this._dt=n-this._timeStamp,this._timeStamp=n,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,o=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(o).filter(e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=s(),l=!1,c=!1,u=null;for(const e of a){const t=r[e];"circle"===t.type?l=!0:"building"===t.type?u=t:"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0)}let h=a.map(e=>r[e]);const d=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();let p=0,f=!1;for(const e in d){const t=d[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++p)}let m=!1;for(const e of h)e.isHidden(this.transform.zoom)||("clip"===e.type&&(m=!0),this.prepareLayer(e));const g={},_={},A={},y={},v={};for(const e in d){const t=d[e];g[e]=t.getVisibleCoordinates(),_[e]=g[e].slice().reverse(),A[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(g[e])}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(p||m||this._clippingActiveLastFrame){const t=[],i=[];let n=0;for(const e of h)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(n)),n++;if(t&&(m||t.length>1)||this._clippingActiveLastFrame){m=!1;const n=[];for(let r=0;r0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D(o)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(A),this.opaquePassCutoff=0,a=s(),h=a.map(e=>r[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in d)for(const t of g[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),w.addShadowReceiver(t.toUnwrapped(),e.min,e.max)}}"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.eQ(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Os(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const T=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(T&&!this._snow&&(this._snow=new _a(this)),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&(this._rain=new ma(this)),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),u){this.buildingTileBorderManager||(this.buildingTileBorderManager=new zs);const e=this.style.getLayerSourceCache(u);this.buildingTileBorderManager.updateBorders(e,u)}if(!j.has(this.context.gl))return;this.renderPass="offscreen";for(const e of h){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const n=i?_[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||n&&n.length)&&this.renderLayer(this,i,e,n)}this.depthRangeFor3D=[0,1-(h.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass="shadow",this._shadowRenderer.drawShadowPass(this.style,y)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const C="globe"===this.transform.projection.name||this.transform.isHorizonVisible(),S=(()=>{if(i.showOverdrawInspector)return e.ao.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const n="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}if(C){const n="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}}return e.ao.transparent})();if(this.context.clear({color:S,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=h[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const n=i?(e.is3D(o)?v:_)[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&C&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass="sky",(!this._atmosphere||e.aj(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--I){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const e=this.currentLayer;this.depthOcclusion=!0;for(const e of this.layersWithOcclusionOpacity){this.currentLayer=e;const i=h[this.currentLayer],n=t.getLayerSourceCache(i),r=n?_[n.id]:void 0;this.terrain||this._renderTileClippingMasks(i,n,n?g[n.id]:void 0),this.renderLayer(this,n,i,r)}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass="translucent",this.layersWithOcclusionOpacity=[]}++this.currentLayer}}if(this.terrain&&this.terrain.postRender(),this._snow&&this._snow.draw(this),this._rain&&this._rain.draw(this),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;h.forEach(e=>{const n=t.getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&n.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const n=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,r=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(r.push("LIGHTING_3D_MODE"),r.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):n||r.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||r.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(r.push("TERRAIN"),this.linearFloatFilteringSupported()&&r.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&r.push("GLOBE"),!this._fogVisible||n||void 0!==t&&!t||r.push("FOG","FOG_DITHERING"),n&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],n=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=eo.cacheKey(Zn[e],e,r,n);return this.cache[o]||(this.cache[o]=new eo(this.context,e,Zn[e],n,Oo[e],r)),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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA8))}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(),this.depthFBO&&(this.depthFBO.destroy(),this.depthFBO=void 0,this.depthTexture=void 0),this.emptyDepthTexture&&this.emptyDepthTexture.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const o=((t,i,n)=>{const r=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:n.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:n.getLut(i.scope)).toArray01(),u=i.properties.get("intensity"),h=[r.x,r.y,r.z],d=e.dM(c,u),p=e.dM(s,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:h,u_lighting_directional_color:p,u_ground_radiance:Xr(h,p,d)}})(n,r,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,n,r,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=t.transform,f="none"===i.properties.get("color-use-theme"),m=i.properties.get("color").toNonPremultipliedRenderColor(f?null:t.style.getLut(i.scope)).toArray01();m[3]=r;const g=t.frameCounter/1e3%1,[_,A]=i.properties.get("vertical-range");return{u_fog_matrix:n?p.calculateFogTileMatrix(n):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,A),A],u_fog_temporal_offset:g,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.aj(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,n,o,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*e.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],r);i.setFogUniformValues(t,a)}o&&i.setCutoffUniformValues(t,o.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 n of i)t[n.key]=e[n.key]||new It(n,512,this.transform.tileZoom,this,void 0,this.worldview);return t}clearBackgroundTiles(){this._backgroundTiles={}}isSourceForClippingOrConflation(e,t){return!(!e.is3D(!(!this.terrain||!this.terrain.enabled))||"clip"!==e.type&&"building"!==e.type&&(e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerPresent||"building"!==e.sourceLayer&&"procedural_buildings"!==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]>=Ve||t[1]>=Ve}setupDepthForOcclusion(e,t,i){const n=this.context,r=n.gl,o=!!i;var s;i||(i={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_depth_range_unpack:[0,1],u_occluder_half_size:16,u_occlusion_depth_offset:-1e-4,u_exaggeration:0}),n.activeTexture.set(r.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(r.NEAREST,r.CLAMP_TO_EDGE),n.activeTexture.set(r.TEXTURE0),o||t.setTerrainUniformValues(n,i)}}function wa(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}class Ta{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aX(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=wa(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const t=Ea(e);if(this._hashName){const e=this._hashName;let i=!1;const n=location.hash.slice(1).split("&").map(n=>{const r=n.split("=")[0];return r===e?(i=!0,`${r}=${t}`):n}).filter(e=>e);return i||n.push(`${e}=${t}`),`#${n.join("&")}`}return`#${t}`}_getCurrentHash(){const e=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(Number(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(){history.replaceState(history.state,"",location.href.replace(/(#.+)?$/,this.getHashString()))}}function Ea(e,t){const i=e.getCenter(),n=Math.round(100*e.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${n}`:`${n}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Ca={linearity:.3,easing:e.eS(0,0,.3,1)},Sa=Object.assign({deceleration:2500,maxSpeed:1400},Ca),Ba=Object.assign({deceleration:20,maxSpeed:1400},Ca),Ia=Object.assign({deceleration:1e3,maxSpeed:360},Ca),Ma=Object.assign({deceleration:1e3,maxSpeed:90},Ca);class Pa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=La(i.pan.mag(),n,Object.assign({},Sa,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Ra(r,e)}if(i.zoom){const e=La(i.zoom,n,Ba);r.zoom=this._map.transform.zoom+e.amount,Ra(r,e)}if(i.bearing){const t=La(i.bearing,n,Ia);r.bearing=this._map.transform.bearing+e.aA(t.amount,-179,179),Ra(r,t)}if(i.pitch){const e=La(i.pitch,n,Ma);r.pitch=this._map.transform.pitch+e.amount,Ra(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function Ra(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class Da extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class Oa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new Da(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Fa(e.type,this._map,e))}mouseup(e){this._map.fire(new Fa(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Fa(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Fa(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new Fa(e.type,this._map,e))}mouseover(e){this._map.fire(new Fa(e.type,this._map,e))}mouseout(e){this._map.fire(new Fa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ka(e.type,this._map,e))}touchmove(e){this._map.fire(new ka(e.type,this._map,e))}touchend(e){this._map.fire(new ka(e.type,this._map,e))}touchcancel(e){this._map.fire(new ka(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class za{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new Fa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Fa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Fa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ua{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&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,n=this._startPos,r=this._lastPos;if(!n||!r||r.equals(i)||!this._box&&i.dist(n){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=c-a+"px")})}mouseupWindow(t,i){if(!this._active)return;const n=this._startPos,r=i;if(n&&0===t.button){if(this.reset(),g(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}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),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function Na(e,t){const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=Na(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=Na(i,t);for(const e in this.touches){const t=n[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 ja{constructor(e){this.singleTap=new Va(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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class Ga{constructor(){this._zoomIn=new ja({numTouches:1,numTaps:2}),this._zoomOut=new ja({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return 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})}):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})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ha={0:1,2:2},Qa={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class $a{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=y(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=Ha[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=Na(n,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Xa{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 n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,o]=n,s=Ja(i,t,r),a=Ja(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[n,r]=this._firstTwoTouches,o=Ja(i,t,n),s=Ja(i,t,r);o&&s||(this._active&&g(),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 Ja(e,t,i){for(let n=0;nMath.abs(e.x)}class rl extends Xa{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,nl(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,n){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.eT()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return nl(e)&&nl(t)&&o}}const ol={panStep:100,bearingStep:15,pitchStep:10};class sl{constructor(){const e=ol;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,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*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 al(e){return e*(2-e)}const ll=4.000244140625,cl=1/450;class ul{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=cl,e.aX(["_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(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.eT()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const n=e.o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%ll==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,this._active||this._start(t)),t.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=_(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 t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>ll?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.ak(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=n,a=!0;this._active=!0,a&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let l=s-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!a,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.eU;if(this._prevEase){const t=this._prevEase,n=(e.o.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.eS(o,s,.25,1)}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(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=window.setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.removeAttribute("role")},200)}}class hl{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 dl{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 pl{constructor(){this._tap=new ja({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 n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/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 fl{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 ml{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 gl{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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 _l=e=>e.zoom||e.drag||e.pitch||e.rotate;class Al extends e.z{}class yl{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.av([],i,t);this.radius=e.ag(n[2]<0?e.eW([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.eW(t,t,this.constants),e.aw(t,t),e.eX(t,t,this.constants);const i=e.c4([],t,this.radius);if(i[2]>0){const t=e.c4([],[0,0,1],e.bI(i,[0,0,1])),n=e.c4([],e.aw([],[i[0],i[1],0]),this.radius),r=e.d7([],i,e.c4([],e.av([],e.d7([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function vl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class xl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new yl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aX(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,n,i)}}destroy(){for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,n,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Oa(t,e));const n=t.boxZoom=new Ua(t,e);this._add("boxZoom",n);const r=new Ga,o=new dl;t.doubleClickZoom=new hl(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new pl;this._add("tapDragZoom",s);const a=t.touchPitch=new rl(t);this._add("touchPitch",a);const l=new Wa(e),c=new qa(e);t.dragRotate=new ml(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new Za(e),h=new Ka(t,e);t.dragPan=new fl(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new il,p=new el;t.touchZoomRotate=new gl(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new za(t));const f=t.scrollZoom=new ul(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new sl;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!!_l(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<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,n=i?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?A(this._el,a):i?void 0:_(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=n);this._previousActiveHandlers=s,(Object.keys(c).length||vl(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||vl(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,n,r){if(!i)return;Object.assign(e,i);const o={handlerName:n,originalEvent:i.originalEvent||r};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 t={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.aroundCoord&&(t.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),Object.assign(i,o),Object.assign(n,s);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,o=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!vl(t)){const e=o.zoom;o.cameraElevationReference="sea",null!=this._originalZoom&&o._orthographicProjectionAtLowPitch&&"globe"!==o.projection.name&&0===o.pitch?(o.cameraElevationReference="ground",o.zoom=this._originalZoom):(o.recenterOnTerrain(),o.cameraElevationReference="ground"),e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&r._stop(!0),!vl(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.eV(e.a_(t.y))*i,f[1]=-a.y*e.eV(o.center.lat)*i}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),i={dir:e.aw([],e.av([],t,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(t,l);e.c4(g,i.dir,n)}}const _=e.d7(f,f,g);o._translateCameraConstrained(_),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,n,!0)}_fireEvents(t,i,n){const r=_l(this._eventsInProgress),o=_l(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=_l(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Al("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const bl="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class wl extends e.E{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,e.aX(["_renderFrameCallback"],this)}getCenter(){return new e.aS(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),n)}panTo(e,t,i){return this.easeTo(Object.assign({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(Object.assign({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(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):n/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,n,r,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.eY(h,d),f=e.aw([],p),m=e.aw([],e.bH([],f,[0,1,0])),g=e.bH([],m,f),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],A=[p,e.eY(c.lat,c.lng),e.eY(u.lat,c.lng),e.eY(u.lat,u.lng),e.eY(c.lat,u.lng),e.eY(h,c.lng),e.eY(h,u.lng),e.eY(c.lat,d),e.eY(u.lat,d)];let y=e.d8.fromPoints(A.map(t=>[e.bI(m,t),e.bI(g,t),e.bI(f,t)]));const v=e.af([],y.center,_);0===e.eZ(v)&&e.e_(v,0,0,1),e.aw(v,v),e.c4(v,v,e.aD),a.center=e.e$(v);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);y=e.d8.applyTransform(y,e.aB([],x,_));const w=this._extendAABB(y,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.af(v,v,x);const T=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(a,y),C=e.c4([],[0,0,1],T),S=e.d7(C,v,C),B=E+(0===a.pitch?0:e.bF(v,S)),I=a.globeCenterInViewSpace,M=e.av([],v,[I[0],I[1],I[2]]);e.aw(M,M),e.c4(M,M,B);const P=e.d7([],v,M);e.af(P,P,b);const R=e.eL/e.aD,L=e.ag(P),F=e.ce(Math.max(L*R-e.eL,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(F),l.maxZoom);return k>.5*(e.cZ+e.cK)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,n,r,o,s)):{center:a.center,zoom:k,bearing:r,pitch:o}}_extendAABB(t,i,n,r){const o=.5*((n.padding.left||0)+(n.padding.right||0)),s=.5*((n.padding.top||0)+(n.padding.bottom||0)),a=s,l=o,c=o,u=s,h=i.width-(l+c),d=i.height-(a+u),p=e.av([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),n.maxZoom);if(isNaN(m))return null;const g=i.scale/i.zoomScale(m),_=new e.d8([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+a*g,t.max[2]]),A=("number"==typeof n.offset.x&&"number"==typeof n.offset.y?new e.P(n.offset.x,n.offset.y):e.P.convert(n.offset)).rotate(-e.an(r));return _.center[0]-=A.x*g,_.center[1]+=A.y*g,_}queryTerrainElevation(t,i){const n=this.transform.elevation;return n?(i=Object.assign({},{exaggerated:!0},i),n.getAtPoint(e.ae.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,n,r,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,n,r,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=new e.aS(c.lng,u.lat),d=new e.aS(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),A=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,g||0,_||0,A||0)],[f.x,f.y,Math.max(m||0,g||0,_||0,A||0)]];let v=e.d8.fromPoints(y);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);v=e.d8.applyTransform(v,x);const w=this._extendAABB(v,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=w;const T=.5*e.av([],v.max,v.min)[2],E=this._minimumAABBFrustumDistance(a,v),C=[0,0,1,0];e.aC(C,C,x),e.f0(C,C);const S=e.c4([],C,E+T),B=e.d7([],v.center,S);e.af(v.center,v.center,b),e.af(B,B,b);const I=a.unproject(new e.P(v.center[0],v.center[1])),M=e.f1(a.projection,I),P=Math.pow(2,M),R=Math.min(a._zoomFromMercatorZ(B[2]*a.pixelsPerMeter*P/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&R<.5*(e.cZ+e.cK)?(a.setProjection({name:"globe"}),a.zoom=R,this._cameraForBounds(a,i,n,r,o,s)):{center:I,zoom:R,bearing:r,pitch:o}}fitBounds(e,t,i){const n=this.cameraForBounds(e,t);return this._fitInternal(n,t,i)}fitScreenCoordinates(t,i,n,r,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],g=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,m,n,g,r);return this._fitInternal(_,r,o)}_fitInternal(e,t,i){return e?(t=Object.assign(e,t)).linear?this.easeTo(t,i):this.flyTo(t,i):this}jumpTo(t,i){this.stop();const n=t.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.aS.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(o=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(s=!0,n.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!n.isPaddingEqual(a))if(!1===t.retainPadding){const e=n.clone();e.padding=a,n.setLocationAtPoint(n.center,e.centerPoint)}else n.padding=a;return t.preloadOnly?(this._preloadTiles(n),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),r&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),o&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),s&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(bl),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return e.w(bl),this;this.stop();const r=n.zoom,o=n.pitch,s=n.bearing;n.setFreeCameraOptions(t);const a=r!==n.zoom,l=o!==n.pitch,c=s!==n.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eU},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===n.projection.name){const i=e.ae.fromLngLat(n.center),r=d.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const o=i.toLngLat(),s=e.aS.convert(t.center||o);this._normalizeCenter(s),p=n.centerPoint.add(r),f=new e.P(i.x,i.y).mult(n.worldSize),m=new e.P(e.aF(s.lng),e.aJ(s.lat)).mult(n.worldSize).sub(f)}else{p=n.centerPoint.add(d);const i=n.pointLocation(p),r=e.aS.convert(t.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let _,A;t.around&&(_=e.aS.convert(t.around),A=n.locationPoint(_));const y=this._zooming||l!==r,v=this._rotating||o!==c,x=this._pitching||u!==s,b=!n.isPaddingEqual(h),w=!1===t.retainPadding?n.clone():n,T=n=>T=>{if(y&&(n.zoom=e.ak(r,l,T)),v&&(n.bearing=e.ak(o,c,T)),x&&(n.pitch=e.ak(s,u,T)),b&&(w.interpolatePadding(a,h,T),p=w.centerPoint.add(d)),_)n.setLocationAtPoint(_,A);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-T),o=n.unproject(f.add(m.mult(T*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(T,t.duration,n);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=v,this._pitching=x,this._padding=b,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||n.moving||this.fire(new e.z("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.z("zoomend",t)),r&&this.fire(new e.z("rotateend",t)),o&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const n=e.aH(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eU},t);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aA(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=n.zoomScale(l-r),p=e.P.convert(t.offset);let f=n.centerPoint.add(p);const m=n.pointLocation(f),g=e.aS.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),A=n.project(g).sub(_);let y=t.curve;const v=Math.max(n.width,n.height),x=v/d,b=A.mag();if("minZoom"in t){const i=e.aA(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),o=v/n.zoomScale(i-r);y=Math.sqrt(o/b*2)}const w=y*y;function T(e){const t=(x*x-v*v+(e?-1:1)*w*w*b*b)/(2*(e?x:v)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}const S=T(0);let B=function(e){return C(S)/C(S+y*e)},I=function(e){return v*((C(S)*(E(t=S+y*e)/C(t))-E(S))/w)/b;var t},M=(T(1)-S)/y;if(Math.abs(b)<1e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(t,i);const e=xt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,L=!n.isPaddingEqual(h),F=!1===t.retainPadding?n.clone():n,k=n=>d=>{const m=d*M,y=1/B(m);n.zoom=1===d?l:r+n.scaleZoom(y),P&&(n.bearing=e.ak(o,c,d)),R&&(n.pitch=e.ak(s,u,d)),L&&(F.interpolatePadding(a,h,d),f=F.centerPoint.add(p));const v=1===d?g:n.unproject(_.add(A.mult(I(m))).mult(y));return n.setLocationAtPoint(n.renderWorldCopies?v.wrap():v,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(k,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=L,this._prepareEase(i,!1),this._ease(k(n),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_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(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.o.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.bS(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const n=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=n;e++){const t=o(e/n);r.push(t.clone())}return r}_preloadTiles(e,t){}}class Tl{constructor(t={}){this.options=t,e.aX(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact,i=e._getUIString("AttributionControl.ToggleAttribution");this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const n=l("span","mapboxgl-ctrl-icon",this._compactButton);return n.setAttribute("aria-hidden","true"),n.setAttribute("title",i),this._innerContainer=l("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}_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 t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.e.ACCESS_TOKEN}];if(t){const n=i.reduce((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${ne.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=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 El{constructor(){e.aX(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("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 Cl{constructor(){e.aX(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",e=>this._onIndoorUpdate(e)),this._container}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_createSeparator(){return l("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,t){this._map&&(e.setAttribute("aria-label",t),e.textContent=t)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px",t&&Array.from(this._container.children).forEach(e=>e.remove()),e.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(e.floors,e.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const e=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const e=this._map;this._model&&e&&e._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(e),this._createSeparator()}_updateBuildingsButtonState(){const e=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");e&&this._model&&(this._model.activeFloorsVisible?e.classList.remove("mapboxgl-ctrl-level-button-selected"):e.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(e,t){for(let i=0;i{this._map._selectIndoorFloor(n.id)});this._setButtonTitle(r,n.zIndex.toString()),this._model&&n.id===this._model.selectedFloorId&&t&&r.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(r),i=this._endTime)return this._end;const i=e.dC((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}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 Il={"AttributionControl.ToggleAttribution":"Toggle attribution","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox homepage","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"};class Ml extends e.z{constructor(e,t,i,n){const{point:r,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=n}}class Pl{constructor(e){this.map=e,this.interactionsByType=new Map,this.delegatedInteractions=new Map,this.typeById=new Map,this.filters=new Map,this.handleType=this.handleType.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOut=this.handleOut.bind(this),this.hoveredFeatures=new Map,this.prevHoveredFeatures=new Map}add(t,i){if(this.typeById.has(t))throw new Error(`Interaction id "${t}" already exists.`);const n=i.filter;let r=i.type;n&&this.filters.set(t,e.b5(n)),"mouseover"===r&&(r="mouseenter"),"mouseout"===r&&(r="mouseleave");const o=this.interactionsByType.get(r)||new Map;"mouseenter"===r||"mouseleave"===r?(0===this.delegatedInteractions.size&&(this.map.on("mousemove",this.handleMove),this.map.on("mouseout",this.handleOut)),this.delegatedInteractions.set(t,i)):0===o.size&&this.map.on(r,this.handleType),0===o.size&&this.interactionsByType.set(r,o),o.set(t,i),this.typeById.set(t,r)}get(e){const t=this.typeById.get(e);if(!t)return;const i=this.interactionsByType.get(t);return i?i.get(e):void 0}remove(e){const t=this.typeById.get(e);if(!t)return;this.typeById.delete(e),this.filters.delete(e);const i=this.interactionsByType.get(t);i&&(i.delete(e),"mouseenter"===t||"mouseleave"===t?(this.delegatedInteractions.delete(e),0===this.delegatedInteractions.size&&(this.map.off("mousemove",this.handleMove),this.map.off("mouseout",this.handleOut))):0===i.size&&this.map.off(t,this.handleType))}queryTargets(e,t){const i=[];for(const[e,n]of t)n.target&&i.push({targetId:e,target:n.target,filter:this.filters.get(e)});return this.map.style.queryRenderedTargets(e,i,this.map.transform)}handleMove(e){this.prevHoveredFeatures=this.hoveredFeatures,this.hoveredFeatures=new Map;const t=this.queryTargets(e.point,Array.from(this.delegatedInteractions).reverse());t.length&&(e.type="mouseenter",this.handleType(e,t));const i=new Map;for(const[e,{feature:t}]of this.prevHoveredFeatures)this.hoveredFeatures.has(e)||i.set(t.id,t);i.size&&(e.type="mouseleave",this.handleType(e,Array.from(i.values())))}handleOut(e){const t=Array.from(this.hoveredFeatures.values()).map(({feature:e})=>e);t.length&&(e.type="mouseleave",this.handleType(e,t)),this.hoveredFeatures.clear()}handleType(t,i){const n="mouseenter"===t.type;if(n&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const r=Array.from(this.interactionsByType.get(t.type)).reverse(),o=!!i;i=i||this.queryTargets(t.point,r);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of r){if(!c.target)continue;const r=l.variants?l.variants[i]:null;if(r){for(const u of r){if(mt(u,l,a,i))continue;const r=new e.dw(l,u),h=ft(u,l,i);o&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const d=n?this.prevHoveredFeatures.get(h):null,p=new Ml(t,i,c,r),f=d?d.stop:c.handler(p);if(n&&this.hoveredFeatures.set(h,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:n,target:r}=i;if(!r&&!1!==n(new Ml(t,e,i,null)))break}}}function Rl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),n=new Set(i);return e.size===n.size&&t.every(e=>n.has(e))}return e.bx(t,i)}const Ll={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,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},Fl={showCompass:!0,showZoom:!0,visualizePitch:!1};class kl{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Wa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new qa({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aX(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),p()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),_(this.element,e)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,_(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=A(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=A(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)n.width||i.y>n.height;n.locationPoint3D(r).distSqr(i)180;){const e=n.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Ol={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%)"},zl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ul extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aX(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:n="center",color:r="#3FB1CE",scale:o=1,draggable:s=!1,clickTolerance:a=0,rotation:l=zl.rotation,rotationAlignment:c=zl.rotationAlignment,pitchAlignment:u=zl.pitchAlignment,occludedOpacity:h=zl.occludedOpacity,altitude:d=zl.altitude}=t||{};this._anchor=n,this._color=r,this._scale=o,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=u,this._occludedOpacity=h,this._altitude=d,this._state="inactive",this._isDragging=!1,this._updateMoving=()=>this._update(!0),t&&t.element?(this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0])):(this._defaultMarker=!0,this._element=this._createDefaultMarker(),this._offset=e.P.convert(t&&t.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 p=this._element.classList;for(const e in Ol)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`);const f=t&&t.className?t.className.trim().split(/\s+/):[];p.add(...f),this._popup=null}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return c("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"},t),c("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"},t),c("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},t),e}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(t){return this._lngLat=e.aS.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||zl.altitude,this._update()),this}getAltitude(){return this._altitude}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,n=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":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,e._marker=this,e._altitude=this._altitude,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,this._altitude),n=e.getFreeCameraOptions();if(!n.position)return!1;const r=n.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const i=this._pos;if(!i||i.x<0||i.x>t.transform.width||i.y<0||i.y>t.transform.height)return void this._clearFadeTimer();const n=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.f4(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.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 ${Ol[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,n=this.getPitchAlignment();if(!i||!t||"map"!==n)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.cW(e.f5(i.transform,this._lngLat)),o=t.sub(e.f6(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=r/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);n=e.cW(Math.atan2(r.y,r.x))-90}else n=-i.getBearing();else if("horizon"===r){const r=e.ah(4,6,i.getZoom()),o=e.f6(i.transform);o.y+=r*i.transform.height;const s=t.sub(o),a=e.cW(Math.atan2(s.y,s.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Dl(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat,this._altitude),!0===e?this._updateFrameId=requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),t._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(t._showingGlobe()||t.getTerrain()||t.getFog())&&!this._fadeTimer&&(this._fadeTimer=window.setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),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(t){const i=this._map;if(!i)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(n)t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.f2(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new an(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies,null,null),t),this._repaint=!!t.repaint,this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Sl,this._domRenderTaskQueue=new Sl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b1(),this._locale=Object.assign({},Il,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._tessellationStep=t.tessellationStep,this._containerWidth=0,this._containerHeight=0,this._showParseStatus=!0,this._precompilePrograms=t.precompilePrograms,this._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Bl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new w(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},t.contextCreateOptions):{},"string"==typeof t.container){const e=document.getElementById(t.container);if(!e)throw new Error(`Container '${t.container.toString()}' not found.`);this._container=e}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.w("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."),t.maxBounds&&this.setMaxBounds(t.maxBounds),this._spriteFormat=t.spriteFormat,e.aX(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new sa),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},()=>{this.setScaleFactor(this._scaleFactor)}),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)),this._fullscreenchangeEvent="onfullscreenchange"in document?"fullscreenchange":"webkitfullscreenchange",window.addEventListener("online",this._onWindowOnline,!1),window.addEventListener("resize",this._onWindowResize,!1),window.addEventListener("orientationchange",this._onWindowResize,!1),window.addEventListener(this._fullscreenchangeEvent,this._onWindowResize,!1),window.addEventListener("visibilitychange",this._onVisibilityChange,!1),this.handlers=new xl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ta("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const e=t.bounds;e&&(this.resize(),this.fitBounds(e,Object.assign({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Tl({customAttribution:t.customAttribution})),this._logoControl=new El,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.z(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))}),this._interactions=new Pl(this)}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){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 i=!this._moving;return i&&this.fire(new e.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aI.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=t??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getScaleFactor(){return this._scaleFactor}setScaleFactor(e){return this._scaleFactor=e,this.painter.scaleFactor=e,this._tp.refreshUI(),this._scaleFactorChanged=!0,this.style._updateFilteredLayers(e=>"symbol"===e.type),this._update(!0),this}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?navigator.language:Array.isArray(e)?0===e.length?void 0:e.map(e=>"auto"===e?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._styleDirty=!0,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 t=this.transform,i=t.projection.name;let n;"globe"===i&&t.zoom>=e.cK?(t.setMercatorFromTransition(),n=!0):"mercator"===i&&t.zoom=e.cK?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&n!==this.transform.mercatorFromTransition;return(i||r)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aS.convert(t),i)}unproject(t,i){return this.transform.pointLocation3D(e.P.convert(t),i)}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){const n=e=>{let i=[];if(Array.isArray(t)){const n=t.filter(e=>this.getLayer(e));i=n.length?this.queryRenderedFeatures(e,{layers:n}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const o=t=>{const o=n(t.point);o.length?r||(r=!0,i.call(this,new Fa(e,this,t.originalEvent,{features:o}))):r=!1};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const o=t=>{n(t.point).length?r=!0:r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))},s=t=>{r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const r=e=>{const t=n(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:r}}}}on(e,t,i){if("function"==typeof t||void 0===i)return super.on(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.delegates[e]);return this}once(e,t,i){if("function"==typeof t||void 0===i)return super.once(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){if("function"==typeof t||void 0===i)return super.off(e,t);if("string"==typeof t&&(t=[t]),!this._areTargetsValid(t))return this;const n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n{if(n){const r="string"==typeof n?n:n instanceof Error?n.message:n.error;e.w(`Unable to perform style diff: ${r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}else r&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),e){const i=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new In(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new In(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.w("There is no style added to the map."),!1)}_isValidId(t){return null==t?(this.fire(new e.y(new Error("IDs can't be empty."))),!1):!e.dq(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${t}".`))),!1)}_isTargetValid(e){return"featuresetId"in e?this._isValidId("importId"in e?e.importId:e.featuresetId):"layerId"in e&&this._isValidId(e.layerId)}_areTargetsValid(e){if(Array.isArray(e)){for(const t of e)if(!this._isValidId(t))return!1;return!0}return this._isTargetValid(e)}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(){return this.style.areTilesLoaded()}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(t,i,{pixelRatio:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:u}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(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:c,height:u}=i,h=i;this.style.addImage(l,{data:new e.q({width:c,height:u},new Uint8Array(h.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const n=e.I.from(t),r=this.style.getImage(n);if(!r)return void this.fire(new e.y(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const o=i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap?e.o.getImageData(i):i,{width:s,height:a,data:l}=o;if(void 0===s||void 0===a)return void this.fire(new e.y(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`")));if(s!==(r.usvg?r.icon.usvg_tree.width:r.data.width)||a!==(r.usvg?r.icon.usvg_tree.height:r.data.height))return void this.fire(new e.y(new Error(`The width and height of the updated image (${s}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let u=!1;r.usvg?(r.data=new e.q({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,u=!0):r.data.replace(l,c),this.style.updateImage(n,r,u)}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.y(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t))}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(t,n)=>{i(t,n instanceof HTMLImageElement?e.o.getImageData(n):n)})}listImages(){return this.style.listImages().map(e=>e.name)}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t)}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.y(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}getSlot(e){const t=this.getLayer(e);return t&&t.slot||null}setSlot(e,t){return this.style.setSlot(e,t),this.style.mergeLayers(),this._update(!0)}addImport(t,i){return this.style.addImport(t,i).catch(t=>this.fire(new e.y(new Error("Failed to add import",t)))),this}updateImport(e,t){return"string"!=typeof t&&t.id!==e?(this.removeImport(e),this.addImport(t)):(this.style.updateImport(e,t),this._update(!0))}removeImport(e){return this.style.removeImport(e),this}moveImport(e,t){return this.style.moveImport(e,t),this._update(!0)}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){if(!this._isValidId(e))return null;const t=this.style.getOwnLayer(e);return t?"custom"===t.type?t.implementation:t.serialize():void 0}getSlots(){return this.style.getSlots()}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,n={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,n),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,n),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayerProperty(e,t,i,n),this._update(!0)):this}getGlyphsUrl(){return this.style.getGlyphsUrl()}setGlyphsUrl(e){return this.style.setGlyphsUrl(e),this._update(!0)}getSchema(e){return this.style.getSchema(e)}setSchema(e,t){return this.style.setSchema(e,t),this._update(!0)}getConfig(e){return this.style.getConfig(e)}setConfig(e,t){return this.style.setConfig(e,t),this._update(!0)}getConfigProperty(e,t){return this.style.getConfigProperty(e,t)}setConfigProperty(e,t,i){return this.style.setConfigProperty(e,t,i),this._update(!0)}getFeaturesetDescriptors(e){return this.style.getFeaturesetDescriptors(e)}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}setSnow(e){return this._lazyInitEmptyStyle(),this.style.setSnow(e),this._update(!0)}getSnow(){return this.style?this.style.getSnow():null}setRain(e){return this._lazyInitEmptyStyle(),this.style.setRain(e),this._update(!0)}getRain(){return this.style?this.style.getRain():null}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),this._update(!0)}setImportColorTheme(e,t){return this._lazyInitEmptyStyle(),this.style.setImportColorTheme(e,t),this._update(!0)}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(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.aS.convert(t),this.transform):0}setFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.setFeatureState(e,t),this._update())}removeFeatureState(e,t){return e.source&&!this._isValidId(e.source)?this:(this.style.removeFeatureState(e,t),this._update())}getFeatureState(e){return e.source&&!this._isValidId(e.source)?null:this.style.getFeatureState(e)}_selectIndoorFloor(e){this.indoor.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.indoor.setActiveFloorsVisibility(e)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Cl),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,n,r,o=this._container;for(;o&&(!n||!r);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(n=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),o=o.parentElement}this._containerWidth=n?Math.abs(e/n):e,this._containerHeight=r?Math.abs(t/r):t}_detectMissingCSS(){"rgb(250, 128, 114)"!==window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.w("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/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new Mn(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("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=l("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{n[e]=l("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.o.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}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 t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(G(i,!0),this.painter=new ba(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp,this._worldview),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.k.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight)),this._updateTerrain(),this.style&&(this.style.clearLayers(),this.style.imageManager.destroyAtlasTextures(),this.style.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.z("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}idle(){return!this.isMoving()&&this.loaded()}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty}_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(t){let r;this.fire(new e.z("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,s=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.o.now(),r=new e.ac(t,{now:n,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s);const u=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),u&&(this._placementDirty=u.needsRerender),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showParseStatus:this.showParseStatus,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:l,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 e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,n.mark(i.load),this.fire(new e.z("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&(this.style.snow||this.style.rain)&&(this._styleDirty=!0),this.style&&this.style.imageManager.hasPatternsInFlight()&&(this._styleDirty=!0),this.style&&!this.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.o.now()-s;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("gpu-timing-layer",{layerTimes:i}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const i=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.z("gpu-timing-deferred-render",{gpuTime:i}))},50)}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,n.mark(i.fullLoad),this._performanceMetricsCollection&&U(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 n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||n)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){V(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===b||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof El&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(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/")))}}),L(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&k(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&O(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,n=i.createFramebuffer();function r(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,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const i=this.style?this.style.getSourceCaches():[];return e.bv(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),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,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.f3(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Fl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aX(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),l("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})}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aX(["_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=l("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(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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 kl(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=l("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 e.E{constructor(t={}){super();const i=navigator.geolocation;this.options=Object.assign({geolocation:i},Nl,t),e.aX(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=wa(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("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 t=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==navigator.permissions?navigator.permissions.query({name:"geolocation"}).then(e=>t("denied"!==e.state)).catch(()=>t()):t()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return!!t&&(i.longitudet.getEast()||i.latitudet.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(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._userLocationDotMarker.removeClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish()}}_updateCamera(t){const i=new e.aS(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),o=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aS(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,i=e.ce(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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(t){if(this._map){if(this.options.trackUserLocation)if(1===t.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===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._userLocationDotMarker.addClassName("mapboxgl-user-location-dot-stale"),this.fire(new e.z("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}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=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ul({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ul({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",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("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 e.w("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 e.z("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 e.z("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 e.z("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=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.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:Tl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Vl,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aX(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,n=t._containerWidth/2-e/2,r=t.unproject([n,i]),o=t.unproject([n+e,i]),s=r.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 n=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),r=n/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(n):`${n} ${jl[i]}`,this._container.style.width=e*r+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("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(t={}){this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),e.aX(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.w("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),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(){(document.fullscreenElement||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()?document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen&&document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},IndoorControl:Cl,Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Gl),t),this._altitude=this.options.altitude,e.aX(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.z("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aS.convert(t),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}getAltitude(){return this._altitude}setAltitude(e){return this._altitude=e,this._update(),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(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}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=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',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,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.xt.transform.width-r/2;if(n.y+et.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(t){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Dl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const n=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=Ql(this.options.offset),o=this._anchor=this._getAnchor(r.y),s=Ql(this.options.offset,o),a=n.add(s).round();i._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${Ol[o]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&i._showingGlobe()){const t=e.f4(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Hl);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:Ul,Style:In,LngLat:e.aS,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ae,FreeCameraOptions:tn,Evented:e.E,config:e.e,prewarm:e.f8,clearPrewarmedResources:e.f7,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t},get workerCount(){return e.fh.workerCount},set workerCount(t){e.fh.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.fg(t)},get workerUrl(){return e.ff.workerUrl},set workerUrl(t){e.ff.workerUrl=t},get workerClass(){return e.ff.workerClass},set workerClass(t){e.ff.workerClass=t},get workerParams(){return e.ff.workerParams},set workerParams(t){e.ff.workerParams=t},get dracoUrl(){return e.fe()},set dracoUrl(t){e.fd(t)},get meshoptUrl(){return e.fc()},set meshoptUrl(t){e.fb(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return $l});var r=i;return r}();var Ze=He($e.exports),We=e({__proto__:null,default:Ze},[$e.exports]),qe={exports:{}};qe.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,n*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),u=Math.sin(n),h=Math.cos(n);switch(r){case"xyz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"xzy":e[0]=s*c*h-a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h+s*l*u;break;case"yxz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;case"yzx":e[0]=s*c*h+a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h-s*l*u;break;case"zxy":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"zyx":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;default:throw new Error("Unknown angle order "+r)}return e}function S(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function B(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),b=new p(4),p!=Float32Array&&(b[0]=0,b[1]=0,b[2]=0,b[3]=0),g(),A(1,0,0),A(0,1,0),E(),E(),f(),S();const I=8192;function M(e,t,i){return t*(I/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function P(e,t){return(e%t+t)%t}function R(e,t,i){return e*(1-i)+t*i}function L(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 F(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";function oe(){return new Error(re)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(n=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new ce(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;if(i.signal.aborted)throw oe();return{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var n;return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(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 n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)fe(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof ge&&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 Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},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:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},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,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},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,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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)}function tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,nt=.82521,rt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,n]){let r,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?r=o=s:(r=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+rt}function ft([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*gt(r),o=it*gt(o),s=nt*gt(s),[mt(3.1338561*o-1.6168667*r-.4906146*s),mt(-.9787684*o+1.9161415*r+.033454*s),mt(.0719453*o-.2289914*r+1.4052427*s),n]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-rt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,n)=>Tt(e,t[n],i))}class Ct{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+r,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=ut(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=ht(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?ut(Math.atan2(n,i)*ct):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Et(e.rgb,t.rgb,i);return new Ct(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:Tt(r,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(n,r,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class St{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}}const Bt=["bottom","center","top"];class It{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof St||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof St)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let n=Vt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Gt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Ht[i],n++}else r=Ve;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],n++}i=qe(r,o)}else{if(!Ht[r])throw new Error(`Types doesn't contain name = ${r}`);i=Ht[r]}const o=[];for(;ne.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{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];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=$t[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Pt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Lt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new qt;try{n=new Gt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}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 n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{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 n=1;n=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,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,Ve),n=t.parse(e[2],2,Ve);return i&&n?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,Ve);if(!i||!n)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ti(i,n,r):null}return new ti(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,Vt(e)))return null}else i=Vt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(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()}}class ni{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class ri{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,ke);if(!i||!n)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ri(i.type,i,n,r):null}return new ri(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,n).join("");if(et(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new si(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[oi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ci=1,li=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=pi(t,e.base,i,n);else if("linear"===e.name)r=pi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new hi(o[0],o[1],o[2],o[3]).solve(pi(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,ke),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,n,r,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=oi(t,n),s=di.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>Je(n,e.type));return new mi(o?Ve:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,n){return 0===n.compare(t,i)}function Ai(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(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,je),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!_i(0,t,i,n)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(n,r,o)}evaluate(e){return new St(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}}class Ci{constructor(e,t,i,n,r){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,De),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,De),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,ke),!a)?null:new Ci(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ge,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Bt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Si(n)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Bi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,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 ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Mi),Math.round(n*r*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Mi+t.x)/i,360*r-180),(n=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Di(e,t,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!ji(e,t,i,n)||!ji(i,n,e,t));var r,o}function Oi(e,t,i){for(const n of i)for(let i=0;i(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Li(t,e)}function $i(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Qi(n,t,i,r),s.push(n)}return s}function Zi(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Qi(n,t,i,r)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=Ji){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Xi(e,i,t),r(e[n],o)>0&&Xi(e,i,n);s0;)a--}0===r(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Xi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=tn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function an(e,t){return t[0]-e[0]}function ln(e){return e[1]-e[0]+1}function cn(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ln(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function hn(e,t){if(!cn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Li(i,e[n]);return i}function dn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function pn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fn(e,t,i){if(!pn(e)||!pn(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(Fi(r,o)){if(xn(e,t))return 0}else if(xn(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(ln(l)<=c){if(!cn(l,e.length))return NaN;if(t){const t=vn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=yn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=un(l,t);wn(s,o,n,e,a,i[0]),wn(s,o,n,e,a,i[1])}}return o}function Cn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],an);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(ln(l)<=u&&ln(c)<=h){if(!cn(l,e.length)&&cn(c,i.length))return NaN;let o;if(t&&n)o=_n(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=mn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=mn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=An(e,l,i,c,r),s=Math.min(s,o)}else{const o=un(l,t),u=un(c,n);Tn(a,s,r,e,i,o[0],u[0]),Tn(a,s,r,e,i,o[0],u[1]),Tn(a,s,r,e,i,o[1],u[0]),Tn(a,s,r,e,i,o[1],u[1])}}return s}function Sn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Bn{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Bn(t,t.features.map(e=>Sn(e.geometry)).flat());if("Feature"===t.type)return new Bn(t,Sn(t.geometry));if("type"in t&&"coordinates"in t)return new Bn(t,Sn(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new sn(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,En([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,En(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,bn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class In{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new In(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Mn={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ni,coalesce:mi,collator:Ei,format:Si,image:Bi,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ri,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Bn,"global-state":In};class Pn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Pn.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Dn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i{i=t?i&&Dn(e):i&&e instanceof Gt}),!!i&&On(e)&&Un(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function On(e){if(e instanceof Pn){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 Wi)return!1;if(e instanceof Bn)return!1;let t=!0;return e.eachChild(e=>{t&&!On(e)&&(t=!1)}),t}function zn(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!zn(e)&&(t=!1)}),t}function Un(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Un(e,t)&&(i=!1)}),i}function Nn(e){return{result:"success",value:e}}function Vn(e){return{result:"error",value:e}}function jn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hn(e){return!!e.expression&&e.expression.interpolated}function Qn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function $n(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function Zn(e){return e}function Wn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||(Hn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Jn;case"interval":return Xn;case"categorical":return Kn;case"identity":return Yn;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Jn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?qn(e.default,t.default):a(e,t,r,l,c)}}}function qn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return qn(typeof i===r?n[i]:void 0,e.default,t.default)}function Xn(e,t,i){if("number"!==Qn(i))return qn(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 r=oi(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Jn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Qn(i))return qn(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 o=oi(e.stops.map(e=>e[0]),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||Zn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Yn(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return qn(i,e.default,t.default)}Pn.register(Mn,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[ze,[ke,ke,ke],Rn],rgba:[ze,[ke,ke,ke,ke],Rn],has:{type:Oe,overloads:[[[De],(e,[t])=>Ln(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Ln(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,kn(ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[ke,kn(ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,kn(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,kn(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,kn(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class er{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&$n(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 Ft(`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 tr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mn}function ir(e,t,i){const n=new Kt(Mn,Dn,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Nn(new er(r,t,i)):Vn(n.errors)}class nr{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}}class rr{constructor(e,t,i,n,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this.interpolationType=n,this._globalState=r}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function or(e,t,i){const n=ir(e,t,i);if("error"===n.result)return n;const r=n.value.expression,o=On(r);if(!o&&!jn(t))return Vn([new Re("","data expressions not supported")]);const s=Un(r,["zoom"]);if(!s&&!Gn(t))return Vn([new Re("","zoom expressions not supported")]);const a=ar(r);return a||s?a instanceof Re?Vn([a]):a instanceof di&&!Hn(t)?Vn([new Re("",'"interpolate" expressions cannot be used with this property')]):Nn(a?new rr(o?"camera":"composite",n.value,a.labels,a instanceof di?a.interpolation:void 0,i):new nr(o?"constant":"source",n.value,i)):Vn([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sr{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Wn(this._parameters,this._specification))}static deserialize(e){return new sr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ar(e){let t=null;if(e instanceof Xt)t=ar(e.result);else if(e instanceof mi){for(const i of e.args)if(t=ar(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=ar(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function lr(e,t=new Set){return e instanceof In&&t.add(e.key),e.eachChild(e=>{lr(e,t)}),t}function cr(e,t){const{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function ur(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(!ur(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const hr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function dr(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};ur(e)||(e=mr(e));const i=ir(e,hr,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,n)=>i.value.evaluate(e,t,{},n),needGeometry:fr(e),getGlobalStateRefs:()=>lr(i.value.expression)}}function pr(e,t){return et?1:0}function fr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?gr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(mr))):"all"===t?["all"].concat(e.slice(1).map(mr)):"none"===t?["all"].concat(e.slice(1).map(mr).map(yr)):"in"===t?_r(e[1],e.slice(2)):"!in"===t?yr(_r(e[1],e.slice(2))):"has"===t?Ar(e[1]):"!has"!==t||yr(Ar(e[1]));var i}function gr(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 _r(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(pr)]]:["filter-in-small",e,["literal",t]]}}function Ar(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function yr(e){return["!",e]}function vr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${vr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new Me(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Br(e){const t=e.valueSpec,i=wr(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Qn(e.value.stops)&&"array"===Qn(e.value.stops[0])&&"object"===Qn(e.value.stops[0][0]),u=Er({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Cr({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Qn(n)&&0===n.length&&t.push(new Me(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Hn(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jn(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!Gn(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Qn(n))return[new Me(a,n,`array expected, ${Qn(n)} found`)];if(2!==n.length)return[new Me(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Qn(n[0]))return[new Me(a,n,`object expected, ${Qn(n[0])} found`)];if(void 0===n[0].zoom)return[new Me(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Me(a,n,"object stop key must have value")];if(o&&o>wr(n[0].zoom))return[new Me(a,n[0].zoom,"stop zoom values must appear in ascending order")];wr(n[0].zoom)!==o&&(o=wr(n[0].zoom),r=void 0,s={}),i=i.concat(Er({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Sr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return tr(Tr(n[1]))?i.concat([new Me(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Qn(e.value),l=wr(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return jn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew Me(`${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 Me(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&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Un(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!On(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Mr(e){const t=e.key,i=e.value,n=Qn(i);return"string"!==n?[new Me(t,i,`color expected, ${n} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Pr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Rr(e){return ur(Tr(e.value))?Ir(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Lr(e)}function Lr(e){const t=e.value,i=e.key;if("array"!==Qn(t))return[new Me(i,t,`array expected, ${Qn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Pr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),wr(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===wr(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Qn(t[1]),"string"!==r&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new Me(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{wr(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(n,i.ref,"ref cannot reference another ref layer")):s=wr(e.type):t.push(new Me(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&wr(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(n,i.source,`source "${i.source}" not found`))}else t.push(new Me(n,i,'missing required property "source"'));return t=t.concat(Er({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Rr,layout:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Dr(Pe({layerType:s},e))}}),paint:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kr(Pe({layerType:s},e))}})}})),t}function zr(e){const t=e.value,i=e.key,n=Qn(t);return"string"!==n?[new Me(i,t,`string expected, ${n} found`)]:[]}const Ur={promoteId:function({key:e,value:t}){if("string"===Qn(t))return zr({key:e,value:t});{const i=[];for(const n in t)i.push(...zr({key:`${e}.${n}`,value:t[n]}));return i}}};function Nr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=wr(t.type);let a;switch(s){case"vector":case"raster":return a=Er({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:Ur,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Qn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Me("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===wr(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Me(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Me(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=Er({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:Ur}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Ir({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Ir({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Er({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return Er({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Vr(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function jr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function Gr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Hr(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Me(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(Er({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zr({key:n,value:i})}function Qr(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Qn(e.value)} found`)];var t}const $r={"*":()=>[],array:Cr,boolean:function(e){const t=e.value,i=e.key,n=Qn(t);return"boolean"!==n?[new Me(i,t,`boolean expected, ${n} found`)]:[]},number:Sr,color:Mr,constants:br,enum:Pr,filter:Rr,function:Br,layer:Or,object:Er,source:Nr,light:Vr,sky:jr,terrain:Gr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Qn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Me(t,i,`projection expected, invalid type "${n}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:zr,formatted:function(e){return 0===zr(e).length?[]:Ir(e)},resolvedImage:function(e){return 0===zr(e).length?[]:Ir(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Qn(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(br({key:"constants",value:e.constants}))),Xr(i)}function Kr(e){return function(t){return e(Object.assign({},t,{validateSpec:Zr}))}}function Xr(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Jr(e){return function(...t){return Xr(e.apply(this,t))}}qr.source=Jr(Kr(Nr)),qr.sprite=Jr(Kr(Hr)),qr.glyphs=Jr(Kr(Wr)),qr.light=Jr(Kr(Vr)),qr.sky=Jr(Kr(jr)),qr.terrain=Jr(Kr(Gr)),qr.state=Jr(Kr(Qr)),qr.layer=Jr(Kr(Or)),qr.filter=Jr(Kr(Rr)),qr.paintProperty=Jr(Kr(kr)),qr.layoutProperty=Jr(Kr(Dr));const Yr=Ae,eo=qr,to=eo.light,io=eo.sky,no=eo.paintProperty,ro=eo.layoutProperty;function oo(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new ge(new Error(n.message))),i=!0;return i}class so{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e=c[l+0]&&n>=c[l+1])?(s[h]=!0,o.push(r[h])):s[h]=!1}}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[n];r[n]=ao[i].shallow.indexOf(n)>=0?o:po(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function fo(e){if(ho(e))return e;if(Array.isArray(e))return e.map(fo);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=uo(e)||"Object";if(!ao[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=ao[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=ao[t].shallow.indexOf(i)>=0?r:fo(r)}return n}class mo{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const bo=xo(["Arab","Dupl","Mong","Ougr","Syrc"]);function wo(e){return!bo.test(String.fromCodePoint(e))}function To(e){return!(_o(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Eo=xo(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Co(e){return Eo.test(String.fromCodePoint(e))}function So(e,t){return!(!t&&Co(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Bo(e){for(const t of e)if(Co(t.codePointAt(0)))return!0;return!1}const Io=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Io.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Mo{constructor(e,t){this.isSupportedScript=Po,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new mo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Po(e){return function(e,t){for(const i of e)if(!So(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===Io.getRTLTextPluginStatus())}const Ro="-transition";class Lo{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if($n(e))return new sr(e,t);if(tr(e)){const n=or(e,t,i);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Fo{constructor(e,t){this.property=e,this.value=new Lo(e,void 0,t)}transitioned(e,t){return new Do(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class ko{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].value=new Lo(this._values[e].property,null===t?void 0:j(t),this._globalState)}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].transition=j(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 n=this.getTransition(t);void 0!==n&&(e[`${t}${Ro}`]=n)}return e}transitioned(e,t){const i=new Oo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Oo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nn.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Mo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Qo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class $o{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Lo(i,void 0,void 0),r=this.defaultTransitionablePropertyValues[t]=new Fo(i,void 0);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}lo("DataDrivenProperty",jo),lo("DataConstantProperty",Vo),lo("CrossFadedDataDrivenProperty",Go),lo("CrossFadedProperty",Ho),lo("ColorRampProperty",Qo);class Zo extends _e{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=dr(e.filter,i)),t.layout&&(this._unevaluatedLayout=new zo(t.layout,i)),t.paint)){this._transitionablePaint=new ko(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._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=dr(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const n=this._transitionablePaint._values[i].value;for(const r of n.getGlobalStateRefs()){const o=null!==(e=t.get(r))&&void 0!==e?e:[];o.push({name:i,value:n.value}),t.set(r,o)}}return t}setLayoutProperty(e,t,i={}){null!=t&&this._validate(ro,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Ro)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(no,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Ro))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):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){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&oo(this,e.call(eo,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Uo&&jn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Wo;var qo={get paint(){return Wo=Wo||new $o({"raster-opacity":new Vo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Vo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Vo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Vo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Vo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Vo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Vo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Vo(Ae.paint_raster["raster-fade-duration"])})}};class Ko extends Zo{constructor(e,t){super(e,qo,t)}}const Xo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Jo{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 Yo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(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")}}function es(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=Xo[e.type].BYTES_PER_ELEMENT,o=i=ts(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:ts(i,Math.max(n,t)),alignment:t}}function ts(e,t){return Math.ceil(e/t)*t}class is extends Yo{_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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}is.prototype.bytesPerElement=4,lo("StructArrayLayout2i4",is);class ns extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}ns.prototype.bytesPerElement=6,lo("StructArrayLayout3i6",ns);class rs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}rs.prototype.bytesPerElement=8,lo("StructArrayLayout4i8",rs);class os extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,lo("StructArrayLayout2i4i12",os);class ss extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ss.prototype.bytesPerElement=8,lo("StructArrayLayout2i4ub8",ss);class as extends Yo{_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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}as.prototype.bytesPerElement=8,lo("StructArrayLayout2f8",as);class ls extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ls.prototype.bytesPerElement=20,lo("StructArrayLayout10ui20",ls);class cs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}cs.prototype.bytesPerElement=16,lo("StructArrayLayout8ui16",cs);class us extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,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]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}us.prototype.bytesPerElement=24,lo("StructArrayLayout4i4ui4i24",us);class hs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}hs.prototype.bytesPerElement=12,lo("StructArrayLayout3f12",hs);class ds extends Yo{_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}}ds.prototype.bytesPerElement=4,lo("StructArrayLayout1ul4",ds);class ps extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ps.prototype.bytesPerElement=20,lo("StructArrayLayout6i1ul2ui20",ps);class fs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}fs.prototype.bytesPerElement=12,lo("StructArrayLayout2i2i2i12",fs);class ms extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ms.prototype.bytesPerElement=16,lo("StructArrayLayout2f1f2i16",ms);class gs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}gs.prototype.bytesPerElement=16,lo("StructArrayLayout2ub2f2i16",gs);class _s extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}_s.prototype.bytesPerElement=6,lo("StructArrayLayout3ui6",_s);class As extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=n,this.uint16[A+3]=r,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}As.prototype.bytesPerElement=48,lo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",As);class ys extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=n,this.int16[I+3]=r,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=S,this.uint16[I+31]=B,e}}ys.prototype.bytesPerElement=64,lo("StructArrayLayout8i15ui1ul2f2ui64",ys);class vs extends Yo{_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}}vs.prototype.bytesPerElement=4,lo("StructArrayLayout1f4",vs);class xs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}xs.prototype.bytesPerElement=12,lo("StructArrayLayout1ui2f12",xs);class bs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}bs.prototype.bytesPerElement=8,lo("StructArrayLayout1ul2ui8",bs);class ws extends Yo{_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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}ws.prototype.bytesPerElement=4,lo("StructArrayLayout2ui4",ws);class Ts extends Yo{_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}}Ts.prototype.bytesPerElement=2,lo("StructArrayLayout1ui2",Ts);class Es extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}Es.prototype.bytesPerElement=16,lo("StructArrayLayout4f16",Es);class Cs extends Jo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Cs.prototype.size=20;class Ss extends ps{get(e){return new Cs(this,e)}}lo("CollisionBoxArray",Ss);class Bs extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Bs.prototype.size=48;class Is extends As{get(e){return new Bs(this,e)}}lo("PlacedSymbolArray",Is);class Ms extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ms.prototype.size=64;class Ps extends ys{get(e){return new Ms(this,e)}}lo("SymbolInstanceArray",Ps);class Rs extends vs{getoffsetX(e){return this.float32[1*e+0]}}lo("GlyphOffsetArray",Rs);class Ls extends ns{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}lo("SymbolLineVertexArray",Ls);class Fs extends Jo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Fs.prototype.size=12;class ks extends xs{get(e){return new Fs(this,e)}}lo("TextAnchorOffsetArray",ks);class Ds extends Jo{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]}}Ds.prototype.size=8;class Os extends bs{get(e){return new Ds(this,e)}}lo("FeatureIndexArray",Os);class zs extends is{}class Us extends is{}class Ns extends is{}class Vs extends os{}class js extends ss{}class Gs extends as{}class Hs extends ls{}class Qs extends cs{}class $s extends us{}class Zs extends hs{}class Ws extends ds{}class qs extends fs{}class Ks extends gs{}class Xs extends _s{}class Js extends ws{}const Ys=es([{name:"a_pos",components:2,type:"Int16"}],4),{members:ea}=Ys;class ta{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return e>ta.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${ta.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ta.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>ta.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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,n){return new ta([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function ia(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}ta.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,lo("SegmentVector",ta);const na=es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ra=es([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var oa,sa,aa,la={exports:{}},ca={exports:{}},ua={exports:{}},ha=function(){if(aa)return la.exports;aa=1;var e=(oa||(oa=1,ca.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>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:r^=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 r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ca.exports),t=(sa||(sa=1,ua.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=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),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ua.exports);return la.exports=e,la.exports.murmur3=e,la.exports.murmur2=t,la.exports}(),da=n(ha);class pa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(fa(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=fa(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return ma(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new pa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function fa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:da(String(e))}function ma(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;ga(e,o,s),ga(t,3*o,3*s),ga(t,3*o+1,3*s+1),ga(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new va(e,t):new Aa(e,t)}}class Ta{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,n){let r=null;"u_pattern_to"===n?r=this.patternTo:"u_pattern_from"===n?r=this.patternFrom:"u_dasharray_to"===n?r=this.dashTo:"u_dasharray_from"===n?r=this.dashFrom:"u_pixel_ratio_to"===n?r=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(r=this.pixelRatioFrom),null!==r&&e.set(r)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)||"u_dasharray_"===i.substr(0,12)?new ya(e,t):new Aa(e,t)}}class Ea{constructor(e,t,i,n){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 n}populatePaintArray(e,t,i){const n=this.paintVertexArray.length,r=this.expression.evaluate(new Mo(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(n,e,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(0,r),i,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=ba(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=r,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){const n=this.expression.evaluate(new Mo(this.zoom,i),t,{},i.canonical,[],i.formattedSection),r=this.expression.evaluate(new Mo(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,n,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(this.zoom,r),i,n),s=this.expression.evaluate(new Mo(this.zoom+1,r),i,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=ba(i),o=ba(n);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ea||i instanceof Ca)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ma(n,t,i);this.needsUpload=!1,this._featureMap=new pa,this._bufferOffset=0}populatePaintArrays(e,t,i,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||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()}}function Ra(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function La(e,t,i){const n={color:{source:as,composite:Es},number:{source:vs,composite:as}},r=function(e){return{"line-pattern":{source:Hs,composite:Hs},"fill-pattern":{source:Hs,composite:Hs},"fill-extrusion-pattern":{source:Hs,composite:Hs},"line-dasharray":{source:Qs,composite:Qs}}[e]}(e);return r&&r[i]||n[t][i]}lo("ConstantBinder",wa),lo("CrossFadedConstantBinder",Ta),lo("SourceExpressionBinder",Ea),lo("CrossFadedPatternBinder",Ba),lo("CrossFadedDasharrayBinder",Ia),lo("CompositeExpressionBinder",Ca),lo("ProgramConfiguration",Ma,{omit:["_buffers"]}),lo("ProgramConfigurationSet",Pa);const Fa=Math.pow(2,14)-1,ka=-Fa-1;function Da(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Oa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Da(e):[]}}const za=-32768;function Ua(e,t,i,n,r){e.emplaceBack(za+8*t+n,za+8*i+r)}class Na{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Us,this.indexArray=new Xs,this.segments=new ta,this.programConfigurations=new Pa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ea),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())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=I||n<0||n>=I)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e1){if(Qa(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function qa(e,t){let i,n,r,o=!1;for(let s=0;st.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function Ka(e,t){let i=!1;for(let n=0,r=e.length-1;nt.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 Xa(e,t,i){const n=i[0],r=i[2];if(e.xr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Ja(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ya(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function el(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(let t=0;tsl(e,t,i,n))}(l,r,s,a),p=c),ol({queryGeometry:d,size:p,transform:r,unwrappedTileID:s,getElevation:a,pitchAlignment:h,pitchScale:u},n)}}class hl extends Na{}let dl;lo("HeatmapBucket",hl,{omit:["layers"]});var pl={get paint(){return dl=dl||new $o({"heatmap-radius":new jo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Vo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Qo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Vo(Ae.paint_heatmap["heatmap-opacity"])})}};function fl(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError(`mismatched image size. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function ml(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=fl({},{width:t,height:i},n);gl(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function gl(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Il(e,this.getUnpackVector())}getPixels(){return new Al({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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;t0)for(let r=t;r=t;r-=n)o=nc(r/n|0,e[r],e[r+1],o);return o&&Xl(o,o.next)&&(rc(o),o=o.next),o}function Dl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Xl(n,n.next)&&0!==Kl(n.prev,n,n.next))n=n.next;else{if(rc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ol(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Ql(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Ul(e,n,r,o):zl(e))t.push(l.i,e.i,c.i),rc(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Ol(e=Nl(Dl(e),t),t,i,n,r,o,2):2===s&&Vl(e,t,i,n,r,o):Ol(Dl(e),t,i,n,r,o,1);break}}}function zl(e){const t=e.prev,i=e,n=e.next;if(Kl(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Wl(r,a,o,l,s,c,f.x,f.y)&&Kl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ul(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Kl(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Ql(p,f,t,i,n),A=Ql(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Nl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!Xl(n,r)&&Jl(n,i,i.next,r)&&tc(n,r)&&tc(r,n)&&(t.push(n.i,i.i,r.i),rc(i),rc(i.next),i=e=r),i=i.next}while(i!==e);return Dl(i)}function Vl(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&ql(s,e)){let a=ic(s,e);return s=Dl(s,s.next),a=Dl(a,a.next),Ol(s,t,i,n,r,o,0),void Ol(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function jl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Gl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(Xl(e,i))return i;do{if(Xl(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Zl(ro.x||i.x===o.x&&Hl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=ic(i,e);return Dl(n,n.next),Dl(i,i.next)}function Hl(e,t){return Kl(e.prev,e,t.prev)<0&&Kl(t.next,e,e.next)<0}function Ql(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $l(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Wl(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Zl(e,t,i,n,r,o,s,a)}function ql(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(tc(e,t)&&tc(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Kl(e.prev,e,t.prev)||Kl(e,t.prev,t))||Xl(e,t)&&Kl(e.prev,e,e.next)>0&&Kl(t.prev,t,t.next)>0)}function Kl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Xl(e,t){return e.x===t.x&&e.y===t.y}function Jl(e,t,i,n){const r=ec(Kl(e,t,i)),o=ec(Kl(e,t,n)),s=ec(Kl(i,n,e)),a=ec(Kl(i,n,t));return r!==o&&s!==a||!(0!==r||!Yl(e,i,t))||!(0!==o||!Yl(e,n,t))||!(0!==s||!Yl(i,e,n))||!(0!==a||!Yl(i,t,n))}function Yl(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 ec(e){return e>0?1:e<0?-1:0}function tc(e,t){return Kl(e.prev,e,e.next)<0?Kl(e,t,e.next)>=0&&Kl(e,e.prev,t)>=0:Kl(e,t,e.prev)<0||Kl(e,e.next,t)<0}function ic(e,t){const i=oc(e.i,e.x,e.y),n=oc(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function nc(e,t,i,n){const r=oc(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function rc(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 oc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class sc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n=1||y<=0)||m&&(ar)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),_=n+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=dc(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;er!=(o===lc)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return Ol(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let n=0;n0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(A-e),r=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?n/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function fc(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(cta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=mc(s,n,o,a,d,m,c),y=mc(s,n,o,a,p,g,c),v=mc(s,n,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;eta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=mc(s,n,o,a,r,f,c),_=mc(s,n,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function mc(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class gc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Ns,this.indexArray=new Xs,this.indexArray2=new Js,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.segments2=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Oa(s,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Da(s),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasDependencies){const e=Fl("fill",this.layers,n,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rl),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,n,r,o){for(const e of Yi(t,500)){const t=hc(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;fc((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,canonical:n})}}let _c,Ac;lo("FillBucket",gc,{omit:["layers","patternFeatures"]});var yc={get paint(){return Ac=Ac||new $o({"fill-antialias":new Vo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new jo(Ae.paint_fill["fill-opacity"]),"fill-color":new jo(Ae.paint_fill["fill-color"]),"fill-outline-color":new jo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Vo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Vo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Go(Ae.paint_fill["fill-pattern"])})},get layout(){return _c=_c||new $o({"fill-sort-key":new jo(Ae.layout_fill["fill-sort-key"])})}};class vc extends Zo{constructor(e,t){super(e,yc,t)}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 gc(e)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ga(el(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const xc=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),bc=es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:wc}=xc;class Tc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(Ec,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new Tc(this._pbf,t,this.extent,this._keys,this._values)}}function Bc(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){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Ic{constructor(e,t){this.layers=e.readFields(Mc,{},t)}}function Mc(e,t,i){if(3===e){const e=new Sc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Pc=Math.pow(2,13);function Rc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*Pc)+s,r*Pc*2,o*Pc*2,Math.round(a))}class Lc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Vs,this.centroidVertexArray=new zs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Ll("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Oa(n,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Da(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push(Fl("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wc),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,bc.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{Rc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;nta.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Fc(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function Dc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let Oc;lo("FillExtrusionBucket",Lc,{omit:["layers","features"]});var zc={get paint(){return Oc=Oc||new $o({"fill-extrusion-opacity":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Go(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Uc extends Zo{constructor(e,t){super(e,zc,t)}createBucket(e){return new Lc(e)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=el(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,n.push(C)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ga(i,t)&&(n=Vc(i,t[0]));for(let r=0;re.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new js,this.layoutVertexArray2=new Gs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("line",this.layers,t)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},dashes:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.hasDependencies?(Ll("line",this.layers,t)?Fl("line",this.layers,n,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,t),this.patternFeatures.push(n)):this.addFeature(n,r,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:n})}addFeatures(e,t,i,n){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,e.subdivisionGranularity)}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,Qc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gc),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&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap"),u=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,u,h,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,dashPositions:o,canonical:n})}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=dc(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":n;if(w&&"round"===T&&(yr&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>Zc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Zc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,n){for(const r of e){const e=r.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===r.layout.get("line-cap"),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,u=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;n.dashDependencies[c]=s,n.dashDependencies[u]=a,n.dashDependencies[h]=l,t.dashes[r.id]={min:c,mid:u,max:h}}}}let qc,Kc;lo("LineBucket",Wc,{omit:["layers","patternFeatures"]});var Xc={get paint(){return Kc=Kc||new $o({"line-opacity":new jo(Ae.paint_line["line-opacity"]),"line-color":new jo(Ae.paint_line["line-color"]),"line-translate":new Vo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Vo(Ae.paint_line["line-translate-anchor"]),"line-width":new jo(Ae.paint_line["line-width"]),"line-gap-width":new jo(Ae.paint_line["line-gap-width"]),"line-offset":new jo(Ae.paint_line["line-offset"]),"line-blur":new jo(Ae.paint_line["line-blur"]),"line-dasharray":new Go(Ae.paint_line["line-dasharray"]),"line-pattern":new Go(Ae.paint_line["line-pattern"]),"line-gradient":new Qo(Ae.paint_line["line-gradient"])})},get layout(){return qc=qc||new $o({"line-cap":new Vo(Ae.layout_line["line-cap"]),"line-join":new jo(Ae.layout_line["line-join"]),"line-miter-limit":new Vo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Vo(Ae.layout_line["line-round-limit"]),"line-sort-key":new jo(Ae.layout_line["line-sort-key"])})}};class Jc extends jo{possiblyEvaluate(e,t){return t=new Mo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let Yc;class eu extends Zo{constructor(e,t){super(e,Xc,t),this.gradientVersion=0,Yc||(Yc=new Jc(Xc.paint.properties["line-width"].specification),Yc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Yc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Wc(e)}queryRadius(e){const t=e,i=tu(Ja("line-width",this,t),Ja("line-gap-width",this,t)),n=Ja("line-offset",this,t);return i/2+Math.abs(n)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=el(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*tu(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(let r=0;r=3)for(let t=0;t0?t+2*e:e}const iu=es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),nu=es([{name:"a_projected_pos",components:3,type:"Float32"}],4);es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ru=es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ou=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),su=es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function au(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)}),e}es([{name:"triangle",components:3,type:"Uint16"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),es([{type:"Float32",name:"offsetX"}]),es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var lu=24;const cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},uu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hu={40:!0};function du(e,t,i,n,r,o){if("fontStack"in t){const n=i[t.fontStack],o=n&&n[e];return o?o.metrics.advance*t.scale+r:0}{const e=n[t.imageName];return e?e.displaySize[0]*t.scale*lu/o+r:0}}function pu(e,t,i,n){const r=Math.pow(e-t,2);return n?eMath.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let n=0;ni))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void H("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName: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)}determineLineBreaks(e,t,i,n,r){const o=[],s=this.determineAverageLineWidth(e,t,i,n,r),a=this.hasZeroWidthSpaces();let l=0,c=0;const u=this.text[Symbol.iterator]();let h=u.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!h.done;){const t=this.getSection(c),g=h.value.codePointAt(0);if(Ao(g)||(l+=du(g,t,i,n,e,r)),!p.done){const e=go(g),i=p.value.codePointAt(0);(uu[g]||e||"imageName"in t||!m.done&&hu[i])&&o.push(mu(c+1,l,s,o,fu(g,i,e&&a),!1))}c++,h=u.next(),p=d.next(),m=f.next()}return gu(mu(this.length(),l,s,o,0,!0))}determineAverageLineWidth(e,t,i,n,r){let o=0,s=0;for(const t of this.text){const a=this.getSection(s);o+=du(t.codePointAt(0),a,i,n,e,r),s++}return o/Math.max(1,Math.ceil(o/t))}}const Au=4294967296,yu=1/Au,vu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class xu{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return bu(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&vu?vu.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&wu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&wu(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Tu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Eu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Cu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Su,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Iu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Mu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Pu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ru,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function bu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function wu(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Tu(e,t){for(let i=0;it.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&eg.toCodeUnitIndex(e));const e=y(g.toString(),A);for(const t of e){const e=[...t].map(()=>0);_.push(new _u(t,g.sections,e))}}else if(v){_=[],A=A.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const i of g.text)t.push(...Array(i.length).fill(g.sectionIndex[e])),e++;const i=v(g.text,t,A);for(const e of i){const t=[];let i="";for(const n of e[0])t.push(e[1][i.length]),i+=n;_.push(new _u(e[0],g.sections,t))}}else _=function(e,t){const i=[];let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return nc){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function Ku(e,t,i,n,r,o){const s=e.image;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 u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}lo("ImagePosition",Ou),lo("ImageAtlas",zu),e.ay=void 0,(Uu=e.ay||(e.ay={}))[Uu.none=0]="none",Uu[Uu.horizontal=1]="horizontal",Uu[Uu.vertical=2]="vertical",Uu[Uu.horizontalOnly=3]="horizontalOnly";const Xu=128,Ju=32640;function Yu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Mo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;re.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Yu(this.zoom,i["text-size"]),this.iconSizeData=Yu(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==eh(n,"text-overlap","text-allow-overlap")||"never"!==eh(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ay[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new oh(new Pa(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new oh(new Pa(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new Ls,this.symbolInstances=new Ps,this.textAnchorOffsets=new ks}calculateGlyphDependencies(e,t,i,n,r){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||n)&&r){const e=cu[o];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,n){const r=this.layers[0],o=r.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Mt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Mo(this.zoom);for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,_=Oa(i,t);if(!r._featureFilter.filter(m,_,n))continue;let A,y;if(t||(_.geometry=Da(i)),c){const e=r.getValueAndResolveTokens("text-field",_,n,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||rh(t);(!i||"unavailable"===Io.getRTLTextPluginStatus()||i&&Io.isParsed())&&(A=au(t,r,_))}if(u){const e=r.getValueAndResolveTokens("icon-image",_,n,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},n):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:Tc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ay.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const n=yo(A.toString()),r=e.fontStack||t,o=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,o,i,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}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.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let lh,ch;lo("SymbolBucket",ah,{omit:["layers","collisionBoxArray","features","compareText"]}),ah.MAX_GLYPHS=65535,ah.addDynamicAttributes=nh;var uh={get paint(){return ch=ch||new $o({"icon-opacity":new jo(Ae.paint_symbol["icon-opacity"]),"icon-color":new jo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new jo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Vo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Vo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(Ae.paint_symbol["text-opacity"]),"text-color":new jo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Vo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Vo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return lh=lh||new $o({"symbol-placement":new Vo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Vo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Vo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Vo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Vo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Vo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Vo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Vo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Vo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Vo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Ae.layout_symbol["icon-image"]),"icon-rotate":new jo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Vo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new jo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Vo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Vo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Vo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Ae.layout_symbol["text-field"]),"text-font":new jo(Ae.layout_symbol["text-font"]),"text-size":new jo(Ae.layout_symbol["text-size"]),"text-max-width":new jo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Vo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new jo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Vo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new jo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new jo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Vo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Vo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Ae.layout_symbol["text-rotate"]),"text-padding":new Vo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Vo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new jo(Ae.layout_symbol["text-transform"]),"text-offset":new jo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Vo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Vo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Vo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Vo(Ae.layout_symbol["text-optional"])})}};class hh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}lo("FormatSectionOverride",hh,{omit:["defaultValue"]});class dh extends Zo{constructor(e,t){super(e,uh,t)}recalculate(e,t){if(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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||tr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new ah(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of uh.paint.overridableProperties){if(!dh.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new hh(t),n=new er(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new nr("source",n):new rr("composite",n,t.value.zoomStops),this.paint._values[e]=new Uo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&dh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=uh.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Mt)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{r||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let ph;var fh={get paint(){return ph=ph||new $o({"background-color":new Vo(Ae.paint_background["background-color"]),"background-pattern":new Ho(Ae.paint_background["background-pattern"]),"background-opacity":new Vo(Ae.paint_background["background-opacity"])})}};class mh extends Zo{constructor(e,t){super(e,fh,t)}}class gh extends Zo{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class _h{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ah={once:!0},yh=6371008.8;class vh{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 vh(O(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return yh*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof vh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new vh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new vh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const xh=2*Math.PI*yh;function bh(e){return xh*Math.cos(e*Math.PI/180)}function wh(e){return(180+e)/360}function Th(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Eh(e,t){return e/bh(t)}function Ch(e){return 360*e-180}function Sh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Bh(e,t){return e*bh(Sh(t))}class Ih{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=vh.convert(e);return new Ih(wh(i.lng),Th(i.lat),Eh(t,i.lat))}toLngLat(){return new vh(Ch(this.x),Sh(this.y))}toAltitude(){return Bh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xh*(e=Sh(this.y),1/Math.cos(e*Math.PI/180));var e}}function Mh(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Ph{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Fh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=Mh(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=Mh(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Rh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Fh(e,t.z,t.z,t.x,t.y)}}class Lh{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Ph(i,+n,+r),this.key=Fh(t,e,i,n,r)}clone(){return new Lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Lh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Fh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Fh(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Lh(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,n=2*this.canonical.y;return[new Lh(t,this.wrap,t,i,n),new Lh(t,this.wrap,t,i+1,n),new Lh(t,this.wrap,t,i,n+1),new Lh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===i);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function Oh(e){var t,i;if(!e)return{};const n={};return n.removeAll=e.removeAll,n.remove=new Set(e.remove||[]),n.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),n.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),n}lo("CanonicalTileID",Ph),lo("OverscaledTileID",Lh,{omit:["terrainRttPosMatrix32f"]});class zh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Uh{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=n,this.properties=e.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Nh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Vh extends Nh{}class jh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Hh extends Nh{delta;constructor(e,t,i,n){super(e,t,n),this.delta=i}}class Qh extends Hh{constructor(e,t,i,n){super(e,Int32Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class $h extends Nh{constructor(e,t,i){super(e,Int32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Zh{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,t,i,n,r=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=n,this._extent=r}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let t=0;for(;t>4,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<3,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<10,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<17,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<24,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(1&r)<<31,r<128)return 4294967296*n+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function cd(e,t,i,n){throw new Error("FastPFor is not implemented yet.")}function ud(e){return e>>>1^-(1&e)}function hd(e){return e>>1n^-(1n&e)}function dd(e,t){let i=0n,n=0,r=t.get();for(;r=64)throw new Error("Varint too long")}return t.set(r),i}function pd(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i=4)for(let n=e[0];i>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const t=e.length/4*4;let i=2;if(t>=4)for(;i>>1^-(1&t))+e[i-2],e[i+1]=(n>>>1^-(1&n))+e[i-1],e[i+2]=(r>>>1^-(1&r))+e[i],e[i+3]=(o>>>1^-(1&o))+e[i+1]}for(;i!=e.length;i+=2)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-2],e[i+1]=(e[i+1]>>>1^-(1&e[i+1]))+e[i-1]}function Ad(e,t,i){return Math.min(i,Math.max(t,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Kh||(Kh={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(Xh||(Xh={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Jh||(Jh={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Yh||(Yh={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(ed||(ed={}));class yd{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,t,i,n,r,o,s){this._physicalStreamType=e,this._logicalStreamType=t,this._logicalLevelTechnique1=i,this._logicalLevelTechnique2=n,this._physicalLevelTechnique=r,this._numValues=o,this._byteLength=s}static decode(e,t){const i=e[t.get()],n=Object.values(qh)[i>>4];let r=null;switch(n){case qh.DATA:r=new od(Object.values(Jh)[15&i]);break;case qh.OFFSET:r=new od(null,Object.values(Yh)[15&i]);break;case qh.LENGTH:r=new od(null,null,Object.values(ed)[15&i])}t.increment();const o=e[t.get()],s=Object.values(Kh)[o>>5],a=Object.values(Kh)[o>>2&7],l=Object.values(Xh)[3&o];t.increment();const c=sd(e,t,2);return new yd(n,r,s,a,l,c[0],c[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class vd extends yd{num_bits;coordinate_shift;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this.num_bits=a,this.coordinate_shift=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new vd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new vd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class xd extends yd{_runs;_numRleValues;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this._runs=a,this._numRleValues=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new xd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new xd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class bd{static decode(e,t){const i=yd.decode(e,t);return i.logicalLevelTechnique1===Kh.MORTON?vd.decodePartial(i,e,t):Kh.RLE!==i.logicalLevelTechnique1&&Kh.RLE!==i.logicalLevelTechnique2||Xh.NONE===i.physicalLevelTechnique?i:xd.decodePartial(i,e,t)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(td||(td={}));class wd{values;_size;constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}class Td{constructor(){}static decodeIntStream(e,t,i,n,r){const o=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeIntBuffer(o,i,n,r)}static decodeLengthStreamToOffsetBuffer(e,t,i){const n=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeLengthToOffsetBuffer(n,i)}static decodePhysicalLevelTechnique(e,t,i){const n=i.physicalLevelTechnique;if(n===Xh.FAST_PFOR)return cd();if(n===Xh.VARINT)return sd(e,t,i.numValues);if(n===Xh.NONE){const n=t.get();t.add(i.byteLength);const r=e.subarray(n,t.get());return new Int32Array(r)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,t,i,n){const r=Td.decodePhysicalLevelTechnique(e,t,i);if(1===r.length){const e=r[0];return n?ud(e):e}return n?function(e){return ud(e[1])}(r):function(e){return e[1]}(r)}static decodeSequenceIntStream(e,t,i){return function(e){if(2==e.length){const t=ud(e[1]);return[t,t]}return[ud(e[2]),ud(e[3])]}(Td.decodePhysicalLevelTechnique(e,t,i))}static decodeSequenceLongStream(e,t,i){return function(e){if(2==e.length){const t=hd(e[1]);return[t,t]}return[hd(e[2]),hd(e[3])]}(ad(e,t,i.numValues))}static decodeLongStream(e,t,i,n){const r=ad(e,t,i.numValues);return this.decodeLongBuffer(r,i,n)}static decodeLongFloat64Stream(e,t,i,n){const r=function(e,t,i){const n=new Float64Array(t);for(let r=0;r>>1^-(1&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&t))+e[i-1],e[i+1]=(n>>>1^-(1&n))+e[i],e[i+2]=(r>>>1^-(1&r))+e[i+1],e[i+3]=(o>>>1^-(1&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i>>1^-(1&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):pd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.MORTON:return gd(e),e;case Kh.COMPONENTWISE_DELTA:return n?(function(e,t,i,n){let r=e[0]>>>1^-(1&e[0]),o=e[1]>>>1^-(1&e[1]);e[0]=Ad(Math.round(r*t),i,n),e[1]=Ad(Math.round(o*t),i,n);const s=e.length/16;let a=2;if(s>=4)for(;a>>1^-(1&s))+r,u=(l>>>1^-(1&l))+o;e[a]=Ad(Math.round(c*t),i,n),e[a+1]=Ad(Math.round(u*t),i,n);const h=e[a+2],d=e[a+3];r=(h>>>1^-(1&h))+c,o=(d>>>1^-(1&d))+u,e[a+2]=Ad(Math.round(r*t),i,n),e[a+3]=Ad(Math.round(o*t),i,n)}for(;a!=e.length;a+=2)r+=e[a]>>>1^-(1&e[a]),o+=e[a+1]>>>1^-(1&e[a+1]),e[a]=Ad(Math.round(r*t),i,n),e[a+1]=Ad(Math.round(o*t),i,n)}(e,n.scale,n.min,n.max),e):(_d(e),e);case Kh.NONE:return i&&function(e){for(let t=0;t>>1^-(1&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE?function(e,t,i){const n=new BigInt64Array(i);let r=0,o=0n;for(let i=0;i>1n^-(1n&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>1n^-(1n&t))+e[i-1],e[i+1]=(n>>1n^-(1n&n))+e[i],e[i+2]=(r>>1n^-(1n&r))+e[i+1],e[i+3]=(o>>1n^-(1n&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>1n^-(1n&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new BigInt64Array(i);let r=0;for(let i=0;i>1n^-(1n&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):fd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.NONE:return i&&function(e){for(let t=0;t>1n^-(1n&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=md(e,t.runs,t.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&r),t[n]=t[n-1]+i}return t}(e);if(t.logicalLevelTechnique1===Kh.RLE&&t.logicalLevelTechnique2===Kh.NONE)return function(e,t,i){const n=new Int32Array(i+1);n[0]=0;let r=1,o=n[0];for(let i=0;i>>1^-(1&a);for(let e=r;e>>1^-(1&t[0]):0,n=1):i[0]=0;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>>1^-(1&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new Int32Array(e.size());let r=0;for(let o=0;o>>1^-(1&a);for(let t=r;t>>1^-(1&e)}else i[r]=0;return i}(n,e):function(e,t){const i=new Int32Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,t,i,n){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=fd(e,t.runs,t.numRleValues)),function(e,t){const i=new BigInt64Array(e.size());let n=0;e.get(0)?(i[0]=e.get(0)?t[0]>>1n^-(1n&t[0]):0n,n=1):i[0]=0n;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>1n^-(1n&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new BigInt64Array(e.size());let r=0;for(let o=0;o>1n^-(1n&a);for(let t=r;t>1n^-(1n&e)}else i[r]=0n;return i}(n,e):function(e,t){const i=new BigInt64Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0n;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,t,i,n){const r=e.logicalLevelTechnique1;if(r===Kh.RLE)return 1===e.runs?td.CONST:td.FLAT;const o=t instanceof wd?t.size():t;if(r===Kh.DELTA&&e.logicalLevelTechnique2===Kh.RLE){const t=e.runs,r=2;if(e.numRleValues!==o)return td.FLAT;if(1===t)return td.SEQUENCE;if(2===t){const t=n.get();let o;if(e.physicalLevelTechnique===Xh.VARINT)o=sd(i,n,4);else{const e=n.get();o=new Int32Array(i.buffer,i.byteOffset+e,4)}if(n.set(t),o[2]===r&&o[3]===r)return td.SEQUENCE}}return 1===e.numValues?td.CONST:td.FLAT}}class Ed extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Cd extends Hh{constructor(e,t,i,n){super(e,BigInt64Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Sd{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,t,i){this._geometryOffsets=e,this._partOffsets=t,this._ringOffsets=i}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class Bd{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,t){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=t+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=t}validateCoordinates(e){if(e.xthis.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Id extends Bd{encode(e){this.validateCoordinates(e);const t=e.x+this._coordinateShift,i=e.y+this._coordinateShift;let n=0;for(let e=0;e>1)-this._coordinateShift}}decodeMorton(e){let t=0;for(let i=0;i>i;return t}static decode(e,t,i){return{x:Id.decodeMorton(e,t)-i,y:Id.decodeMorton(e>>1,t)-i}}static decodeMorton(e,t){let i=0;for(let n=0;n>n;return i}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(id||(id={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(nd||(nd={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(rd||(rd={}));class Md{createPoint(e){return[[e]]}createMultiPoint(e){return e.map(e=>[e])}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,t){return[e,...t]}createMultiPolygon(e){return e.flat()}}function Pd(e){const t=new Array(e.numGeometries);let n=1,r=1,o=1,s=0;const a=new Md;let l=0,c=0;const u=e.mortonSettings,h=e.topologyVector,d=h.geometryOffsets,p=h.partOffsets,f=h.ringOffsets,m=e.vertexOffsets,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let h=0;h0&&t.push(t[0]),h.push(t)}e[t]=h,o&&c++}break;case id.MULTIPOLYGON:{const u=o[c]-o[c-1];c++;const h=[];for(let e=0;e0&&t.push(t[0]),h.push(t)}}e[t]=h}}return e}[Symbol.iterator](){return null}}class jd extends Vd{_numGeometries;_geometryType;constructor(e,t,i,n,r,o){super(i,n,r,o),this._numGeometries=e,this._geometryType=t}static create(e,t,i,n,r,o){return new jd(e,t,i,n,r,o)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class Gd extends Vd{_geometryTypes;constructor(e,t,i,n,r){super(t,i,n,r),this._geometryTypes=e}static create(e,t,i,n,r){return new Gd(e,t,i,n,r)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Hd(e,t,i,n,r){const o=bd.decode(e,i);let s=null,a=null,l=null,c=null,u=null,h=null,d=null,p=null;if(Td.getVectorType(o,n,e,i)===td.CONST){const f=Td.decodeConstIntStream(e,i,o,!1);for(let n=0;ni?t[o++]:1);return n}function $d(e,t,i,n){const r=new Int32Array(t[t.length-1]+1);let o=0;r[0]=o;let s=1,a=0;for(let l=0;l=12?Yd.decode(e.subarray(t,i)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(e,t,i)}class tp extends Nh{offsetBuffer;constructor(e,t,i,n){super(e,i,n),this.offsetBuffer=t}}class ip extends tp{textEncoder;constructor(e,t,i,n){super(e,t,i,n??t.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return ep(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class np extends tp{indexBuffer;textEncoder;constructor(e,t,i,n,r){super(e,i,n,r??t.length),this.indexBuffer=t,this.indexBuffer=t,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const t=this.indexBuffer[e];return ep(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class rp extends tp{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,t,i,n,r,o,s){super(e,i,n,s),this.indexBuffer=t,this.symbolOffsetBuffer=r,this.symbolTableBuffer=o,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,t,i){const n=[],r=new Array(t.length).fill(0);for(let e=1;e1?6:4,i.type="physicalType",t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let t=null;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const n={type:"physicalType"};return n.physicalType=t,i.type="scalarType",i.scalarType=n,i}}const cp=new TextDecoder;function up(e,t){const i=sd(e,t,1)[0];if(0===i)return"";const n=t.get(),r=e.subarray(n,n+i);return t.add(i),cp.decode(r)}function hp(e,t){const i=sd(e,t,1)[0]>>>0,n=!!(4&i),r=!!(2&i),o=sd(e,t,1)[0]>>>0,s={};if(1&i&&(s.nullable=!0),r){const r={};if(n?(r.type="logicalType",r.logicalType=o):(r.type="physicalType",r.physicalType=o),8&i){const i=sd(e,t,1)[0]>>>0;r.children=new Array(i);for(let n=0;n>>0,n=lp.decodeColumnType(i);if(!n)throw new Error(`Unsupported column type code: ${i}`);if(lp.columnTypeHasName(i)?n.name=up(e,t):i>=0&&i<=3?n.name="id":4===i&&(n.name="geometry"),lp.columnTypeHasChildren(i)){const i=sd(e,t,1)[0]>>>0,r=n.complexType;r.children=new Array(i);for(let n=0;n>>0,o=sd(e,t,1)[0]>>>0;n.columns=new Array(o);for(let i=0;ithis.projectPoint(e,t,i,n))}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();let a;switch(this.type){case 1:{const e=[];for(const t of s)e.push(t[0]);const t=this.projectLine(e,r,o,n);a=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{const e=s.map(e=>this.projectLine(e,r,o,n));a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Yi(s),t=[];for(const i of e)t.push(i.map(e=>this.projectLine(e,r,o,n)));a=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw new Error(`unknown feature type: ${this.type}`)}const l={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(l.id=this.id),l}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const n=[];for(const e of t)n.push(new i(e.x,e.y));e.push(n)}return e}bbox(){return[0,0,0,0]}}class gp{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new mp(this.features[e],this.extent)}}class _p{constructor(e){this.layers={};const t=function(e,t,i=!0){const n=new Wh(0),r=[];for(;n.get()>>0,s=n.get()+o;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=sd(e,n,1)[0]>>>0){n.set(s);continue}const a=pp(e,n),l=a[1],c=a[0].featureTables[0];let u=null,h=null;const d=[];let p=0;for(const r of c.columns){const o=r.name;if("id"===o){let t=null;if(r.nullable){const i=bd.decode(e,n),r=n.get(),o=Xd(e,i.numValues,n);n.set(r+i.byteLength),t=new wd(o,i.numValues)}const s=bd.decode(e,n);p=s.getDecompressedCount(),u=fp(e,r,n,o,s,t??p,i)}else if("geometry"===o){const i=sd(e,n,1)[0];if(0===p){const t=n.get();p=bd.decode(e,n).getDecompressedCount(),n.set(t)}h=Hd(e,i,n,p,t)}else{const t=lp.hasStreamCount(r)?sd(e,n,1)[0]:1;if(0===t&&"scalarType"===r.type)continue;const i=sp(e,n,r,t,p,void 0);i&&(Array.isArray(i)?d.push(...i):d.push(i))}}const f=new Zh(c.name,h,u,d,l);r.push(f),n.set(s)}return r}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new gp(t)}),{})}}class Ap{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Ap;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Ap;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}const yp="_geojsonTileLayer";class vp{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new so(I,16,0),this.grid3D=new so(I,16,0),this.featureIndexArray=new Os,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Ic(new xu(this.rawTileData)).layers:new _p(this.rawTileData).layers,this.sourceLayerCoder=new zh(this.vtLayers?Object.keys(this.vtLayers).sort():[yp])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=dr(o.filter,o.globalState),l=e.queryGeometry,c=e.queryPadding*s,u=Ap.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Ap.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(Ka(e,t))return!0;for(let t=0;t(d||(d=Da(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=Oa(p,!0);if(!r.filter(new Mo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new Mo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s})}function bp(e,t){return t-e}function wp(e,t,n,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}function Tp(e,t,i,n,r){switch(t){case 1:return function(e,t,i,n){const r=[];for(const o of e)for(const e of o){const o=0===n?e.x:e.y;o>=t&&o<=i&&r.push([e])}return r}(e,i,n,r);case 2:return Cp(e,i,n,r,!1);case 3:return Cp(e,i,n,r,!0)}return[]}function Ep(e,t,n,r,o){const s=0===r?Sp:Bp;let a=[];const l=[];for(let i=0;it&&a.push(s(c,u,t)):h>n?d=t&&(a.push(s(c,u,t)),p=!0),d>n&&h<=n&&(a.push(s(c,u,n)),p=!0),!o&&p&&(l.push(a),a=[])}const c=e.length-1,u=0===r?e[c].x:e[c].y;return u>=t&&u<=n&&a.push(e[c]),o&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function Cp(e,t,i,n,r){const o=[];for(const s of e){const e=Ep(s,t,i,n,r);e.length>0&&o.push(...e)}return o}function Sp(e,t,n){return new i(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))}function Bp(e,t,n){return new i(e.x+(n-e.y)/(t.y-e.y)*(t.x-e.x),n)}lo("FeatureIndex",vp,{omit:["rawTileData","sourceLayerCoder"]});class Ip extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new Ip(this.x,this.y,this.angle,this.segment)}}function Mp(e,t,i,n,r){if(void 0===t.segment||0===i)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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Pp(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(n.x,r.x,u),d=fi.number(n.y,r.y,u),p=new Ip(h,d,r.angleTo(n),i);return p._round(),!s||Mp(e,p,a,s,t)?p:void 0}l+=o}}function kp(e,t,i,n,r,o,s,a,l){const c=Rp(n,o,s),u=Lp(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Ip(_,A,m,t);i._round(),n&&!Mp(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=Dp(e,h/2,i,n,r,o,s,!0,l)),p}function Op(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=qu(e)),A=zp(h,0,t[0]),v=zp(d,0,t[1]),y=zp(h,t[0],t[2]),x=zp(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=n-x}const C=u.x1,S=u.y1,B=u.x2-C,I=u.y2-S,M=(e,r,o,l)=>{const c=Np(e.stretch-A,y,B,C),u=Vp(e.fixed-b,w,e.stretch,f),h=Np(r.stretch-v,x,I,S),d=Vp(r.fixed-T,E,r.stretch,m),p=Np(o.stretch-A,y,B,C),g=Vp(o.fixed-b,w,o.stretch,f),_=Np(l.stretch-v,x,I,S),M=Vp(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=r.stretch+r.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/B,minFontScaleY:E/a/I,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=Up(h,g,f),t=Up(d,_,m);for(let i=0;i0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?qu(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class Gp{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function Hp(e,t=1,n=!1){const r=Ap.fromPoints(e[0]),o=Math.min(r.width(),r.height());let s=o/2;const a=new Gp([],Qp),{minX:l,minY:c,maxX:u,maxY:h}=r;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,n&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new $p(i.p.x-s,i.p.y-s,s,e)),a.push(new $p(i.p.x+s,i.p.y-s,s,e)),a.push(new $p(i.p.x-s,i.p.y+s,s,e)),a.push(new $p(i.p.x+s,i.p.y+s,s,e)),p+=4)}return n&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Qp(e,t){return t.max-e.max}function $p(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Wa(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Zp;e.aO=void 0,(Zp=e.aO||(e.aO={}))[Zp.center=1]="center",Zp[Zp.left=2]="left",Zp[Zp.right=3]="right",Zp[Zp.top=4]="top",Zp[Zp.bottom=5]="bottom",Zp[Zp["top-left"]=6]="top-left",Zp[Zp["top-right"]=7]="top-right",Zp[Zp["bottom-left"]=8]="bottom-left",Zp[Zp["bottom-right"]=9]="bottom-right";const Wp=Number.POSITIVE_INFINITY;function qp(e,t){return t[1]!==Wp?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Kp(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*lu);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Dt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*lu,Wp]:r.get("text-offset").evaluate(t,{},i).map(e=>e*lu);const o=[];for(const e of s)o.push(e,qp(e,n));return new Dt(o)}return null}function Xp(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 Jp(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=ef(n.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=r&&r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),S=f.get("symbol-placement"),B=x/2,M=f.get("icon-text-fit");let P;r&&"none"!==M&&(t.allowVerticalPlacement&&n.vertical&&(P=Ku(r,n.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(r=Ku(r,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,n);let S,B,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=da("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new jp(c,i,u,h,d,r.vertical,p,f,m,e),a&&(M=new jp(c,i,u,h,d,a,_,A,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{}),r="none"!==l.layout.get("icon-text-fit"),s=Op(o,n,w,r),p=a?Op(a,n,w,r):void 0;B=new jp(c,i,u,h,d,o,_,A,!1,n),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Xu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Ju&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Xu*b.compositeIconSizes[0].evaluate(x,{},T),Xu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ju||m[1]>Ju)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ay.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ay.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(r.horizontal);for(const n of U){const o=r.horizontal[n];if(!S){z=da(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);S=new jp(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=Yp(t,i,o,s,l,m,x,g,C,r.vertical?e.ay.horizontal:e.ay.horizontalOnly,a?U:[n],O,k,b,T),a)break}r.vertical&&(F+=Yp(t,i,r.vertical,s,l,m,x,g,C,e.ay.vertical,["vertical"],O,D,b,T));const N=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=B?B.boxStartIndex:t.collisionBoxArray.length,$=B?B.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(S,q),q=K(I,q),q=K(B,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/lu),t.glyphOffsetArray.length>=ah.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Kp(l,x,T),[Y,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,n,r,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===S)for(const e of wp(i.geometry,0,0,I,I)){const i=dc(e,R),o=kp(i,x,T,n.vertical||g,r,24,y,t.overscaling,I);for(const e of o)g&&tf(t,g.text,B,e)||L(i,e)}else if("line-center"===S){for(const e of i.geometry)if(e.length>1){const t=dc(e,R),i=Fp(t,T,n.vertical||g,r,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Hp(e,16);L(dc(e[0],R,!0),new Ip(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=dc(e,R);L(t,new Ip(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Ip(t.x,t.y,0))}function Yp(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(lu-r.metrics.width*r.scale)/2:(r.scale-1)*lu)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[r.x+g,r.y]:[0,0];let A=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=r.metrics.isDoubleResolution?2:1,x=(r.metrics.left-h)*r.scale-g+A[0],b=(-r.metrics.top-h)*r.scale+A[1],w=x+s.w/v*r.scale/p,T=b+s.h/v*r.scale/p,E=new i(x,b),C=new i(w,b),S=new i(x,T),B=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),S._matMult(i),B._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:S,br:B,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[Xu*o.layout.get("text-size").evaluate(a,{})],A[0]>Ju&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[Xu*f.compositeTextSizes[0].evaluate(a,{},m),Xu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Ju||A[1]>Ju)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function ef(e){for(const t in e)return e[t];return null}function tf(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nf[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new rf(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=nf.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 of(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)cf(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];cf(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function of(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;sf(e,t,s,n,r,o),of(e,t,i,n,s-1,1-o),of(e,t,i,s+1,r,1-o)}function sf(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);sf(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(af(e,t,n,i),t[2*r+o]>s&&af(e,t,n,r);as;)l--}t[2*n+o]===s?af(e,t,n,l):(l++,af(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function af(e,t,i,n){lf(e,i,n),lf(t,2*i,2*n),lf(t,2*i+1,2*n+1)}function lf(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function cf(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}var uf;e.cG=void 0,(uf=e.cG||(e.cG={})).create="create",uf.load="load",uf.fullLoad="fullLoad";let hf=null,df=[];const pf=1e3/60,ff="loadTime",mf="fullLoadTime",gf={mark(e){performance.mark(e)},frame(e){const t=e;null!=hf&&df.push(t-hf),hf=t},clearMetrics(){hf=null,df=[],performance.clearMeasures(ff),performance.clearMeasures(mf);for(const t in e.cG)performance.clearMarks(e.cG[t])},getPerformanceMetrics(){performance.measure(ff,e.cG.create,e.cG.load),performance.measure(mf,e.cG.create,e.cG.fullLoad);const t=performance.getEntriesByName(ff)[0].duration,i=performance.getEntriesByName(mf)[0].duration,n=df.length,r=1/(df.reduce((e,t)=>e+t,0)/n/1e3),o=df.filter(e=>e>pf).reduce((e,t)=>e+(t-pf)/pf,0);return{loadTime:t,fullLoadTime:i,fps:r,percentDroppedFrames:o/(n+o)*100,totalFrames:n}}};e.$=h,e.A=p,e.B=oo,e.C=eo,e.D=Vo,e.E=_e,e.F=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.G=fi,e.H=Mo,e.I=Ou,e.J=io,e.K=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.L=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new _h(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Ah):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:po(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(fo(i.error)):t.resolve(fo(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=fo(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?po(t):null,data:po(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.M=le,e.N=function(){var e=new p(16);return p!=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},e.O=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.P=i,e.Q=function(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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},e.R=Al,e.S=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.T=Sl,e.U=function(e,t){const i={};for(let n=0;n0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0;if((o||s)&&(t=Object.assign({},t),e.set(i.id,t),o&&(t.geometry=i.newGeometry),s)){if(t.properties=i.removeAllProperties?{}:Object.assign({},t.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete t.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:n}of i.addOrUpdateProperties)t.properties[e]=n}}},e.a9=yp,e.aA=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.aB=S,e.aC=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aD=function(e){return e[0]=0,e[1]=0,e},e.aE=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aF=nh,e.aG=T,e.aH=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.aI=wp,e.aJ=Va,e.aK=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return[t,i,n,r]},e.aL=lu,e.aM=M,e.aN=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians: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]}return[r?i[0]:M(t,i[0],e.zoom),r?i[1]:M(t,i[1],e.zoom)]},e.aP=eh,e.aQ=Xp,e.aR=Vu,e.aS=rf,e.aT=es,e.aU=ac,e.aV=zs,e.aW=ta,e.aX=Xs,e.aY=te,e.aZ=Bh,e.a_=v,e.aa=Ih,e.ab=Ap,e.ac=25,e.ad=Ph,e.ae=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.af=Me,e.ag=function(){return U++},e.ah=Ss,e.ai=ah,e.aj=dr,e.ak=Oa,e.al=Uh,e.am=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;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},e.an=D,e.ao=85.051129,e.ap=ee,e.aq=function(e){return Math.pow(2,e)},e.ar=m,e.as=Eh,e.at=function(e){return Math.log(e)/Math.LN2},e.au=function(e){var t=e[0],i=e[1];return t*t+i*i},e.av=class{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}},e.aw=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,n=-1/0,r=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,u=Math.pow(2,t-c),h=e*u,d=l*u;s.push({id:a,x:h,y:d}),hn&&(n=h),do&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==n&&e.y!==r&&e.y!==o||a.add(e.id);return a},e.ax=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?D(di.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.az=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/Xu:"composite"===e.kind?fi.number(n/Xu,r/Xu,i):t},e.b=W,e.b$=class extends _a{constructor(e,t){super(e,t),this.current=xa}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.b0=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.b1=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b2=function(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.b3=x,e.b4=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b5=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},e.b6=_,e.b7=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.b8=w,e.b9=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},e.bA=C,e.bB=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=r*c-o*l,h=o*a-n*c,d=n*l-r*a;return e[0]=a+s*(u+=u)+r*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-n*d,e[2]=c+s*d+n*h-r*u,e},e.bC=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/n),f},e.bD=yh,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bG=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bH=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bI=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.bJ=function(e,t){const i=P(e,360),n=P(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)0?s:-s},e.bM=function(e,t){const i=P(e,2*Math.PI),n=P(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bN=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const n=Ae.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bO=ue,e.bP=mo,e.bQ=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n"raster"===e.type,e.bU=j,e.bV=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!xe(e.version,t.version))return[{command:"setStyle",args:[t]}];xe(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),xe(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),xe(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),xe(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),xe(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),xe(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),xe(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),xe(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),xe(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),xe(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),xe(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),xe(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),xe(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),xe(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const n={},r=[];!function(e,t,i,n){let r;for(r in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(t,r)||Te(r,i,n));for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(Object.prototype.hasOwnProperty.call(e,r)?xe(e[r],t[r])||("geojson"===e[r].type&&"geojson"===t[r].type&&Ce(e,t,r)?be(i,{command:"setGeoJSONSourceData",args:[r,t[r].data]}):Ee(r,t,i,n)):we(r,t,i))}(e.sources,t.sources,r,n);const o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Be),r=t.map(Be),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bm=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),_=(a=n[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Ct,e.bp=Aa,e.bq=lc,e.br=cc,e.bs=sc,e.bt=R,e.bu=L,e.bv=zt,e.bw=function(e,t,i,n,r){return R(n,r,D((e-t)/(i-t),0,1))},e.bx=P,e.by=function(){return new Float64Array(3)},e.bz=function(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e},e.c=oe,e.c$=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},e.c0=ya,e.c1=class extends _a{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c2=class extends _a{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c3=f,e.c4=function(e,t){var i=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=i,e[2]=0,e[3]=-i,e[4]=n,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c5=function(e,t,i){var n=t[0],r=t[1],o=t[2];return e[0]=n*i[0]+r*i[3]+o*i[6],e[1]=n*i[1]+r*i[4]+o*i[7],e[2]=n*i[2]+r*i[5]+o*i[8],e},e.c6=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),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]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.c7=class extends _a{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i25||n<0||n>=1||i<0||i>=1)},e.cD=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},e.cE=class extends ns{},e.cF=gf,e.cH=function(e){return e.message===re},e.cI=ce,e.cJ=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cK=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cL=function(e,t){const i={};for(let n=0;ne*lu)}let y=a?"center":n.get("text-justify").evaluate(r,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(r,{},t.canonical)*lu:1/0,x=()=>{t.bucket.allowVerticalPlacement&&yo(o)&&(f.vertical=Nu(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ay.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cZ=Ic,e.c_=_p,e.ca=su,e.cb=class extends _s{},e.cc=vl,e.cd=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.ce=yl,e.cf=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.cg=class extends rs{},e.ch=class extends Ts{},e.ci=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.cj=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],S=t[8],B=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=d*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-S)<=d*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-B)<=d*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.ck=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},e.cl=e=>"symbol"===e.type,e.cm=e=>"circle"===e.type,e.cn=e=>"heatmap"===e.type,e.co=e=>"line"===e.type,e.cp=e=>"fill"===e.type,e.cq=e=>"fill-extrusion"===e.type,e.cr=e=>"hillshade"===e.type,e.cs=e=>"color-relief"===e.type,e.ct=e=>"background"===e.type,e.cu=e=>"custom"===e.type,e.cv=F,e.cw=function(e,t,i){const n=B(t.x-i.x,t.y-i.y),r=B(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.cx=k,e.cy=function(e,t){return ne[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cz=function(e,t){return ie[t]&&"touches"in e},e.d=de,e.d0=function(e,i,n,r,o){return t(this,void 0,void 0,function*(){if(h())try{return yield K(e,i,n,r,o)}catch(e){}return function(e,t,i,n,r){const o=e.width,s=e.height;X&&J||(X=new OffscreenCanvas(o,s),J=X.getContext("2d",{willReadFrequently:!0})),X.width=o,X.height=s,J.drawImage(e,0,0,o,s);const a=J.getImageData(t,i,n,r);return J.clearRect(0,0,o,s),a.data}(e,i,n,r,o)})},e.d1=Bl,e.d2=n,e.d3=ir,e.d4=Io,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>{n.src=q})},n.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 r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new xu(e).readFields(Lu,[])},e.p=Du,e.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.r=_l,e.s=Y,e.t=$o,e.u=Ae,e.v=Yr,e.w=H,e.x=ko,e.y=to,e.z=Ro}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bS(i,n);t._featureFilter=e.aj(t.filter,n),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const i=t.map(e=>this._layers[e.id]),n=i[0];if("none"===n.visibility)continue;const r=n.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const s=n.sourceLayer||e.a9;let a=o[s];a||(a=o[s]=[]),a.push(i)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.r({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.r.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cM("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.a1(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ah;const l=new e.cN(Object.keys(t.layers).sort()),c=new e.cO(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;ee.id)))}}const p=e.bX(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const y=h.dashDependencies;let v=Promise.resolve({});if(Object.keys(y).length){const e=new AbortController;this.inFlightDependencies.push(e),v=s.sendAsync({type:"GDA",data:{dashes:y}},e)}const[x,b,w,T]=yield Promise.all([f,g,A,v]),E=new i(x),C=new e.cP(b,w);for(const t in u){const i=u[t];i instanceof e.ai?(r(i.layers,this.zoom,o),e.cQ({bucket:i,glyphMap:x,glyphPositions:E.positions,imageMap:b,imagePositions:C.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cR||i instanceof e.cS||i instanceof e.cT)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,C.patternPositions,T))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:E.image,imageAtlas:C,dashPositions:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?E.positions:null}})}}function r(t,i,n){const r=new e.H(i);for(const e of t)e.recalculate(r,n)}class o extends e.cW{constructor(t,i){super(new e.cV,0,i,[],[]),this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],i=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of i){const i=[];for(const t of n)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}class s extends e.cU{constructor(t,i){super(new e.cV),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=i?i.version:1,this.extent=i?i.extent:4096,this.length=t.length,this.features=t}feature(e){return new o(this.features[e],this.extent)}}function a(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n>31}function d(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(u(1,i));const a=3===n?s.length-1:s.length;for(let e=0;et.map(t=>new e.P(t.x,t.y)))}}class m extends e.cU{constructor(t,i,n){super(new e.cV),this.version=2,this._myFeatures=t,this.name=i,this.length=t.length,this.extent=n}feature(e){return this._myFeatures[e]}}class g{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _(t){let i=function(t){const i=new e.cV;return function(e,t){for(const i in e.layers)t.writeMessage(3,a,e.layers[i])}(t,i),i.finish()}(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function A(t,i,n){const{extent:r}=t,o=Math.pow(2,n.z-i.z),s=(n.x-i.x*o)*r,a=(n.y-i.y*o)*r,l=[];for(let i=0;i0&&l.addLayer(r)}const u=_(l);return this.overzoomedTileResultCache.set(s,u),u}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[i];if(n.showCollisionBoxes=t.showCollisionBoxes,"parsing"===n.status){const r=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:n,cacheControl:s,resourceTiming:a}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:n.slice(0),encoding:t.encoding},r,s,a)}else o=r;return o}if("done"===n.status&&n.vectorTile)return n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class v{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.d0(r,-1,-1,c,u)):r,d=new e.d1(i,h,n,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var x,b,w=function(){if(b)return x;function e(e,i){if(0!==e.length){t(e[0],i);for(var n=1;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}return b=1,x=function t(i,n){var r,o=i&&i.type;if("FeatureCollection"===o)for(r=0;re},C=Math.fround||(S=new Float32Array(1),e=>(S[0]=+e,S[0]));var S;class B{constructor(e){this.options=Object.assign(Object.create(E),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(P(i),R(o),P(r),R(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?I(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=M(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=P(n),u=R(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function I(e,t,i){return{type:"Feature",id:e[t+3],properties:M(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),L(e[t+1])]}};var n}function M(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function P(e){return e/360+.5}function R(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function F(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&F(e,t,s,n),e[s+2]=r,i-s>3&&F(e,s,i,n))}function k(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function D(e,t,i,n){const r={id:null==e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)O(r,i);else if("Polygon"===t)O(r,i[0]);else if("MultiLineString"===t)for(const e of i)O(r,e);else if("MultiPolygon"===t)for(const e of i)O(r,e[0]);return r}function O(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,F(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function V(e,t,i,n){for(let r=0;r1?1:i}function H(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)Q(e,u,i,n,r);else if("LineString"===o)$(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)W(e,u,i,n,r,!1);else if("Polygon"===o)W(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];W(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(D(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(D(t.id,o,u,t.tags))}}return l.length?l:null}function Q(e,t,i,n,r){for(let o=0;o=i&&s<=n&&q(t,e[o],e[o+1],e[o+2])}}function $(e,t,i,n,r,o,s){let a=Z(e);const l=0===r?K:X;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=Z(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&q(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Z(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function W(e,t,i,n,r,o){for(const s of e)$(s,t,i,n,r,o,!1)}function q(e,t,i,n){e.push(t,i,n)}function K(e,t,i,n,r,o){const s=(o-t)/(n-t);return q(e,o,i+(r-i)*s,1),s}function X(e,t,i,n,r,o){const s=(o-i)/(r-i);return q(e,t+(n-t)*s,o,1),s}function J(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=ie(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=H(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=H(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=H(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=H(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=H(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=H(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ae(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ee(this.tiles[a],r):null):null}}function ae(e,t,i){return 32*((1<`${e.key}: ${e.message}`).join(", "));const r=t.features.filter(e=>n.value.evaluate({zoom:0},e));return this._toFeatureCollection(r)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}function ce(t,i){return i.cluster?new B(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.d3(s),l=e.d3("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(t.features):function(e,t){return new se(e,t)}(t,i.geojsonVtOptions)}class ue{constructor(t){this.self=t,this.actor=new e.L(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=t=>{e.d4.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d4.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new y(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new le(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new v),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue}),i("index",["exports","./shared"],function(e,t){var i="5.13.0";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o,s;const a={frame(e,i,n){const r=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(r),n(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)},set prefersReducedMotion(e){s=e}},l=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class u{static testProp(e){if(!u.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",u.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=u.getScale(e);return u.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=u.getScale(e);for(let r=0;r{d&&g(d),d=null,m=!0},p.onerror=()=>{f=!0,d=null},p.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{h.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:c}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?l(i,c):t.m(i,c);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},l=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(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."))},o.src=s})}(_||(_={})),_.resetRequestQueue();class A{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function y(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:n,url:r}))}}return t}function v(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function x(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,r&&r.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,r&&r.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const n of e){let e=this.getImage(n);e||(this.fire(new t.l("styleimagemissing",{id:n})),e=this.getImage(n)),e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${n}" 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.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const w=1e20;function T(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new S.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[n,r]of Object.entries(t))new RegExp(`\\b${n}\\b`,"i").test(e)&&(i=`${r}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF&&(t.tinySDF=null),t.ideographTinySDF&&(t.ideographTinySDF=null),t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}S.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},S.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(w,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}T(_,0,0,c,u,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[F]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(a.hardwareConcurrency/2);let O,z;function U(){return O||(O=new k),O}k.workerCount=t.K(globalThis)?Math.max(Math.min(D,3),1):1;class N{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function V(){return z||(z=new N(U(),t.M),z.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),z}function j(e,i){const n=t.N();return t.O(n,n,[1,1,0]),t.Q(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.S(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function G(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(H);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e.getState(),n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,j(o,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])Q(n,t);return e}(function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function H(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function Q(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function $(e,i,n){return t._(this,void 0,void 0,function*(){let r=e;if(e.url?r=(yield t.j(i.transformRequest(e.url,"Source"),n)).data:yield a.frameAsync(n),!r)return null;const o=t.U(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map(e=>e.id)),o})}class Z{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(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 t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.V)r=e,o=e;else{if(!(e instanceof Z))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Z.convert(e)):this.extend(t.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.V.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.V(r.lng,r.lat),this._ne=new t.V(o.lng,o.lat)),this}getCenter(){return new t.V((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 t.V(this.getWest(),this.getNorth())}getSouthEast(){return new t.V(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:i,lat:n}=t.V.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}intersects(e){if((e=Z.convert(e)).getNorth()this.getNorth())return!1;const i=t.W(this.getWest(),-180,180),n=t.W(this.getEast(),-180,180),r=t.W(e.getWest(),-180,180),o=t.W(e.getEast(),-180,180),s=i>n,a=r>o;return!(!s||!a)||(s?o>=i||r<=n:a?n>=r||i<=o:!(r>n||oi.lng?new t.V(i.lng+360,i.lat):i)}}class W{constructor(e,t,i){this.bounds=Z.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 i=Math.pow(2,e.z),n=Math.floor(t.Y(this.bounds.getWest())*i),r=Math.floor(t.X(this.bounds.getNorth())*i),o=Math.ceil(t.Y(this.bounds.getEast())*i),s=Math.ceil(t.X(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class K extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,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=t.e({type:"raster"},i),t.e(this,t.U(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield $(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new W(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield _.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class X extends K{constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield _.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.Z()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.$()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.a0(e,-1,-1,i,n))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.a1(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a1(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}function Y(e){const t=new Z;let i;switch(e.type){case"FeatureCollection":i=e.features.map(e=>J(e.geometry)).flat(1/0);break;case"Feature":i=J(e.geometry);break;default:i=J(e)}if(0==i.length)return t;for(let e=0;e0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(i)})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyDiff(e){const i="string"==typeof this.promoteId?this.promoteId:void 0;this._data.url||this._data.updateable||!t.a6(this._data.geojson,i)||(this._data={updateable:t.a7(this._data.geojson,i)}),e&&this._data.updateable?t.a8(this._data.updateable,e,i):t.w("Cannot apply GeoJSONSource#updateData due to internal error")}_getShouldReloadTileOptions(e){if(this._options.cluster||!e||e.removeAll)return;const{add:i=[],update:n=[],remove:r=[]}=e||{},o=new Set([...n.map(e=>e.id),...r]);for(const e of o.values())if("number"!=typeof e&&null==this.promoteId)return void t.w(`GeoJSONSource "${this.id}": updateData is slower when using string GeoJSON feature IDs (e.g. "${e}"). Consider using promoteId or numeric IDs for better performance.`);return{nextBounds:[...n.map(e=>e.newGeometry),...i.map(e=>e.geometry)].filter(Boolean).map(e=>Y(e)),prevIds:o}}shouldReloadTile(e,{nextBounds:i,prevIds:n}){if(!e.latestFeatureIndex)return"unloaded"!==e.state;const r=e.latestFeatureIndex.loadVTLayers();for(let i=0;i{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.aa.fromLngLat);var n;return this.tileID=function(e){const i=t.ab.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.ad(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.ab.fromPoints(e),s={};for(let e=0;e<=t.ac;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class ie extends te{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.ae(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.af(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.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,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ne extends te{constructor(e,i,n,r){super(e,i,n,r),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 t.k(new t.af(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.af(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.af(`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 t.k(new t.af(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(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 i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0});let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.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}}const re={},oe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return X;case"vector":return q;case"video":return ie;case"canvas":return ne}return re[e]},se="RTLPluginLoaded";class ae extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=V()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(se))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let le=null;function ce(){return le||(le=new ae),le}var ue,he;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(ue||(ue={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(he||(he={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ag(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:n}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=n}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,n){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ah}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=r[t.a9]||r[o];if(!s)return;const a=t.aj(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=ve(n,T,r);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||we)(e.zoom+t.at(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const S=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=S){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const Ce=t.ab.fromPoints([new t.P(0,0),new t.P(t.a4,t.a4)]);class Se extends t.E{constructor(e,i,n){super(),this.id=e,this.dispatcher=n,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(oe(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,i,n,this),this._tiles={},this._cache=new t.av(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}getState(){return this._state}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,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,n)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}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)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Be).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const n=e.tileID,r=i.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(Be).map(e=>e.key)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._isIdRenderable(i.tileID.key)}return!1}_isIdRenderable(e,t=!1){var i;return null===(i=this._tiles[e])||void 0===i?void 0:i.isRenderable(t)}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)t&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[i],t)||(e?this._reloadTile(i,"expired"):"errored"!==this._tiles[i].state&&this._reloadTile(i,"reloading"))}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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){const i=this._getLoadedDescendents(t),n=new Set;for(const r of t){const t=i[r.key];if(!(null==t?void 0:t.length)){n.add(r);continue}const o=r.overscaledZ+Se.maxOverzooming,s=t.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){n.add(r);continue}const a=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,r.overscaledZ)||n.add(r)}return n}_getLoadedDescendents(e){var t;const i={};for(const n in this._tiles){const r=this._tiles[n];if(r.hasData())for(const n of e)r.tileID.isChildOf(n)&&(i[t=n.key]||(i[t]=[])).push(r)}return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){const t=this._tiles[e.key];return(null==t?void 0:t.hasData())?t:null}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e,this._resetTileReloadTimers()}}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a1(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ee(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[],this.usedForTerrain&&(n=this._addTerrainIdealTiles(n));const r=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=Te(e,this._source),s=this._updateRetainedTiles(n,o),a=Ie(this._source.type);a&&this._rasterFadeDuration>0&&!i&&this._updateFadingTiles(n,s),a?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(e){for(const t in this._tiles)e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t in this._tiles){const i=this._tiles[t];e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(n)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n=new Set;for(const t of e)this._addTile(t).hasData()||n.add(t);const r=e.reduce((e,t)=>(e[t.key]=t,e),{}),o=this._retainLoadedChildren(r,n),s={},a=Math.max(t-Se.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._tiles[e.key],n=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&n&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=t.wasRequested(),e)break}}}return r}_updateFadingTiles(e,i){const n=c(),r=t.aw(e);for(const t of e){const e=this._tiles[t.key];e.fadingDirection!==he.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,i,n)||this._updateFadingDescendents(e,i,n)||this._updateFadingEdge(e,r,n)||e.resetFadeLogic()}}_updateFadingAncestor(e,t,i){if(!e.hasData())return!1;const{tileID:n,fadingRole:r,fadingDirection:o,fadingParentID:s}=e;if(r===ue.Base&&o===he.Incoming&&s)return t[s.key]=s,!0;const a=Math.max(n.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let r=n.overscaledZ-1;r>=a;r--){const o=n.scaledTo(r),s=this.getLoadedTile(o);if(s)return e.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Incoming,fadingParentID:s.tileID,fadeEndTime:i+this._rasterFadeDuration}),s.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Departing,fadeEndTime:i+this._rasterFadeDuration}),t[o.key]=o,!0}return!1}_updateFadingDescendents(e,t,i){if(!e.hasData())return!1;const n=e.tileID.children(this._source.maxzoom);let r=this._updateFadingChildren(e,n,t,i);if(r)return!0;for(const o of n){const n=o.children(this._source.maxzoom);this._updateFadingChildren(e,n,t,i)&&(r=!0)}return r}_updateFadingChildren(e,t,i,n){if(t[0].overscaledZ>=this._source.maxzoom)return!1;let r=!1;for(const o of t){const t=this.getLoadedTile(o);if(!t)continue;const{fadingRole:s,fadingDirection:a,fadingParentID:l}=t;s===ue.Base&&a===he.Departing&&l||(t.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Departing,fadingParentID:e.tileID,fadeEndTime:n+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Incoming,fadeEndTime:n+this._rasterFadeDuration})),i[o.key]=o,r=!0}return r}_updateFadingEdge(e,t,i){const n=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(n)&&(e.setSelfFadeLogic(i+this._rasterFadeDuration),!0)}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const n=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,n||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){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])}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._clearTileReloadTimer(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))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.ab.fromPoints(u);for(let e=0;ee.getTilePoint(new t.aa(i.x,i.y)));if(i.expandBy(p),i.intersects(Ce)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.ab.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.ab.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.aa(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(Ie(this._source.type)&&this._rasterFadeDuration>0){const e=c();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,n){this._state.updateState(e=e||t.a9,i,n)}removeFeatureState(e,i,n){this._state.removeFeatureState(e=e||t.a9,i,n)}getFeatureState(e,i){return this._state.getState(e=e||t.a9,i)}setDependencies(e,t,i){const n=this._tiles[e];n&&n.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))}}function Be(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ie(e){return"raster"===e||"image"===e||"video"===e}Se.maxUnderzooming=10,Se.maxOverzooming=3;class Me{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Re{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e0}hitTestCircle(e,t,i,n,r){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!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=r[h+2]&&t<=r[h+3]&&i>=r[h+0]&&n>=r[h+1]&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))&&(o.push({key:d,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const d=this.circleCells[r];if(null!==d){const r=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Le(e,i,r){const o=t.N();if(!e){const{vecSouth:e,vecEast:t}=ke(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.Q(o,o,[1/r,1/r,1]),o}function Fe(e,i,n,r){if(e){const e=t.N();if(!i){const{vecSouth:t,vecEast:i}=ke(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.Q(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function ke(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.aB();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.aC(a);l<1e-9?t.aD(a):t.aE(a,a,1/l);const c=t.aB();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.aC(c);return u<1e-9?t.aD(c):t.aE(c,c,1/u),{vecEast:c,vecSouth:a}}function De(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aG(o,o,n)):(o=[e,i,0,1],Ye(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Oe(e,t){return.5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Ue(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.ax(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let n=0;nMath.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ay.vertical?i.yn.x)?{needsFlipping:!0}:null}function je(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=Ne(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=$e(c.first.point.x,c.first.point.y,i,n),_=$e(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Ve(r.writingMode,g,_,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n0?a.point:Ge(i.tileAnchorPoint,s,e,1,i),c=$e(e.x,e.y,i,n),h=$e(l.x,l.y,i,n),d=Ve(r.writingMode,c,h,u);if(d)return d}const e=Ke(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.aF(c,e.point,e.angle);return{}}function Ge(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=Qe(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function He(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Qe(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded=r.anyProjectionOccluded||s.isOccluded,s.point;const a=e-n.direction;return Ge(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function Qe(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=De(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function $e(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aG(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function We(e,t,i){return e._unit()._perp()._mult(t*i)}function qe(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=He(e+c.direction,l,c),d=We(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.aH(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ke(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=Qe(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=He(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const n=g.sub(_);t=0===n.mag()?We(He(p+u,a,e).sub(g),i,u):We(n,i,u),m||(m=_.add(t)),f=qe(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const Xe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Je(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.xr.x||i.yr.y?[]:t.aI([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=De(e.x,e.y,n,i.getElevation),r=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height,r})}(e,i);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;oi&&(i=r,t=n));return e.slice(t,t+i)}(n)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.ab;for(const r of e){const e=new t.P(r.x+et,r.y+et);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aJ(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));I=e.some(e=>!e.isOccluded),B=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aK(B),allPointsOccluded:!I}}}class it{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class nt{constructor(e,t,i,n,r){this.text=new it(e?e.text:null,t,i,r),this.icon=new it(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class rt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class ot{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class st{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 at(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aR(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class lt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new tt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new st(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.a4,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aM(n,1,this.transform.zoom),m=t.aN(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aN(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Le(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ot(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.ax(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aO[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=at(x,n,r,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:r,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aP(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aP(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!r.hasIconData()||g),C=v&&(A||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const S=this.retainedQueryData[r.bucketInstanceId].tileID,B=this._getTerrainElevationFunc(S),I=this.transform.getFastPathSimpleProjectionMatrix(S),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new rt(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let n=t.ay.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ay.vertical?(k=n(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,u,S,l,b,x,s,f.predicate,B,void 0,I);return n&&n.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(G,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ay.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aO[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ay.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.az(r.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,b,f.predicate,e.collisionCircleDiameter,u,s,B),z.circles.length&&z.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,S,l,b,x,a,f.predicate,B,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),r.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),r.bucketInstanceId,N,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new rt((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ay.horizontal||i===t.ay.horizontalOnly?i:0,o=i===t.ay.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new nt(o,n,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new nt(null,n,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new nt(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new nt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new nt(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n0,A=this.placedOrientations[r.crossTileID],y=A===t.ay.vertical,v=A===t.ay.horizontal||A===t.ay.horizontalOnly;if(o>0||s>0){const t=_t(c.text);m(e.text,o,y?At:t),m(e.text,s,v?At:t);const i=c.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(e,n.anchor,r,A);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(e,"left",r,a),this.markUsedOrientation(e,a,r))}if(_){const t=_t(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:At),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?At:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=at(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=y),n.verticalTextBox&&(r=v),ct(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,x.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!v&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),ct(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),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.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function ct(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-et,a=n[1]-et,l=n[2]-et,c=n[3]-et;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const ut=Math.pow(2,25),ht=Math.pow(2,24),dt=Math.pow(2,17),pt=Math.pow(2,16),ft=Math.pow(2,9),mt=Math.pow(2,8),gt=Math.pow(2,1);function _t(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*ut+t*ht+i*dt+t*pt+i*ft+t*mt+i*gt+t}const At=0;class yt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&c()-n>2;for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new yt(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xt=512/t.a4/2;class bt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*xt),y:Math.floor(e.anchorY*xt)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aS(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=xt/Math.pow(2,l-o),u=(a*t.a4+e.anchorY)*c,h=r*t.a4*xt;return{x:Math.floor((s*t.a4+e.anchorX)*c-n*t.a4*xt),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.ze)}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Tt{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Ct="void main() {fragColor=vec4(1.0);}";const St={prelude:Bt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Bt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Bt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Bt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Bt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Bt("in 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\nvoid 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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out 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\nvoid 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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Bt(Ct,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Bt("uniform 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Bt("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Bt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Bt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Bt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Bt(Ct,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Bt("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Bt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Bt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Bt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Bt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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:Bt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Bt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;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 float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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\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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\nvoid main() {\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\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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.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_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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#ifdef GLOBE\nout float v_depth;\n#endif\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\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_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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 floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\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 floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\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 floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Bt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;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;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Bt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Bt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;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\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\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 inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Bt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;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\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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;if (u_is_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);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Bt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Bt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Bt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Bt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Bt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Bt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Bt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class It{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Mt=t.aT([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Rt="mercator";class Lt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Rt}get shaderDefine(){return Pt}get shaderPreludeCode(){return St.projectionMercator}get vertexShaderPreludeCode(){return St.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aU.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(t.a4,0),s.emplaceBack(0,t.a4),s.emplaceBack(t.a4,t.a4);const a=e.createVertexBuffer(s,Mt.members),l=t.aW.simpleSegment(0,0,4,2),c=new t.aX;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new It(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ft{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.G.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.G.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.G.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.G.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.an((this.left+e-this.right)/2,0,e),r=t.an((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ft(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function kt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Dt(e){return Math.max(0,Math.floor(e))}class Ot{constructor(e,i){var n;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(n=null==i?void 0:i.constrainOverride)&&void 0!==n?n:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ft,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ft(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.W(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aY(this._fovInRadians)}setFov(e){e=t.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aq(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new Z([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.ao,t.ao])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.ab.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ar(new Float64Array(16));t.Q(e,e,[this._width/2,-this._height/2,1]),t.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ar(new Float64Array(16)),t.Q(e,e,[1,-1,1]),t.O(e,e,[-1,-1,0]),t.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,a=t.aa.fromLngLat(e,i),l=-Math.cos(t.ap(s)),c=Math.sin(t.ap(s)),u=c*Math.sin(t.ap(o)),h=-c*Math.cos(t.ap(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aZ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.aa(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.at(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.as(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/i,r=t.aa.fromLngLat(this.center,this.elevation),o=ye(this.center,this.elevation,this.pitch,this.bearing,n);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aZ(o.z,r.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Ut{distanceToTile2d(e,t,i,n){const r=n.distanceX([e,t]),o=n.distanceY([e,t]);return Math.hypot(r,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Nt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),l=[[-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(n=>function(e,i,n,r){const o=t.aG([],e,i),s=1/o[3]/n*r;return t.b5(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.b1([],e[i+s],e[i+o]),r=t.b6(n);t.a_(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.b7(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.b1([],e[i[0]],e[i[1]]),r=t.b1([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.b2(o,t.b3([],n,r)),o[3]=-t.b4(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.b8(e),r=t.b9([],e,1/n),o=t.b1([],i,t.a_([],r,t.b4(i,r))),s=t.b8(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.a_([],r,-r[3]),a=t.a$([],n,t.a_([],o,e/s));return t.ba(i,a)}return null}(n,u);if(null!==h){const e=h/t.b4(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.b1([],l[e[0]],l[e[1]]),n=t.b1([],l[e[2]],l[e[1]]),r=t.b2([],t.b3([],i,n)),o=-t.b4(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Nt(l,c,new zt(u,h))}}class Vt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.an(+i,this.minZoom,this.maxZoom);const n={center:new t.V(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.aq(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.X(e[1])*o,a=t.X(e[0])*o,a-sa&&(_=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.W(f,e-o/2,e+o/2));const n=d/2;i-nc&&(g=c-n)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);n.center=ge(o,e).wrap()}return n},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ut}clone(){const e=new Vt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.bb(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.bb(n,e))}return i}getCameraFrustum(){return Nt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.as(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.aa.fromLngLat(e),a=new t.aa(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.aa.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aa.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aG(r,r,this._pixelMatrixInverse),t.aG(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.aa(t.G.number(r[0]/s,o[0]/a,d)/this.worldSize,t.G.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aG(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-_e(this));return(new Z).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-_e(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.bc(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=Ae(e,this.worldSize);t.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=Ae(e,this.worldSize);return t.S(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ap(this.fov)*(Math.abs(Math.cos(t.ap(this.roll)))*this.height+Math.abs(Math.sin(t.ap(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.an(Math.PI-a-l,.01,Math.PI-.01)),u=_e(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ap(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.an(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.as(1,this.center.lat)*this.worldSize;const o=t.ap(Math.min(this.pitch,fe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.bd(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aA(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.be(a),t.Q(a,a,[1,-1,1]),t.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.bf(a,a,-this.rollInRadians),t.bg(a,a,this.pitchInRadians),t.bf(a,a,-this.bearingInRadians),t.O(a,a,[-n,-r,0]),this._mercatorMatrix=t.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),t.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aA([],a);const l=[0,0,-1,1];t.aG(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.bd(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.bf(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bg(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.bf(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.O(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+h*c+d*u,f=r-Math.round(r)+h*u+d*c,m=new Float64Array(a);if(t.O(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aA(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aG(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.aa.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aG(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&r?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.b0(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aG(s,s,o)):(s=[e,i,0,1],Ye(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.aa.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.bi();return t.O(o,o,[n.x,n.y,n.z]),t.bf(o,o,Math.PI),t.bg(o,o,Math.PI/2),t.Q(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.a1(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=Ae(i,this.worldSize);t.S(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.a4,t.a4,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.Q(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function jt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Gt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bl(r,i,n,e.k);const o=t.bm(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ht(e,i,n,r,o){const s=o.padding,a=me(o.worldSize,n.getNorthWest()),l=me(o.worldSize,n.getNorthEast()),c=me(o.worldSize,n.getSouthEast()),u=me(o.worldSize,n.getSouthWest()),h=t.ap(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void jt();const x=Math.min(t.at(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ap(r)),T=b.add(w).mult(o.scale/t.aq(x));return{center:ge(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:r}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),n=Math.abs(_e(t));return{easingOffset:e.mult(Math.min(.75*n/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Ht(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.V.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.applyConstrain(t.V.convert(i.center||d),null!=u?u:n);kt(e,p);const m=me(e.worldSize,d),g=me(e.worldSize,p).sub(m),_=t.aq(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.G.number(n,f,a)),t.bn(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.aq(e.zoom-n),r=f>n?Math.min(2,_):Math.max(.5,_),o=Math.pow(r,1-a),s=ge(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;kt(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),u=c.mag(),h=t.aq(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.applyConstrain(s,n).zoom;d=t.aq(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.at(n));const h=1===i?s:ge(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class $t{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}$t.Replace=[1,0],$t.disabled=new $t($t.Replace,t.bo.transparent,[!1,!1,!1,!1]),$t.unblended=new $t($t.Replace,t.bo.transparent,[!0,!0,!0,!0]),$t.alphaBlended=new $t([1,771],t.bo.transparent,[!0,!0,!0,!0]);const Zt=2305;class Wt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Wt.disabled=new Wt(!1,1029,Zt),Wt.backCCW=new Wt(!0,1029,Zt),Wt.frontCCW=new Wt(!0,1028,Zt);class qt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const Kt=7680;class Xt{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Xt.disabled=new Xt({func:519,mask:0},0,0,Kt,Kt,Kt);const Jt=new WeakMap;function Yt(e){var t;if(Jt.has(e))return Jt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Jt.set(e,i),i}}class ei{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aV;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aX;o.emplaceBack(0,1,2),this._fullscreenTriangle=new It(i.createVertexBuffer(r,Mt.members),i.createIndexBuffer(o),t.aW.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),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.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Yt(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,qt.disabled,Xt.disabled,$t.unblended,Wt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Yt(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Yt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ei._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const ti=t.a4/128;function ii(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.a4;-1===r&&(o=-ti),r===n+1&&(o=t.a4+ti);let s=i/n*t.a4;-1===i&&(s=e.extendToNorthPole?t.bq:-ti),i===n+1&&(s=e.extendToSouthPole?t.br:t.a4+ti),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ai(e){const t=ui(e.worldSize,e.center.lat);return 2*Math.PI*t}function li(e,i,n,r,o){const s=1/(1<1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.V(t.W(s,-180,180),i)}return new t.V(0,i)}function di(e){return Math.cos(e*Math.PI/180)}function pi(e,i){const n=di(e),r=di(i);return t.at(r/n)}function fi(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+pi(i.center.lat,0),o=t.bt(1/di(i.center.lat),1/di(Math.min(Math.abs(i.center.lat),60)),t.bw(r,7,3,0,1)),s=360/ai({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.V(i.center.lng-n.x*s*o,t.an(i.center.lat+n.y*s,-t.ao,t.ao))}function mi(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function gi(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=mi(s+r*(a-s)),c=mi(s),u=mi(a);return new t.V(e.lng+i*((l-c)/(u-c)),o)}return new t.V(e.lng+i*r,o)}class _i{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class Ai{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new Ai(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.bA([],n[0],n[1],n[2]),o=t.bB([],[i[0],0,0],r),s=t.bB([],[0,i[1],0],r),a=t.bB([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.a$(n,n,t.a_([],o,1&~i?-1:1)),t.a$(n,n,t.a_([],s,1==(i>>1&1)?1:-1)),t.a$(n,n,t.a_([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new Ai(u,[[...o,-t.b4(o,u[0])],[...s,-t.b4(s,u[0])],[...a,-t.b4(a,u[0])],[-o[0],-o[1],-o[2],-t.b4(o,u[7])],[-s[0],-s[1],-s[2],-t.b4(s,u[7])],[-a[0],-a[1],-a[2],-t.b4(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n=0&&o++}if(0===o)return 0;o=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n=0&&i++}return i===t?2:0===i?0:1}}function yi(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function vi(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>1?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,yi(t,n,r))}class xi{constructor(){this._boundingVolumeCache=new _i(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bD,l/=t.bD,a+=1,l+=1,e.z<=0)return Ai.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Ai.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[li(0,0,e.x,e.y,e.z),li(t.a4,0,e.x,e.y,e.z),li(t.a4,t.a4,e.x,e.y,e.z),li(0,t.a4,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.a_([],e,l));if(l!==a)for(const e of i)n.push(t.a_([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<=(1<{const n=t.an(e.lat,-t.ao,t.ao),r=t.an(+i,this.minZoom+pi(0,n),this.maxZoom);return{center:new t.V(e.lng,n),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new xi}clone(){const e=new wi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.b6(u);return t.a_(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ci(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.b3(a,s,o),t.b2(s,s),t.b2(a,a);const l=[0,0,0];return t.b2(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<o&&(o=i),na&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Z(u)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=ci(this.unprojectScreenPoint(i)),r=ci(e),o=t.by();t.bK(o);const s=t.by();t.bH(s,n,o,-this.center.lng*Math.PI/180),t.bG(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(h,e)+t.bM(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bE();return t.aG(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const n=t.b4(e,i),r=t.by(),o=t.by();t.a_(o,i,n),t.b1(r,e,o);const s=1-t.b4(r,r);if(s<0)return null;const a=t.b4(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.by();t.a$(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.by();return t.b2(o,e),hi(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.ba(o,i)/s,l=t.by();if(a>0)t.a$(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.by();t.a$(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.ba(this._cachedClippingPlane,e);t.b1(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.by();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return hi(function(e,i,n){const r=t.by();t.b1(r,n,e);const o=t.by();return t.bz(o,e,r,i/t.b8(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.V.convert(e),r=1/t.bD,o=t.bi();return t.bI(o,o,n.lng/180*Math.PI),t.bg(o,o,-n.lat/180*Math.PI),t.O(o,o,[0,0,1+i/t.bD]),t.bg(o,o,.5*Math.PI),t.Q(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a1(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ti{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Vt,this._verticalPerspectiveTransform=new wi}clone(){const e=new Ti;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bt(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ei{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=fi(e,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bJ(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bJ(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.b4(h,u),p=t.by();t.a$(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.b6(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ui(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bw(g,.9,.5,1,.25),A=(1-t.aq(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.V(i.center.lng+l*A,t.an(i.center.lat+c*A,-t.ao,t.ao));i.setLocationAtPoint(r,n);const b=i.center,w=t.bw(Math.abs(a),45,85,0,1),T=t.bw(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bJ(b.lng,x.lng),S=t.bJ(b.lat,x.lat);i.setCenter(new t.V(b.lng+C*E,b.lat+S*E).wrap()),i.setZoom(v+pi(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(fi(e.panDelta,t).wrap()),t.setZoom(r+pi(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Ht(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bJ(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bJ(d,p),_=f+.5*t.bJ(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ci(n.getNorthWest()),ci(n.getNorthEast()),ci(n.getSouthWest()),ci(n.getSouthEast()),ci(new t.V(p,_)),ci(new t.V(d,_)),ci(new t.V(g,f)),ci(new t.V(g,m))],x=ci(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.at(b),s;jt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.applyConstrain(i.center?t.V.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+pi(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.V.convert(i.center):r,d=e.applyConstrain(h,n).center;kt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+pi(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+pi(r.lat,m.lat),_=n+pi(r.lat,0),A=g+pi(m.lat,0),y=t.bJ(r.lng,m.lng),v=t.bJ(r.lat,m.lat),x=t.aq(A-_);return u=g!==n,{easeFunc:n=>{if(t.bn(s,a)||Gt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-n),o=gi(r,y,v,n*i);e.setCenter(o.wrap())}if(u){const i=t.G.number(_,A,n)+pi(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+pi(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;kt(e,d);const p=function(e,i,n){const r=ci(i),o=ci(n),s=t.b4(r,o),a=Math.acos(s),l=ai(e);return a/(2*Math.PI)*l}(e,r,d),f=o+pi(r.lat,0),m=c+pi(d.lat,0),g=t.aq(m-f);let _;if("number"==typeof i.minZoom){const n=+i.minZoom+pi(d.lat,0),r=Math.min(n,f,m)+pi(0,d.lat),o=e.applyConstrain(d,r).zoom+pi(d.lat,0);_=t.aq(o-f)}const A=t.bJ(r.lng,d.lng),y=t.bJ(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=gi(r,A,y,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.at(o);e.setZoom(1===n?c:m+pi(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.B(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),Bi=t.bN();class Ii extends t.E{constructor(e,i={}){var n,r;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(U(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new b,this.imageManager.setEventedParent(this);const o=(null===(n=e._container)||void 0===n?void 0:n.lang)||"undefined"!=typeof document&&(null===(r=document.documentElement)||void 0===r?void 0:r.lang)||void 0;this.glyphManager=new S(e._requestManager,i.localIdeographFontFamily,o),this.lineAtlas=new L(256,512),this.crossTileSymbolIndex=new Et,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bQ(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const n of e){i[n]=this._globalState[n];for(const e in this._layers){const i=this._layers[e],r=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs();if(r.has(n)&&t.add(i.source),o.has(n))for(const{name:e,value:t}of o.get(n))this._updatePaintProperty(i,e,t)}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const r=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(r,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,n)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(Bi,{validate:!1})}_load(e,i,n){var r,o;let s=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!Si(this,t.C(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new R(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){var e,i,n;const r=t.bR(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",r),this._order=r.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const e of r){const r=t.bS(e,this._globalState);if(r.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=r,t.bT(r)&&this.tileManagers[r.source]){const t=null!==(n=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==n?n:r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,n=void 0){let r;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=y(e),s=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=i.transformRequest(v(n,s,".json"),"SpriteJSON");l[e]=t.j(o,r);const a=i.transformRequest(v(n,s,".png"),"SpriteImage");c[e]=_.getImage(a,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=a.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,r=e,this.fire(new t.k(r))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),n&&n(r)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(n))&&this.fire(new t.k(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bU(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bU(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.tileManagers){const t=this.tileManagers[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in n){const i=this.tileManagers[e];!!n[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&Si(this,t.C(e)))return!1;(e=t.bU(e)).layers=t.bR(e.layers);const o=t.bV(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.C.source,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=this.tileManagers[e]=new Se(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.k(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(Si(this,t.bW(e)))return;o=t.bS(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bU(e),e=t.e(e,{source:r})),this._validate(t.C.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bS(e,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.tileManagers[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bQ(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.C.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bU(i)),this._updateLayer(r)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bU(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getPaintProperty(i),n)||this._updatePaintProperty(o,i,n,r):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,n,r={}){e.setPaintProperty(i,n,r)&&this._updateLayer(e),t.bT(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.tileManagers[n];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.tileManagers[n];if(void 0===r)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.tileManagers[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bX(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bY({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(H);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:r.filter,globalState:r.globalState},r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const n in e)for(const r of e[n])Q(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.C.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.tileManagers[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((r=r||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new vt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.C.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,n]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(n.dasharray,n.round);return e})}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...y(this.stylesheet.sprite),...o];this._validate(t.C.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=y(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return y(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.C.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];if(t.setEventedParent(null),t._tiles){for(const e in t._tiles)t._tiles[e].unloadVectorData();t._tiles={}}t._cache.reset(),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Mi=t.aT([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Li={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Fi(e){const t=[];for(let i=0;i({u_depth:new t.bZ(e,i.u_depth),u_terrain:new t.bZ(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.b$(e,i.u_terrain_matrix),u_terrain_unpack:new t.c0(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.b$(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c0(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c0(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.b$(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=n?n.getUniforms(e,E):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Li[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const n=i.vaos||(i.vaos={});(n[c]||(n[c]=new Pi)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Di(e,i,n){const r=1/t.aM(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Oi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.c3();"viewport"===o.properties.get("anchor")&&t.c4(l,e.transform.bearingInRadians),t.c5(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},zi=(e,i,n,r,o,s,a)=>t.e(Oi(e,i,n,r),Di(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ui=(e,i,n,r)=>t.e(Di(i,e,n),{u_fill_translate:r}),Ni=(e,t)=>({u_world:e,u_fill_translate:t}),Vi=(e,i,n,r,o)=>t.e(Ui(e,i,n,o),{u_world:r}),ji=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aM(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.a4*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Gi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Hi=e=>({u_viewport_size:[e.width,e.height]}),Qi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),$i=(e,i,n,r)=>{const o=t.aM(e,1,i)/(t.a4*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aM(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},Zi=(e,i,n,r)=>{const o=t.N();t.c6(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},Wi=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t{const n=i.stride,r=t.N();return t.c6(r,0,t.a4,-t.a4,0,0,1),t.O(r,r,[0,-t.a4,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ki(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.aa(0,r/n).toLngLat().lat,new t.aa(0,(r+1)/n).toLngLat().lat]}const Xi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Ji=(e,i,n,r)=>{const o=e.transform;return{u_translation:on(e,i,n),u_ratio:r/t.aM(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Yi=(e,i,n,r,o)=>t.e(Ji(e,i,n,r),{u_image:0,u_image_height:o}),en=(e,i,n,r,o)=>{const s=e.transform,a=rn(i,s);return{u_translation:on(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aM(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},tn=(e,i,n,r,o)=>{const s=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},nn=(e,i,n,r,o,s)=>{const a=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_image:0,u_image_height:s,u_tileratio:a,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function rn(e,i){return 1/t.aM(e,1,i.tileZoom)}function on(e,i,n){return t.aN(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const sn=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:an(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function an(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]}const ln=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{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:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},cn=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(ln(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},un=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(cn(e,i,n,r,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),hn=(e,t)=>({u_opacity:e,u_color:t}),dn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aM(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),pn=(e,t)=>{},fn={fillExtrusion:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c2(e,i.u_world),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bZ(e,i.u_scale_with_map),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_extrude_scale:new t.c2(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c2(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c2(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c2(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b_(e,i.u_color),u_overlay:new t.bZ(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:pn,clippingMask:pn,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_color_ramp:new t.bZ(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_latrange:new t.c2(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c8(e,i.u_altitudes),u_azimuths:new t.c8(e,i.u_azimuths),u_accent:new t.b_(e,i.u_accent),u_method:new t.bZ(e,i.u_method),u_shadows:new t.c7(e,i.u_shadows),u_highlights:new t.c7(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_image:new t.bZ(e,i.u_image),u_dimension:new t.c2(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c0(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_unpack:new t.c0(e,i.u_unpack),u_dimension:new t.c2(e,i.u_dimension),u_elevation_stops:new t.bZ(e,i.u_elevation_stops),u_color_stops:new t.bZ(e,i.u_color_stops),u_color_ramp_size:new t.bZ(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_texsize:new t.c2(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.bZ(e,i.u_image),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.bZ(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c2(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.bZ(e,i.u_image0),u_image1:new t.bZ(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c1(e,i.u_spin_weights),u_coords_top:new t.c0(e,i.u_coords_top),u_coords_bottom:new t.c0(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texsize_icon:new t.c2(e,i.u_texsize_icon),u_texture:new t.bZ(e,i.u_texture),u_texture_icon:new t.bZ(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b_(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.bZ(e,i.u_image),u_pattern_tl_a:new t.c2(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c2(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c2(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c2(e,i.u_pattern_br_b),u_texsize:new t.c2(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c2(e,i.u_pattern_size_a),u_pattern_size_b:new t.c2(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.b$(e,i.u_fog_matrix),u_fog_color:new t.b_(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c1(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c1(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.b$(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b_(e,i.u_sky_color),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon:new t.c2(e,i.u_horizon),u_horizon_normal:new t.c2(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class mn{constructor(e,t,i){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||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const gn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class _n{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Gi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.c9;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:B,angle:I})}else Je(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===n.layout.get("text-rotation-alignment");Ue(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?or:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?un(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):cn(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):ln(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:B,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aW([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,hr(i.buffers,t.segments,n,e,i.program,w,h,d,r,i.projectionData,t.terrainData)),r.u_is_halo=0}hr(i.buffers,t.segments,n,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function hr(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,Wt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function dr(e,i,n,r,o){const s=e.context,a=s.gl,l=Xt.disabled,c=new $t([a.ONE,a.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=fr(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,qt.disabled,l,c,Wt.disabled,$i(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function pr(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=mr(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Zi(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function fr(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function mr(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function gr(e,i,n,r,o,s,a,l){let c=256;if(o.stepInterpolant){const r=i.getSource().maxzoom,o=a.canonical.z===r?Math.ceil(1<20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),M=f.getProjectionData({overscaledTileID:b,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),P=sn(S,C,B.fadeMix,i,a),R=m.getMeshFromTileID(h,b.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,n,r?r[b.overscaledZ]:Xt.disabled,g,l?Wt.frontCCW:Wt.backCCW,P,I,M,i.id,R.vertexBuffer,R.indexBuffer,R.segments)}}function Br(e,i,n,r){const o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===n||r)return o;if(e.fadingParentID){const r=i.getLoadedTile(e.fadingParentID);if(!r)return o;const s=Math.pow(2,r.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,n){const r=c(),o=(r-i.timeAdded)/n,s=e.fadingDirection===he.Incoming,a=t.an((r-e.timeAdded)/n,0,1),l=t.an(1-o,0,1),u=s?a:l;return{tileOpacity:u,parentTileOpacity:s?l:a,fadeMix:{opacity:1,mix:1-u}}}(e,r,n);return{parentTile:r,parentScaleBy:s,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const n=(c()-e.timeAdded)/i,r=t.an(n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}(e,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return o}const Ir=new t.bo(1,0,0,1),Mr=new t.bo(0,1,0,1),Pr=new t.bo(0,0,1,1),Rr=new t.bo(1,0,1,1),Lr=new t.bo(0,1,1,1);function Fr(e,t,i,n){Dr(e,0,t+i/2,e.transform.width,i,n)}function kr(e,t,i,n){Dr(e,t-i/2,0,i,e.transform.height,n)}function Dr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Or(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("debug"),a=qt.disabled,l=Xt.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(n).tileSize,m=512/Math.min(f,512)*(n.overscaledZ/e.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,o.TRIANGLES,a,l,$t.alphaBlended,Wt.disabled,Qi(t.bo.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(r,o.LINE_STRIP,a,l,c,Wt.disabled,Qi(t.bo.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function zr(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Ri(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Xt.disabled,l,Wt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Ur(e,i){if(!i.mesh){const n=new t.aV;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aX;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new It(e.createVertexBuffer(n,Mt.members),e.createIndexBuffer(r),t.aW.simpleSegment(0,0,n.length,r.length))}return i.mesh}class Nr{constructor(e,i){this.context=new ir(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Se.maxOverzooming+Se.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Et}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aV;i.emplaceBack(0,0),i.emplaceBack(t.a4,0),i.emplaceBack(0,t.a4),i.emplaceBack(t.a4,t.a4),this.tileExtentBuffer=e.createVertexBuffer(i,Mt.members),this.tileExtentSegments=t.aW.simpleSegment(0,0,4,2);const n=new t.aV;n.emplaceBack(0,0),n.emplaceBack(t.a4,0),n.emplaceBack(0,t.a4),n.emplaceBack(t.a4,t.a4),this.debugBuffer=e.createVertexBuffer(n,Mt.members),this.debugSegments=t.aW.simpleSegment(0,0,4,5);const r=new t.cg;r.emplaceBack(0,0,0,0),r.emplaceBack(t.a4,0,t.a4,0),r.emplaceBack(0,t.a4,0,t.a4),r.emplaceBack(t.a4,t.a4,t.a4,t.a4),this.rasterBoundsBuffer=e.createVertexBuffer(r,Mi.members),this.rasterBoundsSegments=t.aW.simpleSegment(0,0,4,2);const o=new t.aV;o.emplaceBack(0,0),o.emplaceBack(t.a4,0),o.emplaceBack(0,t.a4),o.emplaceBack(t.a4,t.a4),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,Mt.members),this.rasterBoundsSegmentsPosOnly=t.aW.simpleSegment(0,0,4,5);const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Mt.members),this.viewportSegments=t.aW.simpleSegment(0,0,4,2);const a=new t.ch;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aX;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Xt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new It(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.N();t.c6(n,0,this.width,this.height,0,0,1),t.Q(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,qt.disabled,this.stencilClearMode,$t.disabled,Wt.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode($t.disabled),n.setDepthMode(qt.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){const r=this.context,o=r.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,qt.disabled,new Xt({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),$t.disabled,i?Wt.disabled:Wt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,n=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ee(n,{tileSize:n.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=n.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,t.TRIANGLES,o,Xt.disabled,$t.disabled,Wt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Xt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i0};for(const e in s){const t=s[e];t.used&&t.prepare(this.context),a[e]=t.getVisibleCoordinates(!1),l[e]=a[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=_e(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new qt(n.LEQUAL,qt.ReadWrite,[0,1]),s=Xt.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Ur(i,t);l.draw(i,n.TRIANGLES,o,s,a,Wt.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=s[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Ur(r,i);s.draw(r,o.TRIANGLES,a,Xt.disabled,$t.alphaBlended,Wt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let n=0;nh.getElevation(o,e,t):null;lr(s,d,p,c,u,g,i,f,_,t.aN(u,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&ur(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&ur(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(rr(e,i,n,r,!0),rr(e,i,n,r,!1))}(e,i,n,r,this.style.placement.variableOffsets,o):t.cm(n)?function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,qt.ReadOnly),m=Xt.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,d.TRIANGLES,f,m,g,Wt.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}}(e,i,n,r,o):t.cn(n)?function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?dr(e,r,n,t,l):"translucent"===e.renderPass&&pr(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=Xt.disabled,c=new $t([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.cc);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=fr(e,i.width/4,i.height/4),n.heatmapFbos.set(t.cc,o))})(o,e,n),o.clear({color:t.bo.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=i?St.projectionMercator:o.shaderPreludeCode,a=i?Pt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Rt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return this.cache[l]||(this.cache[l]=new ki(this.context,St[e],t,fn[e],this._showOverdrawInspector,r,s,a,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];t&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Vr(e,t){let i,n=!1,r=null,o=null;const s=()=>{r=null,n&&(e.apply(o,i),r=setTimeout(s,t),n=!1)};return(...e)=>(n=!0,o=this,i=e,r||s(),r)}class jr{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Vr(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.V(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Gr={linearity:.3,easing:t.cv(0,0,.3,1)},Hr=t.e({deceleration:2500,maxSpeed:1400},Gr),Qr=t.e({deceleration:20,maxSpeed:1400},Gr),$r=t.e({deceleration:1e3,maxSpeed:360},Gr),Zr=t.e({deceleration:1e3,maxSpeed:90},Gr),Wr=t.e({deceleration:1e3,maxSpeed:360},Gr);class qr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=Xr(i.pan.mag(),n,t.e({},Hr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,Kr(r,o)}if(i.zoom){const e=Xr(i.zoom,n,Qr);r.zoom=this._map.transform.zoom+e.amount,Kr(r,e)}if(i.bearing){const e=Xr(i.bearing,n,$r);r.bearing=this._map.transform.bearing+t.an(e.amount,-179,179),Kr(r,e)}if(i.pitch){const e=Xr(i.pitch,n,Zr);r.pitch=this._map.transform.pitch+e.amount,Kr(r,e)}if(i.roll){const e=Xr(i.roll,n,Wr);r.roll=this._map.transform.roll+t.an(e.amount,-179,179),Kr(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(r,{noMoveStart:!0})}}function Kr(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class eo extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class to{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new eo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Jr(e.type,this._map,e))}mouseup(e){this._map.fire(new Jr(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Jr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Jr(e.type,this._map,e))}mouseover(e){this._map.fire(new Jr(e.type,this._map,e))}mouseout(e){this._map.fire(new Jr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Yr(e.type,this._map,e))}touchmove(e){this._map.fire(new Yr(e.type,this._map,e))}touchend(e){this._map.fire(new Yr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Yr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class io{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Jr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Jr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class no{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class ro{constructor(e,t){this._map=e,this._tr=new no(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&&(u.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(u.remove(this._box),this._box=null),u.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=oo(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=oo(i,t);for(const e in this.touches){const t=n[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 ao{constructor(e){this.singleTap=new so(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class lo{constructor(e){this._tr=new no(e),this._zoomIn=new ao({numTouches:1,numTaps:2}),this._zoomOut=new ao({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(r)},{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}}class co{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)!0}),t=new mo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const _o=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Ao{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=oo(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class Co extends yo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Eo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Eo(e)&&Eo(t)&&o}}const So={panStep:100,bearingStep:15,pitchStep:10};class Bo{constructor(e){this._tr=new no(e);const t=So;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:Io,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:a.center},{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 Io(e){return e*(2-e)}const Mo=4.000244140625,Po=1/450;class Ro{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new no(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Po}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)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Mo==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_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 i=u.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.V.convert(n.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Mo?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),t.at(r*n)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,s=!1;if("wheel"===this._type&&n&&r){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=r(a);o=t.G.number(n,i,l),a<1?this._frameId||(this._frameId=!0):s=!0}else o=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cx;if(this._prevEase){const e=this._prevEase,n=(c()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.cv(o,s,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Lo{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 Fo{constructor(e){this._tr=new no(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ko{constructor(){this._tap=new ao({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Do{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Oo{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class zo{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Uo{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=u.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(u.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const No=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Vo extends t.l{}function jo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Go{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(s,c,a))l.reset();else if(l[i||e.type]){if(t.cy(e,i||e.type)){const t=u.mousePos(this._map.getCanvas(),e);h=l[i||e.type](e,t)}else if(t.cz(e,i||e.type)){const t=this._getMapTouches(e.touches),n=u.touchPos(this._map.getCanvas(),t);h=l[i||e.type](e,n,t)}else t.cA(i||e.type)||(h=l[i||e.type](e));this.mergeHandlerResult(r,o,h,a,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||l.isActive())&&(s[a]=l)}const a={};for(const e in this._previousActiveHandlers)s[e]||(a[e]=n);this._previousActiveHandlers=s,(Object.keys(a).length||jo(r))&&(this._changes.push([r,o,a]),this._triggerRenderFrame()),(Object.keys(s).length||jo(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=r;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)u.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)u.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new to(i,e));const r=i.boxZoom=new ro(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Uo(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new lo(i),a=new Fo(i);i.doubleClickZoom=new Lo(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new ko;this._add("tapDragZoom",l);const c=i.touchPitch=new Co(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const a=new fo({checkCorrectEvent:e=>0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cw(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)});return new co({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:_o})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new fo({checkCorrectEvent:e=>2===u.mouseButton(e)&&e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y0===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:_o})}(e),g=new Ao(e,i);i.dragPan=new Do(n,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new To,A=new bo;i.touchZoomRotate=new zo(n,A,_,l),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new io(i));const y=i.scrollZoom=new Ro(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new Bo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable()}_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=[]}}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 Boolean(No(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(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),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(jo(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||n.transform.centerPoint,o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);this._handleMapControls({terrain:o,tr:r,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:n,combinedEventsInProgress:r,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!r.drag&&!r.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,n)):this._terrainMovement||!r.drag&&!r.zoom?void(r.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,n)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,n));s.handleMapControlsPan(i,t,n)}_fireEvents(e,i,n){const r=No(this._eventsInProgress),o=No(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=No(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ho extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.l("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new t.l("zoomend",e)),r&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const n=t.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(n,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cx},e);const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,s=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(n.width,n.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},S=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},B=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(B)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*B/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==s,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*B,_=1/C(m),A=S(m);this._rotating&&n.setBearing(t.G.number(r,c,a)),this._pitching&&n.setPitch(t.G.number(o,u,a)),this._rolling&&n.setRoll(t.G.number(s,h,a)),this._padding&&(n.interpolatePadding(l,d,a),f=n.centerPoint.add(p)),g.easeFunc(a,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.W(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class $o{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=u.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=u.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=u.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=u.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Zo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=u.create("div","maplibregl-ctrl");const t=u.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){u.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Wo{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){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var qo=t.aT([{name:"a_pos3d",type:"Int16",components:3}]);class Ko extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ee(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.c6(r.terrainRttPosMatrix32f,0,t.a4,t.a4,0,0,1),this._tiles[r.key]=new de(r,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.bj();if(r.canonical.equals(e.canonical))t.c6(s,0,t.a4,t.a4,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<>i<>i;t.c6(s,0,a,a,0,0,1),t.O(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i;t.c6(s,0,t.a4,t.a4,0,0,1),t.O(s,s,[n*a,o*a,0]),t.Q(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.bj();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,n=e.canonical.y-o.canonical.y;t.c6(a,0,t.a4,t.a4,0,0,1),t.O(a,a,[i*t.a4,n*t.a4,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.a4>>i;t.c6(a,0,c,c,0,0,1),t.O(a,a,[-n*c+s*t.a4,-r*c+l*t.a4,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.a4<i.maxzoom&&(n=i.maxzoom),n=i.minzoom&&(!r||!r.dem);)r=this.tileManager.getTileByID(e.scaledTo(n--).key);return r}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Xo{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Ko(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,n,r=t.a4){var o;if(!(i>=0&&i=0&&ne.canonical.z&&(e.canonical.z>=n?r=e.canonical.z-n:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>r<>r<>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.tileManager.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const Yo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class es{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Jo(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),n=e.tileManagers[t].getSource(),r=n instanceof te?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,r);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],n=i.source;if(Yo[i.type]&&!this._coordsAscendingStr[n]){this._coordsAscendingStr[n]={};for(const e in this._coordsAscending[n])this._coordsAscendingStr[n][e]=this._coordsAscending[n][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yo[r]&&(this._prevType&&Yo[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(Yo[this._prevType]||Yo[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(zr(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bo.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,u.mousePos(this.element,e)),u.addEventListener(window,"mousemove",this.mousemove),u.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,u.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),u.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const r=new go;this._rotatePitchHandler=new co({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cw(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,u.addEventListener(i,"mousedown",this.mousedown),u.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),u.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),u.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;u.removeEventListener(e,"mousedown",this.mousedown),u.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend),u.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){u.enableDrag(),u.removeEventListener(window,"mousemove",this.mousemove),u.removeEventListener(window,"mouseup",this.mouseup),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend)}}let ss;function as(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.V(e.lng,e.lat);if(e=new t.V(e.lng,e.lat),i){const r=new t.V(e.lng-360,e.lat),o=new t.V(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const ls={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%)"};function cs(e,t,i){const n=e.classList;for(const e in ls)n.remove(`maplibregl-${i}-anchor-${e}`);n.add(`maplibregl-${i}-anchor-${t}`)}class us extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),u.setTransform(this._element,`${ls[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`),a.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},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._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=u.create("div");const i=u.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=u.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=u.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=u.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=u.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=u.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=u.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const d=u.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=u.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=u.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=u.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=u.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=u.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(a),s.appendChild(c),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),cs(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),u.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,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,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.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 this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const hs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,ps=!1;const fs={maxWidth:100,unit:"metric"};function ms(e,t,i){const n=i&&i.maxWidth||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?gs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):gs(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?gs(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?gs(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):gs(t,c,u,e._getUIString("ScaleControl.Meters"))}function gs(e,t,i,n){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}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r} ${n}`}const _s={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},As=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ys(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ys(new t.P(0,0))}const vs=i;e.AJAXError=t.cI,e.Event=t.l,e.Evented=t.E,e.LngLat=t.V,e.MercatorCoordinate=t.aa,e.Point=t.P,e.addProtocol=t.cJ,e.config=t.a,e.removeProtocol=t.cK,e.AttributionControl=$o,e.BoxZoomHandler=ro,e.CanvasSource=ne,e.CooperativeGesturesHandler=Uo,e.DoubleClickZoomHandler=Lo,e.DragPanHandler=Do,e.DragRotateHandler=Oo,e.EdgeInsets=Ft,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){u.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=u.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);u.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.V(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=Z.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&ps)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=u.create("button","maplibregl-ctrl-geolocate",this._container),u.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=u.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=u.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},hs,e)}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==ss&&!e)return ss;if(void 0===window.navigator.permissions)return ss=!!window.navigator.geolocation,ss;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ss="denied"!==e.state}catch(e){ss=!!window.navigator.geolocation}return ss})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),u.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,ps=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),n=e.distanceTo(i)/100,r=2*this._accuracy/n;this._circleElement.style.width=`${r.toFixed(2)}px`,this._circleElement.style.height=`${r.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("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 t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,ps=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ds++,ds>1?(e={maximumAge:6e5,timeout:0},ps=!0):(e=this.options.positionOptions,ps=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=u.create("button","maplibregl-ctrl-globe",this._container),u.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=jr,e.ImageSource=te,e.KeyboardHandler=Bo,e.LngLatBounds=Z,e.LogoControl=Zo,e.Map=class extends Ho{constructor(e){var i,n;t.cF.mark(t.cG.create);const r=Object.assign(Object.assign(Object.assign({},ns),e),{canvasContextAttributes:Object.assign(Object.assign({},ns.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Vt,s=new Qt;if(void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),null!==r.transformConstrain&&o.setConstrainOverride(r.transformConstrain),super(o,s,{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Wo,this._controls=[],this._mapId=t.ag(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},ts),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,void 0!==r.reduceMotion&&(a.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=_.addThrottleControl(()=>this.isMoving()),this._requestManager=new A(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Vr(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Go(this,r),this._hash=r.hash&&new jr("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const l="string"==typeof r.style||!("globe"===(null===(n=null===(i=r.style)||void 0===i?void 0:i.projection)||void 0===n?void 0:n.type));this.resize(null,l),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new $o("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Zo,r.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const e=t.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Ee(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){const[n,r]=this._containerDimensions(),o=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,o),this.painter.resize(n,r,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,t),this.painter.resize(n,r,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(Z.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),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.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new Jr(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new Jr(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new Jr(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const n=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:e)||{},o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ii(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(null===(n=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const n=this._requestManager.transformRequest(e,"Style");t.j(n,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Xo(this.painter,i,e),this.painter.renderToTexture=new es(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=be(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=be(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.tileManagers[e];if(!n)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.ad(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(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`")));{const{width:n,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:a},new Uint8Array(d)),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:o,height:s,data:l}=r;if(void 0===o||void 0===s)return this.fire(new t.k(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`")));if(o!==n.data.width||s!==n.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return _.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=u.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=u.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=u.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=u.create("div",`maplibregl-ctrl-${e} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Nr(i,this.transform),h.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(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)}_render(e){var i,n,r,o,s;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const n=new t.H(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(u=!0,this._crossFadingFactor=r),this.style.update(n)}const h=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==l;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cF.mark(t.cG.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cF.mark(t.cG.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),_.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),u.remove(this._canvasContainer),u.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cF.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{t.cF.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cH(e)&&!function(e){return e.message===er}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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 version(){return is}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Jr,e.MapTouchEvent=Yr,e.MapWheelEvent=eo,e.Marker=us,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},rs,e),this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=u.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new os(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){u.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=u.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&u.remove(this._content),this._container&&(u.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=u.create("div","maplibregl-popup",this._map.getContainer()),this._tip=u.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const n=ys(this.options.offset);if(!i){const e=this._container.offsetWidth,r=this._container.offsetHeight;let o;o=t.y+n.bottom.ythis._map.transform.height-r?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let r=t.add(n[i]);this.options.subpixelPositioning||(r=r.round()),u.setTransform(this._container,`${ls[i]} translate(${r.x}px,${r.y}px)`),cs(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(_s),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=u.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=u.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(As);e&&e.focus()}},e.RasterDEMTileSource=X,e.RasterTileSource=K,e.ScaleControl=class{constructor(e){this._onMove=()=>{ms(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ms(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fs),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){u.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Ro,e.Style=Ii,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=u.create("button","maplibregl-ctrl-terrain",this._container),u.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){u.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Co,e.TwoFingersTouchRotateHandler=To,e.TwoFingersTouchZoomHandler=bo,e.TwoFingersTouchZoomRotateHandler=zo,e.VectorTileSource=q,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(oe(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{re[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=O;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(F),O=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()"))},e.createTileMesh=ii,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return vs},e.getWorkerCount=function(){return k.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return V().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){U().acquire(F)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){k.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var n=e;return n}();var Ke=He(qe.exports),Xe=e({__proto__:null,default:Ke},[qe.exports]);const Je=[];function Ye(e,i=t){let n;const r=new Set;function o(t){if(a(e,t)&&(e=t,n)){const t=!Je.length;for(const t of r)t[1](),Je.push(t,e);if(t){for(let e=0;e{r.delete(l),0===r.size&&n&&(n(),n=null)}}}}const et=Ye([]),tt=Ye([]),it=Ye([]),nt=Ye(!0),rt=Ye(!0),ot=Ye([]),st=Ye({}),at=e=>{if(!Array.isArray(e))return!1;const t=["id","name","type"],i=e=>{const i=Object.keys(e);return t.filter(e=>!i.includes(e)).length>0};return!(e.filter(e=>"sublist"===e.type?e.presets.every(i):i(e)).length>0)},lt=(e,t)=>Math.round(e*10**t)/10**t;var ct="Expected a function",ut=/^\s+|\s+$/g,ht=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,pt=/^0o[0-7]+$/i,ft=parseInt,mt="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,gt="object"==typeof self&&self&&self.Object===Object&&self,_t=mt||gt||Function("return this")(),At=Object.prototype.toString,yt=Math.max,vt=Math.min,xt=function(){return _t.Date.now()};function bt(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(ct);function p(t){var i=n,o=r;return n=r=void 0,c=t,s=e.apply(o,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function m(){var e=xt();if(f(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-l);return h?vt(i,o-(e-c)):i}(e))}function g(e){return a=void 0,d&&n?p(e):(n=r=void 0,s)}function _(){var e=xt(),i=f(e);if(n=arguments,r=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?p(e):s}(l);if(h)return a=setTimeout(m,t),p(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=Tt(t)||0,wt(i)&&(u=!!i.leading,o=(h="maxWait"in i)?yt(Tt(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=r=a=void 0},_.flush=function(){return void 0===a?s:g(xt())},_}function wt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Tt(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==At.call(e)}(e))return NaN;if(wt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=wt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ut,"");var i=dt.test(e);return i||pt.test(e)?ft(e.slice(2),i?2:8):ht.test(e)?NaN:+e}var Et,Ct=function(e,t,i){var n=!0,r=!0;if("function"!=typeof e)throw new TypeError(ct);return wt(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),bt(e,t,{leading:n,maxWait:t,trailing:r})},St=Object.prototype.toString,Bt=function(e){var t=St.call(e),i="[object Arguments]"===t;return i||(i="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===St.call(e.callee)),i};if(!Object.keys){var It=Object.prototype.hasOwnProperty,Mt=Object.prototype.toString,Pt=Bt,Rt=Object.prototype.propertyIsEnumerable,Lt=!Rt.call({toString:null},"toString"),Ft=Rt.call(function(){},"prototype"),kt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Dt=function(e){var t=e.constructor;return t&&t.prototype===e},Ot={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},zt=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!Ot["$"+e]&&It.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{Dt(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();Et=function(e){var t=null!==e&&"object"==typeof e,i="[object Function]"===Mt.call(e),n=Pt(e),r=t&&"[object String]"===Mt.call(e),o=[];if(!t&&!i&&!n)throw new TypeError("Object.keys called on a non-object");var s=Ft&&i;if(r&&e.length>0&&!It.call(e,0))for(var a=0;a0)for(var l=0;l3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new ei("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new ei("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new ei("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new ei("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,r=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ti&&ti(e,t);if(Jt)Jt(e,t,{configurable:null===o&&a?a.configurable:!o,enumerable:null===n&&a?a.enumerable:!n,value:i,writable:null===r&&a?a.writable:!r});else{if(!s&&(n||r||o))throw new Yt("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=i}},ni=Zt,ri=function(){return!!ni};ri.hasArrayLengthDefineBug=function(){if(!ni)return null;try{return 1!==ni([],"length",{value:1}).length}catch(e){return!0}};var oi=ri,si=Qt,ai="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),li=Object.prototype.toString,ci=Array.prototype.concat,ui=ii,hi=oi(),di=function(e,t,i,n){if(t in e)if(!0===n){if(e[t]===i)return}else if(!function(e){return"function"==typeof e&&"[object Function]"===li.call(e)}(n)||!n())return;hi?ui(e,t,i,!0):ui(e,t,i)},pi=function(e,t){var i=arguments.length>2?arguments[2]:{},n=si(t);ai&&(n=ci.call(n,Object.getOwnPropertySymbols(t)));for(var r=0;r1&&"boolean"!=typeof t)throw new yn('"allowMissing" argument must be a boolean');if(null===Jn(/^%?[^%]*%?$/,e))throw new An("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(e){var t=Xn(e,0,1),i=Xn(e,-1);if("%"===t&&"%"!==i)throw new An("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new An("invalid intrinsic syntax, expected opening `%`");var n=[];return Kn(e,Yn,function(e,t,i,r){n[n.length]=i?Kn(r,er,"$1"):t||e}),n}(e),n=i.length>0?i[0]:"",r=tr("%"+n+"%",t),o=r.name,s=r.value,a=!1,l=r.alias;l&&(n=l[0],qn(i,Wn([0,1],l)));for(var c=1,u=!0;c=i.length){var f=Mn(s,h);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[h]}else u=Zn(s,h),s=s[h];u&&!a&&(jn[o]=s)}}return s},nr=ir,rr=ii,or=oi(),sr=Xt,ar=qt,lr=nr("%Math.floor%"),cr=function(e,t){if("function"!=typeof e)throw new ar("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||lr(t)!==t)throw new ar("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,r=!0;if("length"in e&&sr){var o=sr(e,"length");o&&!o.configurable&&(n=!1),o&&!o.writable&&(r=!1)}return(n||r||!i)&&(or?rr(e,"length",t,!0,!0):rr(e,"length",t)),e},ur=Vi,hr=Gi,dr=$i,pr=function(){return dr(ur,hr,arguments)};!function(e){var t=cr,i=Zt,n=Xi,r=pr;e.exports=function(e){var i=n(arguments),r=e.length-(arguments.length-1);return t(i,1+(r>0?r:0),!0)},i?i(e.exports,"apply",{value:r}):e.exports.apply=r}(gi);var fr=ir,mr=Xi,gr=mr([fr("%String.prototype.indexOf%")]),_r=function(e,t){var i=fr(e,!!t);return"function"==typeof i&&gr(e,".prototype.")>-1?mr([i]):i},Ar=Qt,yr=Pi(),vr=_r,xr=_i,br=vr("Array.prototype.push"),wr=vr("Object.prototype.propertyIsEnumerable"),Tr=yr?xr.getOwnPropertySymbols:null,Er=function(e,t){if(null==e)throw new TypeError("target must be an object");var i=xr(e);if(1===arguments.length)return i;for(var n=1;n2&&!!arguments[2]&&!$r||(Qr?Hr(e,"name",t,!0,!0):Hr(e,"name",t)),e},qr=qt,Kr=Object,Xr=Wr(function(){if(null==this||this!==Kr(this))throw new qr("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),Jr=Xr,Yr=mi.supportsDescriptors,eo=Object.getOwnPropertyDescriptor,to=function(){if(Yr&&"gim"===/a/gim.flags){var e=eo(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var t="",i={};if(Object.defineProperty(i,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(i,"sticky",{get:function(){t+="y"}}),e.get.call(i),"dy"===t)return e.get}}return Jr},io=mi.supportsDescriptors,no=to,ro=Xt,oo=Object.defineProperty,so=Ai,ao=cn,lo=/a/,co=mi,uo=Xr,ho=to,po=function(){if(!io||!ao)throw new so("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=no(),t=ao(lo),i=ro(t,"flags");return i&&i.get===e||oo(t,"flags",{configurable:!0,enumerable:!1,get:e}),e},fo=(0,gi.exports)(ho());co(fo,{getPolyfill:ho,implementation:uo,shim:po});var mo=fo,go=Symbol.iterator,_o=Qe(Object.freeze({__proto__:null,default:{}})),Ao="function"==typeof Map&&Map.prototype,yo=Object.getOwnPropertyDescriptor&&Ao?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,vo=Ao&&yo&&"function"==typeof yo.get?yo.get:null,xo=Ao&&Map.prototype.forEach,bo="function"==typeof Set&&Set.prototype,wo=Object.getOwnPropertyDescriptor&&bo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,To=bo&&wo&&"function"==typeof wo.get?wo.get:null,Eo=bo&&Set.prototype.forEach,Co="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,So="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Bo="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Io=Boolean.prototype.valueOf,Mo=Object.prototype.toString,Po=Function.prototype.toString,Ro=String.prototype.match,Lo=String.prototype.slice,Fo=String.prototype.replace,ko=String.prototype.toUpperCase,Do=String.prototype.toLowerCase,Oo=RegExp.prototype.test,zo=Array.prototype.concat,Uo=Array.prototype.join,No=Array.prototype.slice,Vo=Math.floor,jo="function"==typeof BigInt?BigInt.prototype.valueOf:null,Go=Object.getOwnPropertySymbols,Ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Qo="function"==typeof Symbol&&"object"==typeof Symbol.iterator,$o="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Qo||"symbol")?Symbol.toStringTag:null,Zo=Object.prototype.propertyIsEnumerable,Wo=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function qo(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Oo.call(/e/,t))return t;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-Vo(-e):Vo(e);if(n!==e){var r=String(n),o=Lo.call(t,r.length+1);return Fo.call(r,i,"$&_")+"."+Fo.call(Fo.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Fo.call(t,i,"$&_")}var Ko=_o,Xo=Ko.custom,Jo=as(Xo)?Xo:null,Yo={__proto__:null,double:'"',single:"'"},es={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ts=function e(t,i,n,r){var o=i||{};if(cs(o,"quoteStyle")&&!cs(Yo,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(cs(o,"maxStringLength")&&("number"==typeof o.maxStringLength?o.maxStringLength<0&&o.maxStringLength!==1/0:null!==o.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=!cs(o,"customInspect")||o.customInspect;if("boolean"!=typeof s&&"symbol"!==s)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(cs(o,"indent")&&null!==o.indent&&"\t"!==o.indent&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(cs(o,"numericSeparator")&&"boolean"!=typeof o.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=o.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return ds(t,o);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var l=String(t);return a?qo(t,l):l}if("bigint"==typeof t){var c=String(t)+"n";return a?qo(t,c):c}var u=void 0===o.depth?5:o.depth;if(void 0===n&&(n=0),n>=u&&u>0&&"object"==typeof t)return os(t)?"[Array]":"[Object]";var h=function(e,t){var i;if("\t"===e.indent)i="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;i=Uo.call(Array(e.indent+1)," ")}return{base:i,prev:Uo.call(Array(t+1),i)}}(o,n);if(void 0===r)r=[];else if(hs(r,t)>=0)return"[Circular]";function d(t,i,s){if(i&&(r=No.call(r)).push(i),s){var a={depth:o.depth};return cs(o,"quoteStyle")&&(a.quoteStyle=o.quoteStyle),e(t,a,n+1,r)}return e(t,o,n+1,r)}if("function"==typeof t&&!ss(t)){var p=function(e){if(e.name)return e.name;var t=Ro.call(Po.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),f=As(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Uo.call(f,", ")+" }":"")}if(as(t)){var m=Qo?Fo.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ho.call(t);return"object"!=typeof t||Qo?m:fs(m)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var g="<"+Do.call(String(t.nodeName)),_=t.attributes||[],A=0;A<_.length;A++)g+=" "+_[A].name+"="+is(ns(_[A].value),"double",o);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+=""}if(os(t)){if(0===t.length)return"[]";var y=As(t,d);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(y)?"["+_s(y,h)+"]":"[ "+Uo.call(y,", ")+" ]"}if(function(e){return"[object Error]"===us(e)&&rs(e)}(t)){var v=As(t,d);return"cause"in Error.prototype||!("cause"in t)||Zo.call(t,"cause")?0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Uo.call(v,", ")+" }":"{ ["+String(t)+"] "+Uo.call(zo.call("[cause]: "+d(t.cause),v),", ")+" }"}if("object"==typeof t&&s){if(Jo&&"function"==typeof t[Jo]&&Ko)return Ko(t,{depth:u-n});if("symbol"!==s&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!vo||!e||"object"!=typeof e)return!1;try{vo.call(e);try{To.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var x=[];return xo&&xo.call(t,function(e,i){x.push(d(i,t,!0)+" => "+d(e,t))}),gs("Map",vo.call(t),x,h)}if(function(e){if(!To||!e||"object"!=typeof e)return!1;try{To.call(e);try{vo.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Eo&&Eo.call(t,function(e){b.push(d(e,t))}),gs("Set",To.call(t),b,h)}if(function(e){if(!Co||!e||"object"!=typeof e)return!1;try{Co.call(e,Co);try{So.call(e,So)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return ms("WeakMap");if(function(e){if(!So||!e||"object"!=typeof e)return!1;try{So.call(e,So);try{Co.call(e,Co)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return ms("WeakSet");if(function(e){if(!Bo||!e||"object"!=typeof e)return!1;try{return Bo.call(e),!0}catch(e){}return!1}(t))return ms("WeakRef");if(function(e){return"[object Number]"===us(e)&&rs(e)}(t))return fs(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!jo)return!1;try{return jo.call(e),!0}catch(e){}return!1}(t))return fs(d(jo.call(t)));if(function(e){return"[object Boolean]"===us(e)&&rs(e)}(t))return fs(Io.call(t));if(function(e){return"[object String]"===us(e)&&rs(e)}(t))return fs(d(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||void 0!==Ge&&t===Ge)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===us(e)&&rs(e)}(t)&&!ss(t)){var w=As(t,d),T=Wo?Wo(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",C=!T&&$o&&Object(t)===t&&$o in t?Lo.call(us(t),8,-1):E?"Object":"",S=(T||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(C||E?"["+Uo.call(zo.call([],C||[],E||[]),": ")+"] ":"");return 0===w.length?S+"{}":h?S+"{"+_s(w,h)+"}":S+"{ "+Uo.call(w,", ")+" }"}return String(t)};function is(e,t,i){var n=i.quoteStyle||t,r=Yo[n];return r+e+r}function ns(e){return Fo.call(String(e),/"/g,""")}function rs(e){return!$o||!("object"==typeof e&&($o in e||void 0!==e[$o]))}function os(e){return"[object Array]"===us(e)&&rs(e)}function ss(e){return"[object RegExp]"===us(e)&&rs(e)}function as(e){if(Qo)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Ho)return!1;try{return Ho.call(e),!0}catch(e){}return!1}var ls=Object.prototype.hasOwnProperty||function(e){return e in this};function cs(e,t){return ls.call(e,t)}function us(e){return Mo.call(e)}function hs(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0,n=e.length;it.maxStringLength){var i=e.length-t.maxStringLength,n="... "+i+" more character"+(i>1?"s":"");return ds(Lo.call(e,0,t.maxStringLength),t)+n}var r=es[t.quoteStyle||"single"];return r.lastIndex=0,is(Fo.call(Fo.call(e,r,"\\$1"),/[\x00-\x1f]/g,ps),"single",t)}function ps(e){var t=e.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return i?"\\"+i:"\\x"+(t<16?"0":"")+ko.call(t.toString(16))}function fs(e){return"Object("+e+")"}function ms(e){return e+" { ? }"}function gs(e,t,i,n){return e+" ("+t+") {"+(n?_s(i,n):Uo.call(i,", "))+"}"}function _s(e,t){if(0===e.length)return"";var i="\n"+t.prev+t.base;return i+Uo.call(e,","+i)+"\n"+t.prev}function As(e,t){var i=os(e),n=[];if(i){n.length=e.length;for(var r=0;r=0&&"[object Array]"!==sa(e)&&"callee"in e&&"[object Function]"===sa(e.callee)},ca=function(){return aa(arguments)}();aa.isLegacyArguments=la;var ua,ha=ca?aa:la,da={}.toString,pa=Array.isArray||function(e){return"[object Array]"==da.call(e)},fa=gi.exports,ma=_r,ga=ir("%ArrayBuffer%",!0),_a=ma("ArrayBuffer.prototype.byteLength",!0),Aa=ma("Object.prototype.toString"),ya=!!ga&&!_a&&new ga(0).slice,va=!!ya&&fa(ya),xa=_a||va?function(e){if(!e||"object"!=typeof e)return!1;try{return _a?_a(e):va(e,0),!0}catch(e){return!1}}:ga?function(e){return"[object ArrayBuffer]"===Aa(e)}:function(e){return!1},ba=_r,wa=ba("Date.prototype.getDay"),Ta=ba("Object.prototype.toString"),Ea=ra(),Ca=_r,Sa=ra(),Ba=dn,Ia=Xt;if(Sa){var Ma=Ca("RegExp.prototype.exec"),Pa={},Ra=function(){throw Pa},La={toString:Ra,valueOf:Ra};"symbol"==typeof Symbol.toPrimitive&&(La[Symbol.toPrimitive]=Ra),ua=function(e){if(!e||"object"!=typeof e)return!1;var t=Ia(e,"lastIndex");if(!(t&&Ba(t,"value")))return!1;try{Ma(e,La)}catch(e){return e===Pa}}}else{var Fa=Ca("Object.prototype.toString");ua=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Fa(e)}}var ka=ua,Da=_r("SharedArrayBuffer.prototype.byteLength",!0),Oa=Da?function(e){if(!e||"object"!=typeof e)return!1;try{return Da(e),!0}catch(e){return!1}}:function(e){return!1},za=_r,Ua=za("String.prototype.valueOf"),Na=za("Object.prototype.toString"),Va=ra(),ja=_r,Ga=ja("Number.prototype.toString"),Ha=ja("Object.prototype.toString"),Qa=ra(),$a=_r,Za=$a("Boolean.prototype.toString"),Wa=$a("Object.prototype.toString"),qa=ra(),Ka={exports:{}},Xa=ka,Ja=_r("RegExp.prototype.exec"),Ya=qt,el=_r,tl=el("Object.prototype.toString"),il=function(e){if(!Xa(e))throw new Ya("`regex` must be a RegExp");return function(t){return null!==Ja(e,t)}};if(Fi()){var nl=el("Symbol.prototype.toString"),rl=il(/^Symbol\(.*\)$/);Ka.exports=function(e){if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||"[object Symbol]"!==tl(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&rl(nl(e))}(e)}catch(e){return!1}}}else Ka.exports=function(e){return!1};var ol={exports:{}},sl="undefined"!=typeof BigInt&&BigInt;if("function"==typeof sl&&"function"==typeof BigInt&&"bigint"==typeof sl(42)&&"bigint"==typeof BigInt(42)){var al=BigInt.prototype.valueOf;ol.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return al.call(e),!0}catch(e){}return!1}(e))}}else ol.exports=function(e){return!1};var ll,cl=function(e){return"string"==typeof e||!(!e||"object"!=typeof e)&&(Va?function(e){try{return Ua(e),!0}catch(e){return!1}}(e):"[object String]"===Na(e))},ul=function(e){return"number"==typeof e||!(!e||"object"!=typeof e)&&(Qa?function(e){try{return Ga(e),!0}catch(e){return!1}}(e):"[object Number]"===Ha(e))},hl=function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(qa?function(e){try{return Za(e),!0}catch(e){return!1}}(e):"[object Boolean]"===Wa(e))},dl=Ka.exports,pl=ol.exports,fl="function"==typeof Map&&Map.prototype?Map:null,ml="function"==typeof Set&&Set.prototype?Set:null;fl||(ll=function(e){return!1});var gl=fl?Map.prototype.has:null,_l=ml?Set.prototype.has:null;ll||gl||(ll=function(e){return!1});var Al,yl=ll||function(e){if(!e||"object"!=typeof e)return!1;try{if(gl.call(e),_l)try{_l.call(e)}catch(e){return!0}return e instanceof fl}catch(e){}return!1},vl="function"==typeof Map&&Map.prototype?Map:null,xl="function"==typeof Set&&Set.prototype?Set:null;xl||(Al=function(e){return!1});var bl=vl?Map.prototype.has:null,wl=xl?Set.prototype.has:null;Al||wl||(Al=function(e){return!1});var Tl,El=Al||function(e){if(!e||"object"!=typeof e)return!1;try{if(wl.call(e),bl)try{bl.call(e)}catch(e){return!0}return e instanceof xl}catch(e){}return!1},Cl="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,Sl="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;Cl||(Tl=function(e){return!1});var Bl=Cl?Cl.prototype.has:null,Il=Sl?Sl.prototype.has:null;Tl||Bl||(Tl=function(e){return!1});var Ml=Tl||function(e){if(!e||"object"!=typeof e)return!1;try{if(Bl.call(e,Bl),Il)try{Il.call(e,Il)}catch(e){return!0}return e instanceof Cl}catch(e){}return!1},Pl={exports:{}},Rl=_r,Ll=ir("%WeakSet%",!0),Fl=Rl("WeakSet.prototype.has",!0);if(Fl){var kl=Rl("WeakMap.prototype.has",!0);Pl.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(Fl(e,Fl),kl)try{kl(e,kl)}catch(e){return!0}return e instanceof Ll}catch(e){}return!1}}else Pl.exports=function(e){return!1};var Dl,Ol,zl=yl,Ul=El,Nl=Ml,Vl=Pl.exports,jl=Function.prototype.toString,Gl="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Gl&&"function"==typeof Object.defineProperty)try{Dl=Object.defineProperty({},"length",{get:function(){throw Ol}}),Ol={},Gl(function(){throw 42},null,Dl)}catch(F8){F8!==Ol&&(Gl=null)}else Gl=null;var Hl=/^\s*class\b/,Ql=function(e){try{var t=jl.call(e);return Hl.test(t)}catch(e){return!1}},$l=function(e){try{return!Ql(e)&&(jl.call(e),!0)}catch(e){return!1}},Zl=Object.prototype.toString,Wl="function"==typeof Symbol&&!!Symbol.toStringTag,ql=!(0 in[,]),Kl=function(){return!1};if("object"==typeof document){var Xl=document.all;Zl.call(Xl)===Zl.call(document.all)&&(Kl=function(e){if((ql||!e)&&(void 0===e||"object"==typeof e))try{var t=Zl.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var Jl=Gl?function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Gl(e,null,Dl)}catch(e){if(e!==Ol)return!1}return!Ql(e)&&$l(e)}:function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Wl)return $l(e);if(Ql(e))return!1;var t=Zl.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&$l(e)},Yl=Jl,ec=Object.prototype.toString,tc=Object.prototype.hasOwnProperty;var ic=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],nc="undefined"==typeof globalThis?Ge:globalThis,rc=function(e,t,i){if(!Yl(t))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=i),function(e){return"[object Array]"===ec.call(e)}(e)?function(e,t,i){for(var n=0,r=e.length;n-1?zr(i):i},xc=mo,bc=ir,wc=function(e){if(null!=e&&void 0!==e[go])return e[go]()},Tc=function(){var e,t={assert:function(e){if(!t.has(e))throw new Vs("Side channel does not contain "+js(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,i){e||(e=Hs()),e.set(t,i)}};return t},Ec=ia,Cc=ha,Sc=pa,Bc=xa,Ic=function(e){return"object"==typeof e&&null!==e&&(Ea?function(e){try{return wa(e),!0}catch(e){return!1}}(e):"[object Date]"===Ta(e))},Mc=ka,Pc=Oa,Rc=Qt,Lc=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:cl(e)?"String":ul(e)?"Number":hl(e)?"Boolean":dl(e)?"Symbol":pl(e)?"BigInt":void 0},Fc=function(e){if(e&&"object"==typeof e){if(zl(e))return"Map";if(Ul(e))return"Set";if(Nl(e))return"WeakMap";if(Vl(e))return"WeakSet"}return!1},kc=function(e){if(!e||"object"!=typeof e)return!1;if(!hc){var t=fc(uc(e),8,-1);return mc(pc,t)>-1?t:"Object"===t&&function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{i(e),t=fc(n,1)}catch(e){}}),t}(e)}return lc?function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{"$"+i(e)===n&&(t=fc(n,1))}catch(e){}}),t}(e):null},Dc=function(e){return Ac(e)?_c?_c(e):e.byteLength:NaN},Oc=vc("SharedArrayBuffer.prototype.byteLength",!0),zc=vc("Date.prototype.getTime"),Uc=Object.getPrototypeOf,Nc=vc("Object.prototype.toString"),Vc=bc("%Set%",!0),jc=vc("Map.prototype.has",!0),Gc=vc("Map.prototype.get",!0),Hc=vc("Map.prototype.size",!0),Qc=vc("Set.prototype.add",!0),$c=vc("Set.prototype.delete",!0),Zc=vc("Set.prototype.has",!0),Wc=vc("Set.prototype.size",!0);function qc(e,t,i,n){for(var r,o=wc(e);(r=o.next())&&!r.done;)if(eu(t,r.value,i,n))return $c(e,r.value),!0;return!1}function Kc(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Xc(e,t,i,n,r,o){var s=Kc(i);if(null!=s)return s;var a=Gc(t,s),l=yc({},r,{strict:!1});return!(void 0===a&&!jc(t,s)||!eu(n,a,l,o))&&(!jc(e,s)&&eu(n,a,l,o))}function Jc(e,t,i){var n=Kc(i);return null!=n?n:Zc(t,n)&&!Zc(e,n)}function Yc(e,t,i,n,r,o){for(var s,a,l=wc(e);(s=l.next())&&!s.done;)if(eu(i,a=s.value,r,o)&&eu(n,Gc(t,a),r,o))return $c(e,a),!0;return!1}function eu(e,t,i,n){var r=i||{};if(r.strict?Ec(e,t):e===t)return!0;if(Lc(e)!==Lc(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return r.strict?Ec(e,t):e==t;var o,s=n.has(e),a=n.has(t);if(s&&a){if(n.get(e)===n.get(t))return!0}else o={};return s||n.set(e,o),a||n.set(t,o),function(e,t,i,n){var r,o;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(Nc(e)!==Nc(t))return!1;if(Cc(e)!==Cc(t))return!1;var s=Sc(e),a=Sc(t);if(s!==a)return!1;var l=e instanceof Error,c=t instanceof Error;if(l!==c)return!1;if((l||c)&&(e.name!==t.name||e.message!==t.message))return!1;var u=Mc(e),h=Mc(t);if(u!==h)return!1;if((u||h)&&(e.source!==t.source||xc(e)!==xc(t)))return!1;var d=Ic(e),p=Ic(t);if(d!==p)return!1;if((d||p)&&zc(e)!==zc(t))return!1;if(i.strict&&Uc&&Uc(e)!==Uc(t))return!1;var f=kc(e),m=kc(t);if(f!==m)return!1;if(f||m){if(e.length!==t.length)return!1;for(r=0;r=0;r--)if(b[r]!=w[r])return!1;for(r=b.length-1;r>=0;r--)if(!eu(e[o=b[r]],t[o],i,n))return!1;var T=Fc(e),E=Fc(t);if(T!==E)return!1;if("Set"===T||"Set"===E)return function(e,t,i,n){if(Wc(e)!==Wc(t))return!1;var r,o,s,a=wc(e),l=wc(t);for(;(r=a.next())&&!r.done;)if(r.value&&"object"==typeof r.value)s||(s=new Vc),Qc(s,r.value);else if(!Zc(t,r.value)){if(i.strict)return!1;if(!Jc(e,t,r.value))return!1;s||(s=new Vc),Qc(s,r.value)}if(s){for(;(o=l.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!qc(s,o.value,i.strict,n))return!1}else if(!i.strict&&!Zc(e,o.value)&&!qc(s,o.value,i.strict,n))return!1;return 0===Wc(s)}return!0}(e,t,i,n);if("Map"===T)return function(e,t,i,n){if(Hc(e)!==Hc(t))return!1;var r,o,s,a,l,c,u=wc(e),h=wc(t);for(;(r=u.next())&&!r.done;)if(a=r.value[0],l=r.value[1],a&&"object"==typeof a)s||(s=new Vc),Qc(s,a);else if(void 0===(c=Gc(t,a))&&!jc(t,a)||!eu(l,c,i,n)){if(i.strict)return!1;if(!Xc(e,t,a,l,i,n))return!1;s||(s=new Vc),Qc(s,a)}if(s){for(;(o=h.next())&&!o.done;)if(a=o.value[0],c=o.value[1],a&&"object"==typeof a){if(!Yc(s,e,a,c,i,n))return!1}else if(!(i.strict||e.has(a)&&eu(Gc(e,a),c,i,n)||Yc(s,e,a,c,yc({},i,{strict:!1}),n)))return!1;return 0===Wc(s)}return!0}(e,t,i,n);return!0}(e,t,r,n)}function tu(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&(!(e.length>0&&"number"!=typeof e[0])&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))))}var iu,nu,ru=function(e,t,i){return eu(e,t,i,Tc())};function ou(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function su(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var au=(nu||(nu=1,iu=function e(t,i){if(t===i)return!0;if(t&&i&&"object"==typeof t&&"object"==typeof i){if(t.constructor!==i.constructor)return!1;var n,r,o;if(Array.isArray(t)){if((n=t.length)!=i.length)return!1;for(r=n;0!==r--;)if(!e(t[r],i[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===i.source&&t.flags===i.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===i.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===i.toString();if((n=(o=Object.keys(t)).length)!==Object.keys(i).length)return!1;for(r=n;0!==r--;)if(!Object.prototype.hasOwnProperty.call(i,o[r]))return!1;for(r=n;0!==r--;){var s=o[r];if(!e(t[s],i[s]))return!1}return!0}return t!=t&&i!=i}),iu),lu=su(au);const cu="__googleMapsScriptId";var uu;!function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"}(uu||(uu={}));class hu{constructor({apiKey:e,authReferrerPolicy:t,channel:i,client:n,id:r=cu,language:o,libraries:s=[],mapIds:a,nonce:l,region:c,retries:u=3,url:h="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=i,this.client=n,this.id=r||cu,this.language=o,this.libraries=s,this.mapIds=a,this.nonce=l,this.region=c,this.retries=u,this.url=h,this.version=d,hu.instance){if(!lu(this.options,hu.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(hu.instance.options)}`);return hu.instance}hu.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?uu.FAILURE:this.done?uu.SUCCESS:this.loading?uu.LOADING:uu.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(i=>{i?t(i.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id))return void this.callback();const i={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(i).forEach(e=>!i[e]&&delete i[e]),(null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)||(e=>{let t,i,n,r="The Google Maps JavaScript API",o="google",s="importLibrary",a="__ib__",l=document,c=window;c=c[o]||(c[o]={});const u=c.maps||(c.maps={}),h=new Set,d=new URLSearchParams,p=()=>t||(t=new Promise((s,c)=>ou(this,void 0,void 0,function*(){var p;for(n in yield i=l.createElement("script"),i.id=this.id,d.set("libraries",[...h]+""),e)d.set(n.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[n]);d.set("callback",o+".maps."+a),i.src=this.url+"?"+d,u[a]=s,i.onerror=()=>t=c(Error(r+" could not load.")),i.nonce=this.nonce||(null===(p=l.querySelector("script[nonce]"))||void 0===p?void 0:p.nonce)||"",l.head.append(i)})));u[s]?console.warn(r+" only loads once. Ignoring:",e):u[s]=(e,...t)=>h.add(e)&&p().then(()=>u[s](e,...t))})(i);const n=this.libraries.map(e=>this.importLibrary(e));n.length||n.push(this.importLibrary("core")),Promise.all(n).then(()=>this.callback(),e=>{const t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),!this.loading)if(this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading=!0,this.setScript()}}}function du(e){let i;return{c(){i=b("div"),B(i,"id",e[0]),B(i,"class","map svelte-16c2pp7")},m(e,t){y(e,i,t)},p(e,[t]){1&t&&B(i,"id",e[0])},i:t,o:t,d(e){e&&v(i)}}}function pu(e,t,i){let n,r,{id:o}=t,{bearing:s}=t,{center:a}=t,{pitch:l}=t,{zoom:c}=t,{mapStyle:u}=t,{numberOfMaps:h}=t,{onMapMount:d}=t;it.subscribe(e=>({googleMapsAPIKey:r}=e));const p=H();let f,m={};const g=new hu({apiKey:r,version:"beta"}),_=()=>({bearing:f.getHeading(),center:{lng:f.getCenter().lng(),lat:f.getCenter().lat()},pitch:f.getTilt(),zoom:f.getZoom()-1}),A=()=>{const e=y(_()),t=y(m);return!ru(e,t)},y=e=>({bearing:lt(e.bearing,1),pitch:lt(e.pitch,1),center:{lat:lt(e.center.lat,6),lng:lt(e.center.lng,6)},zoom:lt(e.zoom,2)});return j(()=>{g.load().then(()=>{var t;HTMLCanvasElement.prototype.getContext=(t=HTMLCanvasElement.prototype.getContext,function(e,i){return(i=i||{}).preserveDrawingBuffer=!0,t.call(this,e,i)}),i(8,f=new google.maps.Map(document.getElementById(o),{center:m.center,zoom:m.zoom,mapId:n,disableDefaultUI:!0,isFractionalZoomEnabled:!0,fullscreenControl:!1,zoomControl:!1})),d(f);const r=Ct(()=>{document.getElementById(o).querySelector('div[tabindex="0"]').focus()},250);document.getElementById(o).addEventListener("wheel",r,{passive:!0}),f.addListener("center_changed",e),f.addListener("heading_changed",e),f.addListener("tilt_changed",e),f.addListener("zoom_changed",e)});const e=()=>{document.getElementById(o).contains(document.activeElement)&&A()&&p("mapMove",{options:_()})}}),e.$$set=e=>{"id"in e&&i(0,o=e.id),"bearing"in e&&i(1,s=e.bearing),"center"in e&&i(2,a=e.center),"pitch"in e&&i(3,l=e.pitch),"zoom"in e&&i(4,c=e.zoom),"mapStyle"in e&&i(5,u=e.mapStyle),"numberOfMaps"in e&&i(6,h=e.numberOfMaps),"onMapMount"in e&&i(7,d=e.onMapMount)},e.$$.update=()=>{if(32&e.$$.dirty&&(n=u?.mapId),30&e.$$.dirty&&i(9,m={bearing:s,center:a,pitch:l,zoom:c}),768&e.$$.dirty&&(e=>{e&&A()&&e.moveCamera({center:{lat:a.lat,lng:a.lng},zoom:c+1,heading:s,tilt:l})})(f),321&e.$$.dirty&&f&&h){const e=document.getElementById(o);if(e){new ResizeObserver(()=>{google.maps.event.trigger(f,"resize")}).observe(e)}}},[o,s,a,l,c,u,h,d,f,m]}class fu extends ge{constructor(e){super(),me(this,e,pu,du,a,{id:0,bearing:1,center:2,pitch:3,zoom:4,mapStyle:5,numberOfMaps:6,onMapMount:7})}}const mu=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},gu=e=>{if(!e)return!1;let t;try{t=new URL(e)}catch(e){return!1}return"api.maptiler.com"===t.host&&!t.searchParams.has("key")},_u=(e,t)=>{const{mapboxKey:i,maptilerKey:n}=t;let r=e;return mu(e)&&i?r=((e,t)=>{if(!mu(e))return e;if(!t)return e;const[,,,i,n]=e.split("/");return`https://api.mapbox.com/styles/v1/${i}/${n}?title=true&access_token=${t}`})(r,i):gu(e)&&n&&(r=((e,t)=>{if(!t)return e;let i=new URL(e);return t&&gu(e)&&i.searchParams.append("key",t),i.toString()})(r,n)),r};let Au,yu;it.subscribe(e=>({mapboxGlAccessToken:Au,maptilerApiKey:yu}=e));const vu=async e=>{const t=mu(e);let i,n=e;try{n=new URL(e);const t={mapboxKey:Au,maptilerKey:yu};n=_u(n.toString(),t)}catch(e){}try{i=await fetch(n)}catch(e){throw{message:e.message}}if(!i.ok)throw{status:i.status,message:i.statusText};const r=await i.json();if(t&&r.message)throw{message:r.message};return r},xu=(e,t,i)=>e.replace("{branch}",t).replace("{style}",i),bu=["swipe","mirror","phone","responsive"];async function wu(e,t,i,n){return n._parse(e,t,i,n)}function Tu(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Eu=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Cu="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Cu&&parseFloat(Cu[1]);const Su=globalThis,Bu=globalThis.process||{},Iu=globalThis.navigator||{};function Mu(e){if("undefined"!=typeof window&&"renderer"===window.process?.type)return!0;if("undefined"!=typeof process&&Boolean(process.versions?.electron))return!0;const t="undefined"!=typeof navigator&&navigator.userAgent,i=e||t;return Boolean(i&&i.indexOf("Electron")>=0)}function Pu(){return!("object"==typeof process&&"[object process]"===String(process)&&!process?.browser)||Mu()}const Ru="4.1.0";class Lu{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}var Fu;!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Fu||(Fu={}));function ku(e){return"string"!=typeof e?e:(e=e.toUpperCase(),Fu[e]||Fu.WHITE)}function Du(e,t){if(!e)throw new Error(t||"Assertion failed")}function Ou(){let e;if(Pu()&&Su.performance)e=Su?.performance?.now?.();else if("hrtime"in Bu){const t=Bu?.hrtime?.();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const zu={debug:Pu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Uu={enabled:!0,level:0};function Nu(){}const Vu={},ju={once:!0};class Gu{constructor({id:e}={id:""}){this.VERSION=Ru,this._startTs=Ou(),this._deltaTs=Ou(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Lu(`__probe-${this.id}__`,Uu),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(i),r=e;for(const i of n){const n=r[i];"function"==typeof n&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ou()-this._startTs).toPrecision(10))}getDelta(){return Number((Ou()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,zu.warn,arguments,ju)}error(e){return this._getLogFunction(0,e,zu.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,zu.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,zu.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,zu.debug||zu.info,arguments,ju)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Nu,i&&[i],{tag:$u(t)}):Nu}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Nu)}group(e,t,i={collapsed:!1}){const n=Qu({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Nu)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Hu(e)}_getLogFunction(e,t,i,n,r){if(this._shouldLog(e)){r=Qu({logLevel:e,message:t,args:n,opts:r}),Du(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Ou();const o=r.tag||r.message;if(r.once&&o){if(Vu[o])return Nu;Vu[o]=Ou()}return t=function(e,t,i){if("string"==typeof t){const n=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return`${" ".repeat(i)}${e}`}(function(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}(i.total)):"";t=function(e,t,i){Pu||"string"!=typeof e||(t&&(e=`[${ku(t)}m${e}`),i&&(e=`[${ku(i)+10}m${e}`));return e}(t=i.time?`${e}: ${n} ${t}`:`${e}: ${t}`,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Nu}}function Hu(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Du(Number.isFinite(t)&&t>=0),t}function Qu(e){const{logLevel:t,message:i}=e;e.logLevel=Hu(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&n.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Du("string"===r||"object"===r),Object.assign(e,{args:n},e.opts)}function $u(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}Gu.VERSION=Ru,globalThis.probe={};var Zu=new Gu({id:"@probe.gl/log"});const Wu="4.3.3",qu=Wu[0]>="0"&&Wu[0]<="9"?`v${Wu}`:"";const Ku=function(){const e=new Gu({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=qu,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function Xu(e,t){return Ju(e||{},t)}function Ju(e,t,i=0){if(i>3)return t;const n={...e};for(const[e,r]of Object.entries(t))r&&"object"==typeof r&&!Array.isArray(r)?n[e]=Ju(n[e]||{},t[e],i+1):n[e]=t[e];return n}function Yu(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const eh="object"!=typeof process||"[object process]"!==String(process)||process.browser,th="undefined"!=typeof window&&void 0!==window.orientation,ih="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ih&&parseFloat(ih[1]);class nh{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Yu(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Yu(this.isRunning),this.isRunning=!1,this._reject(e)}}class rh{terminate(){}}const oh=new Map;function sh(e){Yu(e.source&&!e.url||!e.source&&e.url);let t=oh.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return ah((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),oh.set(e.url,t)),e.source&&(t=ah(e.source),oh.set(e.source,t))),Yu(t),t}function ah(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function lh(e,t=!0,i){const n=i||new Set;if(e){if(ch(e))n.add(e);else if(ch(e.buffer))n.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)lh(e[i],t,n)}else;return void 0===i?Array.from(n):[]}function ch(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const uh=()=>{};class hh{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&eh||void 0!==rh&&!eh}constructor(e){const{name:t,source:i,url:n}=e;Yu(i||n),this.name=t,this.source=i,this.url=n,this.onMessage=uh,this.onError=e=>console.log(e),this.worker=eh?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=uh,this.onError=uh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||lh(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=sh({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new rh(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new rh(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class dh{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return hh.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new nh(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!eh||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class fh{props;workerPools=new Map;static _workerFarm;static isSupported(){return hh.isSupported()}static getWorkerFarm(e={}){return fh._workerFarm=fh._workerFarm||new fh({}),fh._workerFarm.setProps(e),fh._workerFarm}constructor(e){this.props={...ph},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:n}=e;let r=this.workerPools.get(t);return r||(r=new dh({name:t,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}async function mh(e,t,i,n,r){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},n=eh?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r=eh?`modules/${e.module}/dist/${n}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${n}`}return Yu(r),r}(e,i),a=fh.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await a.startJob("process-on-worker",gh.bind(null,r));l.postMessage("process",{input:t,options:i,context:n});const c=await l.result;return await c.result}async function gh(e,t,i,n){switch(i){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:r,input:o,options:s}=n;try{const i=await e(o,s);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function _h(e,t,i){if(e.byteLength<=t+i)return"";const n=new DataView(e);let r="";for(let e=0;ee instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(i);let r=0;for(const e of t)n.set(e,r),r+=e.byteLength;return n.buffer}(e)}function vh(...e){const t=e,i=t&&t.length>1&&t[0].constructor||null;if(!i)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');const n=new i(t.reduce((e,t)=>e+t.length,0));let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}function xh(e,t,i){const n=void 0!==i?new Uint8Array(e).subarray(t,t+i):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}function bh(e,t){return Tu(e>=0),Tu(t>0),e+(t-1)&~(t-1)}function wh(e,t,i){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(n,i),i+bh(n.byteLength,4)}function Th(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Eh{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Th(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Th()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Ch{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:i}=e;let n=this.stats[t];return n||(n=e instanceof Eh?e:new Eh(t,i),this.stats[t]=n),n}}const Sh={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class Bh{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...Sh,...e},this.stats=new Ch({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const i={handle:e,priority:0,getPriority:t},n=new Promise(e=>(i.resolve=e,i));return this.requestQueue.push(i),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:i}=e;let n=!1;const r=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:r}):Promise.resolve({done:r})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;te.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}const Ih={};function Mh(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Ph(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Rh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function Lh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function Fh(...e){const t=[];for(let i=0;i=-1&&!r;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=Ph()),o=i),0!==o.length&&(n=`${o}/${n}`,r=o.charCodeAt(0)===kh)}return n=function(e,t){let i,n="",r=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=n.length-1;let t=e;for(;t>=0&&n.charCodeAt(t)!==kh;--t);if(t!==e){n=-1===t?"":n.slice(0,t),r=a,o=0,s=!1;continue}}else if(2===n.length||1===n.length){n="",r=a,o=0,s=!1;continue}t&&(n.length>0?n+="/..":n="..",s=!0)}else{const t=e.slice(r+1,a);n.length>0?n+=`/${t}`:n=t,s=!1}r=a,o=0}else i===Dh&&-1!==o?++o:o=-1}return n}(n,!r),r?`/${n}`:n.length>0?n:"."}const kh=47,Dh=46;const Oh=e=>"function"==typeof e,zh=e=>null!==e&&"object"==typeof e,Uh=e=>zh(e)&&e.constructor==={}.constructor,Nh=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,Vh=e=>"undefined"!=typeof Blob&&e instanceof Blob,jh=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||zh(e)&&Oh(e.tee)&&Oh(e.cancel)&&Oh(e.getReader))(e)||(e=>zh(e)&&Oh(e.read)&&Oh(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class Gh extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const Hh=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Qh=/^([-\w.]+\/[-\w.+]+)/;function $h(e,t){return e.toLowerCase()===t.toLowerCase()}function Zh(e){const t=Hh.exec(e);return t?t[1]:""}const Wh=/\?.*/;function qh(e){return e.replace(Wh,"")}function Kh(e){if(Nh(e)){return e.url}if(Vh(e)){return e.name||""}return"string"==typeof e?e:""}function Xh(e){if(Nh(e)){const t=e,i=t.headers.get("content-type")||"",n=qh(t.url);return function(e){const t=Qh.exec(e);return t?t[1]:e}(i)||Zh(n)}if(Vh(e)){return e.type||""}return"string"==typeof e?Zh(e):""}async function Jh(e){if(Nh(e))return e;const t={},i=function(e){if(Nh(e))return e.headers["content-length"]||-1;if(Vh(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const n=Kh(e),r=Xh(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const n={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");n.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(e){}return new Gh(i,n)}(e);throw t}}async function ed(e,t){if("string"==typeof e){const i=function(e){for(const t in Ih)if(e.startsWith(t)){const i=Ih[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await Jh(e)}const td=new Gu({id:"loaders.gl"});class id{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const nd={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Eu,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},rd={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function od(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function sd(){const e=od();return e.globalOptions=e.globalOptions||{...nd},e.globalOptions}function ad(e,t,i,n){return i=i||[],function(e,t){ld(e,null,nd,rd,t);for(const i of t){const n=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ld(n,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const n=e.options||{},r={...n};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(r,i),null===r.log&&(r.log=new id);return ud(r,sd()),ud(r,t),r}(t,e,n)}function ld(e,t,i,n,r){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&zh(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in n)td.warn(`${o} loader option '${s}${a}' no longer supported, use '${n[a]}'`)();else if(!l){const e=cd(a,r);td.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function cd(e,t){const i=e.toLowerCase();let n="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(n=n||`Did you mean '${r.id}.${t}'?`)}return n}function ud(e,t){for(const i in t)if(i in t){const n=t[i];Uh(n)&&Uh(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function hd(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function dd(e){let t;return Tu(e,"null loader"),Tu(hd(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const pd=()=>{const e=od();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const fd=/\.([^.]+)$/;function md(e,t=[],i,n){if(!gd(e))return null;if(t&&!Array.isArray(t))return dd(t);let r=[];t&&(r=r.concat(t)),i?.ignoreRegisteredLoaders||r.push(...pd()),function(e){for(const t of e)dd(t)}(r);const o=function(e,t,i,n){const r=Kh(e),o=Xh(e),s=qh(r)||n?.url;let a=null,l="";i?.mimeType&&(a=Ad(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&fd.exec(t),n=i&&i[1];return n?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,n):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||Ad(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(yd(t,i))return i}else if(ArrayBuffer.isView(t)){if(vd(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(vd(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${xd(e)}`:""),i?.fallbackMimeType&&(a=a||Ad(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&Ku.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,r,i,n);if(!o&&!i?.nothrow)throw new Error(_d(e));return o}function gd(e){return!(e instanceof Response&&204===e.status)}function _d(e){const t=Kh(e),i=Xh(e);let n="No valid loader found (";n+=t?`${Rh(t)}, `:"no url provided, ",n+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const r=e?xd(e):"";return n+=r?` first bytes: "${r}"`:"first bytes: not available",n+=")",n}function Ad(e,t){for(const i of e){if(i.mimeTypes?.some(e=>$h(t,e)))return i;if($h(t,`application/x.${i.id}`))return i}return null}function yd(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function vd(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,n){if(n instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+n)),i}throw new Error(Sd)}(e,t);if(Vh(e)&&(e=await Jh(e)),Nh(e)){const i=e;return await Yh(i),t.binary?await i.arrayBuffer():await i.text()}if(jh(e)&&(e=Cd(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return yh(...t)}(e);throw new Error(Sd)}function Id(e,t){const i=sd(),n=e||i;return"function"==typeof n.fetch?n.fetch:zh(n.fetch)?e=>ed(e,n.fetch):t?.fetch?t?.fetch:ed}function Md(e,t,i){if(i)return i;const n={fetch:Id(t,e),...e};if(n.url){const e=qh(n.url);n.baseUrl=e,n.queryString=function(e){const t=e.match(Wh);return t&&t[0]}(n.url),n.filename=Rh(e),n.baseUrl=Lh(e)}return Array.isArray(n.loaders)||(n.loaders=null),n}async function Pd(e,t,i,n){!t||Array.isArray(t)||hd(t)||(n=void 0,i=t,t=void 0),i=i||{};const r=Kh(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,n),s=await async function(e,t=[],i,n){if(!gd(e))return null;let r=md(e,t,{...i,nothrow:!0},n);if(r)return r;if(Vh(e)&&(r=md(e=await e.slice(0,10).arrayBuffer(),t,i,n)),!r&&!i?.nothrow)throw new Error(_d(e));return r}(e,o,i);return s?(n=Md({url:r,_parse:Pd,loaders:o},i=ad(i,s,o,r),n||null),await async function(e,t,i,n){if(function(e){wd(e,"no worker provided");const t=e.version}(e),i=Xu(e.options,i),Nh(t)){const e=t,{ok:i,redirected:r,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:i,redirected:r,status:o,statusText:s,type:a,url:l}}t=await Bd(t,e,i);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,i,n);if(function(e,t){return!!fh.isSupported()&&!(!eh&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await mh(e,t,i,n,Pd);if(r.parseText&&"string"==typeof t)return await r.parseText(t,i,n);if(r.parse)return await r.parse(t,i,n);throw wd(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,n)):null}function Rd(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=c>o?c:o,s=u>s?u:s}return[[t,i,n],[r,o,s]]}function Ld(e,t,i){const n=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),r=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:r}}async function Fd(e,t,i,n){let r,o;Array.isArray(t)||hd(t)?(r=t,o=i):(r=[],o=t);const s=Id(o);let a=e;return"string"==typeof e&&(a=await s(e)),Vh(e)&&(a=await s(e)),Array.isArray(r),await Pd(a,r,o)}const kd=globalThis.loaders?.parseImageNode,Dd="undefined"!=typeof Image,Od="undefined"!=typeof ImageBitmap,zd=Boolean(kd),Ud=!!Eu||zd;function Nd(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}function Vd(e){switch(Nd(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}const jd=/^data:image\/svg\+xml/,Gd=/\.svg((\?|#).*)?$/;function Hd(e){return e&&(jd.test(e)||Gd.test(e))}function Qd(e,t){if(Hd(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function $d(e,t,i){const n=function(e,t){if(Hd(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Qd(e,t)}(e,i),r=self.URL||self.webkitURL,o="string"!=typeof n&&r.createObjectURL(n);try{return await async function(e,t){const i=new Image;if(i.src=e,t.image&&t.image.decode&&i.decode)return await i.decode(),i;return await new Promise((e,t)=>{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||n,t)}finally{o&&r.revokeObjectURL(o)}}const Zd={};let Wd=!0;async function qd(e,t,i){let n;if(Hd(i)){n=await $d(e,t,i)}else n=Qd(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Zd)return!1;return!0}(t)&&Wd||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Wd=!1}return await createImageBitmap(e)}(n,r)}function Kd(e){return function(e,t,i=0){const n=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t=24&&2303741511===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,Xd),height:t.getUint32(20,Xd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=3&&65496===t.getUint16(0,Xd)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,Jd),height:t.getUint16(8,Jd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=14&&16973===t.getUint16(0,Xd)&&t.getUint32(2,Jd)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Jd),height:t.getUint32(22,Jd)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=Kd(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function ep(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const tp={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.3.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const n=((t=t||{}).image||{}).type||"auto",{url:r}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(Od)return"imagebitmap";if(Dd)return"image";if(Ud)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Od||Dd||Ud;case"imagebitmap":return Od;case"image":return Dd;case"data":return Ud;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n);let s;switch(o){case"imagebitmap":s=await qd(e,t,r);break;case"image":s=await $d(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Yd(e)||{},i=globalThis.loaders?.parseImageNode;return Tu(i),await i(e,t)}(e);break;default:Tu(!1)}return"data"===n&&(s=Vd(s)),s},tests:[e=>Boolean(Yd(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},ip={};function np(e){if(void 0===ip[e]){const t=Eu?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&i.includes(e)}(e);ip[e]=t}return ip[e]}var rp=new Gu({id:"deck"});const op={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]};let sp={};function ap(e){sp=e}function lp(e,t,i,n){rp.level>0&&sp[e]&&sp[e].call(null,t,i,n)}sp=(e=>({"layer.changeFlag":(t,i,n)=>{e.log(3,`${t.id} ${i}: `,n[i])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,i)=>{if(i){const i=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(i).filter(e=>i[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,i)=>{i&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,i,n)=>{i?e.log(2,`Composite layer rendered new subLayers ${t}`,n)():e.log(4,`Composite layer reused subLayers ${t}`,n)()},"layerManager.setLayers":(t,i,n)=>{i&&e.log(2,`Updating ${n.length} deck layers`)()},"layerManager.activateViewport":(t,i)=>{e.log(3,"Viewport changed",i)()},"attributeManager.invalidate":(t,i,n)=>{e.log(1,n?`invalidated attributes ${n} (${i}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{op.attributeUpdateMessages.length=0,op.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,i)=>{const n=Math.round(Date.now()-op.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${i} instances in ${t.id} in ${n}ms`)();for(const t of op.attributeUpdateMessages)e.log(3,t)();e.groupEnd(2)()},"attribute.updateStart":e=>{op.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const i=`${e.id} allocated ${t}`;op.attributeUpdateMessages.push(i)},"attribute.updateEnd":(e,t)=>{const i=Math.round(Date.now()-op.attributeUpdateStart),n=`${e.id} updated ${t} in ${i}ms`;op.attributeUpdateMessages.push(n)},"deckRenderer.renderLayers":(t,i,n)=>{const{pass:r,redrawReason:o,stats:s}=n;for(const n of i){const{totalCount:i,visibleCount:a,compositeCount:l,pickableCount:c}=n,u=i-l-a;e.log(2,`RENDER #${t.renderCount} ${a} (of ${i} layers) to ${r} because ${o} (${u} hidden, ${l} composite ${c} pickable)`)(),s&&s.get("Redraw Layers").add(a)}}}))(rp);var cp={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],i=e[e.length-1];return"{"===t&&"}"===i||"["===t&&"]"===i},parseTextSync:JSON.parse};const up=function(){const e="9.0.41",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(rp.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:rp,_registerLoggers:ap},function(e){const t=pd();e=Array.isArray(e)?e:[e];for(const i of e){const e=dd(i);t.find(t=>e===t)||t.unshift(e)}}([cp,[tp,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function hp(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const dp={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function pp(e){let t=fp(e);if("object"!==t)return{value:e,...dp[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...dp[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=fp(e.value),{...e,...dp[t],type:t}):{type:"object",value:null};throw new Error("props")}function fp(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const mp={vertex:"#ifdef MODULE_LOGDEPTH\nlogdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\ngl_FragColor = material_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_LIGHTING\ngl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_FOG\ngl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_PICKING\ngl_FragColor = picking_filterHighlightColor(gl_FragColor);\ngl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n#ifdef MODULE_LOGDEPTH\nlogdepth_setFragDepth();\n#endif\n"},gp=/void\s+main\s*\([^)]*\)\s*\{\n?/,_p=/}\n?[^{}]*$/,Ap=[],yp="__LUMA_INJECT_DECLARATIONS__";function vp(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function xp(e,t,i,n=!1){const r="vertex"===t;for(const t in i){const n=i[t];n.sort((e,t)=>e.order-t.order),Ap.length=n.length;for(let e=0,t=n.length;ee+o));break;case"vs:#main-end":r&&(e=e.replace(_p,e=>o+e));break;case"fs:#decl":r||(e=e.replace(yp,o));break;case"fs:#main-start":r||(e=e.replace(gp,e=>e+o));break;case"fs:#main-end":r||(e=e.replace(_p,e=>o+e));break;default:e=e.replace(t,e=>e+o)}}return e=e.replace(yp,""),n&&(e=e.replace(/\}\s*$/,e=>e+mp[t])),e}let bp=1;class wp{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(e=>{if(e instanceof wp)return e;hp("string"!=typeof e,`Shader module use by name is deprecated. Import shader module '${JSON.stringify(e)}' and use it directly.`),e.name||(console.warn("shader module has no name"),e.name="shader-module-"+bp++);const t=new wp(e);return t.dependencies=wp.instantiateModules(e.dependencies||[]),t})}constructor(e){const{name:t,vs:i,fs:n,dependencies:r=[],uniformTypes:o={},uniformPropTypes:s={},getUniforms:a,deprecations:l=[],defines:c={},inject:u={}}=e;hp("string"==typeof t),this.name=t,this.vs=i,this.fs=n,this.getModuleUniforms=a,this.dependencies=wp.instantiateModules(r),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=c,this.injections=function(e){const t={vertex:{},fragment:{}};for(const i in e){let n=e[i];"string"==typeof n&&(n={order:0,injection:n}),t[vp(i)][i]=n}return t}(u),this.uniformTypes=o,s&&(this.uniforms=function(e){const t={};for(const[i,n]of Object.entries(e))t[i]=pp(n);return t}(s))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:hp(!1)}const i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------\n\n#define MODULE_${i}\n${t}\n\n`}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):function(e,t,i){const n={};for(const[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&hp(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}_defaultGetUniforms(e={}){const t={},i=this.uniforms;for(const n in i){const r=i[n];n in e&&!r.private?(r.validate&&hp(r.validate(e[n],r),`${this.name}: invalid ${n}`),t[n]=e[n]):t[n]=r.value}return t}}function Tp(e){if(e.source&&"webgpu"===e.platformInfo.type){return{...e,vs:void 0,fs:void 0}}if(!e.vs)throw new Error("no vertex shader");const t=Ep(e.platformInfo,e.vs);let i;return e.fs&&(i=Ep(e.platformInfo,e.fs)),{...e,vs:t,fs:i}}function Ep(e,t){if("string"==typeof t)return t;if("webgpu"===e.type){if(t?.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders")}if(t?.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}function Cp(e){return function(e){const t={},i={};return Sp({modules:e,level:0,moduleMap:t,moduleDepth:i}),Object.keys(i).sort((e,t)=>i[t]-i[e]).map(e=>t[e])}(wp.instantiateModules(e))}function Sp(e){const{modules:t,level:i,moduleMap:n,moduleDepth:r}=e;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)n[e.name]=e,(void 0===r[e.name]||r[e.name]e.order-t.order);for(const t of e)i+=` ${t.injection}\n`}r.footer&&(i+=` ${r.footer}`),i+="}\n"}return i}function Fp(e){const t={vertex:{},fragment:{}};for(const i of e){let e,n;"string"!=typeof i?(e=i,n=e.hook):(e={},n=i),n=n.trim();const[r,o]=n.split(":"),s=n.replace(/\(.+/,""),a=Object.assign(e,{signature:o});switch(r){case"vs":t.vertex[s]=a;break;case"fs":t.fragment[s]=a;break;default:throw new Error(r)}}return t}function kp(e,t="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function Dp(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const Op=`\n\n${yp}\n`;function zp(e,t){const{source:i,stage:n,modules:r,hookFunctions:o=[],inject:s={},log:a}=t;hp("string"==typeof i,"shader source must be a string");const l=i;let c="";const u=Fp(o),h={},d={},p={};for(const e in s){const t="string"==typeof s[e]?{injection:s[e],order:0}:s[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?d[e]=[t]:p[e]=[t]:h[e]=[t]}else p[e]=[t]}const f="webgpu"!==e.type?r:[];for(const e of f){a&&e.checkDeprecations(l,a);c+=e.getModuleSource(n,"wgsl");const t=e.injections[n];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?d:p;n[e]=n[e]||[],n[e].push(t[e])}else h[e]=h[e]||[],h[e].push(t[e])}}return c+=Op,c=xp(c,n,d),c+=Lp(u[n],h),c+=l,c=xp(c,n,p),c}function Up(e,t){const{id:i,source:n,stage:r,language:o="glsl",modules:s,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:h}=t;hp("string"==typeof n,"shader source must be a string");const d="glsl"===o?function(e,t){return{name:kp(e,t),language:"glsl",version:Dp(e)}}(n).version:-1,p=e.shaderLanguageVersion,f=100===d?"#version 100":"#version 300 es",m=n.split("\n").slice(1).join("\n"),g={};s.forEach(e=>{Object.assign(g,e.getDefines())}),Object.assign(g,a);let _="";switch(o){case"wgsl":break;case"glsl":_=u?`${f}\n\n// ----- PROLOGUE -------------------------\n${function(e){const{id:t,source:i,stage:n}=e,r=t&&-1===i.indexOf("SHADER_NAME");return r?`\n#define SHADER_NAME ${t}_${n}\n\n`:""}({id:i,source:n,stage:r})}\n#define SHADER_TYPE_${r.toUpperCase()}\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const i in e){const n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}\n`)}return t}(g)}\n\n`:`${f}\n`}const A=Fp(l),y={},v={},x={};for(const e in c){const t="string"==typeof c[e]?{injection:c[e],order:0}:c[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?v[e]=[t]:x[e]=[t]:y[e]=[t]}else x[e]=[t]}for(const e of s){h&&e.checkDeprecations(m,h);_+=e.getModuleSource(r);const t=e.injections[r];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?v:x;n[e]=n[e]||[],n[e].push(t[e])}else y[e]=y[e]||[],y[e].push(t[e])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Op,_=xp(_,r,v),_+=Lp(A[r],y),_+=m,_=xp(_,r,x),"glsl"===o&&d!==p&&(_=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Pp(e,Ip);case"fragment":return Pp(e,Mp);default:throw new Error(t)}}(_,r)),_.trim()}function Np(e){return function(t){const i={};for(const n of e){const e=n.getUniforms(t,i);Object.assign(i,e)}return i}}class Vp{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Vp.defaultShaderAssembler=Vp.defaultShaderAssembler||new Vp,Vp.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,n=Tp(e),r=function(e){const t=Cp(e.modules||[]);return{source:zp(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:Np(t)}}({platformInfo:e.platformInfo,...n,modules:t,hookFunctions:i});return{...r,modules:t}}assembleShaderPair(e){const t=Tp(e),i=this._getModuleList(e.modules),n=this._hookFunctions,{platformInfo:r}=e,o="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=Cp(e.modules||[]);return{vs:zp(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:zp(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:Np(t)}}({platformInfo:r,...t,modules:i,hookFunctions:n}):function(e){const{vs:t,fs:i}=e,n=Cp(e.modules||[]);return{vs:Up(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:Up(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:Np(n)}}({platformInfo:r,...t,modules:i,hookFunctions:n});return{...o,modules:i}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let n=0;for(let e=0,r=this._defaultModules.length;eGp.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=Qp;constructor(e){this.props={...lf.defaultProps,...e},this.id=this.props.id||Wp(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Hp;_lumaData={};isTextureFormatCompressed(e){return t=e,tf.some(e=>t.startsWith(e));var t}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||"string"==typeof e)&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};return(e.usage||0)&Xp.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":Gp.warn("indices buffer content must be of integer type")()),t}}function cf(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const uf=new Map;class hf{static defaultProps={...lf.defaultProps,type:"best-available",devices:void 0};static stats=Hp;static log=Gp;static registerDevices(e){for(const t of e)cf(t.type&&t.isSupported&&t.create),uf.set(t.type,t)}static getAvailableDevices(){return Array.from(uf).map(e=>e.type)}static getSupportedDevices(){return Array.from(uf).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(lf.defaultProps,e)}static async attachDevice(e){const t=df(e.devices)||uf;if(e.handle instanceof WebGL2RenderingContext){const i=t.get("webgl");if(i)return await i.attach(e.handle)}if(null===e.handle){const e=t.get("unknown");if(e)return await e.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){(e={...hf.defaultProps,...e}).gl&&(e.type="webgl");const t=df(e.devices)||uf;let i,n;switch(e.type){case"webgpu":if(i=t.get("webgpu"),i)return await i.create(e);break;case"webgl":if(n=t.get("webgl"),n)return await n.create(e);break;case"unknown":const r=t.get("unknown");if(r)return await r.create(e);break;case"best-available":if(i=t.get("webgpu"),i?.isSupported?.())return await i.create(e);if(n=t.get("webgl"),n?.isSupported?.())return await n.create(e)}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){return"webgl"===e||"experimental-webgl"===e?this.originalGetContext("webgl2",t):this.originalGetContext(e,t)}}}function df(e){if(!e||0===e?.length)return null;const t=new Map;for(const i of e)t.set(i.type,i);return t}const pf=Pu()&&"undefined"!=typeof document,ff=()=>pf&&"complete"===document.readyState,mf={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"};class gf{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ff()}static pageLoaded=function(){if(ff()||"undefined"==typeof window)return Promise.resolve();return new Promise(e=>{window.addEventListener("load",()=>e())})}();constructor(e){if(this.props={...mf,...e},e=this.props,!Pu())return this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,void(this.canvas=null);if(e.canvas)"string"==typeof e.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas;else{const t=function(e){const{width:t,height:i}=e,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=t||1,n.height=i||1,n.style.width=Number.isFinite(t)?`${t}px`:"100%",n.style.height=Number.isFinite(i)?`${i}px`:"100%",n}(e),i=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!t)throw new Error(`${e} is not an HTML element`);return t}if(e)return e;return document.body}(e?.container||null);i.insertBefore(t,i.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(const t of e)t.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){if("undefined"!=typeof OffscreenCanvas&&this.canvas instanceof OffscreenCanvas)return 1;if(!(e=void 0===e?this.props.useDevicePixels:e)||e<=0)return 1;if(!0===e){return"undefined"!=typeof window&&window.devicePixelRatio||1}return e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":const e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){const[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),t=this._canvasSizeInfo.clientWidth||this.htmlCanvas?.clientWidth;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[n,r]=this.getDrawingBufferSize();return function(e,t,i,n,r){const o=e,s=_f(o[0],t,i);let a=Af(o[1],t,n,r),l=_f(o[0]+1,t,i);const c=l===i-1?l:l-1;let u;l=Af(o[1]+1,t,n,r),r?(l=0===l?l:l+1,u=a,a=l):u=l===n-1?l:l-1;return{x:s,y:a,width:Math.max(c-s+1,1),height:Math.max(u-a+1,1)}}(e,i,n,r,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let i="width"in t?t.width:this.htmlCanvas.clientWidth,n="height"in t?t.height:this.htmlCanvas.clientHeight;i&&n||(Gp.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);const r=this._canvasSizeInfo;if(r.clientWidth!==i||r.clientHeight!==n||r.devicePixelRatio!==e){let t=e;const r=Math.floor(i*t),o=Math.floor(n*t);this.htmlCanvas.width=r,this.htmlCanvas.height=o;const[s,a]=this.getDrawingBufferSize();s===r&&a===o||(t=Math.min(s/i,a/n),this.htmlCanvas.width=Math.floor(i*t),this.htmlCanvas.height=Math.floor(n*t),Gp.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){const e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){"lumagl-auto-created-canvas"===this.htmlCanvas?.id&&(this.htmlCanvas.id=e)}}function _f(e,t,i){return Math.min(Math.round(e*t),i-1)}function Af(e,t,i,n){return n?Math.max(0,i-1-Math.round(e*t)):Math.min(Math.round(e*t),i-1)}class yf extends Kp{static defaultProps={...Kp.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,t,i=yf.defaultProps){super(e,t,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}}class vf extends Kp{static defaultProps={...Kp.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,vf.defaultProps)}}function xf(e,t,i,n){if(n?.inlineSource){const n=function(e,t,i){let n="";for(let r=t-2;r<=t;r++){const o=e[r-1];void 0!==o&&(n+=bf(o,t,i))}return n}(t,i);return`\n${n}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}return n?.html?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function bf(e,t,i){const n=i?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e,t){let i="";for(let n=e.length;n":"\n"}`}function wf(e,t){return{name:Tf(e,t),language:"glsl",version:Ef(e)}}function Tf(e,t="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return i?i[1]:t}function Ef(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}return t}class Cf extends Kp{static defaultProps={...Kp.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Sf(t),...t},Cf.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}const t=await this.getCompilationInfo();"warnings"===this.props.debug&&0===t?.length||this._displayShaderLog(t)}_displayShaderLog(e){if("undefined"==typeof document||!document?.createElement)return;const t=wf(this.source).name,i=`${this.stage} ${t}`;let n=function(e,t,i){let n="";const r=t.split(/\r?\n/),o=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(i?.showSourceCode||"no"){case"all":let t=0;for(let e=1;e<=r.length;e++)for(n+=bf(r[e-1],e,i);o.length>t&&o[t].lineNum===e;){const e=o[t++];n+=xf(e,r,e.lineNum,{...i,inlineSource:!1})}return n;case"issues":case"no":for(const t of e)n+=xf(t,r,t.lineNum,{inlineSource:"no"!==i?.showSourceCode});return n}}(e,this.source,{showSourceCode:"all",html:!0});const r=this.getTranslatedSource();r&&(n+=`

Translated Source



${r}
`);const o=document.createElement("Button");o.innerHTML=`\n

Shader Compilation Error in ${i}



\n
\n${n}\n
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);const s=document.getElementsByClassName("luma-compiler-log-error");s[0]?.scrollIntoView&&s[0].scrollIntoView(),o.onclick=()=>{const e=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(e)}}}function Sf(e){return wf(e.source).name||e.id||Wp(`unnamed ${e.stage}-shader`)}class Bf extends Kp{static defaultProps={...Kp.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,Bf.defaultProps)}}class If extends Kp{static defaultProps={...Kp.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,If.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){const[i,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||i!==this.width,this.width=i,this.height=n}t&&(Gp.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(e=>{if("string"==typeof e){const t=this.createColorTexture(e);return this.attachResource(t),t.view}return e instanceof yf?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else this.depthStencilAttachment=e instanceof yf?e.view:e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Df={f32:4,f16:2,i32:4,u32:4};function Of(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[i,n]=e.split("x"),r=i,o=n?parseInt(n):1,s=Jp(r),a={type:r,components:o,byteLength:s.byteLength*o,integer:s.integer,signed:s.signed,normalized:s.normalized};return t&&(a.webglOnly=!0),a}function zf(e,t){const i={};for(const n of e.attributes)i[n.name]=Uf(e,t,n.name);return i}function Uf(e,t,i){const n=function(e,t){const i=e.attributes.find(e=>e.name===t);i||Gp.warn(`shader layout attribute "${t}" not present in shader`);return i||null}(e,i),r=function(e,t){Nf(e);let i=function(e,t){for(const i of e)if(i.format&&i.name===t)return{attributeName:i.name,bufferName:t,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}(e,t);if(i)return i;if(i=function(e,t){for(const i of e){let e=i.byteStride;if("number"!=typeof i.byteStride)for(const t of i.attributes||[]){e+=Of(t.format).byteLength}const n=i.attributes?.find(e=>e.attribute===t);if(n)return{attributeName:n.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:e}}return null}(e,t),i)return i;return Gp.warn(`layout for attribute "${t}" not present in buffer layout`),null}(t,i);if(!n)return null;const o=function(e){const[t,i]=kf[e],n="i32"===t||"u32"===t,r="u32"!==t,o=Df[t]*i,s=function(e,t){let i;switch(e){case"f32":i="float32";break;case"i32":i="sint32";break;case"u32":i="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return 1===t?i:`${i}x${t}`}(t,i);return{dataType:t,components:i,defaultVertexFormat:s,byteLength:o,integer:n,signed:r}}(n.type),s=r?.vertexFormat||o.defaultVertexFormat,a=Of(s);return{attributeName:r?.attributeName||n.name,bufferName:r?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:o.integer,stepMode:r?.stepMode||n.stepMode,byteOffset:r?.byteOffset||0,byteStride:r?.byteStride||0}}function Nf(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Gp.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}class Vf extends Kp{static defaultProps={...Kp.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Vf.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,i=16){const n=zf(e,t),r=new Array(i).fill(null);for(const e of Object.values(n))r[e.location]=e;return r}(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}}class jf extends Kp{static defaultProps={...Kp.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,jf.defaultProps)}}class Gf extends Kp{static defaultProps={...Kp.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Gf.defaultProps)}}const Hf={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Qf(e){const t=Hf[e];return cf(e),t}function $f(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}let Zf;function Wf(e){return(!Zf||Zf.byteLength"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const i=t;for(const e of i.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){(function(e,t){if(e!==t)return!1;const i=$p(e);if(!i)return!1;const n=$p(t);if(n&&i.length===n.length)for(let e=0;e4)throw new Error(`size ${t}`);const n=t;let r=Jf(e);if("uint8"===r&&i&&1===n)return"unorm8-webgl";if("uint8"===r&&i&&3===n)return"unorm8x3-webgl";if("uint8"===r||"sint8"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}if("uint16"===r||"sint16"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}return 1===n?r:`${r}x${n}`}function tm(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const n=e[i];var r;null!==$p(r=n)||"number"==typeof r||"boolean"==typeof r?t.uniforms[i]=n:t.bindings[i]=n}),t}async function im(e,t){return await new Promise((i,n)=>{try{const r=new Image;r.onload=()=>i(r),r.onerror=()=>n(new Error(`Could not load image ${e}.`)),r.crossOrigin=t?.crossOrigin||"anonymous",r.src=e.startsWith("http")?e:""+e}catch(e){n(e)}})}async function nm(e,t){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",e),t&&(n.id=t),new Promise((t,r)=>{n.onload=t,n.onerror=t=>r(new Error(`Unable to load script '${e}': ${t}`)),i.appendChild(n)})}function rm(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n`}}class cm extends om{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class um extends om{constructor(e,t,i,n){super(e,i),this.format=t,this.access=n}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+="f",e;if("i32"===this.format.name)return e+="i",e;if("u32"===this.format.name)return e+="u",e;if("bool"===this.format.name)return e+="b",e;if("f16"===this.format.name)return e+="h",e}e+=`<${this.format.name}>`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}var hm;(e=>{e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(hm||(hm={}));class dm{constructor(e,t,i,n,r,o,s){this.name=e,this.type=t,this.group=i,this.binding=n,this.attributes=r,this.resourceType=o,this.access=s}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class pm{constructor(e,t){this.name=e,this.type=t}}class fm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n,this.interpolation=null}}class mm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n}}class gm{constructor(e,t,i,n){this.name=e,this.type=t,this.attributes=i,this.id=n}}class _m{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Am{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class ym{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function vm(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0==i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))}const xm=new Float32Array(1),bm=new Int32Array(xm.buffer),wm=new Uint16Array(1);function Tm(e){xm[0]=e;const t=bm[0],i=t>>31&1;let n=t>>23&255,r=8388607&t;if(255===n)return wm[0]=i<<15|31744|(0!==r?512:0),wm[0];if(0===n){if(0===r)return wm[0]=i<<15,wm[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return n=127-e,r&=8388607,n>0?(r=(r>>126-n)+(r>>127-n&1),wm[0]=i<<15|n<<10|r>>13,wm[0]):(wm[0]=i<<15,wm[0])}return n=n-127+15,n>=31?(wm[0]=i<<15|31744,wm[0]):n<=0?n<-10?(wm[0]=i<<15,wm[0]):(r=(8388608|r)>>1-n,wm[0]=i<<15|r>>13,wm[0]):(r>>=13,wm[0]=i<<15|n<<10|r,wm[0])}const Em=new Uint32Array(1),Cm=new Float32Array(Em.buffer,0,1);function Sm(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Em[0]=t,Cm[0]}function Bm(e,t,i,n){const r=[0,0,0,0];for(let o=0;o{e.increment="++",e.decrement="--"})(Qm||(Qm={})),(e=>{e.parse=function(t){const i=t;if("parse"==i)throw new Error("Invalid value for IncrementOperator");return e[i]}})(Qm||(Qm={}));class qm extends km{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(e=>{e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})($m||($m={})),($m||($m={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class Km extends km{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Xm extends km{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Fm.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Jm extends km{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class Ym extends km{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class eg extends km{constructor(e,t,i,n){super(),this.condition=e,this.body=t,this.elseif=i,this.else=n}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class tg extends km{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class ig extends km{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class ng extends km{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class rg extends km{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class og extends km{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class sg extends km{constructor(){super()}get astNodeType(){return"discard"}}class ag extends km{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class lg extends km{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class cg extends km{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let i=1;i`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}dg.vec2f=new dg("vec2",cg.f32,null),dg.vec3f=new dg("vec3",cg.f32,null),dg.vec4f=new dg("vec4",cg.f32,null),dg.vec2i=new dg("vec2",cg.i32,null),dg.vec3i=new dg("vec3",cg.i32,null),dg.vec4i=new dg("vec4",cg.i32,null),dg.vec2u=new dg("vec2",cg.u32,null),dg.vec3u=new dg("vec3",cg.u32,null),dg.vec4u=new dg("vec4",cg.u32,null),dg.vec2h=new dg("vec2",cg.f16,null),dg.vec3h=new dg("vec3",cg.f16,null),dg.vec4h=new dg("vec4",cg.f16,null),dg.vec2b=new dg("vec2",cg.bool,null),dg.vec3b=new dg("vec3",cg.bool,null),dg.vec4b=new dg("vec4",cg.bool,null),dg.mat2x2f=new dg("mat2x2",cg.f32,null),dg.mat2x3f=new dg("mat2x3",cg.f32,null),dg.mat2x4f=new dg("mat2x4",cg.f32,null),dg.mat3x2f=new dg("mat3x2",cg.f32,null),dg.mat3x3f=new dg("mat3x3",cg.f32,null),dg.mat3x4f=new dg("mat3x4",cg.f32,null),dg.mat4x2f=new dg("mat4x2",cg.f32,null),dg.mat4x3f=new dg("mat4x3",cg.f32,null),dg.mat4x4f=new dg("mat4x4",cg.f32,null),dg.mat2x2h=new dg("mat2x2",cg.f16,null),dg.mat2x3h=new dg("mat2x3",cg.f16,null),dg.mat2x4h=new dg("mat2x4",cg.f16,null),dg.mat3x2h=new dg("mat3x2",cg.f16,null),dg.mat3x3h=new dg("mat3x3",cg.f16,null),dg.mat3x4h=new dg("mat3x4",cg.f16,null),dg.mat4x2h=new dg("mat4x2",cg.f16,null),dg.mat4x3h=new dg("mat4x3",cg.f16,null),dg.mat4x4h=new dg("mat4x4",cg.f16,null),dg.mat2x2i=new dg("mat2x2",cg.i32,null),dg.mat2x3i=new dg("mat2x3",cg.i32,null),dg.mat2x4i=new dg("mat2x4",cg.i32,null),dg.mat3x2i=new dg("mat3x2",cg.i32,null),dg.mat3x3i=new dg("mat3x3",cg.i32,null),dg.mat3x4i=new dg("mat3x4",cg.i32,null),dg.mat4x2i=new dg("mat4x2",cg.i32,null),dg.mat4x3i=new dg("mat4x3",cg.i32,null),dg.mat4x4i=new dg("mat4x4",cg.i32,null),dg.mat2x2u=new dg("mat2x2",cg.u32,null),dg.mat2x3u=new dg("mat2x3",cg.u32,null),dg.mat2x4u=new dg("mat2x4",cg.u32,null),dg.mat3x2u=new dg("mat3x2",cg.u32,null),dg.mat3x3u=new dg("mat3x3",cg.u32,null),dg.mat3x4u=new dg("mat3x4",cg.u32,null),dg.mat4x2u=new dg("mat4x2",cg.u32,null),dg.mat4x3u=new dg("mat4x3",cg.u32,null),dg.mat4x4u=new dg("mat4x4",cg.u32,null);class pg extends cg{constructor(e,t,i,n){super(e),this.storage=t,this.type=i,this.access=n}get astNodeType(){return"pointer"}}class fg extends cg{constructor(e,t,i,n){super(e),this.attributes=t,this.format=i,this.count=n}get astNodeType(){return"array"}get isArray(){return!0}}class mg extends cg{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class gg extends Pm{constructor(){super(),this.postfix=null}}class _g extends gg{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class Ag extends gg{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class yg extends gg{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Fm.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class vg extends gg{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class xg extends gg{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class bg extends gg{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Ug}get isVector(){return this.value instanceof Vg||this.value instanceof jg}get scalarValue(){return this.value instanceof Ug?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof Vg||this.value instanceof jg?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class wg extends gg{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class Tg extends gg{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Eg extends gg{constructor(){super()}}class Cg extends Eg{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Sg extends Eg{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?cg.f32:"u32"===e.name||"u32"===t.name?cg.u32:cg.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Bg extends Pm{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Ig extends gg{constructor(){super()}get astNodeType(){return"default"}}class Mg extends Bg{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Pg extends Bg{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Rg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class Lg extends Pm{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Fg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class kg extends Pm{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Dg{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Dg._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,n){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Dg._id=0;class Og extends Dg{constructor(){super(new om("void",null),null)}toString(){return"void"}}Og.void=new Og;class zg extends Dg{constructor(e){super(new cm("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,n){this.reference.setDataValue(e,t,i,n)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class Ug extends Dg{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):"f32"===this.typeInfo.name||"f16"===this.typeInfo.name?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new Ug(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Ug(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Ug(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,n){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof Ug))return void console.error("SetDataValue: Invalid value",t);let r=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?r=Math.floor(r):"bool"===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Ng(e,t,i){const n=t.length;return 2===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${i}`),null):3===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${i}`),null):4===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${i}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Vg extends Dg{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):"vec2"===t||"vec3"===t||"vec4"===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Vg(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Vg(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Vg(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,n){i instanceof _g?console.error("TODO: Set vector postfix"):t instanceof Vg?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(null===t)return this;let n=e.getTypeInfo("f32");if(this.typeInfo instanceof um)n=this.typeInfo.format||n;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?n=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?n=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?n=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?n=e.getTypeInfo("u32"):"vec2h"===t||"vec3h"===t||"vec4h"===t?n=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${t}`)}let r=this;for(;null!==t&&null!==r;){if(t instanceof Tg){const o=t.index;let s=-1;if(o instanceof bg){if(!(o.value instanceof Ug))return console.error(`GetSubData: Invalid array index ${o.value}`),null;s=o.value.value}else{const t=e.evalExpression(o,i);if(!(t instanceof Ug))return console.error("GetSubData: Unknown index type",o),null;s=t.value}if(s<0||s>=r.data.length)return console.error("GetSubData: Index out of range",s),null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}throw"GetSubData: Invalid data type"}if(!(t instanceof _g))return console.error("GetSubData: Unknown postfix",t),null;{const i=t.value.toLowerCase();if(1===i.length){let e=0;if("x"===i||"r"===i)e=0;else if("y"===i||"g"===i)e=1;else if("z"===i||"b"===i)e=2;else{if("w"!==i&&"a"!==i)return console.error(`GetSubData: Unknown member ${i}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}}const o=[];for(const e of i)"x"===e||"r"===e?o.push(this.data[0]):"y"===e||"g"===e?o.push(this.data[1]):"z"===e||"b"===e?o.push(this.data[2]):"w"===e||"a"===e?o.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);r=Ng(e,o,n.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const s=n.endsWith("h")?"h":"f";let a;if("mat2x2"===n||"mat2x2f"===n||"mat2x2h"===n||"mat3x2"===n||"mat3x2f"===n||"mat3x2h"===n||"mat4x2"===n||"mat4x2f"===n||"mat4x2h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${s}`));else if("mat2x3"===n||"mat2x3f"===n||"mat2x3h"===n||"mat3x3"===n||"mat3x3f"===n||"mat3x3h"===n||"mat4x3"===n||"mat4x3f"===n||"mat4x3h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${s}`));else{if("mat2x4"!==n&&"mat2x4f"!==n&&"mat2x4h"!==n&&"mat3x4"!==n&&"mat3x4f"!==n&&"mat3x4h"!==n&&"mat4x4"!==n&&"mat4x4f"!==n&&"mat4x4h"!==n)return console.error(`GetDataValue: Unknown type ${n}`),null;a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${s}`))}return t.postfix?a.getSubData(e,t.postfix,i):a}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t"!==o&&"x32"!==o)if("u32"!==o&&"atomic"!==o)if("bool"!==o){if("vec2f"===o||"vec2h"===o){const e=new Float32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===o||"vec3h"===o){const e=new Float32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===o||"vec4h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===o){const e=new Int32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===o){const e=new Int32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===o){const e=new Int32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===o||"mat2x2h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===o||"mat2x3h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===o||"mat2x4h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat3x2f"===o||"mat3x2h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===o||"mat3x3h"===o){const e=new Float32Array(this.buffer,n,9);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(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]))}if("mat3x4f"===o||"mat3x4h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x2f"===o||"mat4x2h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat4x3f"===o||"mat4x3h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x4f"===o||"mat4x4h"===o){const e=new Float32Array(this.buffer,n,16);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(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]))}if(t instanceof Gg){if(i===t.typeInfo)return void new Uint8Array(this.buffer,n,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Uint32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Float32Array(this.buffer,n,1)[0]=t.value)}getSubData(e,t,i){var n,r,o;if(null===t)return this;let s=this.offset,a=this.typeInfo;for(;t;){if(t instanceof Tg){const n=t.index,r=n instanceof gg?e.evalExpression(n,i):n;let o=0;if(r instanceof Ug?o=r.value:"number"==typeof r?o=r:console.error("GetDataValue: Invalid index type",n),a instanceof lm)s+=o*a.stride,a=a.format;else{const t=a.getTypeName();"mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t?(s+=16*o,a=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${a.getTypeName()} is not an array`)}}else{if(!(t instanceof _g))return console.error("GetDataValue: Unknown postfix type",t),null;{const i=t.value;if(a instanceof am){let e=!1;for(const t of a.members)if(t.name===i){s+=t.offset,a=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${i} not found`),null}else if(a instanceof om){const t=a.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(i.length>0&&i.length<5){let n="f";const r=[];for(let o=0;o=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const e=new Float32Array(this.buffer,s,3);r.push(e[l])}else if("vec4f"===t)r.push(new Float32Array(this.buffer,s,4)[l]);else if("vec2i"===t)n="i",r.push(new Int32Array(this.buffer,s,2)[l]);else if("vec3i"===t)n="i",r.push(new Int32Array(this.buffer,s,3)[l]);else if("vec4i"===t)n="i",r.push(new Int32Array(this.buffer,s,4)[l]);else if("vec2u"===t){n="u";const e=new Uint32Array(this.buffer,s,2);r.push(e[l])}else"vec3u"===t?(n="u",r.push(new Uint32Array(this.buffer,s,3)[l])):"vec4u"===t&&(n="u",r.push(new Uint32Array(this.buffer,s,4)[l]))}return 2===r.length?a=e.getTypeInfo(`vec2${n}`):3===r.length?a=e.getTypeInfo(`vec3${n}`):4===r.length?a=e.getTypeInfo(`vec4${n}`):console.error(`GetDataValue: Invalid vector length ${r.length}`),new Vg(r,a,null)}return console.error(`GetDataValue: Unknown member ${i}`),null}return console.error(`GetDataValue: Type ${t} is not a struct`),null}}}t=t.postfix}const l=a.getTypeName();return"f32"===l?new Ug(new Float32Array(this.buffer,s,1),a,this):"i32"===l?new Ug(new Int32Array(this.buffer,s,1),a,this):"u32"===l?new Ug(new Uint32Array(this.buffer,s,1),a,this):"vec2f"===l?new Vg(new Float32Array(this.buffer,s,2),a,this):"vec3f"===l?new Vg(new Float32Array(this.buffer,s,3),a,this):"vec4f"===l?new Vg(new Float32Array(this.buffer,s,4),a,this):"vec2i"===l?new Vg(new Int32Array(this.buffer,s,2),a,this):"vec3i"===l?new Vg(new Int32Array(this.buffer,s,3),a,this):"vec4i"===l?new Vg(new Int32Array(this.buffer,s,4),a,this):"vec2u"===l?new Vg(new Uint32Array(this.buffer,s,2),a,this):"vec3u"===l?new Vg(new Uint32Array(this.buffer,s,3),a,this):"vec4u"===l?new Vg(new Uint32Array(this.buffer,s,4),a,this):a instanceof um&&"atomic"===a.name?"u32"===(null===(n=a.format)||void 0===n?void 0:n.name)?new Ug(new Uint32Array(this.buffer,s,1)[0],a.format,this):"i32"===(null===(r=a.format)||void 0===r?void 0:r.name)?new Ug(new Int32Array(this.buffer,s,1)[0],a.format,this):(console.error(`GetDataValue: Invalid atomic format ${null===(o=a.format)||void 0===o?void 0:o.name}`),null):new Gg(this.buffer,a,s,this)}toString(){let e="";if(this.typeInfo instanceof lm)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i0?null!==(e=i[0])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.width)&&void 0!==t?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?null!==(e=i[1])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?null!==(e=i[2])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i>e);return t}get texelByteSize(){const e=this.format,t=Mm[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Mm[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Mm[e],i=this.width;if(!e||i<=0||!t)return-1;const n=this.height,r=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*("1d"===o?1:n/t.blockHeight)*t.bytesPerBlock*r}getPixel(e,t,i=0,n=0){const r=this.texelByteSize,o=this.bytesPerRow,s=this.height,a=this.data[n];return function(e,t,i,n,r,o,s,a,l){const c=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return[Bm(e,c,"8unorm",1)[0]];case"r8snorm":return[Bm(e,c,"8snorm",1)[0]];case"r8uint":return[Bm(e,c,"8uint",1)[0]];case"r8sint":return[Bm(e,c,"8sint",1)[0]];case"rg8unorm":{const t=Bm(e,c,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Bm(e,c,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Bm(e,c,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Bm(e,c,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Bm(e,c,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Bm(e,c,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Bm(e,c,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Bm(e,c,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Bm(e,c,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Bm(e,c,"16uint",1)[0]];case"r16sint":return[Bm(e,c,"16sint",1)[0]];case"r16float":return[Bm(e,c,"16float",1)[0]];case"rg16uint":{const t=Bm(e,c,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Bm(e,c,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Bm(e,c,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Bm(e,c,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Bm(e,c,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Bm(e,c,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Bm(e,c,"32uint",1)[0]];case"r32sint":return[Bm(e,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Bm(e,c,"32float",1)[0]];case"rg32uint":{const t=Bm(e,c,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Bm(e,c,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Bm(e,c,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Bm(e,c,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Bm(e,c,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Bm(e,c,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,c,1)[0],i=(4192256&t)>>11,n=(4290772992&t)>>22;return[Sm(2047&t),Sm(i),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Em[0]=t,Cm[0]}(n),1]}}return null}(new Uint8Array(a),e,t,i,n,s,o,r,this.format)}setPixel(e,t,i,n,r){const o=this.texelByteSize,s=this.bytesPerRow,a=this.height,l=this.data[n];!function(e,t,i,n,r,o,s,a,l,c){const u=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return void Im(e,u,"8unorm",1,c);case"r8snorm":return void Im(e,u,"8snorm",1,c);case"r8uint":return void Im(e,u,"8uint",1,c);case"r8sint":return void Im(e,u,"8sint",1,c);case"rg8unorm":return void Im(e,u,"8unorm",2,c);case"rg8snorm":return void Im(e,u,"8snorm",2,c);case"rg8uint":return void Im(e,u,"8uint",2,c);case"rg8sint":return void Im(e,u,"8sint",2,c);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Im(e,u,"8unorm",4,c);case"rgba8snorm":return void Im(e,u,"8snorm",4,c);case"rgba8uint":return void Im(e,u,"8uint",4,c);case"rgba8sint":return void Im(e,u,"8sint",4,c);case"r16uint":return void Im(e,u,"16uint",1,c);case"r16sint":return void Im(e,u,"16sint",1,c);case"r16float":return void Im(e,u,"16float",1,c);case"rg16uint":return void Im(e,u,"16uint",2,c);case"rg16sint":return void Im(e,u,"16sint",2,c);case"rg16float":return void Im(e,u,"16float",2,c);case"rgba16uint":return void Im(e,u,"16uint",4,c);case"rgba16sint":return void Im(e,u,"16sint",4,c);case"rgba16float":return void Im(e,u,"16float",4,c);case"r32uint":return void Im(e,u,"32uint",1,c);case"r32sint":return void Im(e,u,"32sint",1,c);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Im(e,u,"32float",1,c);case"rg32uint":return void Im(e,u,"32uint",2,c);case"rg32sint":return void Im(e,u,"32sint",2,c);case"rg32float":return void Im(e,u,"32float",2,c);case"rgba32uint":return void Im(e,u,"32uint",4,c);case"rgba32sint":return void Im(e,u,"32sint",4,c);case"rgba32float":return void Im(e,u,"32float",4,c);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}}(new Uint8Array(l),e,t,i,n,a,s,o,this.format,r)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(Wm||(Wm={}));class Qg{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class $g{}Zm=$g,$g.none=new Qg("",Wm.reserved,""),$g.eof=new Qg("EOF",Wm.token,""),$g.reserved={asm:new Qg("asm",Wm.reserved,"asm"),bf16:new Qg("bf16",Wm.reserved,"bf16"),do:new Qg("do",Wm.reserved,"do"),enum:new Qg("enum",Wm.reserved,"enum"),f16:new Qg("f16",Wm.reserved,"f16"),f64:new Qg("f64",Wm.reserved,"f64"),handle:new Qg("handle",Wm.reserved,"handle"),i8:new Qg("i8",Wm.reserved,"i8"),i16:new Qg("i16",Wm.reserved,"i16"),i64:new Qg("i64",Wm.reserved,"i64"),mat:new Qg("mat",Wm.reserved,"mat"),premerge:new Qg("premerge",Wm.reserved,"premerge"),regardless:new Qg("regardless",Wm.reserved,"regardless"),typedef:new Qg("typedef",Wm.reserved,"typedef"),u8:new Qg("u8",Wm.reserved,"u8"),u16:new Qg("u16",Wm.reserved,"u16"),u64:new Qg("u64",Wm.reserved,"u64"),unless:new Qg("unless",Wm.reserved,"unless"),using:new Qg("using",Wm.reserved,"using"),vec:new Qg("vec",Wm.reserved,"vec"),void:new Qg("void",Wm.reserved,"void")},$g.keywords={array:new Qg("array",Wm.keyword,"array"),atomic:new Qg("atomic",Wm.keyword,"atomic"),bool:new Qg("bool",Wm.keyword,"bool"),f32:new Qg("f32",Wm.keyword,"f32"),i32:new Qg("i32",Wm.keyword,"i32"),mat2x2:new Qg("mat2x2",Wm.keyword,"mat2x2"),mat2x3:new Qg("mat2x3",Wm.keyword,"mat2x3"),mat2x4:new Qg("mat2x4",Wm.keyword,"mat2x4"),mat3x2:new Qg("mat3x2",Wm.keyword,"mat3x2"),mat3x3:new Qg("mat3x3",Wm.keyword,"mat3x3"),mat3x4:new Qg("mat3x4",Wm.keyword,"mat3x4"),mat4x2:new Qg("mat4x2",Wm.keyword,"mat4x2"),mat4x3:new Qg("mat4x3",Wm.keyword,"mat4x3"),mat4x4:new Qg("mat4x4",Wm.keyword,"mat4x4"),ptr:new Qg("ptr",Wm.keyword,"ptr"),sampler:new Qg("sampler",Wm.keyword,"sampler"),sampler_comparison:new Qg("sampler_comparison",Wm.keyword,"sampler_comparison"),struct:new Qg("struct",Wm.keyword,"struct"),texture_1d:new Qg("texture_1d",Wm.keyword,"texture_1d"),texture_2d:new Qg("texture_2d",Wm.keyword,"texture_2d"),texture_2d_array:new Qg("texture_2d_array",Wm.keyword,"texture_2d_array"),texture_3d:new Qg("texture_3d",Wm.keyword,"texture_3d"),texture_cube:new Qg("texture_cube",Wm.keyword,"texture_cube"),texture_cube_array:new Qg("texture_cube_array",Wm.keyword,"texture_cube_array"),texture_multisampled_2d:new Qg("texture_multisampled_2d",Wm.keyword,"texture_multisampled_2d"),texture_storage_1d:new Qg("texture_storage_1d",Wm.keyword,"texture_storage_1d"),texture_storage_2d:new Qg("texture_storage_2d",Wm.keyword,"texture_storage_2d"),texture_storage_2d_array:new Qg("texture_storage_2d_array",Wm.keyword,"texture_storage_2d_array"),texture_storage_3d:new Qg("texture_storage_3d",Wm.keyword,"texture_storage_3d"),texture_depth_2d:new Qg("texture_depth_2d",Wm.keyword,"texture_depth_2d"),texture_depth_2d_array:new Qg("texture_depth_2d_array",Wm.keyword,"texture_depth_2d_array"),texture_depth_cube:new Qg("texture_depth_cube",Wm.keyword,"texture_depth_cube"),texture_depth_cube_array:new Qg("texture_depth_cube_array",Wm.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Qg("texture_depth_multisampled_2d",Wm.keyword,"texture_depth_multisampled_2d"),texture_external:new Qg("texture_external",Wm.keyword,"texture_external"),u32:new Qg("u32",Wm.keyword,"u32"),vec2:new Qg("vec2",Wm.keyword,"vec2"),vec3:new Qg("vec3",Wm.keyword,"vec3"),vec4:new Qg("vec4",Wm.keyword,"vec4"),bitcast:new Qg("bitcast",Wm.keyword,"bitcast"),block:new Qg("block",Wm.keyword,"block"),break:new Qg("break",Wm.keyword,"break"),case:new Qg("case",Wm.keyword,"case"),continue:new Qg("continue",Wm.keyword,"continue"),continuing:new Qg("continuing",Wm.keyword,"continuing"),default:new Qg("default",Wm.keyword,"default"),diagnostic:new Qg("diagnostic",Wm.keyword,"diagnostic"),discard:new Qg("discard",Wm.keyword,"discard"),else:new Qg("else",Wm.keyword,"else"),enable:new Qg("enable",Wm.keyword,"enable"),fallthrough:new Qg("fallthrough",Wm.keyword,"fallthrough"),false:new Qg("false",Wm.keyword,"false"),fn:new Qg("fn",Wm.keyword,"fn"),for:new Qg("for",Wm.keyword,"for"),function:new Qg("function",Wm.keyword,"function"),if:new Qg("if",Wm.keyword,"if"),let:new Qg("let",Wm.keyword,"let"),const:new Qg("const",Wm.keyword,"const"),loop:new Qg("loop",Wm.keyword,"loop"),while:new Qg("while",Wm.keyword,"while"),private:new Qg("private",Wm.keyword,"private"),read:new Qg("read",Wm.keyword,"read"),read_write:new Qg("read_write",Wm.keyword,"read_write"),return:new Qg("return",Wm.keyword,"return"),requires:new Qg("requires",Wm.keyword,"requires"),storage:new Qg("storage",Wm.keyword,"storage"),switch:new Qg("switch",Wm.keyword,"switch"),true:new Qg("true",Wm.keyword,"true"),alias:new Qg("alias",Wm.keyword,"alias"),type:new Qg("type",Wm.keyword,"type"),uniform:new Qg("uniform",Wm.keyword,"uniform"),var:new Qg("var",Wm.keyword,"var"),override:new Qg("override",Wm.keyword,"override"),workgroup:new Qg("workgroup",Wm.keyword,"workgroup"),write:new Qg("write",Wm.keyword,"write"),r8unorm:new Qg("r8unorm",Wm.keyword,"r8unorm"),r8snorm:new Qg("r8snorm",Wm.keyword,"r8snorm"),r8uint:new Qg("r8uint",Wm.keyword,"r8uint"),r8sint:new Qg("r8sint",Wm.keyword,"r8sint"),r16uint:new Qg("r16uint",Wm.keyword,"r16uint"),r16sint:new Qg("r16sint",Wm.keyword,"r16sint"),r16float:new Qg("r16float",Wm.keyword,"r16float"),rg8unorm:new Qg("rg8unorm",Wm.keyword,"rg8unorm"),rg8snorm:new Qg("rg8snorm",Wm.keyword,"rg8snorm"),rg8uint:new Qg("rg8uint",Wm.keyword,"rg8uint"),rg8sint:new Qg("rg8sint",Wm.keyword,"rg8sint"),r32uint:new Qg("r32uint",Wm.keyword,"r32uint"),r32sint:new Qg("r32sint",Wm.keyword,"r32sint"),r32float:new Qg("r32float",Wm.keyword,"r32float"),rg16uint:new Qg("rg16uint",Wm.keyword,"rg16uint"),rg16sint:new Qg("rg16sint",Wm.keyword,"rg16sint"),rg16float:new Qg("rg16float",Wm.keyword,"rg16float"),rgba8unorm:new Qg("rgba8unorm",Wm.keyword,"rgba8unorm"),rgba8unorm_srgb:new Qg("rgba8unorm_srgb",Wm.keyword,"rgba8unorm_srgb"),rgba8snorm:new Qg("rgba8snorm",Wm.keyword,"rgba8snorm"),rgba8uint:new Qg("rgba8uint",Wm.keyword,"rgba8uint"),rgba8sint:new Qg("rgba8sint",Wm.keyword,"rgba8sint"),bgra8unorm:new Qg("bgra8unorm",Wm.keyword,"bgra8unorm"),bgra8unorm_srgb:new Qg("bgra8unorm_srgb",Wm.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Qg("rgb10a2unorm",Wm.keyword,"rgb10a2unorm"),rg11b10float:new Qg("rg11b10float",Wm.keyword,"rg11b10float"),rg32uint:new Qg("rg32uint",Wm.keyword,"rg32uint"),rg32sint:new Qg("rg32sint",Wm.keyword,"rg32sint"),rg32float:new Qg("rg32float",Wm.keyword,"rg32float"),rgba16uint:new Qg("rgba16uint",Wm.keyword,"rgba16uint"),rgba16sint:new Qg("rgba16sint",Wm.keyword,"rgba16sint"),rgba16float:new Qg("rgba16float",Wm.keyword,"rgba16float"),rgba32uint:new Qg("rgba32uint",Wm.keyword,"rgba32uint"),rgba32sint:new Qg("rgba32sint",Wm.keyword,"rgba32sint"),rgba32float:new Qg("rgba32float",Wm.keyword,"rgba32float"),static_assert:new Qg("static_assert",Wm.keyword,"static_assert")},$g.tokens={decimal_float_literal:new Qg("decimal_float_literal",Wm.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new Qg("hex_float_literal",Wm.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new Qg("int_literal",Wm.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Qg("uint_literal",Wm.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new Qg("name",Wm.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new Qg("ident",Wm.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Qg("and",Wm.token,"&"),and_and:new Qg("and_and",Wm.token,"&&"),arrow:new Qg("arrow ",Wm.token,"->"),attr:new Qg("attr",Wm.token,"@"),forward_slash:new Qg("forward_slash",Wm.token,"/"),bang:new Qg("bang",Wm.token,"!"),bracket_left:new Qg("bracket_left",Wm.token,"["),bracket_right:new Qg("bracket_right",Wm.token,"]"),brace_left:new Qg("brace_left",Wm.token,"{"),brace_right:new Qg("brace_right",Wm.token,"}"),colon:new Qg("colon",Wm.token,":"),comma:new Qg("comma",Wm.token,","),equal:new Qg("equal",Wm.token,"="),equal_equal:new Qg("equal_equal",Wm.token,"=="),not_equal:new Qg("not_equal",Wm.token,"!="),greater_than:new Qg("greater_than",Wm.token,">"),greater_than_equal:new Qg("greater_than_equal",Wm.token,">="),shift_right:new Qg("shift_right",Wm.token,">>"),less_than:new Qg("less_than",Wm.token,"<"),less_than_equal:new Qg("less_than_equal",Wm.token,"<="),shift_left:new Qg("shift_left",Wm.token,"<<"),modulo:new Qg("modulo",Wm.token,"%"),minus:new Qg("minus",Wm.token,"-"),minus_minus:new Qg("minus_minus",Wm.token,"--"),period:new Qg("period",Wm.token,"."),plus:new Qg("plus",Wm.token,"+"),plus_plus:new Qg("plus_plus",Wm.token,"++"),or:new Qg("or",Wm.token,"|"),or_or:new Qg("or_or",Wm.token,"||"),paren_left:new Qg("paren_left",Wm.token,"("),paren_right:new Qg("paren_right",Wm.token,")"),semicolon:new Qg("semicolon",Wm.token,";"),star:new Qg("star",Wm.token,"*"),tilde:new Qg("tilde",Wm.token,"~"),underscore:new Qg("underscore",Wm.token,"_"),xor:new Qg("xor",Wm.token,"^"),plus_equal:new Qg("plus_equal",Wm.token,"+="),minus_equal:new Qg("minus_equal",Wm.token,"-="),times_equal:new Qg("times_equal",Wm.token,"*="),division_equal:new Qg("division_equal",Wm.token,"/="),modulo_equal:new Qg("modulo_equal",Wm.token,"%="),and_equal:new Qg("and_equal",Wm.token,"&="),or_equal:new Qg("or_equal",Wm.token,"|="),xor_equal:new Qg("xor_equal",Wm.token,"^="),shift_right_equal:new Qg("shift_right_equal",Wm.token,">>="),shift_left_equal:new Qg("shift_left_equal",Wm.token,"<<=")},$g.simpleTokens={"@":Zm.tokens.attr,"{":Zm.tokens.brace_left,"}":Zm.tokens.brace_right,":":Zm.tokens.colon,",":Zm.tokens.comma,"(":Zm.tokens.paren_left,")":Zm.tokens.paren_right,";":Zm.tokens.semicolon},$g.literalTokens={"&":Zm.tokens.and,"&&":Zm.tokens.and_and,"->":Zm.tokens.arrow,"/":Zm.tokens.forward_slash,"!":Zm.tokens.bang,"[":Zm.tokens.bracket_left,"]":Zm.tokens.bracket_right,"=":Zm.tokens.equal,"==":Zm.tokens.equal_equal,"!=":Zm.tokens.not_equal,">":Zm.tokens.greater_than,">=":Zm.tokens.greater_than_equal,">>":Zm.tokens.shift_right,"<":Zm.tokens.less_than,"<=":Zm.tokens.less_than_equal,"<<":Zm.tokens.shift_left,"%":Zm.tokens.modulo,"-":Zm.tokens.minus,"--":Zm.tokens.minus_minus,".":Zm.tokens.period,"+":Zm.tokens.plus,"++":Zm.tokens.plus_plus,"|":Zm.tokens.or,"||":Zm.tokens.or_or,"*":Zm.tokens.star,"~":Zm.tokens.tilde,_:Zm.tokens.underscore,"^":Zm.tokens.xor,"+=":Zm.tokens.plus_equal,"-=":Zm.tokens.minus_equal,"*=":Zm.tokens.times_equal,"/=":Zm.tokens.division_equal,"%=":Zm.tokens.modulo_equal,"&=":Zm.tokens.and_equal,"|=":Zm.tokens.or_equal,"^=":Zm.tokens.xor_equal,">>=":Zm.tokens.shift_right_equal,"<<=":Zm.tokens.shift_left_equal},$g.regexTokens={decimal_float_literal:Zm.tokens.decimal_float_literal,hex_float_literal:Zm.tokens.hex_float_literal,int_literal:Zm.tokens.int_literal,uint_literal:Zm.tokens.uint_literal,ident:Zm.tokens.ident},$g.storage_class=[Zm.keywords.function,Zm.keywords.private,Zm.keywords.workgroup,Zm.keywords.uniform,Zm.keywords.storage],$g.access_mode=[Zm.keywords.read,Zm.keywords.write,Zm.keywords.read_write],$g.sampler_type=[Zm.keywords.sampler,Zm.keywords.sampler_comparison],$g.sampled_texture_type=[Zm.keywords.texture_1d,Zm.keywords.texture_2d,Zm.keywords.texture_2d_array,Zm.keywords.texture_3d,Zm.keywords.texture_cube,Zm.keywords.texture_cube_array],$g.multisampled_texture_type=[Zm.keywords.texture_multisampled_2d],$g.storage_texture_type=[Zm.keywords.texture_storage_1d,Zm.keywords.texture_storage_2d,Zm.keywords.texture_storage_2d_array,Zm.keywords.texture_storage_3d],$g.depth_texture_type=[Zm.keywords.texture_depth_2d,Zm.keywords.texture_depth_2d_array,Zm.keywords.texture_depth_cube,Zm.keywords.texture_depth_cube_array,Zm.keywords.texture_depth_multisampled_2d],$g.texture_external_type=[Zm.keywords.texture_external],$g.any_texture_type=[...Zm.sampled_texture_type,...Zm.multisampled_texture_type,...Zm.storage_texture_type,...Zm.depth_texture_type,...Zm.texture_external_type],$g.texel_format=[Zm.keywords.r8unorm,Zm.keywords.r8snorm,Zm.keywords.r8uint,Zm.keywords.r8sint,Zm.keywords.r16uint,Zm.keywords.r16sint,Zm.keywords.r16float,Zm.keywords.rg8unorm,Zm.keywords.rg8snorm,Zm.keywords.rg8uint,Zm.keywords.rg8sint,Zm.keywords.r32uint,Zm.keywords.r32sint,Zm.keywords.r32float,Zm.keywords.rg16uint,Zm.keywords.rg16sint,Zm.keywords.rg16float,Zm.keywords.rgba8unorm,Zm.keywords.rgba8unorm_srgb,Zm.keywords.rgba8snorm,Zm.keywords.rgba8uint,Zm.keywords.rgba8sint,Zm.keywords.bgra8unorm,Zm.keywords.bgra8unorm_srgb,Zm.keywords.rgb10a2unorm,Zm.keywords.rg11b10float,Zm.keywords.rg32uint,Zm.keywords.rg32sint,Zm.keywords.rg32float,Zm.keywords.rgba16uint,Zm.keywords.rgba16sint,Zm.keywords.rgba16float,Zm.keywords.rgba32uint,Zm.keywords.rgba32sint,Zm.keywords.rgba32float],$g.const_literal=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.keywords.true,Zm.keywords.false],$g.literal_or_ident=[Zm.tokens.ident,Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.tokens.name],$g.element_count_expression=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.ident],$g.template_types=[Zm.keywords.vec2,Zm.keywords.vec3,Zm.keywords.vec4,Zm.keywords.mat2x2,Zm.keywords.mat2x3,Zm.keywords.mat2x4,Zm.keywords.mat3x2,Zm.keywords.mat3x3,Zm.keywords.mat3x4,Zm.keywords.mat4x2,Zm.keywords.mat4x3,Zm.keywords.mat4x4,Zm.keywords.atomic,Zm.keywords.bitcast,...Zm.any_texture_type],$g.attribute_name=[Zm.tokens.ident,Zm.keywords.block,Zm.keywords.diagnostic],$g.assignment_operators=[Zm.tokens.equal,Zm.tokens.plus_equal,Zm.tokens.minus_equal,Zm.tokens.times_equal,Zm.tokens.division_equal,Zm.tokens.modulo_equal,Zm.tokens.and_equal,Zm.tokens.or_equal,Zm.tokens.xor_equal,Zm.tokens.shift_right_equal,Zm.tokens.shift_left_equal],$g.increment_operators=[Zm.tokens.plus_plus,Zm.tokens.minus_minus];class Zg{constructor(e,t,i,n,r){this.type=e,this.lexeme=t,this.line=i,this.start=n,this.end=r}toString(){return this.lexeme}isTemplateType(){return-1!=$g.template_types.indexOf(this.type)}isArrayType(){return this.type==$g.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Wg{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Zg($g.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0;){if(this._isAtEnd())return!0;if(e=this._advance(),"\n"==e)this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),t--,0==t))return!0}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++)}return!0}}const t=$g.simpleTokens[e];if(t)return this._addToken(t),!0;let i=$g.none;const n=this._isAlpha(e),r="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(n){const t=$g.keywords[e];if(t)return this._addToken(t),!0}if(n||r)return this._addToken($g.tokens.ident),!0;for(;;){let t=this._findType(e);const n=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==n)return this._current++,e+=n,this._addToken($g.tokens.minus_equal),!0;if("-"==n)return this._current++,e+=n,this._addToken($g.tokens.minus_minus),!0;const i=this._tokens.length-1;if((-1!=$g.literal_or_ident.indexOf(this._tokens[i].type)||this._tokens[i].type==$g.tokens.paren_right)&&">"!=n)return this._addToken(t),!0}if(">"==e&&(">"==n||"="==n)){let e=!1,i=this._tokens.length-1;for(let t=0;t<5&&i>=0&&-1===$g.assignment_operators.indexOf(this._tokens[i].type);++t,--i)if(this._tokens[i].type===$g.tokens.less_than){i>0&&this._tokens[i-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===$g.none){let n=e,r=0;const o=2;for(let e=0;e=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"\t"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"\t"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Zg(e,t,this._line,this._start,this._current))}}function qg(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const Kg=new Float32Array(1),Xg=new Uint32Array(Kg.buffer),Jg=new Uint32Array(Kg.buffer),Yg=new Int32Array(1),e_=new Float32Array(Yg.buffer),t_=new Uint32Array(Yg.buffer),i_=new Uint32Array(1),n_=new Float32Array(i_.buffer),r_=new Int32Array(i_.buffer);function o_(e,t,i){if(t===i)return e;if("f32"===t){if("i32"===i||"x32"===i)return Kg[0]=e,Xg[0];if("u32"===i)return Kg[0]=e,Jg[0]}else if("i32"===t||"x32"===t){if("f32"===i)return Yg[0]=e,e_[0];if("u32"===i)return Yg[0]=e,t_[0]}else if("u32"===t){if("f32"===i)return i_[0]=e,n_[0];if("i32"===i||"x32"===i)return i_[0]=e,r_[0]}return console.error(`Unsupported cast from ${t} to ${i}`),e}class s_{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class a_{constructor(e,t){this.align=e,this.size=t}}class l_{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new ym,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(const t of e)t instanceof Dm&&this._functions.set(t.name,new s_(t));for(const t of e)if(t instanceof hg){const e=this.getTypeInfo(t,null);e instanceof am&&this.structs.push(e)}for(const t of e)if(t instanceof og)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof jm){const e=t,i=this._getAttributeNum(e.attributes,"id",0),n=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new gm(e.name,n,e.attributes,i));continue}if(this._isUniformVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Uniform,e.access);o.access||(o.access="read"),this.uniforms.push(o);continue}if(this._isStorageVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Storage,e.access);s.access||(s.access="read"),this.storage.push(s);continue}if(this._isTextureVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Texture,e.access);s.access||(s.access="read"),o?this.storage.push(s):this.textures.push(s);continue}if(this._isSamplerVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Sampler,e.access);this.samplers.push(o);continue}}for(const t of e)if(t instanceof Dm){const e=this._getAttribute(t,"vertex"),i=this._getAttribute(t,"fragment"),n=this._getAttribute(t,"compute"),r=e||i||n,o=new Am(t.name,null==r?void 0:r.name,t.attributes);o.attributes=t.attributes,o.startLine=t.startLine,o.endLine=t.endLine,this.functions.push(o),this._functions.get(t.name).info=o,r&&(this._functions.get(t.name).inUse=!0,o.inUse=!0,o.resources=this._findResources(t,!!r),o.inputs=this._getInputs(t.args),o.outputs=this._getOutputs(t.returnType),this.entry[r.name].push(o)),o.arguments=t.args.map(e=>new _m(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),o.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const e of this._functions.values())e.info&&(e.info.inUse=e.inUse,this._addCalls(e.node,e.info.calls));for(const e of this._functions.values())e.node.search(t=>{var i,n,r;if(t instanceof kg){if(t.value)if(qg(t.value))for(const n of t.value)for(const t of this.overrides)n===t.name&&(null===(i=e.info)||void 0===i||i.overrides.push(t));else for(const i of this.overrides)t.value===i.name&&(null===(n=e.info)||void 0===n||n.overrides.push(i))}else if(t instanceof vg)for(const i of this.overrides)t.name===i.name&&(null===(r=e.info)||void 0===r||r.overrides.push(i))});for(const e of this.uniforms)this._markStructsInUse(e.type);for(const e of this.storage)this._markStructsInUse(e.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const n of e.calls){const e=null===(i=this._functions.get(n.name))||void 0===i?void 0:i.info;e&&t.add(e)}}findResource(e,t,i){if(i){for(const n of this.entry.compute)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.vertex)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.fragment)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i}for(const i of this.uniforms)if(i.group==e&&i.binding==t)return i;for(const i of this.storage)if(i.group==e&&i.binding==t)return i;for(const i of this.textures)if(i.group==e&&i.binding==t)return i;for(const i of this.samplers)if(i.group==e&&i.binding==t)return i;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],n=this,r=[];return e.search(o=>{if(o instanceof Rm)r.push({});else if(o instanceof Lm)r.pop();else if(o instanceof Vm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof Ag){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(o instanceof Gm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof vg){const e=o;if(r.length>0&&r[r.length-1][e.name])return;const t=n._findResource(e.name);t&&i.push(t)}else if(o instanceof yg){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}else if(o instanceof Xm){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}}),[...new Map(i.map(e=>[e.name,e])).values()]}getBindGroups(){const e=[];function t(t,i){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),i>=e[t].length&&(e[t].length=i+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(void 0===t&&(t=[]),e instanceof hg)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);null!==i&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructOutputs(i.type,t);else{const e=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(null!==e){const n=this.getTypeInfo(i.type,i.type.attributes),r=this._parseInt(e.value),o=new mm(i.name,n,e.name,r);t.push(o)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this.getTypeInfo(e,e.attributes),n=this._parseInt(t.value);return new mm("",i,t.name,n)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const i of e)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this._getAttribute(e,"interpolation"),n=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(t.value),o=new fm(e.name,n,t.name,r);return null!==i&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new pm(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof pg){const i=e.type?this.getTypeInfo(e.type,e.attributes):null,n=new cm(e.name,i,t);return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof fg){const i=e,n=i.format?this.getTypeInfo(i.format,i.attributes):null,r=new lm(i.name,t);return r.format=n,r.count=i.count,this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof hg){const i=e,n=new am(i.name,t);n.startLine=i.startLine,n.endLine=i.endLine;for(const e of i.members){const t=this.getTypeInfo(e.type,e.attributes);n.members.push(new sm(e.name,t,e.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof mg){const i=e,n=i.format instanceof cg,r=i.format?n?this.getTypeInfo(i.format,null):new om(i.format,null):null,o=new um(i.name,r,t,i.access);return this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof dg){const i=e,n=i.format?this.getTypeInfo(i.format,null):null,r=new um(i.name,n,t,i.access);return this._types.set(e,r),this._updateTypeInfo(r),r}const i=new om(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,n;const r=this._getTypeSize(e);if(e.size=null!==(t=null==r?void 0:r.size)&&void 0!==t?t:0,e instanceof lm&&e.format){const t=this._getTypeSize(e.format);e.stride=Math.max(null!==(i=null==t?void 0:t.size)&&void 0!==i?i:0,null!==(n=null==t?void 0:t.align)&&void 0!==n?n:0),this._updateTypeInfo(e.format)}e instanceof cm&&this._updateTypeInfo(e.format),e instanceof am&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,n=0,r=0,o=0;for(let s=0,a=e.members.length;se.name),l_._samplerTypes=$g.sampler_type.map(e=>e.name);let c_=0;class u_{constructor(e,t,i){this.id=c_++,this.name=e,this.value=t,this.node=i}clone(){return new u_(this.name,this.value,this.node)}}class h_{constructor(e){this.id=c_++,this.name=e.name,this.node=e}clone(){return new h_(this.node)}}class d_{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=c_++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new u_(e,t,null!=i?i:null))}setVariable(e,t,i){const n=this.getVariable(e);null!==n?n.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return null!==(t=null==i?void 0:i.value)&&void 0!==t?t:null}clone(){return new d_(this)}}class p_{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class f_{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let n=!0;if(i instanceof Vg)return i.data.forEach(e=>{e||(n=!1)}),new Ug(n?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const e=i.data.some(e=>e);return new Ug(e?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof Ug))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.evalExpression(i,t);if(n instanceof Gg&&0===n.typeInfo.size){const e=n.typeInfo,t=n.buffer.byteLength/e.stride;return new Ug(t,this.getTypeInfo("u32"))}return new Ug(n.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.abs(e)),i.typeInfo);const n=i;return new Ug(Math.abs(n.value),n.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acos(e)),i.typeInfo);const n=i;return new Ug(Math.acos(n.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acosh(e)),i.typeInfo);const n=i;return new Ug(Math.acosh(n.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asin(e)),i.typeInfo);const n=i;return new Ug(Math.asin(n.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asinh(e)),i.typeInfo);const n=i;return new Ug(Math.asinh(n.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atan(e)),i.typeInfo);const n=i;return new Ug(Math.atan(n.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atanh(e)),i.typeInfo);const n=i;return new Ug(Math.atanh(n.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.atan2(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.atan2(r.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.ceil(e)),i.typeInfo);const n=i;return new Ug(Math.ceil(n.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>this._clamp(e,n.data[t],r.data[t])),i.typeInfo);const o=i,s=n,a=r;return new Ug(this._clamp(o.value,s.value,a.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cos(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cosh(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.clz32(e)),i.typeInfo);const n=i;return new Ug(Math.clz32(n.value),i.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countOneBits(e)),i.typeInfo);const n=i;return new Ug(this._countOneBits(n.value),i.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countTrailingZeros(e)),i.typeInfo);const n=i;return new Ug(this._countTrailingZeros(n.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){if(3!==i.data.length||3!==n.data.length)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const t=i.data,r=n.data;return new Vg([t[1]*r[2]-r[1]*t[2],t[2]*r[0]-r[2]*t[0],t[0]*r[1]-r[0]*t[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),n=180/Math.PI;return i instanceof Vg?new Vg(i.data.map(e=>e*n),i.typeInfo):new Ug(i.value*n,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof jg){const e=i.data,t=i.typeInfo.getTypeName(),n=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new Ug(e[0]*e[3]-e[1]*e[2],n);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t)console.error(`TODO: Determinant for ${t}`);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t)console.error(`TODO: Determinant for ${t}`);else{if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);"mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t||"mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t||"mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t?console.error(`TODO: Determinant for ${t}`):"mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||console.error(`TODO: Determinant for ${t}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){let e=0;for(let t=0;tMath.exp(e)),i.typeInfo);const n=i;return new Ug(Math.exp(n.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.pow(2,e)),i.typeInfo);const n=i;return new Ug(Math.pow(2,n.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if("u32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=n.value,s=r.value;if(i instanceof Vg)return new Vg(i.data.map(e=>e>>o&(1<>o&(1<-e),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstLeadingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstLeadingBit(n.value),i.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstTrailingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstTrailingBit(n.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.floor(e)),i.typeInfo);const n=i;return new Ug(Math.floor(n.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return i.data.length!==n.data.length||i.data.length!==r.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new Vg(i.data.map((e,t)=>e*n.data[t]+r.data[t]),i.typeInfo);const o=i,s=n,a=r;return new Ug(o.value*s.value+a.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>e-Math.floor(e)),i.typeInfo);const n=i;return new Ug(n.value-Math.floor(n.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const s=r.value,a=(1<e&l|n.data[t]<1/Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(1/Math.sqrt(n.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){let e=0;return i.data.forEach(t=>{e+=t*t}),new Ug(Math.sqrt(e),this.getTypeInfo("f32"))}const n=i;return new Ug(Math.abs(n.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log(e)),i.typeInfo);const n=i;return new Ug(Math.log(n.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log2(e)),i.typeInfo);const n=i;return new Ug(Math.log2(n.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.max(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.max(r.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.min(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.min(r.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>i.data[t]*(1-r.data[t])+n.data[t]*r.data[t]),i.typeInfo);const o=n,s=r;return new Ug(i.value*(1-s.value)+o.value*s.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>e%n.data[t]),i.typeInfo);const r=n;return new Ug(i.value%r.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const n=this.Length(e,t).value;return new Vg(i.data.map(e=>e/n),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.pow(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.pow(r.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e),i.typeInfo):new Ug(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e*Math.PI/180),i.typeInfo):new Ug(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){const e=this._dot(i.data,n.data);return new Vg(i.data.map((t,i)=>t-2*e*n.data[i]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Ug){const e=this._dot(n.data,i.data);return new Vg(i.data.map((t,i)=>{const o=1-r.value*r.value*(1-e*e);if(o<0)return 0;const s=Math.sqrt(o);return r.value*t-(r.value*e+s)*n.data[i]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.round(e)),i.typeInfo);const n=i;return new Ug(Math.round(n.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.min(Math.max(e,0),1)),i.typeInfo);const n=i;return new Ug(Math.min(Math.max(n.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sign(e)),i.typeInfo);const n=i;return new Ug(Math.sign(n.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sin(e)),i.typeInfo);const n=i;return new Ug(Math.sin(n.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sinh(e)),i.typeInfo);const n=i;return new Ug(Math.sinh(n.value),i.typeInfo)}_smoothstep(e,t,i){const n=Math.min(Math.max((i-e)/(t-e),0),1);return n*n*(3-2*n)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(r instanceof Vg&&i instanceof Vg&&n instanceof Vg)return new Vg(r.data.map((e,t)=>this._smoothstep(i.data[t],n.data[t],e)),r.typeInfo);const o=i,s=n,a=r;return new Ug(this._smoothstep(o.value,s.value,a.value),r.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(Math.sqrt(n.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(n instanceof Vg&&i instanceof Vg)return new Vg(n.data.map((e,t)=>eMath.tan(e)),i.typeInfo);const n=i;return new Ug(Math.tan(n.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.tanh(e)),i.typeInfo);const n=i;return new Ug(Math.tanh(n.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):("mat4x4f"===t||"mat4x4h"===t||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof jg))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const n=this._getTransposeType(i.typeInfo);if("mat2x2"===i.typeInfo.name||"mat2x2f"===i.typeInfo.name||"mat2x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[2],e[1],e[3]],n)}if("mat2x3"===i.typeInfo.name||"mat2x3f"===i.typeInfo.name||"mat2x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7]],n)}if("mat2x4"===i.typeInfo.name||"mat2x4f"===i.typeInfo.name||"mat2x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],n)}if("mat3x2"===i.typeInfo.name||"mat3x2f"===i.typeInfo.name||"mat3x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[1],e[4],e[2],e[5]],n)}if("mat3x3"===i.typeInfo.name||"mat3x3f"===i.typeInfo.name||"mat3x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],n)}if("mat3x4"===i.typeInfo.name||"mat3x4f"===i.typeInfo.name||"mat3x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],n)}if("mat4x2"===i.typeInfo.name||"mat4x2f"===i.typeInfo.name||"mat4x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[1],e[5],e[2],e[6]],n)}if("mat4x3"===i.typeInfo.name||"mat4x3f"===i.typeInfo.name||"mat4x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],n)}if("mat4x4"===i.typeInfo.name||"mat4x4f"===i.typeInfo.name||"mat4x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],n)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.trunc(e)),i.typeInfo);const n=i;return new Ug(Math.trunc(n.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],n=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof vg){const r=i.name,o=t.getVariableValue(r);if(o instanceof Hg){if(n<0||n>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const t=o.getMipLevelSize(n),i=o.dimension;return"1d"===i?new Ug(t[0],this.getTypeInfo("u32")):"3d"===i?new Vg(t,this.getTypeInfo("vec3u")):"2d"===i?new Vg(t.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${i} not found. Line ${e.line}`),null)}return console.error(`Texture ${r} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof vg){const o=i.name,s=t.getVariableValue(o);if(s instanceof Hg){const t=Math.floor(n.data[0]),i=Math.floor(n.data[1]);if(t<0||t>=s.width||i<0||i>=s.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const a=s.getPixel(t,i,0,r);return null===a?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new Vg(a,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,o=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==o.length)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof vg){const s=i.name,a=t.getVariableValue(s);if(a instanceof Hg){const t=a.getMipLevelSize(0),i=Math.floor(n.data[0]),l=Math.floor(n.data[1]);return i<0||i>=t[0]||l<0||l>=t[1]?(console.error(`Texture ${s} out of bounds. Line ${e.line}`),null):(a.setPixel(i,l,0,r,Array.from(o)),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t);return t.getVariable(n).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value+=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicSub(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value-=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMax(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.max(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMin(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.min(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicAnd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value&s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicOr(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value|s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicXor(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value^s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicExchange(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const m_={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},g_={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class __ extends p_{constructor(e,t){var i;super(),this.ast=null!=e?e:[],this.reflection=new l_,this.reflection.updateAST(this.ast),this.context=null!==(i=null==t?void 0:t.clone())&&void 0!==i?i:new d_,this.builtins=new f_(this),this.typeInfo={bool:this.getTypeInfo(cg.bool),i32:this.getTypeInfo(cg.i32),u32:this.getTypeInfo(cg.u32),f32:this.getTypeInfo(cg.f32),f16:this.getTypeInfo(cg.f16),vec2f:this.getTypeInfo(dg.vec2f),vec2u:this.getTypeInfo(dg.vec2u),vec2i:this.getTypeInfo(dg.vec2i),vec2h:this.getTypeInfo(dg.vec2h),vec3f:this.getTypeInfo(dg.vec3f),vec3u:this.getTypeInfo(dg.vec3u),vec3i:this.getTypeInfo(dg.vec3i),vec3h:this.getTypeInfo(dg.vec3h),vec4f:this.getTypeInfo(dg.vec4f),vec4u:this.getTypeInfo(dg.vec4u),vec4i:this.getTypeInfo(dg.vec4i),vec4h:this.getTypeInfo(dg.vec4h),mat2x2f:this.getTypeInfo(dg.mat2x2f),mat2x3f:this.getTypeInfo(dg.mat2x3f),mat2x4f:this.getTypeInfo(dg.mat2x4f),mat3x2f:this.getTypeInfo(dg.mat3x2f),mat3x3f:this.getTypeInfo(dg.mat3x3f),mat3x4f:this.getTypeInfo(dg.mat3x4f),mat4x2f:this.getTypeInfo(dg.mat4x2f),mat4x3f:this.getTypeInfo(dg.mat4x3f),mat4x4f:this.getTypeInfo(dg.mat4x4f)}}getVariableValue(e){var t,i;const n=null!==(i=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==i?i:null;if(null===n)return null;if(n instanceof Ug)return n.value;if(n instanceof Vg)return Array.from(n.data);if(n instanceof jg)return Array.from(n.data);if(n instanceof Gg&&n.typeInfo instanceof lm){if("u32"===n.typeInfo.format.name)return Array.from(new Uint32Array(n.buffer,n.offset,n.typeInfo.count));if("i32"===n.typeInfo.format.name)return Array.from(new Int32Array(n.buffer,n.offset,n.typeInfo.count));if("f32"===n.typeInfo.format.name)return Array.from(new Float32Array(n.buffer,n.offset,n.typeInfo.count))}return console.error(`Unsupported return variable type ${n.typeInfo.name}`),null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,n){const r=this.context.clone();(n=null!=n?n:{}).constants&&this._setOverrides(n.constants,r),this._execStatements(this.ast,r);const o=r.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return void console.error("Invalid dispatch count");1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const s=t[0],a=t[1],l=t[2],c=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new Vg(t,c));const u=this.reflection.getFunctionInfo(e);null===u&&console.error(`Function ${e} not found in reflection data`);for(const e in i)for(const t in i[e]){const n=i[e][t];r.variables.forEach(i=>{var r;const o=i.node;if(null==o?void 0:o.attributes){let s=null,a=null;for(const e of o.attributes)"binding"===e.name?s=e.value:"group"===e.name&&(a=e.value);if(t==s&&e==a){let s=!1;for(const n of u.resources)if(n.name===i.name&&n.group===parseInt(e)&&n.binding===parseInt(t)){s=!0;break}if(s)if(void 0!==n.texture&&void 0!==n.descriptor){const e=new Hg(n.texture,this.getTypeInfo(o.type),n.descriptor,null!==(r=n.texture.view)&&void 0!==r?r:null);i.value=e}else void 0!==n.uniform?i.value=new Gg(n.uniform,this.getTypeInfo(o.type)):i.value=new Gg(n,this.getTypeInfo(o.type))}}})}for(let e=0;e0){const e=i.getVariableValue(t.value[0]);n[0]=e instanceof Ug?e.value:parseInt(t.value[0])}if(t.value.length>1){const e=i.getVariableValue(t.value[1]);n[1]=e instanceof Ug?e.value:parseInt(t.value[1])}if(t.value.length>2){const e=i.getVariableValue(t.value[2]);n[2]=e instanceof Ug?e.value:parseInt(t.value[2])}}const r=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new Vg(n,r));const s=n[0],a=n[1],l=n[2];for(let c=0,u=0;c",r=null;if(e.variable instanceof Cg){const i=this._getVariableData(e.variable,t),n=this.evalExpression(e.value,t),r=e.operator;if("="===r){if(i instanceof Ug||i instanceof Vg||i instanceof jg){if(n instanceof Ug||n instanceof Vg||n instanceof jg&&i.data.length===n.data.length)return void i.data.set(n.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(i instanceof Gg&&n instanceof Gg&&i.buffer.byteLength-i.offset>=n.buffer.byteLength-n.offset)return void(i.buffer.byteLength%4==0?new Uint32Array(i.buffer,i.offset,i.typeInfo.size/4).set(new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4)):new Uint8Array(i.buffer,i.offset,i.typeInfo.size).set(new Uint8Array(n.buffer,n.offset,n.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if("+="===r)return i instanceof Ug||i instanceof Vg||i instanceof jg?n instanceof Ug||n instanceof Vg||n instanceof jg?void i.data.set(n.data.map((e,t)=>i.data[t]+e)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if("-="===r)return(i instanceof Ug||i instanceof Vg||i instanceof jg)&&(n instanceof Ug||n instanceof Vg||n instanceof jg)?void i.data.set(n.data.map((e,t)=>i.data[t]-e)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Cg){if("*"===e.variable.operator){n=this.getVariableName(e.variable.right,t);const r=t.getVariable(n);if(!(r&&r.value instanceof zg))return void console.error(`Variable ${n} is not a pointer. Line ${e.line}`);i=r.value.reference;let o=e.variable.postfix;if(!o){let t=e.variable.right;for(;t instanceof Cg;){if(t.postfix){o=t.postfix;break}t=t.right}}o&&(i=i.getSubData(this,o,t))}}else{r=e.variable.postfix,n=this.getVariableName(e.variable,t);const o=t.getVariable(n);if(null===o)return void console.error(`Variable ${n} not found. Line ${e.line}`);i=o.value}if(i instanceof zg&&(i=i.reference),null===i)return void console.error(`Variable ${n} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),s=e.operator;if("="!==s){const n=i.getSubData(this,r,t);if(n instanceof Vg&&o instanceof Ug){const t=n.data,i=o.value;if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i;else console.error(`Invalid operator ${s}. Line ${e.line}`)}else if(n instanceof Vg&&o instanceof Vg){const t=n.data,i=o.data;if(t.length!==i.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i[e];else console.error(`Invalid operator ${s}. Line ${e.line}`)}else{if(!(n instanceof Ug&&o instanceof Ug))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);"+="===s?n.value+=o.value:"-="===s?n.value-=o.value:"*="===s?n.value*=o.value:"/="===s?n.value/=o.value:"%="===s?n.value%=o.value:"&="===s?n.value&=o.value:"|="===s?n.value|=o.value:"^="===s?n.value^=o.value:"<<="===s?n.value<<=o.value:">>="===s?n.value>>=o.value:console.error(`Invalid operator ${s}. Line ${e.line}`)}return void(i instanceof Gg&&i.setDataValue(this,n,r,t))}if(i instanceof Gg)i.setDataValue(this,o,r,t);else if(r){if(!(i instanceof Vg||i instanceof jg))return void console.error(`Variable ${n} is not a vector or matrix. Line ${e.line}`);if(r instanceof Tg){const s=this.evalExpression(r.index,t).value;if(i instanceof Vg){if(!(o instanceof Ug))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[s]=o.value}else{if(!(i instanceof jg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const s=this.evalExpression(r.index,t).value;if(s<0)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const t=i.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(s<2&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(s<2&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(s<2&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(s<3&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(s<3&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(s<3&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(s<4&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(s<4&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(s<4&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}}}}}else if(r instanceof _g){const t=r.value;if(!(i instanceof Vg))return void console.error(`Invalid assignment to ${t}. Variable ${n} is not a vector. Line ${e.line}`);if(o instanceof Ug){if(t.length>1)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);if("x"===t)i.data[0]=o.value;else if("y"===t){if(i.data.length<2)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[1]=o.value}else if("z"===t){if(i.data.length<3)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[2]=o.value}else if("w"===t){if(i.data.length<4)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(t.length!==o.data.length)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);for(let r=0;r+e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(+e,t)}case"-":{if(qg(n)){const e=n.map((e,t)=>-e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(-e,t)}case"!":{if(qg(n)){const e=n.map((e,t)=>e?0:1);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(e?0:1,t)}case"~":{if(qg(n)){const e=n.map((e,t)=>~e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(~e,t)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),n=this.evalExpression(e.right,t),r=i instanceof Ug?i.value:i instanceof Vg||i instanceof jg?Array.from(i.data):null,o=n instanceof Ug?n.value:n instanceof Vg||n instanceof jg?Array.from(n.data):null;switch(e.operator){case"+":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e+n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t+e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e+t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t+s,a)}case"-":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e-n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t-e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e-t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t-s,a)}case"*":{if(qg(r)&&qg(o)){const t=r,s=o;if(i instanceof jg&&n instanceof jg){const r=function(e,t,i,n){if(void 0===g_[t.name]||void 0===g_[n.name])return null;const r=g_[t.name][0],o=g_[t.name][1],s=g_[n.name][0];if(r!==g_[n.name][1])return null;const a=new Array(s*o);for(let t=0;te*s[t]);return new Vg(n,i.typeInfo)}}if(qg(r)){const e=o,t=r.map((t,i)=>t*e);return i instanceof jg?new jg(t,i.typeInfo):new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e*t);return n instanceof jg?new jg(t,n.typeInfo):new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t*s,a)}case"%":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e%n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t%e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e%t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t%s,a)}case"/":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e/n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t/e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e/t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t/s,a)}case"&":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t&s,a)}case"|":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e|n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t|e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e|t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t|s,a)}case"^":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e^n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t^e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e^t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t^s,a)}case"<<":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<t<e<>":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>>n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>>e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>>t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t>>s,a)}case">":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>o?1:0,this.getTypeInfo("bool"));case"<":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>etee===n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r===o?1:0,this.getTypeInfo("bool"));case"!=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e!==n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t!==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e!==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r!==o?1:0,this.getTypeInfo("bool"));case">=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>=o?1:0,this.getTypeInfo("bool"));case"<=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t<=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e<=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r<=o?1:0,this.getTypeInfo("bool"));case"&&":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&&n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&&e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&&t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r&&o?1:0,this.getTypeInfo("bool"));case"||":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e||n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t||e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e||t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const n=t.getFunction(e.name);if(!n)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let t=0;tr?o.slice(0,r):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),n=e.type.getTypeName(),r=g_[n];if(void 0===r)return console.error(`Invalid matrix constructor ${n}. Line ${e.line}`),null;const o=[];if(e instanceof bg)if(e.isVector){const t=e.vectorValue;for(const e of t)o.push(e)}else o.push(e.scalarValue);else if(e.args)for(const i of e.args){const e=this.evalExpression(i,t);e instanceof Vg?o.push(...e.data):e instanceof Ug?o.push(e.value):e instanceof jg&&o.push(...e.data)}if(i instanceof um&&null===i.format&&(i.format=this.getTypeInfo("f32")),0===o.length){const n=new Array(r[2]).fill(0);return new jg(n,i).getSubData(this,e.postfix,t)}return o.length!==r[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new jg(o,i).getSubData(this,e.postfix,t)}}__._breakObj=new Dg(new om("BREAK",null),null),__._continueObj=new Dg(new om("CONTINUE",null),null),__._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class A_{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class y_{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new A_,this._exec=new __,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const i=t.arrayType,n=t.countNode;if(n instanceof vg){const t=n.name,r=this._context.constants.get(t);if(r)try{const e=r.constEvaluate(this._exec);i.count=e}catch(e){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const e of t)e.search(e=>{e instanceof Fg||e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg?e.format=this._forwardType(e.format):e instanceof Vm||e instanceof Gm||e instanceof Hm?e.type=this._forwardType(e.type):e instanceof Dm?e.returnType=this._forwardType(e.returnType):e instanceof Rg&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof ug){const t=this._getType(e.name);if(t)return t}else e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new Wg(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==$g.eof}_match(e){if(e instanceof Qg)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check($g.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match($g.keywords.continue)){const t=this._updateNode(new lg);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume($g.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match($g.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Om(t),e)}_while_statement(){if(!this._match($g.keywords.while))return null;const e=this._updateNode(new zm(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match($g.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new Um(i,e),t)}_for_statement(){if(!this._match($g.keywords.for))return null;this._consume($g.tokens.paren_left,"Expected '('.");const e=this._updateNode(new Nm(null,null,null,null));return this._currentLoop.push(e),e.init=this._check($g.tokens.semicolon)?null:this._for_init(),this._consume($g.tokens.semicolon,"Expected ';'."),e.condition=this._check($g.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume($g.tokens.semicolon,"Expected ';'."),e.increment=this._check($g.tokens.paren_right)?null:this._for_increment(),this._consume($g.tokens.paren_right,"Expected ')'."),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check($g.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match($g.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Vm(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match($g.keywords.let)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for let.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for let.");const n=this._short_circuit_or_expression();return this._updateNode(new Gm(t,i,null,null,n),e)}if(this._match($g.keywords.const)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for const.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for const.");const n=this._short_circuit_or_expression();return null===i&&n instanceof bg&&(i=n.type),this._updateNode(new Hm(t,i,null,null,n),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check($g.increment_operators))return this._current=e,null;const i=this._consume($g.increment_operators,"Expected increment operator");return this._updateNode(new qm(i.type===$g.tokens.plus_plus?Qm.increment:Qm.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check($g.tokens.brace_right))return null;let i=this._match($g.tokens.underscore);if(i||(e=this._unary_expression()),!i&&null==e)return null;const n=this._consume($g.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new Km($m.parse(n.lexeme),e,r),t)}_func_call_statement(){if(!this._check($g.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume($g.tokens.ident,"Expected function name."),n=this._argument_expression_list();return null===n?(this._current=t,null):this._updateNode(new Xm(i.lexeme,n),e)}_loop_statement(){if(!this._match($g.keywords.loop))return null;this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Jm([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof Um){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume($g.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match($g.keywords.switch))return null;const e=this._updateNode(new Ym(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume($g.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([$g.keywords.default,$g.keywords.case]);){if(this._match($g.keywords.case)){const i=this._case_selectors();for(const e of i)if(e instanceof Ig){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch case.");const n=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Mg(i,n)))}if(this._match($g.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Pg(i)))}}return e}_case_selectors(){const e=[];for(this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());this._match($g.tokens.comma);)this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());return e}_case_body(){if(this._match($g.keywords.fallthrough))return this._consume($g.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);const t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match($g.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check($g.tokens.attr)&&this._attribute();const i=this._compound_statement();let n=[];this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),n=this._elseif_statement(n));let r=null;return this._match($g.keywords.else)&&(this._check($g.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new eg(t,i,n,r),e)}_match_elseif(){return this._tokens[this._current].type===$g.keywords.else&&this._tokens[this._current+1].type===$g.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new Lg(t,i))),this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match($g.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new tg(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match($g.tokens.or_or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match($g.tokens.and_and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match($g.tokens.or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match($g.tokens.xor);)e=this._updateNode(new Sg(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match($g.tokens.and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([$g.tokens.equal_equal,$g.tokens.not_equal])?this._updateNode(new Sg(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([$g.tokens.less_than,$g.tokens.greater_than,$g.tokens.less_than_equal,$g.tokens.greater_than_equal]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([$g.tokens.shift_left,$g.tokens.shift_right]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([$g.tokens.plus,$g.tokens.minus]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([$g.tokens.star,$g.tokens.forward_slash,$g.tokens.modulo]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([$g.tokens.minus,$g.tokens.bang,$g.tokens.tilde,$g.tokens.star,$g.tokens.and])?this._updateNode(new Cg(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match($g.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume($g.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new Tg(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match($g.tokens.period)){const e=this._consume($g.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new _g(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(null!==t)return t;switch(e){case"void":return cg.void;case"bool":return cg.bool;case"i32":return cg.i32;case"u32":return cg.u32;case"f32":return cg.f32;case"f16":return cg.f16;case"vec2f":return dg.vec2f;case"vec3f":return dg.vec3f;case"vec4f":return dg.vec4f;case"vec2i":return dg.vec2i;case"vec3i":return dg.vec3i;case"vec4i":return dg.vec4i;case"vec2u":return dg.vec2u;case"vec3u":return dg.vec3u;case"vec4u":return dg.vec4u;case"vec2h":return dg.vec2h;case"vec3h":return dg.vec3h;case"vec4h":return dg.vec4h;case"mat2x2f":return dg.mat2x2f;case"mat2x3f":return dg.mat2x3f;case"mat2x4f":return dg.mat2x4f;case"mat3x2f":return dg.mat3x2f;case"mat3x3f":return dg.mat3x3f;case"mat3x4f":return dg.mat3x4f;case"mat4x2f":return dg.mat4x2f;case"mat4x3f":return dg.mat4x3f;case"mat4x4f":return dg.mat4x4f;case"mat2x2h":return dg.mat2x2h;case"mat2x3h":return dg.mat2x3h;case"mat2x4h":return dg.mat2x4h;case"mat3x2h":return dg.mat3x2h;case"mat3x3h":return dg.mat3x3h;case"mat3x4h":return dg.mat3x4h;case"mat4x2h":return dg.mat4x2h;case"mat4x3h":return dg.mat4x3h;case"mat4x4h":return dg.mat4x4h;case"mat2x2i":return dg.mat2x2i;case"mat2x3i":return dg.mat2x3i;case"mat2x4i":return dg.mat2x4i;case"mat3x2i":return dg.mat3x2i;case"mat3x3i":return dg.mat3x3i;case"mat3x4i":return dg.mat3x4i;case"mat4x2i":return dg.mat4x2i;case"mat4x3i":return dg.mat4x3i;case"mat4x4i":return dg.mat4x4i;case"mat2x2u":return dg.mat2x2u;case"mat2x3u":return dg.mat2x3u;case"mat2x4u":return dg.mat2x4u;case"mat3x2u":return dg.mat3x2u;case"mat3x3u":return dg.mat3x3u;case"mat3x4u":return dg.mat3x4u;case"mat4x2u":return dg.mat4x2u;case"mat4x3u":return dg.mat4x3u;case"mat4x4u":return dg.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match($g.tokens.ident)){const e=this._previous().toString();if(this._check($g.tokens.paren_left)){const t=this._argument_expression_list(),i=this._getType(e);return null!==i?this._updateNode(new Ag(i,t)):this._updateNode(new yg(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new xg(e,t.value))}return this._updateNode(new vg(e))}if(this._match($g.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?cg.i32:e.endsWith("u")||e.endsWith("U")?cg.u32:cg.x32;const i=parseInt(e);return this._validateTypeRange(i,t),this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(t)),t))}if(this._match($g.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,cg.u32),this._updateNode(new bg(new Ug(e,this._exec.getTypeInfo(cg.u32)),cg.u32))}if(this._match([$g.tokens.decimal_float_literal,$g.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));const i=parseFloat(e);this._validateTypeRange(i,t?cg.f16:cg.f32);const n=t?cg.f16:cg.f32;return this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(n)),n))}if(this._match([$g.keywords.true,$g.keywords.false])){let e=this._previous().toString()===$g.keywords.true.rule;return this._updateNode(new bg(new Ug(e?1:0,this._exec.getTypeInfo(cg.bool)),cg.bool))}if(this._check($g.tokens.paren_left))return this._paren_expression();if(this._match($g.keywords.bitcast)){this._consume($g.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume($g.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new wg(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Ag(e,t))}_argument_expression_list(){if(!this._match($g.tokens.paren_left))return null;const e=[];do{if(this._check($g.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match($g.tokens.comma));return this._consume($g.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match($g.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match($g.tokens.paren_right),e}_paren_expression(){this._consume($g.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume($g.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match($g.keywords.struct))return null;const e=this._currentLine,t=this._consume($g.tokens.ident,"Expected name for struct.").toString();this._consume($g.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check($g.tokens.brace_right);){const e=this._attribute(),t=this._consume($g.tokens.name,"Expected variable name.").toString();this._consume($g.tokens.colon,"Expected ':' for struct member type.");const n=this._attribute(),r=this._type_decl();null!=r&&(r.attributes=n),this._check($g.tokens.brace_right)?this._match($g.tokens.comma):this._consume($g.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new Fg(t,r,e)))}this._consume($g.tokens.brace_right,"Expected '}' after struct body.");const n=this._currentLine,r=this._updateNode(new hg(t,i,e,n),e);return this._context.structs.set(t,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match($g.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof bg){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof bg&&(e.type="x32"===e.value.type.name?cg.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match($g.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match($g.keywords.const))return null;const t=this._consume($g.tokens.name,"Expected variable name"),i=this._currentLine;let n=null;if(this._match($g.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}let r=null;this._consume($g.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let e=[cg.f32],i=o.constEvaluate(this._exec,e);i instanceof Ug&&this._validateTypeRange(i.value,e[0]),e[0]instanceof dg&&null===e[0].format&&i.typeInfo instanceof um&&null!==i.typeInfo.format&&("f16"===i.typeInfo.format.name?e[0].format=cg.f16:"f32"===i.typeInfo.format.name?e[0].format=cg.f32:"i32"===i.typeInfo.format.name?e[0].format=cg.i32:"u32"===i.typeInfo.format.name?e[0].format=cg.u32:"bool"===i.typeInfo.format.name?e[0].format=cg.bool:console.error(`TODO: impelement template format type ${i.typeInfo.format.name}`)),r=this._updateNode(new bg(i,e[0])),this._exec.context.setVariable(t.toString(),i)}catch(e){r=o}if(null!==n&&r instanceof bg){if("x32"!==r.type.name&&n.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${n.name}. Line:${this._currentLine}`);r.type=n,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else null===n&&r instanceof bg&&(n=null!==(e=null==r?void 0:r.type)&&void 0!==e?e:cg.f32,n===cg.x32&&(n=cg.i32));const s=this._updateNode(new Hm(t.toString(),n,"","",r),i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match($g.keywords.let))return null;const e=this._currentLine,t=this._consume($g.tokens.name,"Expected variable name");let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}let n=null;if(this._match($g.tokens.equal)&&(n=this._const_expression()),null!==i&&n instanceof bg){if("x32"!==n.type.name&&i.getTypeName()!==n.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${n.type.name} to ${i.name}. Line:${this._currentLine}`);n.type=i}else null===i&&n instanceof bg&&(i="x32"===n.type.name?cg.i32:n.type);return n instanceof bg&&n.isScalar&&this._validateTypeRange(n.scalarValue,i),this._updateNode(new Gm(t.toString(),i,"","",n),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match($g.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match($g.tokens.less_than)&&(t=this._consume($g.storage_class,"Expected storage_class.").toString(),this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode.").toString()),this._consume($g.tokens.greater_than,"Expected '>'."));const n=this._consume($g.tokens.name,"Expected variable name");let r=null;if(this._match($g.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}return this._updateNode(new Vm(n.toString(),r,t,i,null),e)}_override_decl(){if(!this._match($g.keywords.override))return null;const e=this._consume($g.tokens.name,"Expected variable name");let t=null;if(this._match($g.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new jm(e.toString(),t,null))}_diagnostic(){this._consume($g.tokens.paren_left,"Expected '('");const e=this._consume($g.tokens.ident,"Expected severity control name.");this._consume($g.tokens.comma,"Expected ','");let t=this._consume($g.tokens.ident,"Expected diagnostic rule name.").toString();return this._match($g.tokens.period)&&(t+=`.${this._consume($g.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume($g.tokens.paren_right,"Expected ')'"),this._updateNode(new rg(e.toString(),t))}_enable_directive(){const e=this._consume($g.tokens.ident,"identity expected.");return this._updateNode(new ig(e.toString()))}_requires_directive(){const e=[this._consume($g.tokens.ident,"identity expected.").toString()];for(;this._match($g.tokens.comma);){const t=this._consume($g.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new ng(e))}_type_alias(){const e=this._consume($g.tokens.ident,"identity expected.");this._consume($g.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new og(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([$g.tokens.ident,...$g.texel_format,$g.keywords.bool,$g.keywords.f32,$g.keywords.i32,$g.keywords.u32])){const e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){const t=this._updateNode(new ug(e));return this._forwardTypeCount++,t}return this._updateNode(new cg(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check($g.template_types)){let e=this._advance().toString(),t=null,i=null;return this._match($g.tokens.less_than)&&(t=this._type_decl(),i=null,this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new dg(e,t,i))}if(this._match($g.keywords.ptr)){let e=this._previous().toString();this._consume($g.tokens.less_than,"Expected '<' for pointer.");const t=this._consume($g.storage_class,"Expected storage_class for pointer");this._consume($g.tokens.comma,"Expected ',' for pointer.");const i=this._type_decl();let n=null;return this._match($g.tokens.comma)&&(n=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new pg(e,t.toString(),i,n))}const t=this._attribute();if(this._match($g.keywords.array)){let i=null,n=-1;const r=this._previous();let o=null;if(this._match($g.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let t="";if(this._match($g.tokens.comma)){o=this._shift_expression();try{t=o.constEvaluate(this._exec).toString(),o=null}catch(e){t="1"}}this._consume($g.tokens.greater_than,"Expected '>' for array."),n=t?parseInt(t):0}const s=this._updateNode(new fg(r.toString(),t,i,n));return o&&this._deferArrayCountEval.push({arrayType:s,countNode:o}),s}return null}_texture_sampler_types(){if(this._match($g.sampler_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.depth_texture_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.sampled_texture_type)||this._match($g.multisampled_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,null))}if(this._match($g.storage_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume($g.texel_format,"Invalid texel format.").toString();this._consume($g.tokens.comma,"Expected ',' after texel format.");const i=this._consume($g.access_mode,"Expected access mode for storage texture type.").toString();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match($g.tokens.attr);){const t=this._consume($g.attribute_name,"Expected attribute name"),i=this._updateNode(new kg(t.toString(),null));if(this._match($g.tokens.paren_left)){if(i.value=this._consume($g.literal_or_ident,"Expected attribute value").toString(),this._check($g.tokens.comma)){this._advance();do{const e=this._consume($g.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(e)}while(this._match($g.tokens.comma))}this._consume($g.tokens.paren_right,"Expected ')'")}e.push(i)}return 0==e.length?null:e}}class v_ extends l_{constructor(e){super(),e&&this.update(e)}update(e){const t=(new y_).parse(e);this.updateAST(t)}}function x_(e){const t={attributes:[],bindings:[]};let i;try{i=function(e){try{return new v_(e)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw"object"==typeof e&&e?.message&&(t+=`: ${e.message} `),"object"==typeof e&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}(e)}catch(e){return Gp.error(e.message)(),t}for(const e of i.uniforms){const i=[];for(const t of e.type?.members||[])i.push({name:t.name,type:b_(t.type)});t.bindings.push({type:"uniform",name:e.name,location:e.binding,group:e.group,members:i})}const n=i.entry.vertex[0],r=n?.inputs.length||0;for(let e=0;e`:e.name}const w_={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\nfloat sin_taylor_fp32(float a) {\nfloat r, s, t, x;\nif (a == 0.0) {\nreturn 0.0;\n}\nx = -a * a;\ns = a;\nr = a;\nr = r * x;\nt = r * INVERSE_FACTORIAL_3;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_5;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_7;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_9;\ns = s + t;\nreturn s;\n}\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\nif (a == 0.0) {\nsin_t = 0.0;\ncos_t = 1.0;\n}\nsin_t = sin_taylor_fp32(a);\ncos_t = sqrt(1.0 - sin_t * sin_t);\n}\nfloat tan_taylor_fp32(float a) {\nfloat sin_a;\nfloat cos_a;\nif (a == 0.0) {\nreturn 0.0;\n}\nfloat z = floor(a / TWO_PI);\nfloat r = a - TWO_PI * z;\nfloat t;\nfloat q = floor(r / PI_2 + 0.5);\nint j = int(q);\nif (j < -2 || j > 2) {\nreturn 1.0 / 0.0;\n}\nt = r - PI_2 * q;\nq = floor(t / PI_16 + 0.5);\nint k = int(q);\nint abs_k = int(abs(float(k)));\nif (abs_k > 4) {\nreturn 1.0 / 0.0;\n} else {\nt = t - PI_16 * q;\n}\nfloat u = 0.0;\nfloat v = 0.0;\nfloat sin_t, cos_t;\nfloat s, c;\nsincos_taylor_fp32(t, sin_t, cos_t);\nif (k == 0) {\ns = sin_t;\nc = cos_t;\n} else {\nif (abs(float(abs_k) - 1.0) < 0.5) {\nu = COS_TABLE_0;\nv = SIN_TABLE_0;\n} else if (abs(float(abs_k) - 2.0) < 0.5) {\nu = COS_TABLE_1;\nv = SIN_TABLE_1;\n} else if (abs(float(abs_k) - 3.0) < 0.5) {\nu = COS_TABLE_2;\nv = SIN_TABLE_2;\n} else if (abs(float(abs_k) - 4.0) < 0.5) {\nu = COS_TABLE_3;\nv = SIN_TABLE_3;\n}\nif (k > 0) {\ns = u * sin_t + v * cos_t;\nc = u * cos_t - v * sin_t;\n} else {\ns = u * sin_t - v * cos_t;\nc = u * cos_t + v * sin_t;\n}\n}\nif (j == 0) {\nsin_a = s;\ncos_a = c;\n} else if (j == 1) {\nsin_a = c;\ncos_a = -s;\n} else if (j == -1) {\nsin_a = -c;\ncos_a = s;\n} else {\nsin_a = -s;\ncos_a = -c;\n}\nreturn sin_a / cos_a;\n}\n#endif\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nreturn tan_taylor_fp32(a);\n#else\nreturn tan(a);\n#endif\n}\n"},T_={name:"picking",vs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nout vec4 picking_vRGBcolor_Avalid;\nvec3 picking_normalizeColor(vec3 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nvec4 picking_normalizeColor(vec4 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nbool picking_isColorZero(vec3 color) {\nreturn dot(color, vec3(1.0)) < 0.00001;\n}\nbool picking_isColorValid(vec3 color) {\nreturn dot(color, vec3(1.0)) > 0.00001;\n}\nbool isVertexHighlighted(vec3 vertexColor) {\nvec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\nreturn\nbool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\nvoid picking_setPickingColor(vec3 pickingColor) {\npickingColor = picking_normalizeColor(pickingColor);\nif (bool(picking.isActive)) {\npicking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\nif (!bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = pickingColor;\n}\n} else {\npicking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n}\n}\nvoid picking_setPickingAttribute(float value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.r = value;\n}\n}\nvoid picking_setPickingAttribute(vec2 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rg = value;\n}\n}\nvoid picking_setPickingAttribute(vec3 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = value;\n}\n}\n",fs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\nif (picking.isActive > 0.5) {\nreturn color;\n}\nbool selected = bool(picking_vRGBcolor_Avalid.a);\nif (selected) {\nfloat highLightAlpha = picking.highlightColor.a;\nfloat blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\nfloat highLightRatio = highLightAlpha / blendedAlpha;\nvec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\nreturn vec4(blendedRGB, blendedAlpha);\n} else {\nreturn color;\n}\n}\nvec4 picking_filterPickingColor(vec4 color) {\nif (bool(picking.isActive)) {\nif (picking_vRGBcolor_Avalid.a == 0.0) {\ndiscard;\n}\nreturn picking_vRGBcolor_Avalid;\n}\nreturn color;\n}\nvec4 picking_filterColor(vec4 color) {\nvec4 highlightColor = picking_filterHighlightColor(color);\nreturn picking_filterPickingColor(highlightColor);\n}\n",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},getUniforms:function(e={},t){const i={};if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=t}if(e.highlightColor){const t=Array.from(e.highlightColor,e=>e/255);Number.isFinite(t[3])||(t[3]=1),i.highlightColor=t}void 0!==e.isActive&&(i.isActive=Boolean(e.isActive),i.isAttribute=Boolean(e.isAttribute));void 0!==e.useFloatColors&&(i.useFloatColors=Boolean(e.useFloatColors));return i}};function E_(e,t=[],i=0){const n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function C_(e){return e-Math.fround(e)}function S_(e){const t=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){const r=4*i+n;E_(e[4*n+i],t,2*r)}return t}const B_={ONE:1};const I_={name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\nconst float SPLIT = 4097.0;\nfloat t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat a_hi = t * ONE - (t - a);\nfloat a_lo = a * ONE - a_hi;\n#else\nfloat a_hi = t - (t - a);\nfloat a_lo = a - a_hi;\n#endif\nreturn vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\nvec2 b = split(a.x);\nb.y += a.y;\nreturn b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat sum = (a + b) * ONE;\nfloat err = b - (sum - a) * ONE;\n#else\nfloat sum = a + b;\nfloat err = b - (sum - a);\n#endif\nreturn vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\nfloat s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) + (b - v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSub(float a, float b) {\nfloat s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) - (b + v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSqr(float a) {\nfloat prod = a * a;\nvec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\na_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\nfloat err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\nreturn vec2(prod, err);\n}\nvec2 twoProd(float a, float b) {\nfloat prod = a * b;\nvec2 a_fp64 = split(a);\nvec2 b_fp64 = split(b);\nfloat err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\na_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\nreturn vec2(prod, err);\n}\nvec2 sum_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSum(a.x, b.x);\nt = twoSum(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 sub_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSub(a.x, b.x);\nt = twoSub(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 mul_fp64(vec2 a, vec2 b) {\nvec2 prod = twoProd(a.x, b.x);\nprod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nprod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nreturn prod;\n}\nvec2 div_fp64(vec2 a, vec2 b) {\nfloat xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nvec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\nvec2 yn = a * xn;\n#endif\nfloat diff = (sub_fp64(a, mul_fp64(b, yn))).x;\nvec2 prod = twoProd(xn, diff);\nreturn sum_fp64(yn, prod);\n}\nvec2 sqrt_fp64(vec2 a) {\nif (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\nif (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\nfloat x = 1.0 / sqrt(a.x);\nfloat yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nvec2 yn_sqr = twoSqr(yn) * ONE;\n#else\nvec2 yn_sqr = twoSqr(yn);\n#endif\nfloat diff = sub_fp64(a, yn_sqr).x;\nvec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nreturn sum_fp64(split(yn), prod);\n#else\nreturn sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",getUniforms:function(){return B_},fp64ify:E_,fp64LowPart:C_,fp64ifyMatrix4:S_},M_=1/Math.PI*180,P_=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};const R_=globalThis.mathgl.config;function L_(e,{precision:t=R_.precision}={}){return e=function(e){return Math.round(e/R_.EPSILON)*R_.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function F_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function k_(e){return function(e,t){return V_(e,e=>e*P_,t)}(e)}function D_(e){return O_(e)}function O_(e,t){return V_(e,e=>e*M_,t)}function z_(e,t,i){return V_(e,e=>Math.max(t,Math.min(i,e)))}function U_(e,t,i){return F_(e)?e.map((e,n)=>U_(e,t[n],i)):i*t+(1-i)*e}function N_(e,t,i){const n=R_.EPSILON;i&&(R_.EPSILON=i);try{if(e===t)return!0;if(F_(e)&&F_(t)){if(e.length!==t.length)return!1;for(let i=0;i0?", ":"")+L_(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t=0&&e=0&&e0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(TA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=n,this[2]=s,this[3]=t,this[4]=r,this[5]=a,this[6]=i,this[7]=o,this[8]=l,this.check()}determinant(){return function(e){const t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*(c*o-s*l)+i*(-c*r+s*a)+n*(l*r-o*a)}(this)}transpose(){return function(e,t){if(e===t){const i=t[1],n=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=n,e[7]=r}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]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*s-a*c,d=-u*o+a*l,p=c*o-s*l;let f=i*h+n*d+r*p;f&&(f=1/f,e[0]=h*f,e[1]=(-u*n+r*c)*f,e[2]=(a*n-r*s)*f,e[3]=d*f,e[4]=(u*i-r*l)*f,e[5]=(-a*i+r*o)*f,e[6]=p*f,e[7]=(-c*i+n*l)*f,e[8]=(s*i-n*o)*f)}(this,this),this.check()}multiplyLeft(e){return xA(this,e,this),this.check()}multiplyRight(e){return xA(this,this,e),this.check()}rotate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(i),p=Math.cos(i);e[0]=p*n+d*s,e[1]=p*r+d*a,e[2]=p*o+d*l,e[3]=p*s-d*n,e[4]=p*a-d*r,e[5]=p*l-d*o,e[6]=c,e[7]=u,e[8]=h}(this,this,e),this.check()}scale(e){return Array.isArray(e)?bA(this,this,e):bA(this,this,[e,e]),this.check()}translate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1];e[0]=n,e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*n+p*s+c,e[7]=d*r+p*a+u,e[8]=d*o+p*l+h}(this,this,e),this.check()}transform(e,t){let i;switch(e.length){case 2:i=J_(t||[-0,-0],e,this);break;case 3:i=uA(t||[-0,-0,-0],e,this);break;case 4:i=iA(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return H_(i,e.length),i}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let CA,SA=null;function BA(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g;let M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(M=1/M,e[0]=(a*I-l*B+c*S)*M,e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function IA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15];let y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*n+v*a+x*h+b*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*n+v*a+x*h+b*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*n+v*a+x*h+b*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function MA(e,t,i){const n=i[0],r=i[1],o=i[2];let s,a,l,c,u,h,d,p,f,m,g,_;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*o+t[12],e[13]=t[1]*n+t[5]*r+t[9]*o+t[13],e[14]=t[2]*n+t[6]*r+t[10]*o+t[14],e[15]=t[3]*n+t[7]*r+t[11]*o+t[15]):(s=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*n+u*r+f*o+t[12],e[13]=a*n+h*r+m*o+t[13],e[14]=l*n+d*r+g*o+t[14],e[15]=c*n+p*r+_*o+t[15]),e}function PA(e,t,i){const n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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}function RA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function LA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}const FA=function(e,t,i,n,r){const o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=r&&r!==1/0){const t=1/(n-r);e[10]=(r+n)*t,e[14]=2*r*n*t}else e[10]=-1,e[14]=-2*n;return e};const kA=function(e,t,i,n,r,o,s){const a=1/(t-i),l=1/(n-r),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]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e};function DA(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}function OA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}var zA;!function(){const e=function(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}(),function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(zA||(zA={}));const UA=45*Math.PI/180,NA=1,VA=.1,jA=500,GA=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class HA extends vA{static get IDENTITY(){return function(){$A||($A=new HA,Object.freeze($A));return $A}()}static get ZERO(){return function(){QA||(QA=new HA([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(QA));return QA}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return zA}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this[9]=c,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=f,this[15]=m,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=r,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=c,this[7]=p,this[8]=i,this[9]=s,this[10]=u,this[11]=f,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(GA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:i,bottom:n,top:r,near:o=VA,far:s=jA}=e;return s===1/0?function(e,t,i,n,r,o){const s=2*o/(i-t),a=2*o/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),u=-1,h=-1,d=-2*o;e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=l,e[9]=c,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,i,n,r,o):function(e,t,i,n,r,o,s){const a=1/(i-t),l=1/(r-n),c=1/(o-s);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]=(r+n)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0}(this,t,i,n,r,o,s),this.check()}lookAt(e){const{eye:t,center:i=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,i,n){let r,o,s,a,l,c,u,h,d,p;const f=t[0],m=t[1],g=t[2],_=n[0],A=n[1],y=n[2],v=i[0],x=i[1],b=i[2];Math.abs(f-v)2*Math.PI)throw Error("expected radians")}function WA(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function qA(e,t,i){i*=.5;const n=Math.sin(i);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i),e}function KA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=n*u+s*a+r*c-o*l,e[1]=r*u+s*l+o*a-n*c,e[2]=o*u+s*c+n*l-r*a,e[3]=s*u-n*a-r*l-o*c,e}function XA(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];let l,c,u,h,d,p=i[0],f=i[1],m=i[2],g=i[3];return l=r*p+o*f+s*m+a*g,l<0&&(l=-l,p=-p,f=-f,m=-m,g=-g),1-l>Z_?(c=Math.acos(l),d=Math.sin(c),u=Math.sin((1-n)*c)/d,h=Math.sin(n*c)/d):(u=1-n,h=n),e[0]=u*r+h*p,e[1]=u*o+h*f,e[2]=u*s+h*m,e[3]=u*a+h*g,e}function JA(e,t){const i=t[0]+t[4]+t[8];let n;if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);const r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e}const YA=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},ey=DA,ty=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},iy=function(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},ny=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)},ry=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return t*t+i*i+n*n+r*r},oy=function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3];let s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e},sy=function(){const e=rA(),t=sA(1,0,0),i=sA(0,1,0);return function(n,r,o){const s=aA(r,o);return s<-.999999?(lA(e,t,r),pA(e)<1e-6&&lA(e,i,r),function(e,t){const i=t[0],n=t[1],r=t[2];let o=i*i+n*n+r*r;o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o}(e,e),qA(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(lA(e,r,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,oy(n,n))}}();!function(){const e=WA(),t=WA()}(),function(){const e=function(){const e=new W_(9);return W_!=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}()}();const ay=[0,0,0,1];class ly extends j_{constructor(e=0,t=0,i=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,i,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,i,n){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return JA(this,e),this.check()}fromAxisRotation(e,t){return qA(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=G_(e)}get y(){return this[1]}set y(e){this[1]=G_(e)}get z(){return this[2]}set z(e){this[2]=G_(e)}get w(){return this[3]}set w(e){this[3]=G_(e)}len(){return ny(this)}lengthSquared(){return ry(this)}dot(e){return ty(this,e)}rotationTo(e,t){return sy(this,e,t),this.check()}add(e){return YA(this,this,e),this.check()}calculateW(){return function(e,t){const i=t[0],n=t[1],r=t[2];e[0]=i,e[1]=n,e[2]=r,e[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o,a=s?1/s:0;e[0]=-i*a,e[1]=-n*a,e[2]=-r*a,e[3]=o*a}(this,this),this.check()}lerp(e,t,i){return void 0===i?this.lerp(this,e,t):(iy(this,e,t,i),this.check())}multiplyRight(e){return KA(this,this,e),this.check()}multiplyLeft(e){return KA(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a}(this,this,e),this.check()}rotateY(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=o*l+s*a,e[3]=s*l-o*a}(this,this,e),this.check()}scale(e){return ey(this,this,e),this.check()}slerp(e,t,i){let n,r,o;switch(arguments.length){case 1:({start:n=ay,target:r,ratio:o}=e);break;case 2:n=this,r=e,o=t;break;default:n=e,r=t,o=i}return XA(this,n,r,o),this.check()}transformVector4(e,t=new yA){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],u=c*n+a*o-l*r,h=c*r+l*n-s*o,d=c*o+s*r-a*n,p=-s*n-a*r-l*o;e[0]=u*c+p*-s+h*-l-d*-a,e[1]=h*c+p*-a+d*-s-u*-l,e[2]=d*c+p*-l+u*-a-h*-s,e[3]=t[3]}(t,e,this),H_(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const cy="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\nvec3 color;\n};\nstruct PointLight {\nvec3 color;\nvec3 position;\nvec3 attenuation;\n};\nstruct DirectionalLight {\nvec3 color;\nvec3 direction;\n};\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\nuniform bool lighting_uEnabled;\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\nreturn pointLight.attenuation.x\n+ pointLight.attenuation.y * distance\n+ pointLight.attenuation.z * distance * distance;\n}\n#endif\n",uy={lightSources:{}};function hy(e={}){const{color:t=[0,0,0],intensity:i=1}=e;return t.map(e=>e*i/255)}const dy={name:"lights",vs:cy,fs:cy,getUniforms:function e(t=uy){if("lightSources"in t){const{ambientLight:e,pointLights:i,directionalLights:n}=t.lightSources||{};return e||i&&i.length>0||n&&n.length>0?Object.assign({},function({ambientLight:e,pointLights:t=[],directionalLights:i=[]}){const n={};return n["lighting_uAmbientLight.color"]=e?hy(e):[0,0,0],t.forEach((e,t)=>{n[`lighting_uPointLight[${t}].color`]=hy(e),n[`lighting_uPointLight[${t}].position`]=e.position,n[`lighting_uPointLight[${t}].attenuation`]=e.attenuation||[1,0,0]}),n.lighting_uPointLightCount=t.length,i.forEach((e,t)=>{n[`lighting_uDirectionalLight[${t}].color`]=hy(e),n[`lighting_uDirectionalLight[${t}].direction`]=e.direction}),n.lighting_uDirectionalLightCount=i.length,n}({ambientLight:e,pointLights:i,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const i={pointLights:[],directionalLights:[]};for(const e of t.lights||[])switch(e.type){case"ambient":i.ambientLight=e;break;case"directional":i.directionalLights?.push(e);break;case"point":i.pointLights?.push(e)}return e({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}},py="uniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\nvec3 halfway_direction = normalize(light_direction + view_direction);\nfloat lambertian = dot(light_direction, normal_worldspace);\nfloat specular = 0.0;\nif (lambertian > 0.0) {\nfloat specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\nspecular = pow(specular_angle, lighting_uShininess);\n}\nlambertian = max(lambertian, 0.0);\nreturn (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = surfaceColor;\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nlightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = vec3(0, 0, 0);\nvec3 surfaceColor = vec3(0, 0, 0);\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\n",fy={};function my(e=fy){if(!("material"in e))return{};const{material:t}=e;return t?function(e){const{ambient:t=.35,diffuse:i=.6,shininess:n=32,specularColor:r=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:i,lighting_uShininess:n,lighting_uSpecularColor:r.map(e=>e/255)}}(t):{lighting_uEnabled:!1}}const gy={name:"gouraud-lighting",dependencies:[dy],vs:py,defines:{LIGHTING_VERTEX:1},getUniforms:my},_y={name:"phong-lighting",dependencies:[dy],fs:py,defines:{LIGHTING_FRAGMENT:1},getUniforms:my},Ay={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\nout vec3 pbr_vPosition;\nout vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\nvec4 pos = u_ModelMatrix * position;\npbr_vPosition = vec3(pos.xyz) / pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\nvec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\nvec3 bitangentW = cross(normalW, tangentW) * tangent.w;\npbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\npbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"precision highp float;\nuniform bool pbr_uUnlit;\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\nstruct PBRInfo\n{\nfloat NdotL;\nfloat NdotV;\nfloat NdotH;\nfloat LdotH;\nfloat VdotH;\nfloat perceptualRoughness;\nfloat metalness;\nvec3 reflectance0;\nvec3 reflectance90;\nfloat alphaRoughness;\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 n;\nvec3 v;\n};\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\nvec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\nvec3 bLess = step(vec3(0.04045),srgbIn.xyz);\nvec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\nreturn vec4(linOut,srgbIn.w);;\n#else\nreturn srgbIn;\n#endif\n}\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\nvec3 pos_dx = dFdx(pbr_vPosition);\nvec3 pos_dy = dFdy(pbr_vPosition);\nvec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\nvec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\nvec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng = normalize(pbr_vNormal);\n#else\nvec3 ng = cross(pos_dx, pos_dy);\n#endif\nt = normalize(t - ng * dot(ng, t));\nvec3 b = normalize(cross(ng, t));\nmat3 tbn = mat3(t, b, ng);\n#else\nmat3 tbn = pbr_vTBN;\n#endif\n#ifdef HAS_NORMALMAP\nvec3 n = texture(u_NormalSampler, pbr_vUV).rgb;\nn = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\nvec3 n = normalize(tbn[2].xyz);\n#endif\nreturn n;\n}\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\nfloat mipCount = 9.0;\nfloat lod = (pbrInputs.perceptualRoughness * mipCount);\nvec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,\nvec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\nvec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n#ifdef USE_TEX_LOD\nvec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\nvec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\nvec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\nvec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\ndiffuse *= u_ScaleIBLAmbient.x;\nspecular *= u_ScaleIBLAmbient.y;\nreturn diffuse + specular;\n}\n#endif\nvec3 diffuse(PBRInfo pbrInputs)\n{\nreturn pbrInputs.diffuseColor / M_PI;\n}\nvec3 specularReflection(PBRInfo pbrInputs)\n{\nreturn pbrInputs.reflectance0 +\n(pbrInputs.reflectance90 - pbrInputs.reflectance0) *\npow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\nfloat NdotL = pbrInputs.NdotL;\nfloat NdotV = pbrInputs.NdotV;\nfloat r = pbrInputs.alphaRoughness;\nfloat attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\nfloat attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\nreturn attenuationL * attenuationV;\n}\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\nfloat roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\nfloat f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\nreturn roughnessSq / (M_PI * f * f);\n}\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\npbrInputs.NdotL = 1.0;\npbrInputs.NdotH = 0.0;\npbrInputs.LdotH = 0.0;\npbrInputs.VdotH = 1.0;\n}\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\nvec3 n = pbrInputs.n;\nvec3 v = pbrInputs.v;\nvec3 l = normalize(lightDirection);\nvec3 h = normalize(l+v);\npbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\npbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\npbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\npbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\nvec3 light_direction = normalize(pointLight.position - pbr_vPosition);\nPBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\nvec3 F = specularReflection(pbrInputs);\nfloat G = geometricOcclusion(pbrInputs);\nfloat D = microfacetDistribution(pbrInputs);\nvec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\nvec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\nreturn pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\nvec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\nvec4 baseColor = u_BaseColorFactor;\n#endif\n#ifdef ALPHA_CUTOFF\nif (baseColor.a < u_AlphaCutoff) {\ndiscard;\n}\n#endif\nvec3 color = vec3(0, 0, 0);\nif(pbr_uUnlit){\ncolor.rgb = baseColor.rgb;\n}\nelse{\nfloat perceptualRoughness = u_MetallicRoughnessValues.y;\nfloat metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\nvec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);\nperceptualRoughness = mrSample.g * perceptualRoughness;\nmetallic = mrSample.b * metallic;\n#endif\nperceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat alphaRoughness = perceptualRoughness * perceptualRoughness;\nvec3 f0 = vec3(0.04);\nvec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\ndiffuseColor *= 1.0 - metallic;\nvec3 specularColor = mix(f0, baseColor.rgb, metallic);\nfloat reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\nfloat reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\nvec3 specularEnvironmentR0 = specularColor.rgb;\nvec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\nvec3 n = getNormal();\nvec3 v = normalize(u_Camera - pbr_vPosition);\nfloat NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\nvec3 reflection = -normalize(reflect(v, n));\nPBRInfo pbrInputs = PBRInfo(\n0.0,\nNdotV,\n0.0,\n0.0,\n0.0,\nperceptualRoughness,\nmetallic,\nspecularEnvironmentR0,\nspecularEnvironmentR90,\nalphaRoughness,\ndiffuseColor,\nspecularColor,\nn,\nv\n);\n#ifdef USE_LIGHTS\nPBRInfo_setAmbientLight(pbrInputs);\ncolor += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\nfor(int i = 0; i < lighting_uDirectionalLightCount; i++) {\nif (i < lighting_uDirectionalLightCount) {\nPBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\ncolor += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n}\n}\nfor(int i = 0; i < lighting_uPointLightCount; i++) {\nif (i < lighting_uPointLightCount) {\nPBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\nfloat attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\ncolor += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n}\n}\n#endif\n#ifdef USE_IBL\ncolor += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\nfloat ao = texture(u_OcclusionSampler, pbr_vUV).r;\ncolor = mix(color, color * ao, u_OcclusionStrength);\n#endif\n#ifdef HAS_EMISSIVEMAP\nvec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\ncolor += emissive;\n#endif\n#ifdef PBR_DEBUG\ncolor = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\ncolor = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\ncolor = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n}\nreturn vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[dy]},yy="#define SMOOTH_EDGE_RADIUS 0.5";var vy={name:"geometry",vs:`\n${yy}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`\n${yy}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};const xy={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(xy,"IDENTITY",{get:()=>(rp.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const by={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},wy={common:0,meters:1,pixels:2},Ty={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var Ey=`${Object.keys(xy).map(e=>`const int COORDINATE_SYSTEM_${e} = ${xy[e]};`).join("")}\n${Object.keys(by).map(e=>`const int PROJECTION_MODE_${e} = ${by[e]};`).join("")}\n${Object.keys(wy).map(e=>`const int UNIT_${e.toUpperCase()} = ${wy[e]};`).join("")}\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject_uPseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project_uCommonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project_uWrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project_uModelMatrix * position;\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project_uCoordinateOrigin;\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project_uCommonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n(project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project_uCoordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\nreturn offset * project_uFocalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project_uScale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project_uScale;\n}\n`;function Cy(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let n=0;n{for(const r in n)if(!Cy(n[r],i[r])){t=e(n),i=n;break}return t}}const By=[0,0,0,0],Iy=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],My=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Py=[0,0,0],Ry=[0,0,0],Ly=Sy(function({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:r,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,i){const{viewMatrixUncentered:n,projectionMatrix:r}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=By,l=By,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=Fy(e,t,i);d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=OA([],l,s),o=n||o,s=IA([],r,o),s=IA([],s,Iy));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,i,n),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=OA([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={project_uCoordinateSystem:i,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:s.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:t,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Py,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:o,project_uModelMatrix:My,project_uCameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(i){case xy.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=t.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case xy.LNGLAT:case xy.LNGLAT_OFFSETS:e._pseudoMeters||(p.project_uCommonUnitsPerMeter=t.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=t.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case xy.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return p});function Fy(e,t,i=Ry){i.length<3&&(i=[i[0],i[1],0]);let n,r=i,o=!0;switch(n=t===xy.LNGLAT_OFFSETS||t===xy.METER_OFFSETS?i:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case by.WEB_MERCATOR:t!==xy.LNGLAT&&t!==xy.CARTESIAN||(n=[0,0,0],o=!1);break;case by.WEB_MERCATOR_AUTO_OFFSET:t===xy.LNGLAT?r=n:t===xy.CARTESIAN&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],n=e.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case by.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case by.GLOBE:o=!1,n=null;break;default:o=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:r,offsetMode:o}}function ky({viewport:e,devicePixelRatio:t=1,modelMatrix:i=null,coordinateSystem:n=xy.DEFAULT,coordinateOrigin:r=Ry,autoWrapLongitude:o=!1}){n===xy.DEFAULT&&(n=e.isGeospatial?xy.LNGLAT:xy.CARTESIAN);const s=Ly({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r});return s.project_uWrapLongitude=o,s.project_uModelMatrix=i||My,s}const Dy={};var Oy={name:"project",dependencies:[w_,vy],vs:Ey,getUniforms:function(e=Dy){return"viewport"in e?ky(e):{}}};var zy={name:"project32",dependencies:[Oy],vs:"\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};function Uy(e,t){const i=OA([],t,e);return DA(i,i,1/i[3]),i}function Ny(e,t){const i=e%t;return i<0?t+i:i}function Vy(e,t,i){return ei?i:e}const jy=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Gy(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Hy=Math.PI,Qy=Hy/4,$y=Hy/180,Zy=180/Hy,Wy=512,qy=4003e4,Ky=85.051129,Xy=1.5;function Jy(e){const[t,i]=e;Gy(Number.isFinite(t)),Gy(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const n=i*$y;return[Wy*(t*$y+Hy)/(2*Hy),Wy*(Hy+Math.log(Math.tan(Qy+.5*n)))/(2*Hy)]}function Yy(e){const[t,i]=e,n=t/Wy*(2*Hy)-Hy,r=2*(Math.atan(Math.exp(i/Wy*(2*Hy)-Hy))-Qy);return[n*Zy,r*Zy]}function ev(e){const{latitude:t}=e;Gy(Number.isFinite(t));const i=Math.cos(t*$y);return function(e){return jy(e)}(qy*i)-9}function tv(e){return 12790407194604047e-21/Math.cos(e*$y)}function iv(e){const{latitude:t,longitude:i,highPrecision:n=!1}=e;Gy(Number.isFinite(t)&&Number.isFinite(i));const r=Wy,o=Math.cos(t*$y),s=r/360,a=s/o,l=12790407194604047e-21/o,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[s,a,l],degreesPerUnit:[.703125,1/a,1/l]};if(n){const e=$y*Math.tan(t*$y)/o,i=s*e/2,n=12790407194604047e-21*e,r=n/a*l;c.unitsPerDegree2=[0,i,n],c.unitsPerMeter2=[r,0,r]}return c}function nv(e,t){const[i,n,r]=e,[o,s,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=iv({longitude:i,latitude:n,highPrecision:!0}),u=Jy(e);u[0]+=o*(l[0]+c[0]*s),u[1]+=s*(l[1]+c[1]*s);const h=Yy(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function rv(e){return 2*Math.atan(.5/e)*Zy}function ov(e){return.5/Math.tan(.5*e*$y)}function sv(e,t){const[i,n,r=0]=e;return Gy(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)),Uy(t,[i,n,r,1])}function av(e,t,i=0){const[n,r,o]=e;if(Gy(Number.isFinite(n)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(o)){return Uy(t,[n,r,o,1])}const s=Uy(t,[n,r,0,1]),a=Uy(t,[n,r,1,1]),l=s[2],c=a[2];return X_([],s,a,l===c?0:((i||0)-l)/(c-l))}function lv(e){const{width:t,height:i,bounds:n,minExtent:r=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,l],[c,u]]=n,h=function(e=0){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return Gy(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e}(e.padding),d=Jy([a,Vy(u,-85.051129,Ky)]),p=Jy([c,Vy(l,-85.051129,Ky)]),f=[Math.max(Math.abs(p[0]-d[0]),r),Math.max(Math.abs(p[1]-d[1]),r)],m=[t-h.left-h.right-2*Math.abs(s[0]),i-h.top-h.bottom-2*Math.abs(s[1])];Gy(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],A=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/_,v=Yy([(p[0]+d[0])/2+A,(p[1]+d[1])/2+y]),x=Math.min(o,jy(Math.abs(Math.min(g,_))));return Gy(Number.isFinite(x)),{longitude:v[0],latitude:v[1],zoom:x}}const cv=Math.PI/180;function uv(e,t,i){const{pixelUnprojectionMatrix:n}=e,r=Uy(n,[t,0,1,1]),o=Uy(n,[t,e.height,1,1]),s=Yy(X_([],r,o,(i*e.distanceScales.unitsPerMeter[2]-r[2])/(o[2]-r[2])));return s.push(i),s}const hv=Sy(function({viewport:e,center:t}){return new HA(e.viewProjectionMatrix).invert().transform(t)}),dv=Sy(function({viewport:e,shadowMatrices:t}){const i=[],n=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,o=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[i,n,r]=e,o=av([i,n,r],t);if(Number.isFinite(r))return o;return[o[0],o[1],0]}(e,n));for(const n of t){const t=n.clone().translate(new AA(e.center).negate()),r=o.map(e=>t.transform(e)),s=(new HA).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});i.push(s.multiplyRight(n))}return i}),pv=[0,0,0,1],fv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var mv={name:"shadow",dependencies:[Oy],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n if (shadow_uDrawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n }\n if (shadow_uUseShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow_uLightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow_uDrawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow_uUseShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow_uLightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?function(e,t){const{shadowEnabled:i=!0}=e;if(!i||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const n={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,shadow_uColor:e.shadowColor||pv,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},r=hv({viewport:e.viewport,center:t.project_uCenter}),o=[],s=dv({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let i=0;ithis.device.clearWebGL(e))}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let i=0;i{const s=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in t)&&n(r.parent,!1),l in i){const e=i[l]=i[l]||Pv(t[l],t);c=e(r,o),i[a]=e}else Number.isFinite(s)?(c=s+(t[l]||0),i[a]=null):c=e;return o&&c>=e&&(e=c+1),t[a]=c,c};return n}class Rv extends Mv{constructor(e,t){super(e,t),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],r=n.width*i,o=n.height*i;r===t.width&&o===t.height||t.resize({width:r,height:o}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const Lv={color:[255,255,255],intensity:1},Fv=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],kv=[0,0,0,200/255];class Dv{constructor(e={}){this.id="lighting-effect",this.shadowColor=kv,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(mv),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const t in e){const i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:n,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;ot.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},t}cleanup(e){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(mv))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const i=(new HA).lookAt({eye:new AA(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tn&&(r=n);const o=this._pool,s=e.BYTES_PER_ELEMENT*r,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,r);return i&&t.fill(0),t}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:i}=e,{byteLength:n}=i,r=t.findIndex(e=>e.byteLength>=n);r<0?t.push(i):(r>0||t.lengththis.opts.poolSize&&t.shift()}};const zv=new AA;function Uv(e,t,i,n){zv.set(e,t,i);const r=zv.len();return{distance:n/r,normal:new AA(-e/r,-t/r,-i/r)}}function Nv(e){return e-Math.fround(e)}let Vv;function jv(e,t){const{size:i=1,startIndex:n=0}=t,r=void 0!==t.endIndex?t.endIndex:e.length,o=(r-n)/i;Vv=Ov.allocate(Vv,o,{type:Float32Array,size:2*i});let s=n,a=0;for(;s(90-e.pitch)*cv-.01?(l=uv(e,0,t),c=uv(e,i,t)):(l=r([0,0],o),c=r([i,0],o)),[s,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:i,height:n}=this,{longitude:r,latitude:o,zoom:s}=lv({width:i,height:n,bounds:e,...t});return new Kv({width:i,height:n,longitude:r,latitude:o,zoom:s})}}Kv.displayName="WebMercatorViewport";var Xv=Kv;const Jv=[0,0,0];function Yv(e,t,i=!1){const n=t.projectPosition(e);if(i&&t instanceof Xv){const[i,r,o=0]=e,s=t.getDistanceScales([i,r]);n[2]=o*s.unitsPerMeter[2]}return n}function ex(e,{viewport:t,modelMatrix:i,coordinateSystem:n,coordinateOrigin:r,offsetMode:o}){let[s,a,l=0]=e;switch(i&&([s,a,l]=OA([],[s,a,l,1],i)),n){case xy.LNGLAT:return Yv([s,a,l],t,o);case xy.LNGLAT_OFFSETS:return Yv([s+r[0],a+r[1],l+(r[2]||0)],t,o);case xy.METER_OFFSETS:return Yv(nv(r,[s,a,l]),t,o);case xy.CARTESIAN:default:return t.isGeospatial?[s+r[0],a+r[1],l+r[2]]:t.projectPosition([s,a,l])}}function tx(e,t){const{viewport:i,coordinateSystem:n,coordinateOrigin:r,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:i,coordinateOrigin:n}=e;let{coordinateSystem:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}=e;return r===xy.DEFAULT&&(r=t.isGeospatial?xy.LNGLAT:xy.CARTESIAN),void 0===o&&(o=r),void 0===s&&(s=n),{viewport:t,coordinateSystem:r,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=Jv,shaderCoordinateOrigin:u=Jv,offsetMode:h=!1}=l?Fy(i,n,r):{},d=ex(e,{viewport:i,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){const e=i.projectPosition(c||u);dA(d,d,e)}return d}const ix=[255,255,255],nx=1,rx=[0,0,1],ox=[0,0,1];let sx=0;class ax{constructor(e={}){this.type="point";const{color:t=ix}=e,{intensity:i=nx}=e,{position:n=ox}=e;this.id=e.id||"point-"+sx++,this.color=t,this.intensity=i,this.type="point",this.position=n,this.attenuation=function(e){if(e.attenuation)return e.attenuation;if("intensity"in e)return[0,0,e.intensity||0];return rx}(e),this.projectedLight={...this}}getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r}=e.props,o=tx(this.position,{viewport:i,coordinateSystem:n,coordinateOrigin:r,fromCoordinateSystem:i.isGeospatial?xy.LNGLAT:xy.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=o,t}}class lx extends ax{getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r,modelMatrix:o}=e.props,{project_uCameraPosition:s}=ky({viewport:i,modelMatrix:o,coordinateSystem:n,coordinateOrigin:r});return t.color=this.color,t.intensity=this.intensity,t.position=s,t}}let cx=1,ux=1;class hx{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){const{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=e,o=cx++,s={time:0,delay:t,duration:i,rate:n,repeat:r};return this._setChannelTime(s,this.time),this.channels.set(o,s),o}removeChannel(e){this.channels.delete(e);for(const[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const i=this.animations.values();for(const e of i){const{animation:t,channel:i}=e;t.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const i=ux++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const i=t-e.delay;i>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}let dx=0;const px={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:hf.stats.get("animation-loop-"+dx++),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class fx{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...px,...e},!(e=this.props).device)throw new Error("No device provided");const{useDevicePixels:t=!0}=this.props;this.stats=e.stats||new Ch({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:t}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){var e;this._running&&(this._animationFrameId=(e=this._animationFrame.bind(this),"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)))}_cancelAnimationFrame(){var e;null!==this._animationFrameId&&(e=this._animationFrameId,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),this.device.submit())}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:i}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,t]=this.device?.canvasContext?.getPixelSize()||[1,1];let i=1;const n=this.device?.canvasContext?.canvas;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:e>0&&t>0&&(i=e/t),{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class mx{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Wp("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&cf(this.indices.usage===Xp.INDEX)}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function gx(e,t){if(t instanceof mx)return t;const i=function(e,t){if(!t.indices)return;const i=t.indices.value;return e.createBuffer({usage:Xp.INDEX,data:i})}(e,t),{attributes:n,bufferLayout:r}=function(e,t){const i=[],n={};for(const[r,o]of Object.entries(t.attributes)){let t=r;switch(r){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}n[t]=e.createBuffer({data:o.value,id:`${r}-buffer`});const{value:s,size:a,normalized:l}=o;i.push({name:t,format:em(s,a,l)})}const r=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:i,vertexCount:r}}(e,t);return new mx({topology:t.topology||"triangle-list",bufferLayout:r,vertexCount:t.vertexCount,indices:i,attributes:n})}class _x{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){const t=Cp(Object.values(e).filter(e=>e.dependencies));for(const i of t)e[i.name]=i;Gp.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[t,i]of Object.entries(e)){const e=t;this.moduleUniforms[e]=i.defaultUniforms||{},this.moduleBindings[e]={}}}destroy(){}setProps(e){for(const t of Object.keys(e)){const i=t,n=e[i],r=this.modules[i];if(!r){Gp.warn(`Module ${t} not found`)();continue}const o=this.moduleUniforms[i],s=this.moduleBindings[i],a=r.getUniforms?.(n,o)||n,{uniforms:l,bindings:c}=tm(a);this.moduleUniforms[i]={...o,...l},this.moduleBindings[i]={...s,...c}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){const e={};for(const[t,i]of Object.entries(this.moduleUniforms))for(const[n,r]of Object.entries(i))e[`${t}.${n}`]={type:this.modules[t].uniformTypes?.[n],value:String(r)};return e}}class Ax{static defaultProps={...Mf.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Ax(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){const t={...Mf.defaultProps,...e},i=this._hashRenderPipeline(t);if(!this._renderPipelineCache[i]){const e=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._renderPipelineCache[i]={pipeline:e,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){const t={...Rf.defaultProps,...e},i=this._hashComputePipeline(t);if(!this._computePipelineCache[i]){const e=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._computePipelineCache[i]={pipeline:e,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){const t=e.hash,i=e instanceof Rf?this._computePipelineCache:this._renderPipelineCache;i[t].useCount--,0===i[t].useCount&&(i[t].pipeline.destroy(),delete i[t])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const t=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,n=this._getHash(JSON.stringify(e.bufferLayout));if("webgl"===this.device.type)return`${t}/${i}V-BL${n}`;{const r=this._getHash(JSON.stringify(e.parameters));return`${t}/${i}V-T${e.topology}P${r}BL${n}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}}class yx{static defaultProps={...Cf.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new yx(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){const t=this._hashShader(e);let i=this._cache[t];if(!i){const n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:n,useCount:0}}return i.useCount++,i.shader}release(e){const t=this._hashShader(e),i=this._cache[t];i&&(i.useCount--,0===i.useCount&&(delete this._cache[t],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}}let vx=null,xx=null;class bx{static defaultProps={...Mf.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Vp.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(e,t){this.props={...bx.defaultProps,...t},t=this.props,this.id=t.id||Wp("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]);this.setShaderInputs(t.shaderInputs||new _x(i));const n=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(e),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if("webgpu"===this.device.type&&this.props.source){this.props.shaderLayout||=x_(this.props.source);const{source:e,getUniforms:t}=this.props.shaderAssembler.assembleShader({platformInfo:n,...this.props,modules:r});this.source=e,this._getModuleUniforms=t}else{const{vs:e,fs:t,getUniforms:i}=this.props.shaderAssembler.assembleShaderPair({platformInfo:n,...this.props,modules:r});this.vs=e,this.fs=t,this._getModuleUniforms=i}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ax.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||yx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.uniforms&&this.setUniforms(t.uniforms),t.moduleSettings&&this.updateModuleSettings(t.moduleSettings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t;this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),qp(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:i}=this.vertexArray,n=i?i.byteLength/("uint32"===i.indexType?4:2):void 0;t=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:n,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),t?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",t}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&gx(this.device,e);t&&(this.setTopology(t.topology||"triangle-list"),this.bufferLayout=wx(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)),this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?wx(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){rm(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Xf(this.shaderInputs.modules);for(const e of Object.keys(this.shaderInputs.modules)){const t=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){e.indices&&Gp.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[i,n]of Object.entries(e)){const e=this.bufferLayout.find(e=>Tx(e).includes(i));if(!e){Gp.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}const r=Tx(e);let o=!1;for(const e of r){const t=this._attributeInfos[e];t&&(this.vertexArray.setBuffer(t.location,n),o=!0)}o||(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,n]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,n):(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){qp(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:t,uniforms:i}=tm(this._getModuleUniforms(e));Object.assign(this.bindings,t),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof vf?e=Math.max(e,t.texture.updateTimestamp):t instanceof Xp||t instanceof yf?e=Math.max(e,t.updateTimestamp):t instanceof Bf||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[e]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(t=>t.name===e)||"positions"===e||delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Gp.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let n=null;this.source?n=i:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:n}),this._attributeInfos=zf(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=Gp.level>3?0:1e4;Gp.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Gp.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},i="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(const n of e.attributes)n&&(t[`in ${n.location} ${n.name}: ${n.type}`]={[i]:n.stepMode||"vertex"});for(const n of e.varyings||[])t[`out ${n.location} ${n.name}`]={[i]:JSON.stringify(n.accessor)};return t}(this.pipeline.shaderLayout,this.id);Gp.table(2,e)();const t=this.shaderInputs.getDebugTable();for(const[e,i]of Object.entries(this.uniforms))t[e]={value:i};Gp.table(2,t)();const i=this._getAttributeDebugTable();Gp.table(2,this._attributeInfos)(),Gp.table(2,i)(),Gp.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=Gp.get("framebuffer");if(this._drawCount++,!t||this._drawCount++>3&&this._drawCount%60)return;const i=e.props.framebuffer;i&&function(e,{id:t,minimap:i,opaque:n,top:r="0",left:o="0",rgbaScale:s=1}){vx||(vx=document.createElement("canvas"),vx.id=t,vx.title=t,vx.style.zIndex="100",vx.style.position="absolute",vx.style.top=r,vx.style.left=o,vx.style.border="blue 1px solid",vx.style.transform="scaleY(-1)",document.body.appendChild(vx),xx=vx.getContext("2d")),vx.width===e.width&&vx.height===e.height||(vx.width=e.width/2,vx.height=e.height/2,vx.style.width="400px",vx.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),l=xx.createImageData(e.width,e.height);for(let e=0;et.name===e.name);t<0?i.push(e):i[t]=e}return i}function Tx(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}class Ex{device;model;transformFeedback;static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=bx.defaultProps){cf(Ex.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new bx(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||jp(),topology:t.topology||"point-list",...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(t instanceof Xp)return t.readAsync();const{buffer:i,byteOffset:n=0,byteLength:r=i.byteLength}=t;return i.readAsync(n,r)}}class Cx{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:i=null,vertexCount:n=null}=e;this.id=e.id||Wp("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(const[e,i]of Object.entries(t)){const t=ArrayBuffer.isView(i)?{value:i}:i;cf(ArrayBuffer.isView(t.value),`${this._print(e)}: must be typed array or object with value as typed array`),"POSITION"!==e&&"positions"!==e||t.size||(t.size=3),"indices"===e?(cf(!this.indices),this.indices=t):this.attributes[e]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(const t of Object.values(e)){const{value:e,size:n,constant:r}=t;!r&&e&&n>=1&&(i=Math.min(i,e.length/n))}return cf(Number.isFinite(i)),i}}class Sx{id;matrix=new HA;display=!0;position=new AA;rotation=new AA;scale=new AA(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||Wp(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return cf(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return cf(3===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return cf(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:i,scale:n,update:r=!0}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),r&&this.updateMatrix(),this}updateMatrix(){const e=this.position,t=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(i),this}update(e={}){const{position:t,rotation:i,scale:n}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){cf(e),t=t||this.matrix;const i=new HA(e).multiplyRight(t),n=i.invert(),r=n.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:i,worldInverseMatrix:n,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class Bx extends Sx{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;Gp.assert(t.every(e=>e instanceof Sx),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:i})=>{const n=t.getBounds();if(!n)return;const[r,o]=n,s=new AA(r).add(o).divide([2,2,2]);i.transformAsPoint(s,s);const a=new AA(o).subtract(r).divide([2,2,2]);i.transformAsVector(a,a);for(let t=0;t<8;t++){const i=new AA(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(a).add(s);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],i[t]),e[1][t]=Math.max(e[1][t],i[t])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,i=t.indexOf(e);return i>-1&&t.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new HA}={}){const i=new HA(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof Bx?t.traverse(e,{worldMatrix:i}):e(t,{worldMatrix:i})}}class Ix extends Sx{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}}const Mx={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class Px extends Mv{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,pickingFBO:o,deviceRect:{x:s,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:p,moduleParameters:f}){this.pickZ=p;const m=this._resetColorEncoder(p),g=[s,a,l,c],_=super.render({target:o,layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,cullRect:u,effects:h?.filter(e=>e.useInPicking),pass:d,isPicking:!0,moduleParameters:f,clearColor:[0,0,0,0],colorMask:15,scissorRect:g});this._colorEncoderState=null;return{decodePickingColor:m&&Rx.bind(null,m),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,t,i){const n={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:r,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?n.blend=!1:r&&o.includes("draw")&&(Object.assign(n,Mx),n.blend=!0,n.blendColor=function(e,t,i){const{byLayer:n,byAlpha:r}=e;let o,s=n.get(t);s?(s.viewports.push(i),o=s.a):(o=n.size+1,o<=255?(s={a:o,layer:t,viewports:[i]},n.set(t,s),r[o]=s):(rp.warn("Too many pickable layers, only picking the first 255")(),o=0));return[0,0,0,o/255]}(this._colorEncoderState,e,i)),n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function Rx(e,t){const i=e.byAlpha[t[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(t)}}const Lx="Awaiting state",Fx="Matched. State transferred from previous layer",kx="Initialized",Dx="Discarded. Awaiting garbage collection",Ox="No longer matched. Awaiting garbage collection",zx="Finalized! Awaiting garbage collection",Ux=Symbol.for("component"),Nx=Symbol.for("propTypes"),Vx=Symbol.for("deprecatedProps"),jx=Symbol.for("asyncPropDefaults"),Gx=Symbol.for("asyncPropOriginal"),Hx=Symbol.for("asyncPropResolved");function Qx(e,t=()=>!0){return Array.isArray(e)?$x(e,t,[]):t(e)?[e]:[]}function $x(e,t,i){let n=-1;for(;++n0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const i=++this._loadCount;let n=e;"string"==typeof e&&(n=Fd(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class qx{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:n=!0}){let r=this._resources[e];r?r.setData(t,i):(r=new Wx(e,t,this._context),this._resources[e]=r),r.persistent=n}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const i=t[e],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:n="default"}){const{_resources:r,protocol:o}=this;e.startsWith(o)&&(r[e=e.replace(o,"")]||this.add({resourceId:e,data:null,persistent:!1}));const s=r[e];if(this._track(i,n,s,t),s)return s.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,i,n){const r=this._consumers,o=r[e]=r[e]||{};let s=o[t];const a=s&&s.resourceId&&this._resources[s.resourceId];a&&(a.unsubscribe(s),this.prune()),i&&(s?(s.onChange=n,s.resourceId=i.id):s={onChange:n,resourceId:i.id},o[t]=s,i.subscribe(s))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}class Kx{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{lp("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:i,stats:n,viewport:r,timeline:o}=t||{};this.layers=[],this.resourceManager=new qx({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:yv(),defaultShaderModules:[],renderPass:void 0,stats:n||new Ch({id:"deck.gl"}),viewport:r||new qv({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new hx,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const n=i.getNeedsRedraw(e);t=t||n}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){lp("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const i=Qx(e,Boolean);for(const e of i)e.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,i=t.findIndex(t=>t.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){const i={};for(const t of e)i[t.id]?rp.warn(`Multiple old layers with same id ${t.id}`)():i[t.id]=t;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const n=[];this._updateSublayersRecursively(t,i,n),this._finalizeOldLayers(i);let r=!1;for(const e of n)if(e.hasUniformTransition()){r=`Uniform transition in ${e}`;break}this._needsUpdate=r,this.layers=n}_updateSublayersRecursively(e,t,i){for(const n of e){n.context=this.context;const e=t[n.id];null===e&&rp.warn(`Multiple new layers with same id ${n.id}`)(),t[n.id]=null;let r=null;try{this._debug&&e!==n&&n.validateProps(),e?(this._transferLayerState(e,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),r=n.isComposite?n.getSubLayers():null}catch(e){this._handleError("matching",e,n)}r&&this._updateSublayersRecursively(r,t,i)}}_finalizeOldLayers(e){for(const t in e){const i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=kx}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Fx,t!==e&&(e.lifecycle=Dx)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ox;try{e._finalize(),e.lifecycle=zx}catch(t){this._handleError("finalization",t,e)}}}function Xx(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;nt.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,t){const i=this.getViewports(),n={x:e[0],y:e[1]};for(let r=i.length-1;r>=0;--r){const o=i[r];if(o.containsPixel(n)){const i=e.slice();return i[0]-=o.x,i[1]-=o.y,o.unproject(i,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Qx(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!Xx(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else rp.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height})})}_updateController(e,t,i,n){const r=e.controller;if(r&&i){const o={...t,...r,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return n&&n.constructor===r.type||(n=this._createController(e,o)),n&&n.setProps(o),n}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=e.length;n--;){const r=e[n],o=this.getViewState(r),s=r.makeViewport({viewState:o,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(i=!0),!i&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,o,s,a),s&&this._viewports.unshift(s)}for(const e in t){const i=t[e];i&&!this.controllers[e]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((i,n)=>!e[n].equals(t[n]))}}const Yx=/([0-9]+\.?[0-9]*)(%|px)/;function eb(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=Yx.exec(e);if(t&&t.length>=3){const e="%"===t[2],i=parseFloat(t[1]);return{position:e?i/100:i,relative:e}}default:throw new Error(`Could not parse position string ${e}`)}}function tb(e,t){return e.relative?Math.round(e.position*t):e.position}class ib{constructor(e){const{id:t,x:i=0,y:n=0,width:r="100%",height:o="100%",padding:s=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=eb(i),this._y=eb(n),this._width=eb(r),this._height=eb(o),this._padding=s&&{left:eb(s.left||0),right:eb(s.right||0),top:eb(s.top||0),bottom:eb(s.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.ViewportType===e.ViewportType&&Xx(this.props,e.props,2)}makeViewport({width:e,height:t,viewState:i}){i=this.filterViewState(i);const n=this.getDimensions({width:e,height:t});return n.height&&n.width?new this.ViewportType({...i,...this.props,...n}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const i={x:tb(this._x,e),y:tb(this._y,t),width:tb(this._width,e),height:tb(this._height,t)};return this._padding&&(i.padding={left:tb(this._padding.left,e),top:tb(this._padding.top,t),right:tb(this._padding.right,e),bottom:tb(this._padding.bottom,t)}),i}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class nb{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const rb=()=>{},ob=2,sb=3,ab=e=>e,lb=1;class cb{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:i,startProps:n,endProps:r,duration:o,easing:s}}=e,a=s(t/o),l=i.interpolateProps(n,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new nb(e.timeline),this.onViewStateChange=e.onViewStateChange||rb,this.onStateChange=e.onStateChange||rb}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let n=i;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;n={...i,...e===ob?t:this.propsInTransition||i}}this._triggerTransition(n,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||"auto"===t)&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){if(this.transition.inProgress){return this.transition.settings.interruption===sb||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const i=this.getControllerState(e),n=this.getControllerState(t).shortestPathFrom(i),r=t.transitionInterpolator,o=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===o)return;const s=r.initializeProps(e,n);this.propsInTransition={};const a={duration:o,easing:t.transitionEasing||ab,interpolator:r,interruption:t.transitionInterruption||lb,startProps:s.start,endProps:s.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}function ub(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class hb{constructor(e){const{compare:t,extract:i,required:n}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=n}arePropsEqual(e,t){for(const i of this._propsToCompare)if(!(i in e)||!(i in t)||!N_(e[i],t[i]))return!1;return!0}initializeProps(e,t){const i={},n={};for(const r of this._propsToExtract)(r in e||r in t)&&(i[r]=e[r],n[r]=t[r]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const i=e[t];ub(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}}const db=["longitude","latitude","zoom","bearing","pitch"],pb=["longitude","latitude","zoom"];class fb extends hb{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:db,required:pb},super(i.transitionProps),this.opts=i}initializeProps(e,t){const i=super.initializeProps(e,t),{makeViewport:n,around:r}=this.opts;if(n&&r){const o=n(e),s=n(t),a=o.unproject(r);i.start.around=r,Object.assign(i.end,{around:s.project(a),aroundPosition:a,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){const n={};for(const r of this._propsToExtract)n[r]=U_(e[r]||0,t[r]||0,i);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...n});Object.assign(n,r.panByPosition(t.aroundPosition,U_(e.around,t.around,i)))}return n}}const mb={transitionDuration:0},gb=e=>1-(1-e)*(1-e),_b=["wheel"],Ab=["panstart","panmove","panend"],yb=["pinchstart","pinchmove","pinchend"],vb=["tripanstart","tripanmove","tripanend"],xb=["doubletap"],bb=["keydown"],wb={};class Tb{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new cb({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return!t&&this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:i}=this.props,{offsetCenter:n}=e;return[n.x-t,n.y-i]}isPointInBounds(e,t){const{width:i,height:n}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=n;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:i=!0,dragPan:n=!0,dragRotate:r=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(_b,c&&i),this.toggleEvents(Ab,c),this.toggleEvents(yb,c&&(s||a)),this.toggleEvents(vb,c&&a),this.toggleEvents(xb,c&&o),this.toggleEvents(bb,c&&l),this.scrollZoom=i,this.dragPan=n,this.dragRotate=r,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,i={}){const n={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const n=this.controllerState[i?"panStart":"rotateStart"]({pos:t});return this._panMove=i,this.updateViewport(n,mb,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),i=this.controllerState.pan({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:i=.01,smooth:n=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let o=2/(1+Math.exp(-Math.abs(r*i)));r<0&&0!==o&&(o=1/o);const s=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(s,{...this._getTransitionProps({around:t}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.rotateStart({pos:t});return this.updateViewport(i,mb,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const i=this.getCenter(e),n=[i[0],i[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:n});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return wb._startPinchRotation=e.rotation,wb._lastPinchEvent=e,this.updateViewport(i,mb,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:i}=e,n=this.getCenter(e);t=t.zoom({pos:n,scale:i})}if(this.touchRotate){const{rotation:i}=e;t=t.rotate({deltaAngleX:wb._startPinchRotation-i})}return this.updateViewport(t,mb,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),wb._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:i}=wb;if(this.touchZoom&&t&&i&&e.scale!==i.scale){const n=this.getCenter(e);let r=this.controllerState.rotateEnd();const o=Math.log2(e.scale),s=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),a=Math.pow(2,o+s*t/2);r=r.zoom({pos:n,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:n}),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return wb._startPinchRotation=null,wb._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:t,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:r,rotateSpeedY:o}=!0===this.keyboard?{}:this.keyboard,{controllerState:s}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?s.zoomOut(i).zoomOut(i):s.zoomOut(i),l.isZooming=!0;break;case"Equal":a=t?s.zoomIn(i).zoomIn(i):s.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":t?(a=s.rotateLeft(r),l.isRotating=!0):(a=s.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":t?(a=s.rotateRight(r),l.isRotating=!0):(a=s.moveRight(n),l.isPanning=!0);break;case"ArrowUp":t?(a=s.rotateUp(o),l.isRotating=!0):(a=s.moveUp(n),l.isPanning=!0);break;case"ArrowDown":t?(a=s.rotateDown(o),l.isRotating=!0):(a=s.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new fb({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:mb}}class Eb{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Cb extends Eb{constructor(e){const{width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y,normalize:v=!0}=e;ub(Number.isFinite(r)),ub(Number.isFinite(n)),ub(Number.isFinite(o)),super({width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:p,normalize:v,position:c},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){const{startRotatePos:n,startBearing:r,startPitch:o}=this.getState();if(!n||void 0===r||void 0===o)return this;let s;return s=e?this._getNewRotation(e,n,o,r):{bearing:r+t,pitch:o+i},this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:i}){let{startZoom:n,startZoomLngLat:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const{maxZoom:o,minZoom:s}=this.getViewportProps();let a=n+Math.log2(i);a=z_(a,s,o);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:r}=i;return Math.abs(n-t.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(r-t.longitude)>180&&(i.longitude=r<0?r+360:r-360),i}applyConstraints(e){const{maxZoom:t,minZoom:i,zoom:n}=e;e.zoom=z_(n,i,t);const{maxPitch:r,minPitch:o,pitch:s}=e;e.pitch=z_(s,o,r);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:i,pitch:n=0}=e;let{longitude:r,latitude:o,zoom:s,bearing:a=0}=e;(r<-180||r>180)&&(r=Ny(r+180,360)-180),(a<-180||a>180)&&(a=Ny(a+180,360)-180);const l=jy(i/512);if(s<=l)s=l,o=0;else{const e=i/2/Math.pow(2,s),t=Yy([0,e])[1];if(ot&&(o=t)}}return{width:t,height:i,longitude:r,latitude:o,zoom:s,pitch:n,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.zoom({pos:[t/2,i/2],scale:e})}_panFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.pan({startPos:[t/2,i/2],pos:[t/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,i,n){const r=e[0]-t[0],o=e[1]-t[1],s=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;o>0?Math.abs(c-a)>5&&(h=o/(a-c)*1.2):o<0&&a>5&&(h=1-s/a),h=z_(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=i;return h>0?f=i+h*(p-i):h<0&&(f=i-h*(d-i)),{pitch:f,bearing:n+180*u}}}class Sb extends Tb{constructor(){super(...arguments),this.ControllerState=Cb,this.transition={transitionDuration:300,transitionInterpolator:new fb({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e);(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class Bb extends ib{constructor(e={}){super(e)}get ViewportType(){return Xv}get ControllerType(){return Sb}}Bb.displayName="MapView";var Ib=Bb;const Mb=new Dv;class Pb{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const i=t.findIndex(t=>{return i=e,(t.order??1/0)-(i.order??1/0)>0;var i});i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Xx(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const i=[];for(const n of e){const e=t[n.id];let r=n;e&&e!==n?e.setProps?(e.setProps(n.props),r=e):e.cleanup(this._context):e||n.setup(this._context),i.push(r),delete t[n.id]}for(const e in t)t[e].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(e=>e instanceof Dv)||this._resolvedEffects.push(Mb),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class Rb extends Mv{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Lb{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Rb(e),this.pickLayersPass=new Px(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);const n=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);const r=t.render({...i,target:n});i.effects&&this._postRender(i.effects,i),this.renderCount++,lp("deckRenderer.renderLayers",this,r,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize();0===e.length&&[0,1].map(t=>{const i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(const i of e)i.resize(t)}_postRender(e,t){const{renderBuffers:i}=this,n={...t,inputBuffer:i[0],swapBuffer:i[1]};for(const r of e)if(r.postRender){n.target=r.id===this.lastPostProcessEffect?t.target:void 0;const e=r.postRender(n);n.inputBuffer=e,n.swapBuffer=e===i[0]?i[1]:i[0]}}}const Fb={pickedColor:null,pickedObjectIndex:-1};function kb({pickedColors:e,decodePickingColor:t,deviceX:i,deviceY:n,deviceRadius:r,deviceRect:o}){const{x:s,y:a,width:l,height:c}=o;let u=r*r,h=-1,d=0;for(let t=0;tu)d+=4*l;else for(let t=0;t=0){const e=t+s-i,n=e*e+o;n<=u&&(u=n,h=d)}d+=4}}if(h>=0){const i=e.slice(h,h+4),n=t(i);if(n){const e=Math.floor(h/4/l),t=h/4-e*l;return{...n,pickedColor:i,pickedX:s+t,pickedY:a+e}}rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Fb}function Db({pickInfo:e,viewports:t,pixelRatio:i,x:n,y:r,z:o}){let s,a=t[0];if(t.length>1&&(a=function(e,t){for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.containsPixel(t))return n}return e[0]}(e?.pickedViewports||t,{x:n,y:r})),a){const e=[n-a.x,r-a.y];void 0!==o&&(e[2]=o),s=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:n,y:r,pixel:[n,r],coordinate:s,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:i}}function Ob(e){const{pickInfo:t,lastPickedInfo:i,mode:n,layers:r}=e,{pickedColor:o,pickedLayer:s,pickedObjectIndex:a}=t,l=s?[s]:[];if("hover"===n){const e=i.index,t=i.layerId,n=s?s.props.id:null;if(n!==t||a!==e){if(n!==t){const e=r.find(e=>e.props.id===t);e&&l.unshift(e)}i.layerId=n,i.index=a,i.info=null}}const c=Db(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===s&&(t.color=o,t.index=a,t.picked=!0),t=zb({layer:e,info:t,mode:n});const r=t.layer;e===s&&"hover"===n&&(i.info=t),u.set(r.id,t),"hover"===n&&r.updateAutoHighlight(t)}),u}function zb({layer:e,info:t,mode:i}){for(;e&&t;){const n=t.layer||null;t.sourceLayer=n,t.layer=e,t=e.getPickingInfo({info:t,mode:i,sourceLayer:n}),e=e.parent}return t}class Ub{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Px(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:n},r=this.lastPickedInfo.info){const o=r&&r.layer&&r.layer.id,s=r&&r.viewport&&r.viewport.id,a=o?i.find(e=>e.id===o):null,l=s&&n.find(e=>e.id===s)||n[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const e=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=e}const{canvas:e}=this.device.getCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}_pickClosestObject({layers:e,views:t,viewports:i,x:n,y:r,radius:o=0,depth:s=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===i.length)return{result:[],emptyInfo:Db({viewports:i,x:n,y:r,pixelRatio:h})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([n,r],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*h),{width:g,height:_}=this.pickingFBO,A=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),y={x:n-o,y:r-o,width:2*o+1,height:2*o+1};let v;const x=[],b=new Set;for(let e=0;e=0){const r=e.slice(n,n+4),o=r.join(",");if(!i.has(o)){const e=t(r);e?i.set(o,{...e,color:r}):rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(i.values())}(this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:y,cullRect:{x:n,y:r,width:o,height:s},effects:u,pass:`picking:${a}`})),x=new Map,b=[],w=Number.isFinite(l);for(let e=0;e=l);e++){const t=v[e];let i={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:n,y:r,pixelRatio:d};i=zb({layer:t.pickedLayer,info:i,mode:a});const o=i.layer.id;x.has(o)||x.set(o,new Set);const s=x.get(o),l=i.object??i.index;s.has(l)||(s.add(l),b.push(i))}return b}_drawAndSample({layers:e,views:t,viewports:i,onViewportActive:n,deviceRect:r,cullRect:o,effects:s,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:n,pickingFBO:c,deviceRect:r,cullRect:o,effects:s,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of s)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:p,width:f,height:m}=r,g=new(l?Float32Array:Uint8Array)(f*m*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:n,deviceHeight:r}){const o=Math.max(0,e-i),s=Math.max(0,t-i),a=Math.min(n,e+i+1)-o,l=Math.min(r,t+i+1)-s;return a<=0||l<=0?null:{x:o,y:s,width:a,height:l}}}const Nb={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Vb="top-left",jb="__root";class Gb{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Xx(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const t={};for(const e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(const e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let i of e){const e=t[i.id];e?e.viewId!==i.viewId||e.placement!==i.placement?(this._remove(e),this._add(i)):i!==e&&(e.setProps(i.props),i=e):this._add(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(const e in t){const i=t[e];i&&this._remove(i)}this.widgets=e}_add(e){const{viewId:t=null,placement:i=Vb}=e,n=e.onAdd({deck:this.deck,viewId:t});n&&this._getContainer(t,i).append(n),e._element=n}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,t){const i=e||jb;let n=this.containers[i];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[i]=n);let r=n.querySelector(`.${t}`);return r||(r=document.createElement("div"),r.className=t,r.style.position="absolute",r.style.zIndex="2",Object.assign(r.style,Nb[t]),n.append(r)),r}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const i in this.containers){const n=this.lastViewports[i]||null,r=i===jb||n,o=this.containers[i];r?(o.style.display="block",o.style.left=`${n?n.x:0}px`,o.style.top=`${n?n.y:0}px`,o.style.width=`${n?n.width:e}px`,o.style.height=`${n?n.height:t}px`):o.style.display="none"}}onRedraw({viewports:e,layers:t}){const i=e.reduce((e,t)=>(e[t.id]=t,e),{}),{lastViewports:n}=this;for(const r of this.getWidgets()){const{viewId:o}=r;if(o){const e=i[o];e&&(r.onViewportChange&&!e.equals(n[o])&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(const t of e)t.equals(n[t.id])||r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(const i of this.getWidgets()){const{viewId:n}=i;n&&n!==e.viewport?.id||i.onHover?.(e,t)}}onEvent(e,t){const i=Ty[t.type];if(i)for(const n of this.getWidgets()){const{viewId:r}=n;r&&r!==e.viewport?.id||n[i.handler]?.(e,t)}}}const Hb={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Qb{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const t=document.createElement("div");return t.className="deck-tooltip",Object.assign(t.style,Hb),this.deck=e,this.element=t,t}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;const n=i(e);this.lastViewport=e.viewport,this.setTooltip(n,e.x,e.y)}setTooltip(e,t,i){const n=this.element;if(n){if("string"==typeof e)n.innerText=e;else{if(!e)return this.isVisible=!1,void(n.style.display="none");e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className)}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${t}px, ${i}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(n.style,e.style)}}}var $b;!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}($b||($b={}));const Zb={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Wb=(e,t,i)=>t?e.enable(i):e.disable(i),qb=(e,t,i)=>e.hint(i,t),Kb=(e,t,i)=>e.pixelStorei(i,t),Xb=(e,t,i)=>{const n=36006===i?36009:36008;return e.bindFramebuffer(n,t)},Jb=(e,t,i)=>{const n={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];e.bindBuffer(n,t)};function Yb(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const ew={3042:Wb,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Wb,2885:(e,t)=>e.cullFace(t),2929:Wb,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Wb,35723:qb,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Xb,36010:Xb,34964:Jb,36662:Jb,36663:Jb,35053:Jb,35055:Jb,2886:(e,t)=>e.frontFace(t),33170:qb,2849:(e,t)=>e.lineWidth(t),32823:Wb,32824:"polygonOffset",10752:"polygonOffset",35977:Wb,32926:Wb,32928:Wb,32938:"sampleCoverage",32939:"sampleCoverage",3089:Wb,3088:(e,t)=>e.scissor(...t),2960:Wb,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:Wb,10754:Wb,12288:Wb,12289:Wb,12290:Wb,12291:Wb,12292:Wb,12293:Wb,12294:Wb,12295:Wb,3333:Kb,3317:Kb,37440:Kb,37441:Kb,37443:Kb,3330:Kb,3332:Kb,3331:Kb,3314:Kb,32878:Kb,3316:Kb,3315:Kb,32877:Kb,framebuffer:(e,t)=>{const i=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,i)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const i="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...i)},blendFunc:(e,t)=>{const i=2===t?.length?[...t,...t]:t;e.blendFuncSeparate(...i)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Yb(t)?t:[t,t];const[i,n]=t;e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilFuncSeparate(1028,i,n,r),e.stencilFuncSeparate(1029,o,s,a)},stencilOp:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilOpSeparate(1028,i,n,r),e.stencilOpSeparate(1029,o,s,a)},viewport:(e,t)=>e.viewport(...t)};function tw(e,t,i){return void 0!==t[e]?t[e]:i[e]}const iw={blendEquation:(e,t,i)=>e.blendEquationSeparate(tw(32777,t,i),tw(34877,t,i)),blendFunc:(e,t,i)=>e.blendFuncSeparate(tw(32969,t,i),tw(32968,t,i),tw(32971,t,i),tw(32970,t,i)),polygonOffset:(e,t,i)=>e.polygonOffset(tw(32824,t,i),tw(10752,t,i)),sampleCoverage:(e,t,i)=>e.sampleCoverage(tw(32938,t,i),tw(32939,t,i)),stencilFuncFront:(e,t,i)=>e.stencilFuncSeparate(1028,tw(2962,t,i),tw(2967,t,i),tw(2963,t,i)),stencilFuncBack:(e,t,i)=>e.stencilFuncSeparate(1029,tw(34816,t,i),tw(36003,t,i),tw(36004,t,i)),stencilOpFront:(e,t,i)=>e.stencilOpSeparate(1028,tw(2964,t,i),tw(2965,t,i),tw(2966,t,i)),stencilOpBack:(e,t,i)=>e.stencilOpSeparate(1029,tw(34817,t,i),tw(34818,t,i),tw(34819,t,i))},nw={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,i)=>e({[t]:i}),hint:(e,t,i)=>e({[t]:i}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,i)=>e({36007:i}),bindTransformFeedback:(e,t,i)=>e({36389:i}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,i)=>{switch(t){case 36160:return e({36006:i,36010:i});case 36009:return e({36006:i});case 36008:return e({36010:i});default:return null}},bindBuffer:(e,t,i)=>{const n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return n?e({[n]:i}):{valueChanged:!0}},blendColor:(e,t,i,n,r)=>e({32773:new Float32Array([t,i,n,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,i)=>e({32777:t,34877:i}),blendFunc:(e,t,i)=>e({32969:t,32968:i,32971:t,32970:i}),blendFuncSeparate:(e,t,i,n,r)=>e({32969:t,32968:i,32971:n,32970:r}),clearColor:(e,t,i,n,r)=>e({3106:new Float32Array([t,i,n,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,i,n,r)=>e({3107:[t,i,n,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,i)=>e({2928:new Float32Array([t,i])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,i)=>e({32824:t,10752:i}),sampleCoverage:(e,t,i)=>e({32938:t,32939:i}),scissor:(e,t,i,n,r)=>e({3088:new Int32Array([t,i,n,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,i)=>e({[1028===t?2968:36005]:i}),stencilFunc:(e,t,i,n)=>e({2962:t,2967:i,2963:n,34816:t,36003:i,36004:n}),stencilFuncSeparate:(e,t,i,n,r)=>e({[1028===t?2962:34816]:i,[1028===t?2967:36003]:n,[1028===t?2963:36004]:r}),stencilOp:(e,t,i,n)=>e({2964:t,2965:i,2966:n,34817:t,34818:i,34819:n}),stencilOpSeparate:(e,t,i,n,r)=>e({[1028===t?2964:34817]:i,[1028===t?2965:34818]:n,[1028===t?2966:34819]:r}),viewport:(e,t,i,n,r)=>e({2978:[t,i,n,r]})},rw=(e,t)=>e.isEnabled(t),ow={3042:rw,2884:rw,2929:rw,3024:rw,32823:rw,32926:rw,32928:rw,3089:rw,2960:rw,35977:rw},sw=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function aw(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const i={};for(const n in t){const r=Number(n),o=ew[n];o&&("string"==typeof o?i[o]=!0:o(e,t[n],r))}const n=e.state&&e.state.cache;if(n)for(const r in i){(0,iw[r])(e,t,n)}}function lw(e,t=Zb){if("number"==typeof t){const i=t,n=ow[i];return n?n(e,i):e.getParameter(i)}const i=Array.isArray(t)?t:Object.keys(t),n={};for(const t of i){const i=ow[t];n[t]=i?i(e,Number(t)):e.getParameter(Number(t))}return n}function cw(e,t){if(e===t)return!0;const i=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(i&&n&&e.length===t.length){for(let i=0;i{}}={}){this.gl=e,this.cache=t?lw(e):Object.assign({},Zb),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){cf(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];aw(this.gl,e),this.stateStack.pop()}_updateCache(e){let t,i=!1;const n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){cf(void 0!==r);const o=e[r],s=this.cache[r];cw(o,s)||(i=!0,t=s,n&&!(r in n)&&(n[r]=s),this.cache[r]=o)}return{valueChanged:i,oldValue:t}}}function hw(e){return e.state}function dw(e,t){const{enable:i=!0,copyState:n}=t;if(cf(void 0!==n),!e.state){e.state=new uw(e,{copyState:n}),function(e){const t=e.useProgram.bind(e);e.useProgram=function(i){const n=hw(e);n.program!==i&&(t(i),n.program=i)}}(e);for(const t in nw){gw(e,t,nw[t])}mw(e,"getParameter"),mw(e,"isEnabled")}return hw(e).enable=i,e}function pw(e){let t=hw(e);t||(dw(e,{copyState:!1}),t=hw(e)),t.push()}function fw(e){const t=hw(e);cf(t),t.pop()}function mw(e,t){const i=e[t].bind(e);e[t]=function(t){if(void 0===t||sw.has(t))return i(t);const n=hw(e);return t in n.cache||(n.cache[t]=i(t)),n.enable?n.cache[t]:i(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function gw(e,t,i){if(!e[t])return;const n=e[t].bind(e);e[t]=function(...t){const r=hw(e),{valueChanged:o,oldValue:s}=i(r._updateCache,...t);return o&&n(...t),s},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}const _w={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Aw(e,t,i){return void 0===i[t]&&(i[t]=e.getExtension(t)||null),i[t]}function yw(e,t){const i=e.getParameter(7936),n=e.getParameter(7937);Aw(e,"WEBGL_debug_renderer_info",t);const r=t.WEBGL_debug_renderer_info,o=e.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936)||i,s=e.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937)||n,a=e.getParameter(7938),l=vw(o,s),c=function(e,t){if(/Metal/i.exec(e)||/Metal/i.exec(t))return"metal";if(/ANGLE/i.exec(e)||/ANGLE/i.exec(t))return"opengl";return"unknown"}(o,s),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(vw(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(o,s);return{type:"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:o,renderer:s,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function vw(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function xw(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const bw="texture-compression-bc",ww="texture-compression-astc",Tw="texture-compression-etc2",Ew="texture-compression-pvrtc-webgl",Cw="texture-compression-atc-webgl",Sw="float32-renderable-webgl",Bw="float16-renderable-webgl",Iw="snorm8-renderable-webgl",Mw="norm16-renderable-webgl",Pw="snorm16-renderable-webgl",Rw="float32-filterable",Lw="float16-filterable-webgl",Fw="WEBGL_compressed_texture_s3tc",kw="WEBGL_compressed_texture_s3tc_srgb",Dw="EXT_texture_compression_rgtc",Ow="EXT_texture_compression_bptc",zw="EXT_texture_norm16",Uw="EXT_render_snorm",Nw={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Uw],"norm16-renderable-webgl":[zw],"snorm16-renderable-webgl":[zw,Uw],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Fw,kw,Dw,Ow],"texture-compression-bc5-webgl":[Dw],"texture-compression-bc7-webgl":[Ow],"texture-compression-etc2":["WEBGL_compressed_texture_etc"],"texture-compression-astc":["WEBGL_compressed_texture_astc"],"texture-compression-etc1-webgl":["WEBGL_compressed_texture_etc1"],"texture-compression-pvrtc-webgl":["WEBGL_compressed_texture_pvrtc"],"texture-compression-atc-webgl":["WEBGL_compressed_texture_atc"]};const Vw={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:Iw},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:Iw},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:Bw,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Mw,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:Pw},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:Iw},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:Bw,filter:Lw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Mw},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:Pw},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Sw,filter:Rw},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"rgb9e5ufloat_renderable-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Sw,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Mw},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Mw},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Sw,filter:Rw,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:Bw,filter:Lw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Mw,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:Pw},"rgb32float-webgl":{gl:34837,render:Sw,filter:Rw,gl2ext:"EXT_color_buffer_float",dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Sw,filter:Rw,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fw,f:bw},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:kw,f:bw},"bc1-rgba-unorm":{gl:33777,x:Fw,f:bw},"bc1-rgba-unorm-srgb":{gl:35916,x:kw,f:bw},"bc2-rgba-unorm":{gl:33778,x:Fw,f:bw},"bc2-rgba-unorm-srgb":{gl:35918,x:kw,f:bw},"bc3-rgba-unorm":{gl:33779,x:Fw,f:bw},"bc3-rgba-unorm-srgb":{gl:35919,x:kw,f:bw},"bc4-r-unorm":{gl:36283,x:Dw,f:bw},"bc4-r-snorm":{gl:36284,x:Dw,f:bw},"bc5-rg-unorm":{gl:36285,x:Dw,f:bw},"bc5-rg-snorm":{gl:36286,x:Dw,f:bw},"bc6h-rgb-ufloat":{gl:36495,x:Ow,f:bw},"bc6h-rgb-float":{gl:36494,x:Ow,f:bw},"bc7-rgba-unorm":{gl:36492,x:Ow,f:bw},"bc7-rgba-unorm-srgb":{gl:36493,x:Ow,f:bw},"etc2-rgb8unorm":{gl:37492,f:Tw},"etc2-rgb8unorm-srgb":{gl:37494,f:Tw},"etc2-rgb8a1unorm":{gl:37496,f:Tw},"etc2-rgb8a1unorm-srgb":{gl:37497,f:Tw},"etc2-rgba8unorm":{gl:37493,f:Tw},"etc2-rgba8unorm-srgb":{gl:37495,f:Tw},"eac-r11unorm":{gl:37488,f:Tw},"eac-r11snorm":{gl:37489,f:Tw},"eac-rg11unorm":{gl:37490,f:Tw},"eac-rg11snorm":{gl:37491,f:Tw},"astc-4x4-unorm":{gl:37808,f:ww},"astc-4x4-unorm-srgb":{gl:37840,f:ww},"astc-5x4-unorm":{gl:37809,f:ww},"astc-5x4-unorm-srgb":{gl:37841,f:ww},"astc-5x5-unorm":{gl:37810,f:ww},"astc-5x5-unorm-srgb":{gl:37842,f:ww},"astc-6x5-unorm":{gl:37811,f:ww},"astc-6x5-unorm-srgb":{gl:37843,f:ww},"astc-6x6-unorm":{gl:37812,f:ww},"astc-6x6-unorm-srgb":{gl:37844,f:ww},"astc-8x5-unorm":{gl:37813,f:ww},"astc-8x5-unorm-srgb":{gl:37845,f:ww},"astc-8x6-unorm":{gl:37814,f:ww},"astc-8x6-unorm-srgb":{gl:37846,f:ww},"astc-8x8-unorm":{gl:37815,f:ww},"astc-8x8-unorm-srgb":{gl:37847,f:ww},"astc-10x5-unorm":{gl:37819,f:ww},"astc-10x5-unorm-srgb":{gl:37851,f:ww},"astc-10x6-unorm":{gl:37817,f:ww},"astc-10x6-unorm-srgb":{gl:37849,f:ww},"astc-10x8-unorm":{gl:37818,f:ww},"astc-10x8-unorm-srgb":{gl:37850,f:ww},"astc-10x10-unorm":{gl:37819,f:ww},"astc-10x10-unorm-srgb":{gl:37851,f:ww},"astc-12x10-unorm":{gl:37820,f:ww},"astc-12x10-unorm-srgb":{gl:37852,f:ww},"astc-12x12-unorm":{gl:37821,f:ww},"astc-12x12-unorm-srgb":{gl:37853,f:ww},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Ew},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Ew},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Ew},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Ew},"etc1-rbg-unorm-webgl":{gl:36196,f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{gl:35986,f:Cw},"atc-rgba-unorm-webgl":{gl:35986,f:Cw},"atc-rgbai-unorm-webgl":{gl:34798,f:Cw}},jw={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},Gw={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function Hw(e,t,i){const n=Vw[t];if(!n)return!1;if(void 0===n.gl)return!1;const r=n.x||n.gl2ext;return!r||Boolean(Aw(e,r,i))}function Qw(e){const t=Vw[e],i=t?.gl;if(void 0===i)throw new Error(`Unsupported texture format ${e}`);return i}function $w(e){const t=Vw[e],i=Qw(e),n=rf(e);return{format:i,dataFormat:t?.dataFormat||Ww(n.format,n.integer,n.normalized,i),type:n.dataType?xw(n.dataType):t?.types?.[0]||5121,compressed:n.compressed}}function Zw(e){const t=$w(e);return(jw[t.dataFormat]||4)*(Gw[t.type]||1)}function Ww(e,t,i,n){if(6408===n||6407===n)return n;switch(e){case"r":return t&&!i?36244:6403;case"rg":return t&&!i?33320:33319;case"rgb":return t&&!i?36248:6407;case"rgba":return t&&!i?36249:6408;default:return 6408}}const qw={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Kw extends af{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,Aw(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){return!this.disabledFeatures[e]&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in Nw}(e)&&function(e,t,i){return(Nw[t]||[]).every(t=>Aw(e,t,i))}(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(qw),...Object.keys(Nw)]}getWebGLFeature(e){const t=qw[e];return"string"==typeof t?Boolean(Aw(this.gl,t,this.extensions)):Boolean(t)}}class Xw extends sf{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}}function Jw(e,t,i){if(function(e){for(const t in e)return!1;return!0}(t))return i(e);const{nocatch:n=!0}=t;let r;if(pw(e),aw(e,t),n)r=i(e),fw(e);else try{r=i(e)}finally{fw(e)}return r}function Yw(e,t,i,n){if(qp(t))return n(e);const r=e;pw(r.gl);try{return function(e,t){const i=e,{gl:n}=i;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029)}t.frontFace&&n.frontFace(rT("frontFace",t.frontFace,{ccw:2305,cw:2304}));t.unclippedDepth&&e.features.has("depth-clip-control")&&n.enable(34383);void 0!==t.depthBias&&(n.enable(32823),n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0));if(t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=rT("provokingVertex",t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(n)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=rT("polygonMode",t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,n),e?.polygonModeWEBGL(1029,n)}t.polygonOffsetLine&&n.enable(10754)}e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&n.enable(12288),t.clipDistance1&&n.enable(12289),t.clipDistance2&&n.enable(12290),t.clipDistance3&&n.enable(12291),t.clipDistance4&&n.enable(12292),t.clipDistance5&&n.enable(12293),t.clipDistance6&&n.enable(12294),t.clipDistance7&&n.enable(12295));void 0!==t.depthWriteEnabled&&n.depthMask(t.depthWriteEnabled);t.depthCompare&&("always"!==t.depthCompare?n.enable(2929):n.disable(2929),n.depthFunc(eT("depthCompare",t.depthCompare)));if(t.stencilWriteMask){const e=t.stencilWriteMask;n.stencilMaskSeparate(1028,e),n.stencilMaskSeparate(1029,e)}t.stencilReadMask&&Gp.warn("stencilReadMask not supported under WebGL");if(t.stencilCompare){const e=t.stencilReadMask||4294967295,i=eT("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,i,0,e),n.stencilFuncSeparate(1029,i,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=tT("stencilPassOperation",t.stencilPassOperation),i=tT("stencilFailOperation",t.stencilFailOperation),r=tT("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,i,r,e),n.stencilOpSeparate(1029,i,r,e)}if(t.blendColorOperation||t.blendAlphaOperation){n.enable(3042);const e=iT("blendColorOperation",t.blendColorOperation||"add"),i=iT("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(e,i);const r=nT("blendColorSrcFactor",t.blendColorSrcFactor||"one"),o=nT("blendColorDstFactor",t.blendColorDstFactor||"zero"),s=nT("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=nT("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(r,o,s,a)}}(e,t),aw(r.gl,i),n(e)}finally{fw(r.gl)}}function eT(e,t){return rT(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function tT(e,t){return rT(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function iT(e,t){return rT(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function nT(e,t){return rT(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function rT(e,t,i){if(!(t in i))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return i[t]}function oT(e){const t={};return e.addressModeU&&(t[10242]=sT(e.addressModeU)),e.addressModeV&&(t[10243]=sT(e.addressModeV)),e.addressModeW&&(t[32882]=sT(e.addressModeW)),e.magFilter&&(t[10240]=aT(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t){if(!t)return aT(e);switch(e){case"nearest":return"nearest"===t?9984:9986;case"linear":return"nearest"===t?9985:9987}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=eT("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function sT(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function aT(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class lT extends Xp{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const i="object"==typeof t?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=function(e){if(e&Xp.INDEX)return 34963;if(e&Xp.VERTEX)return 34962;if(e&Xp.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&Xp.INDEX)return 35044;if(e&Xp.VERTEX)return 35044;if(e&Xp.UNIFORM)return 35048;return 35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,i=e.byteLength+t){const n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.glUsage),this.gl.bufferSubData(n,t,e),this.gl.bindBuffer(n,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){cf(e>=0);let t=e;0===e&&(t=new Float32Array(0));const i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){const i=36663;this.gl.bindBuffer(i,this.handle),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const i=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}class cT extends Bf{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=oT(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,i]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,i);break;default:this.device.gl.samplerParameteri(this.handle,e,i)}}}}class uT extends vf{device;gl;handle;texture;constructor(e,t){super(e,{...yf.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}const hT={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0};class dT extends yf{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...hT,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=function(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;default:throw new Error(e.dimension)}}(this.props),this.loaded=!1,"string"==typeof this.props?.data&&Object.assign(this.props,{data:im(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new uT(this.device,{...e,texture:this})}initialize(e={}){if("cube"===this.props.dimension)return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(t=>this.initialize(Object.assign({},e,{pixels:t,data:t}))),this;const i="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(i&&t.readyStatethis.initialize(e)),this;const{parameters:n={}}=e,{pixels:r=null,pixelStore:o={},textureUnit:s,mipmaps:a=!0}=e;t||(t=r);let{width:l,height:c,dataFormat:u,type:h,compressed:d=!1}=e;const{depth:p=0}=e,f=Qw(e.format);return({width:l,height:c,compressed:d,dataFormat:u,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:u,compressed:d,data:t,width:l,height:c})),this.width=l,this.height=c,this.glFormat=f,this.type=h,this.dataFormat=u,this.textureUnit=s,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=a,this.setImageData({data:t,width:l,height:c,depth:p,format:e.format,type:h,dataFormat:u,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(n),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),a&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:t,parameters:n,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){const{mipmaps:t=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let t;e instanceof cT?(this.sampler=e,t=e.props):(this.sampler=new cT(this.device,e),t=e);const i=oT(t);return this._setSamplerParameters(i),this}resize(e){const{height:t,width:i,mipmaps:n=!1}=e;return i!==this.width||t!==this.height?this.initialize({width:i,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:n}):this}update(){if(this._video){const{video:e,parameters:t,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if("3d"===this.props.dimension||"2d-array"===this.props.dimension)return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");const{target:t=this.target,pixels:i=null,level:n=0,glFormat:r=this.glFormat,offset:o=0,parameters:s={}}=e;let{data:a=null,type:l=this.type,width:c=this.width,height:u=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;a||(a=i),({type:l,dataFormat:h,compressed:d,width:c,height:u}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:a,width:c,height:u}));const{gl:p}=this;p.bindTexture(this.target,this.handle);let f=null;if(({data:a,dataType:f}=this._getDataType({data:a,compressed:d})),Jw(this.gl,s,()=>{switch(f){case"null":case"browser-object":p.texImage2D(t,n,r,c,u,0,h,l,a);break;case"typed-array":p.texImage2D(t,n,r,c,u,0,h,l,a,o);break;case"buffer":this.device.gl.bindBuffer(35052,a.handle||a),this.device.gl.texImage2D(t,n,r,c,u,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"compressed":for(const[e,i]of a.entries())p.compressedTexImage2D(t,e,i.format,i.width,i.height,0,i.data);break;default:cf(!1,"Unknown image data type")}}),a&&a.byteLength)this.trackAllocatedMemory(a.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*e,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:i=null,x:n=0,y:r=0,width:o=this.width,height:s=this.height,level:a=0,glFormat:l=this.glFormat,type:c=this.type,dataFormat:u=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if(({type:c,dataFormat:u,compressed:h,width:o,height:s}=this._deduceParameters({format:this.props.format,type:c,dataFormat:u,compressed:h,data:i,width:o,height:s})),cf(1===this.depth,"texSubImage not supported for 3D textures"),i||(i=t),i&&i.data){const e=i;i=e.data,o=e.shape[0],s=e.shape[1]}i instanceof lT&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Jw(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,a,n,r,o,s,l,i):null===i?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,i,d):"undefined"!=typeof WebGLBuffer&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return Gp.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof lT?{data:e.handle,dataType:"buffer"}:"undefined"!=typeof WebGLBuffer&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){const{format:t,data:i}=e;let{width:n,height:r,dataFormat:o,type:s,compressed:a}=e;const l=$w(t);return o=o||l.dataFormat,s=s||l.type,a=a||l.compressed,({width:n,height:r}=this._deduceImageSize(i,n,r)),{dataFormat:o,type:s,compressed:a,width:n,height:r,format:t,data:i}}_deduceImageSize(e,t,i){let n;return n="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:i}:{width:t>=0?t:1,height:i>=0?i:1},cf(n,"Could not deduced texture size"),cf(void 0===t||n.width===t,"Deduced texture width does not match supplied width"),cf(void 0===i||n.height===i,"Deduced texture height does not match supplied height"),n}async setCubeMapImageData(e){const{gl:t}=this,{width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,l=r||o,c=await Promise.all(dT.FACES.map(e=>{const t=l[e];return Promise.all(Array.isArray(t)?t:[t])}));this.bind(),dT.FACES.forEach((e,r)=>{c[r].length>1&&!1!==this.props.mipmaps&&Gp.warn(`${this.id} has mipmap and multiple LODs.`)(),c[r].forEach((r,o)=>{i&&n?t.texImage2D(e,o,s,i,n,0,s,a,r):t.texImage2D(e,o,s,s,a,r)})}),this.unbind()}setImageDataForFace(e){const{face:t,width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,{gl:l}=this,c=r||o;return this.bind(),c instanceof Promise?c.then(i=>this.setImageDataForFace(Object.assign({},e,{face:t,data:i,pixels:i}))):this.width||this.height?l.texImage2D(t,0,s,i,n,0,s,a,c):l.texImage2D(t,0,s,s,a,c),this}setImageData3D(e){const{level:t=0,dataFormat:i,format:n,type:r,width:o,height:s,depth:a=1,offset:l=0,data:c,parameters:u={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const h=$w(n);if(Jw(this.gl,u,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,t,h.format,o,s,a,0,h.dataFormat,h.type,c),c instanceof lT&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,t,i,o,s,a,0,n,r,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*e,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!qp(e)){!function(e){Gp.log(1,"texture sampler parameters",e)()}(e),this.gl.bindTexture(this.target,this.handle);for(const[t,i]of Object.entries(e)){const e=Number(t),n=i;switch(e){case 33082:case 33083:this.gl.texParameterf(this.target,e,n);break;default:this.gl.texParameteri(this.target,e,n)}}this.gl.bindTexture(this.target,null)}}}class pT extends If{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);const i=null===t.handle;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const i=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;evoid 0===e?"undefined":e);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${e}(${i})`}function xT(e,t,i,n){n=Array.from(n).map(e=>void 0===e?"undefined":e);const r=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${i}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(i,n)})`;if(Gp.error(r)(),e.throwOnError)throw new Error(r)}function bT(e,t,i){let n="";if(Gp.level>=1&&(n=vT(t,i),Gp.log(1,n)()),e.break&&e.break.length>0){n=n||vT(t,i);e.break.every(e=>-1!==n.indexOf(e))}for(const r of i)if(void 0===r){if(n=n||vT(t,i),e.throwOnError)throw new Error(`Undefined argument: ${n}`);Gp.error(`Undefined argument: ${n}`)()}}function wT(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class TT extends Cf{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){return function(e){const t=e.split(/\r?\n/),i=[];for(const e of t){if(e.length<=1)continue;const t=e.split(":");if(2===t.length){const[e,n]=t;i.push({message:n.trim(),type:wT(e),lineNum:0,linePos:0});continue}const[n,r,o,...s]=t;let a=parseInt(o,10);isNaN(a)&&(a=0);let l=parseInt(r,10);isNaN(l)&&(l=0),i.push({message:s.join(":").trim(),type:wT(n),lineNum:a,linePos:l})}return i}(this.device.gl.getShaderInfoLog(this.handle))}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(e=>e.startsWith("#version ")?e:`#version 100\n${e}`)(e);const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),0!==Gp.level){if(this.device.features.has("compilation-status-async-webgl"))Gp.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),Gp.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader();else if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}const ET=6144,CT=[1,2,4,8];class ST extends Pf{device;glParameters;constructor(e,t){super(e,t),this.device=e,pw(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){fw(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(t.colorMask=CT.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,aw(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;!1!==this.props.clearColor&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&Jw(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Jw(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(ET,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(ET,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(ET,e,t)}})}}function BT(e,t){const{clamped:i=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return i?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}const IT={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},MT={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class PT{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return BT(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){cf(e.size);return BT(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new PT(...[IT,...e])}constructor(...e){e.forEach(e=>this._assign(e)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return PT.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return PT.getBytesPerVertex(this)}_assign(e={}){return void 0!==(e=function(e,t,i){const{removedProps:n={},deprecatedProps:r={},replacedProps:o={}}=i;for(const i in n)if(i in t){const t=n[i]?`${e}.${n[i]}`:"N/A";Gp.removed(`${e}.${i}`,t)()}for(const i in r)if(i in t){const t=r[i];Gp.deprecated(`${e}.${i}`,`${e}.${t}`)()}let s=null;for(const[i,n]of Object.entries(o))i in t&&(Gp.deprecated(`${e}.${i}`,`${e}.${n}`)(),s=s||Object.assign({},t),s[n]=t[i],delete s[i]);return s||t}("Accessor",e,MT)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalize&&(this.normalized=e.normalize),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),void 0===this.offset&&delete this.offset,void 0===this.stride&&delete this.stride,void 0===this.type&&delete this.type,void 0===this.size&&delete this.size,void 0===this.divisor&&delete this.divisor,void 0===this.normalized&&delete this.normalized,void 0===this.integer&&delete this.integer,void 0===this.buffer&&delete this.buffer,void 0===this.index&&delete this.index,this}}function RT(e){return LT.includes(e)}const LT=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],FT={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function kT(e){const t=FT[e];if(!t)throw new Error("uniform");const[i,n,,r]=t;return{format:r,components:n,glType:i}}function DT(e){const t=FT[e];if(!t)throw new Error("attribute");const[,i,,n,r]=t;return{attributeType:n,vertexFormat:r,components:i}}function OT(e,t){const i={attributes:[],bindings:[]};i.attributes=function(e,t){const i=[],n=e.getProgramParameter(t,35721);for(let r=0;r=0){const{attributeType:e}=DT(s),t=/instance/i.test(o)?"instance":"vertex";i.push({name:o,location:a,stepMode:t,type:e})}}return i.sort((e,t)=>e.location-t.location),i}(e,t);const n=function(e,t){const i=(i,n)=>e.getActiveUniformBlockParameter(t,i,n),n=[],r=e.getProgramParameter(t,35382);for(let o=0;oe.location-t.location),n}(e,t);for(const e of n){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));i.bindings.push({type:"uniform",name:e.name,location:e.location,visibility:(e.vertex?1:0)&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}const r=function(e,t){const i=[],n=e.getProgramParameter(t,35718);for(let r=0;r1)for(let n=0;ne.location-t.location),i}(e,t);return s?.length&&(i.varyings=s),i}const zT={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function UT(e){const t=zT[e];if(!t)throw new Error("sampler");const[i,n]=t;return{viewDimension:i,sampleType:n}}function NT(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}function VT(e,t,i,n){const r=e;let o=n;!0===o&&(o=1),!1===o&&(o=0);const s="number"==typeof o?[o]:o;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof n)throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,s);case 35664:return e.uniform2fv(t,s);case 35665:return e.uniform3fv(t,s);case 35666:return e.uniform4fv(t,s);case 5124:case 35670:return e.uniform1iv(t,s);case 35667:case 35671:return e.uniform2iv(t,s);case 35668:case 35672:return e.uniform3iv(t,s);case 35669:case 35673:return e.uniform4iv(t,s);case 5125:return r.uniform1uiv(t,s,1);case 36294:return r.uniform2uiv(t,s,2);case 36295:return r.uniform3uiv(t,s,3);case 36296:return r.uniform4uiv(t,s,4);case 35674:return e.uniformMatrix2fv(t,!1,s);case 35675:return e.uniformMatrix3fv(t,!1,s);case 35676:return e.uniformMatrix4fv(t,!1,s);case 35685:return r.uniformMatrix2x3fv(t,!1,s);case 35686:return r.uniformMatrix2x4fv(t,!1,s);case 35687:return r.uniformMatrix3x2fv(t,!1,s);case 35688:return r.uniformMatrix3x4fv(t,!1,s);case 35689:return r.uniformMatrix4x2fv(t,!1,s);case 35690:return r.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}class jT extends Mf{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;const{varyings:i,bufferMode:n=35981}=t;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,n)),this._linkShaders(),Gp.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=OT(this.device.gl,this.handle),Gp.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=function(e,t){const i={...e,attributes:e.attributes.map(e=>({...e}))};for(const e of t?.attributes||[]){const t=i.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Gp.warn(`shader layout attribute ${e.name} not present in shader`)}return i}(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":Gp.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`)}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,t){for(const[i,n]of Object.entries(e)){const e=this.shaderLayout.bindings.find(e=>e.name===i)||this.shaderLayout.bindings.find(e=>e.name===`${i}Uniforms`);if(!e){const e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||Gp.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${e}`)();continue}switch(n||Gp.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(n instanceof lT||n.buffer instanceof lT))throw new Error("buffer value");break;case"texture":if(!(n instanceof uT||n instanceof dT||n instanceof pT))throw new Error("texture value");break;case"sampler":Gp.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(e.type)}this.bindings[i]=n}}draw(e){const{renderPass:t,parameters:i=this.props.parameters,topology:n=this.props.topology,vertexArray:r,vertexCount:o,instanceCount:s,isInstanced:a=!1,firstVertex:l=0,transformFeedback:c}=e,u=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}(n),h=Boolean(r.indexBuffer),d=r.indexBuffer?.glIndexType;if("success"!==this.linkStatus)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),r.bindBeforeRender(t),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const p=t;return Yw(this.device,i,p.glParameters,()=>{h&&a?this.device.gl.drawElementsInstanced(u,o||0,d,l,s||0):h?this.device.gl.drawElements(u,o||0,d,l):a?this.device.gl.drawArraysInstanced(u,l,o||0,s||0):this.device.gl.drawArrays(u,l,o||0),c&&c.end()}),r.unbindAfterRender(t),!0}setUniformsWebGL(e){const{bindings:t}=tm(e);Object.keys(t).forEach(e=>{Gp.warn(`Unsupported value "${JSON.stringify(t[e])}" used in setUniforms() for key ${e}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Gp.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Gp.timeEnd(4,`linkProgram for ${this.id}`)(),Gp.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}Gp.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Gp.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){if("success"!==e){if("error"===this.vs.compilationStatus)throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);if("error"===this.fs?.compilationStatus)throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);throw new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){const{gl:e}=this.device;if(!e.getProgramParameter(this.handle,35714))return this.linkStatus="error","linking";e.validateProgram(this.handle);return e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const[,t]of Object.entries(this.bindings))t instanceof dT&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if("success"!==this.linkStatus)return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=0;for(const n of this.shaderLayout.bindings){const r=this.bindings[n.name]||this.bindings[n.name.replace(/Uniforms$/,"")];if(!r)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":const{name:o}=n,s=e.getUniformBlockIndex(this.handle,o);if(4294967295===s)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,s),r instanceof lT?e.bindBufferBase(35345,i,r.handle):e.bindBufferRange(35345,i,r.buffer.handle,r.offset||0,r.size||r.buffer.byteLength-r.offset),i+=1;break;case"texture":if(!(r instanceof uT||r instanceof dT||r instanceof pT))throw new Error("texture");let a;if(r instanceof uT)a=r.texture;else if(r instanceof dT)a=r;else{if(!(r instanceof pT&&r.colorAttachments[0]instanceof uT))throw new Error("No texture");Gp.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=r.colorAttachments[0].texture}e.activeTexture(33984+t),e.bindTexture(a.target,a.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:i,type:n,textureUnit:r}=e,o=this.uniforms[t]??r;void 0!==o&&VT(this.device.gl,i,n,o)}}}class GT extends Ff{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":HT(this.device,t.options);break;case"copy-buffer-to-texture":QT(this.device,t.options);break;case"copy-texture-to-buffer":$T(this.device,t.options);break;case"copy-texture-to-texture":ZT(this.device,t.options)}}}function HT(e,t){const i=t.source,n=t.destination;e.gl.bindBuffer(36662,i.handle),e.gl.bindBuffer(36663,n.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function QT(e,t){throw new Error("Not implemented")}function $T(e,t){const{source:i,mipLevel:n=0,aspect:r="all",width:o=t.source.width,height:s=t.source.height,depthOrArrayLayers:a=0,origin:l=[0,0],destination:c,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if("all"!==r)throw new Error("not supported");if(0!==n||0!==a||h||d)throw new Error("not implemented");const{framebuffer:p,destroyFramebuffer:f}=WT(i);let m;try{const t=c,i=o||p.width,n=s||p.height,r=$w(p.texture.props.format),a=r.dataFormat,h=r.type;e.gl.bindBuffer(35051,t.handle),m=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(l[0],l[1],i,n,a,h,u)}finally{e.gl.bindBuffer(35051,null),void 0!==m&&e.gl.bindFramebuffer(36160,m),f&&p.destroy()}}function ZT(e,t){const{source:i,destinationMipLevel:n=0,origin:r=[0,0],destinationOrigin:o=[0,0],destination:s}=t;let{width:a=t.destination.width,height:l=t.destination.height}=t;const{framebuffer:c,destroyFramebuffer:u}=WT(i),[h,d]=r,[p,f,m]=o,g=e.gl.bindFramebuffer(36160,c.handle);let _,A=null;if(!(s instanceof dT))throw new Error("invalid destination");switch(A=s,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A.bind(0),_=A.target,_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,n,p,f,h,d,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,n,p,f,m,h,d,a,l)}A&&A.unbind(),e.gl.bindFramebuffer(36160,g),u&&c.destroy()}function WT(e){if(e instanceof yf){const{width:t,height:i,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:i,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class qT extends Lf{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new GT(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){}}class KT extends Vf{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||Pu()?Mu(t)?"Electron":(t||Iu.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node");var t}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const i=t;if(34963===i.glTarget)throw new Error("Use .setIndexBuffer()");const{size:n,type:r,stride:o,offset:s,normalized:a,integer:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,n,r,o,s):this.device.gl.vertexAttribPointer(e,n,r,a,o,s),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,c||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const i=this._getVaryingIndex(e),{buffer:n,byteLength:r,byteOffset:o}=this._getBufferRange(t);if(i<0)return this.unusedBuffers[e]=n,void Gp.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[i]={buffer:n,byteLength:r,byteOffset:o},this.bindOnUse||this._bindBuffer(i,n,o,r)}getBuffer(e){if(JT(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof lT)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:i=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:n}}_getVaryingIndex(e){if(JT(e))return Number(e);for(const t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:i,byteOffset:n}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,n,i)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,n){const r=t&&t.handle;r&&void 0!==n?this.gl.bindBufferRange(35982,e,r,i,n):this.gl.bindBufferBase(35982,e,r)}}function JT(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class YT extends Gf{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((i,n)=>{const r=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):t++>e?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}}function eE(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return cf(!1),0}}function tE(e,t){const{sourceX:i=0,sourceY:n=0,sourceFormat:r=6408,sourceAttachment:o=36064}=t||{};let{target:s=null,sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u);const{gl:d,handle:p}=u;a=a||u.width,l=l||u.height;const f=o-36064;c=c||u.colorAttachments[f]?.texture?.type||5121,s=function(e,t,i,n,r){if(e)return e;t=t||5121;const o=BT(t,{clamped:!1}),s=eE(i);return new o(n*r*s)}(s,c,r,a,l),c=c||function(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}(s);const m=d.bindFramebuffer(36160,p);return d.readPixels(i,n,a,l,r,c,s),d.bindFramebuffer(36160,m||null),h&&u.destroy(),s}function iE(e,t){const{target:i,sourceX:n=0,sourceY:r=0,sourceFormat:o=6408,targetByteOffset:s=0}=t||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u),a=a||u.width,l=l||u.height;const d=u;c=c||5121;let p=i;if(!p){const e=eE(o),t=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return cf(!1),0}}(c),i=s+a*l*e*t;p=d.device.createBuffer({byteLength:i})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({source:e,width:a,height:l,origin:[n,r],destination:p,byteOffset:s}),f.destroy(),h&&u.destroy(),p}function nE(e){return e instanceof If?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:rE(e),deleteFramebuffer:!0}}function rE(e,t){const{device:i,width:n,height:r,id:o}=e;return i.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:n,height:r,colorAttachments:[e]})}class oE extends lf{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return"undefined"!=typeof WebGL2RenderingContext}static attach(e){if(e instanceof oE)return e;if(e?.device instanceof lf)return e.device;if(!function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return!0;return Boolean(e&&Number.isFinite(e._version))}(e))throw new Error("Invalid WebGL2RenderingContext");return new oE({gl:e})}static async create(e={}){Gp.groupCollapsed(1,"WebGLDevice created")();const t=[];e.debug&&t.push(async function(){Pu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await nm("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.spector&&t.push(async function(){if(!globalThis.SPECTOR)try{await nm("https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js")}catch(e){Gp.warn(String(e))}}()),"string"==typeof e.canvas&&t.push(gf.pageLoaded);const i=await Promise.allSettled(t);for(const e of i)"rejected"===e.status&&Gp.error(`Failed to initialize debug libraries ${e.reason}`)();if(Gp.probe(2,"DOM is loaded")(),e.gl?.device)return Gp.warn("reattaching existing device")(),oE.attach(e.gl);const n=new oE(e),r=`Created ${n.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Gp.probe(1,r)(),Gp.table(1,n.info)(),Gp.groupEnd(1)(),n}constructor(e){super({...e,id:e.id||Wp("webgl-device")});const t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);const i=e.gl?.canvas||e.canvas,n=!e.gl;this.canvasContext=new fT(this,{...e,autoResize:n,canvas:i}),this.lost=new Promise(e=>{this._resolveContextLost=e});let r=e.gl||null;if(r||=function(e,t){t={..._w,...t};let i=null;const n=e=>i=e.statusMessage||i;e.addEventListener("webglcontextcreationerror",n,!1);let r=null;if(r||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",n,!1),!r)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(t.onContextLost){const{onContextLost:i}=t;e.addEventListener("webglcontextlost",e=>i(e),!1)}if(t.onContextRestored){const{onContextRestored:i}=t;e.addEventListener("webglcontextrestored",e=>i(e),!1)}return r}(this.canvasContext.canvas,{...e,onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!r)throw new Error("WebGL context creation failed");this.handle=r,this.gl=r,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=function(e){if(e={...mT,...e},!e?.spector)return null;if(!gT&&globalThis.SPECTOR&&(Gp.probe(1,"SPECTOR found and initialized")(),gT=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=gT)),!gT)return null;if(_T||(_T=!0,gT.spyCanvases(),gT?.onCaptureStarted.add(e=>Gp.info("Spector capture started:",e)()),gT?.onCapture.add(e=>{Gp.info("Spector capture complete:",e)(),gT?.getResultUI(),gT?.resultView.display(),gT?.resultView.addCapture(e)})),e?.canvas){if("string"==typeof e.spector&&e.spector!==e.canvas.id)return gT;gT?.startCapture(e?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{Gp.info("Spector capture stopped after 2 seconds")(),gT?.stopCapture()})}return gT}({...this.props,canvas:this.handle.canvas})),this.info=yw(this.gl,this._extensions),this.limits=new Xw(this.gl),this.features=new Kw(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),n&&this.canvasContext.resize();const{enable:o=!0,copyState:s=!1}=e;dw(this.gl,{enable:o,copyState:s,log:(...e)=>Gp.log(1,...e)()}),e.debug&&(this.gl=yT(this.gl,{...e,throwOnError:!0}),this.debug=!0,Gp.level=Math.max(Gp.level,1),Gp.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return Hw(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return function(e,t,i){if(!Hw(e,t,i))return!1;if(t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(rf(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(Aw(e,"OES_texture_float_linear, extensions",i)):!t.endsWith("16float")||Boolean(Aw(e,"OES_texture_half_float_linear, extensions",i))}(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return function(e,t,i){return!!Hw(e,t,i)&&"number"!=typeof t}(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._getBufferProps(e);return new lT(this,t)}_createTexture(e){return new dT(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new cT(this,e)}createShader(e){return new TT(this,e)}createFramebuffer(e){return new pT(this,e)}createVertexArray(e){return new KT(this,e)}createTransformFeedback(e){return new XT(this,e)}createQuerySet(e){return new YT(this,e)}createRenderPipeline(e){return new jT(this,e)}beginRenderPass(e){return new ST(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new qT(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return tE(e,t)}readPixelsToBufferWebGL(e,t){return iE(e,t)}setParametersWebGL(e){aw(this.gl,e)}getParametersWebGL(e){return lw(this.gl,e)}withParametersWebGL(e,t){return Jw(this.gl,e,t)}clearWebGL(e){!function(e,t){const{framebuffer:i=null,color:n=null,depth:r=null,stencil:o=null}=t||{},s={};i&&(s.framebuffer=i);let a=0;n&&(a|=16384,!0!==n&&(s.clearColor=n)),r&&(a|=256,!0!==r&&(s.clearDepth=r)),o&&(a|=1024,!0!==r&&(s.clearStencil=r)),cf(0!==a,"clear: bad arguments");const l=e.gl;Jw(l,s,()=>{l.clear(a)})}(this,e)}resetWebGL(){Gp.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),function(e){aw(e,Zb)}(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1;const t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){pw(this.gl)}popState(){fw(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;const i=Number(e);for(const e in t)if(t[e]===i)return`GL.${e}`;return String(e)}_constants;setConstantAttributeWebGL(e,t){const i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);const n=this._constants[e];switch(n&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let i=0;i>>=0)&&e<256)&&(n=Z$[e])?n:(i=K$(e,0,!0),r&&(Z$[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=$$[e])?n:(i=K$(e,e<0?-1:0,!1),r&&($$[e]=i),i)}function q$(e,t){if(isNaN(e))return t?oZ:rZ;if(t){if(e<0)return oZ;if(e>=tZ)return uZ}else{if(e<=-iZ)return hZ;if(e+1>=iZ)return cZ}return e<0?q$(-e,t).neg():K$(e%eZ|0,e/eZ|0,t)}function K$(e,t,i){return new G$(e,t,i)}G$.fromInt=W$,G$.fromNumber=q$,G$.fromBits=K$;var X$=Math.pow;function J$(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?oZ:rZ;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===n)return J$(e.substring(1),t,i).neg();for(var r=q$(X$(i,8)),o=rZ,s=0;s>>0:this.low},dZ.toNumber=function(){return this.unsigned?(this.high>>>0)*eZ+(this.low>>>0):this.high*eZ+(this.low>>>0)},dZ.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},dZ.getHighBits=function(){return this.high},dZ.getHighBitsUnsigned=function(){return this.high>>>0},dZ.getLowBits=function(){return this.low},dZ.getLowBitsUnsigned=function(){return this.low>>>0},dZ.getNumBitsAbs=function(){if(this.isNegative())return this.eq(hZ)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},dZ.isZero=function(){return 0===this.high&&0===this.low},dZ.eqz=dZ.isZero,dZ.isNegative=function(){return!this.unsigned&&this.high<0},dZ.isPositive=function(){return this.unsigned||this.high>=0},dZ.isOdd=function(){return!(1&~this.low)},dZ.isEven=function(){return!(1&this.low)},dZ.equals=function(e){return H$(e)||(e=Y$(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},dZ.eq=dZ.equals,dZ.notEquals=function(e){return!this.eq(e)},dZ.neq=dZ.notEquals,dZ.ne=dZ.notEquals,dZ.lessThan=function(e){return this.comp(e)<0},dZ.lt=dZ.lessThan,dZ.lessThanOrEqual=function(e){return this.comp(e)<=0},dZ.lte=dZ.lessThanOrEqual,dZ.le=dZ.lessThanOrEqual,dZ.greaterThan=function(e){return this.comp(e)>0},dZ.gt=dZ.greaterThan,dZ.greaterThanOrEqual=function(e){return this.comp(e)>=0},dZ.gte=dZ.greaterThanOrEqual,dZ.ge=dZ.greaterThanOrEqual,dZ.compare=function(e){if(H$(e)||(e=Y$(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},dZ.comp=dZ.compare,dZ.negate=function(){return!this.unsigned&&this.eq(hZ)?hZ:this.not().add(sZ)},dZ.neg=dZ.negate,dZ.add=function(e){H$(e)||(e=Y$(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=r+(65535&e.low))>>>16,c+=(u+=n+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,K$((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},dZ.subtract=function(e){return H$(e)||(e=Y$(e)),this.add(e.neg())},dZ.sub=dZ.subtract,dZ.multiply=function(e){if(this.isZero())return this;if(H$(e)||(e=Y$(e)),j$)return K$(j$.mul(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned);if(e.isZero())return this.unsigned?oZ:rZ;if(this.eq(hZ))return e.isOdd()?hZ:rZ;if(e.eq(hZ))return this.isOdd()?hZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(nZ)&&e.lt(nZ))return q$(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=r*l)>>>16,u+=(h+=n*l)>>>16,h&=65535,u+=(h+=r*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=n*a)>>>16,u&=65535,c+=(u+=r*s)>>>16,c+=t*l+i*a+n*s+r*o,K$((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},dZ.mul=dZ.multiply,dZ.divide=function(e){if(H$(e)||(e=Y$(e)),e.isZero())throw Error("division by zero");var t,i,n;if(j$)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?K$((this.unsigned?j$.div_u:j$.div_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?oZ:rZ;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return oZ;if(e.gt(this.shru(1)))return aZ;n=oZ}else{if(this.eq(hZ))return e.eq(sZ)||e.eq(lZ)?hZ:e.eq(hZ)?sZ:(t=this.shr(1).div(e).shl(1)).eq(rZ)?e.isNegative()?sZ:lZ:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(hZ))return this.unsigned?oZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=rZ}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),o=r<=48?1:X$(2,r-48),s=q$(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=q$(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=sZ),n=n.add(s),i=i.sub(a)}return n},dZ.div=dZ.divide,dZ.modulo=function(e){return H$(e)||(e=Y$(e)),j$?K$((this.unsigned?j$.rem_u:j$.rem_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},dZ.mod=dZ.modulo,dZ.rem=dZ.modulo,dZ.not=function(){return K$(~this.low,~this.high,this.unsigned)},dZ.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},dZ.clz=dZ.countLeadingZeros,dZ.countTrailingZeros=function(){return this.low?Q$(this.low):Q$(this.high)+32},dZ.ctz=dZ.countTrailingZeros,dZ.and=function(e){return H$(e)||(e=Y$(e)),K$(this.low&e.low,this.high&e.high,this.unsigned)},dZ.or=function(e){return H$(e)||(e=Y$(e)),K$(this.low|e.low,this.high|e.high,this.unsigned)},dZ.xor=function(e){return H$(e)||(e=Y$(e)),K$(this.low^e.low,this.high^e.high,this.unsigned)},dZ.shiftLeft=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low<>>32-e,this.unsigned):K$(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):K$(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},dZ.shr=dZ.shiftRight,dZ.shiftRightUnsigned=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):K$(32===e?this.high:this.high>>>e-32,0,this.unsigned)},dZ.shru=dZ.shiftRightUnsigned,dZ.shr_u=dZ.shiftRightUnsigned,dZ.rotateLeft=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),K$(this.high<>>t,this.low<>>t,this.unsigned))},dZ.rotl=dZ.rotateLeft,dZ.rotateRight=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),K$(this.low<>>e,this.high<>>e,this.unsigned))},dZ.rotr=dZ.rotateRight,dZ.toSigned=function(){return this.unsigned?K$(this.low,this.high,!1):this},dZ.toUnsigned=function(){return this.unsigned?this:K$(this.low,this.high,!0)},dZ.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},dZ.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},dZ.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},G$.fromBytes=function(e,t,i){return i?G$.fromBytesLE(e,t):G$.fromBytesBE(e,t)},G$.fromBytesLE=function(e,t){return new G$(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},G$.fromBytesBE=function(e,t){return new G$(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(G$.fromBigInt=function(e,t){return K$(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},G$.fromValue=function(e,t){return"bigint"==typeof e?G$.fromBigInt(e,t):Y$(e,t)},dZ.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function _Z(e){return[gZ(e[0]),gZ(e[1])]}function AZ(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function yZ([e,t,i]){const n=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*fZ,n*fZ]}function vZ(e,t,i,n){if(0===n){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const n=t[0];t[0]=t[1],t[1]=n}}function xZ(e){const{face:t,ij:i,level:n}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-n))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),u=r[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function bZ(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=pZ(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),n=t.substring(0,3),r=t.substring(3,i),o=r.length/2,s=G$.fromString(n,!0,2).toString(10);let a="";if(0!==o)for(a=G$.fromString(r,!0,2).toString(4);a.length=0;e--){o=r-e;const t=n[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);vZ(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function wZ(e){return function(e){const t=_Z(mZ(e.ij,e.level,[.5,.5]));return yZ(AZ(e.face,t))}(bZ(e))}function TZ(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let n=0;ne-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function EZ(e,t){const i=t?.minimumHeight||0,n=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let i=null,n=0;for(let t=0;t<4;t++){const r=xZ(bZ(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*r.length)),i.set(r,n),n+=r.length}t=TZ(i)}else t=TZ(xZ(e));return t}(bZ(e)),o=r.west,s=r.south,a=r.east,l=r.north,c=[];return c.push(new AA(o,l,i)),c.push(new AA(a,l,i)),c.push(new AA(a,s,i)),c.push(new AA(o,s,i)),c.push(new AA(o,l,n)),c.push(new AA(a,l,n)),c.push(new AA(a,s,n)),c.push(new AA(o,s,n)),c}function CZ(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=EZ(t,i),r=wZ(t),o=r[0],s=r[1],a=PO.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new AA(a[0],a[1],a[2]);n.push(l);const c=NR(n);return[...c.center,...c.halfAxes]}const SZ={QUADTREE:4,OCTREE:8};function BZ(e,t,i){if(e?.box){const n=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(G$.fromNumber(2*t+1-4).multiply(i))}(pZ(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}(n),o={...e.s2VolumeInfo};if(o.token=r,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,n=i/2,r=t.minimumHeight+i/2;t.minimumHeight=r-n,t.maximumHeight=r+n}return{box:CZ(o),s2VolumeInfo:o}}}async function IZ(e){const{implicitOptions:t,parentData:i={mortonIndex:0,x:0,y:0,z:0},childIndex:n=0,s2VolumeBox:r,loaderOptions:o}=e;let{subtree:s,level:a=0,globalData:l={level:0,mortonIndex:0,x:0,y:0,z:0}}=e;const{subdivisionScheme:c,subtreeLevels:u,maximumLevel:h,contentUrlTemplate:d,subtreesUriTemplate:p,basePath:f}=t,m={children:[],lodMetricValue:0,contentUrl:""};if(!h)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=a+l.level;if(g>h)return m;const _=SZ[c],A=Math.log2(_),y=1&n,v=n>>1&1,x=n>>2&1,b=(_**a-1)/(_-1);let w=RZ(i.mortonIndex,n,A),T=b+w,E=RZ(i.x,y,1),C=RZ(i.y,v,1),S=RZ(i.z,x,1),B=!1;a>=u&&(B=MZ(s.childSubtreeAvailability,w));const I=RZ(l.x,E,a),M=RZ(l.y,C,a),P=RZ(l.z,S,a);if(B){const e=LZ(`${f}/${p}`,g,I,M,P);s=await dI(e,V$,o),l={mortonIndex:w,x:E,y:C,z:S,level:a},w=0,T=0,E=0,C=0,S=0,a=0}if(!MZ(s.tileAvailability,T))return m;MZ(s.contentAvailability,T)&&(m.contentUrl=LZ(d,g,I,M,P));const R=a+1,L={mortonIndex:w,x:E,y:C,z:S};for(let e=0;e<_;e++){const i=BZ(r,e,c),n=await IZ({subtree:s,implicitOptions:t,loaderOptions:o,parentData:L,childIndex:e,level:R,globalData:{...l},s2VolumeBox:i});if(n.contentUrl||n.children.length){const e=PZ(n,g+1,{childTileX:E,childTileY:C,childTileZ:S},t,r);m.children.push(e)}}return m}function MZ(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),n=e%8;return 1==(t[i]>>n&1)}(t,i.explicitBitstream)}function PZ(e,t,i,n,r){const{basePath:o,refine:s,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=n,d=e.contentUrl&&e.contentUrl.replace(`${o}/`,""),p=u/2**t,f=function(e,t,i){if(t.region){const{childTileX:n,childTileY:r,childTileZ:o}=i,[s,a,l,c,u,h]=t.region,d=2**e,p=(l-s)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[s+p*n,s+p*(n+1)],[A,y]=[a+f*r,a+f*(r+1)],[v,x]=[u+m*o,u+m*(o+1)];return{region:[g,A,_,y,v,x]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}(t,r?.box?{box:r.box}:h,i);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(s),type:c(e),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function RZ(e,t,i){return(e<o[e])}function FZ(e,t=""){if(!t)return cj.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return cj.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return cj.SCENEGRAPH;default:return i||cj.EMPTY}}function kZ(e){switch(e){case"REPLACE":case"replace":return lj.REPLACE;case"ADD":case"add":return lj.ADD;default:return e}}function DZ(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:oj(t,e)}function OZ(e,t){if(!e)return null;let i;if(e.content){const n=e.content.uri||e.content?.url;void 0!==n&&(i=DZ(n,t))}return{...e,id:i,contentUrl:i,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,i),refine:kZ(e.refine)}}async function zZ(e,t,i,n,r){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=n,u=DZ(LZ(c,0,0,0,0),i),h=await dI(u,V$,r),d=e.content?.uri,p=d?DZ(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:CZ(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:hj.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:FZ,getRefine:kZ};return await async function(e,t,i,n,r){if(!e)return null;const{children:o,contentUrl:s}=await IZ({subtree:i,implicitOptions:n,loaderOptions:r});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,a),refine:kZ(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,r)}function UZ(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const NZ={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:dj,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const n=t["3d-tiles"]||{};let r;r="auto"===n.isTileset?i?.url&&-1!==i.url.indexOf(".json"):n.isTileset;return r?async function(e,t,i){const n=JSON.parse((new TextDecoder).decode(e)),r=i?.url||"",o=function(e){return function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}(r),s=await async function(e,t,i){let n=null;const r=UZ(e.root);n=r&&e.root?await zZ(e.root,e,t,r,i):OZ(e.root,t);const o=[];for(o.push(n);o.length>0;){const n=o.pop()||{},r=n.children||[],s=[];for(const n of r){const r=UZ(n);let a;a=r?await zZ(n,e,t,r,i):OZ(n,t),a&&(s.push(a),o.push(a))}n.children=s}return n}(n,o,t||{}),a={...n,shape:"tileset3d",loader:NZ,url:r,queryString:i?.queryString||"",basePath:o,root:s||n.root,type:uj.TILES3D,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const n={content:{shape:"tile3d",featureIds:null}},r=0;return await z$(e,r,t,i,n.content),n.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const VZ={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const e in VZ)Object.freeze(VZ[e]);var jZ=Object.freeze(VZ);const GZ=Object.create(null);for(const e in jZ)Object.hasOwn(jZ,e)&&(GZ[jZ[e]]=e);const HZ={to:{},get:{}};function QZ(e,t,i){return Math.min(Math.max(t,e),i)}function $Z(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}HZ.get=function(e){let t,i;switch(e.slice(0,3).toLowerCase()){case"hsl":t=HZ.get.hsl(e),i="hsl";break;case"hwb":t=HZ.get.hwb(e),i="hwb";break;default:t=HZ.get.rgb(e),i="rgb"}return t?{model:i,value:t}:null},HZ.get.rgb=function(e){if(!e)return null;let t,i,n,r=[0,0,0,1];if(t=e.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(n=t[2],t=t[1],i=0;i<3;i++){const e=2*i;r[i]=Number.parseInt(t.slice(e,e+2),16)}n&&(r[3]=Number.parseInt(n,16)/255)}else if(t=e.match(/^#([a-f\d]{3,4})$/i)){for(t=t[1],n=t[3],i=0;i<3;i++)r[i]=Number.parseInt(t[i]+t[i],16);n&&(r[3]=Number.parseInt(n+n,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(i=0;i<3;i++)r[i]=Number.parseFloat(t[i+1]);t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(t=e.toLowerCase().match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:Object.hasOwn(jZ,t[1])?(r=jZ[t[1]].slice(),r[3]=1,r):null:null;for(i=0;i<3;i++)r[i]=Math.round(2.55*Number.parseFloat(t[i+1]));t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}for(i=0;i<3;i++)r[i]=QZ(r[i],0,255);return r[3]=QZ(r[3],0,1),r},HZ.get.hsl=function(e){if(!e)return null;const t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.get.hwb=function(e){if(!e)return null;const t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.to.hex=function(...e){return"#"+$Z(e[0])+$Z(e[1])+$Z(e[2])+(e[3]<1?$Z(Math.round(255*e[3])):"")},HZ.to.rgb=function(...e){return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},HZ.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),i=Math.round(e[1]/255*100),n=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+i+"%, "+n+"%)":"rgba("+t+"%, "+i+"%, "+n+"%, "+e[3]+")"},HZ.to.hsl=function(...e){return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},HZ.to.hwb=function(...e){let t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},HZ.to.keyword=function(...e){return GZ[e.slice(0,3)]};const ZZ={};for(const e of Object.keys(jZ))ZZ[jZ[e]]=e;const WZ={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},qZ=(6/29)**3;function KZ(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function XZ(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(WZ)){if(!("channels"in WZ[e]))throw new Error("missing channels property: "+e);if(!("labels"in WZ[e]))throw new Error("missing channel labels property: "+e);if(WZ[e].labels.length!==WZ[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=WZ[e];delete WZ[e].channels,delete WZ[e].labels,Object.defineProperty(WZ[e],"channels",{value:t}),Object.defineProperty(WZ[e],"labels",{value:i})}function JZ(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function YZ(e){const t=function(){const e={},t=Object.keys(WZ);for(let{length:i}=t,n=0;n0;){const e=i.pop(),n=Object.keys(WZ[e]);for(let{length:r}=n,o=0;o1&&(r-=1)}return[360*r,100*o,100*c]},WZ.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const r=WZ.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[r,100*o,100*n]},WZ.rgb.oklab=function(e){const t=XZ(e[0]/255),i=XZ(e[1]/255),n=XZ(e[2]/255),r=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*n),o=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*n),s=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(1-t,1-i,1-n);return[100*((1-t-r)/(1-r)||0),100*((1-i-r)/(1-r)||0),100*((1-n-r)/(1-r)||0),100*r]},WZ.rgb.keyword=function(e){const t=ZZ[e];if(t)return t;let i,n=Number.POSITIVE_INFINITY;for(const t of Object.keys(jZ)){const r=JZ(e,jZ[t]);rqZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116,r=r>qZ?r**(1/3):7.787*r+16/116;return[116*n-16,500*(i-n),200*(n-r)]},WZ.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let r,o;if(0===i)return o=255*n,[o,o,o];const s=n<.5?n*(1+i):n+i-n*i,a=2*n-s,l=[0,0,0];for(let e=0;e<3;e++)r=t+1/3*-(e-1),r<0&&r++,r>1&&r--,o=6*r<1?a+6*(s-a)*r:2*r<1?s:3*r<2?a+(s-a)*(2/3-r)*6:a,l[e]=255*o;return l},WZ.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,r=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,r*=o<=1?o:2-o;return[t,100*(0===n?2*r/(o+r):2*i/(n+i)),100*((n+i)/2)]},WZ.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const r=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,r){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},WZ.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,r=Math.max(n,.01);let o,s;s=(2-i)*n;const a=(2-i)*r;return o=i*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},WZ.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const r=i+n;let o;r>1&&(i/=r,n/=r);const s=Math.floor(6*t),a=1-n;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},WZ.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},WZ.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let r,o,s;return r=3.2404542*t+-1.5371385*i+-.4985314*n,o=-.969266*t+1.8760108*i+.041556*n,s=.0556434*t+-.2040259*i+1.0572252*n,r=KZ(r),o=KZ(o),s=KZ(s),[255*r,255*o,255*s]},WZ.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>qZ?t**(1/3):7.787*t+16/116,i=i>qZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},WZ.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*n),o=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*n),s=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.oklab.oklch=function(e){return WZ.lab.lch(e)},WZ.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(.999999998*t+.396337792*i+.215803758*n)**3,o=(1.000000008*t-.105561342*i-.063854175*n)**3,s=(1.000000055*t-.089484182*i-1.291485538*n)**3;return[100*(1.227013851*r-.55779998*o+.281256149*s),100*(-.040580178*r+1.11225687*o-.071676679*s),100*(-.076381285*r-.421481978*o+1.58616322*s)]},WZ.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(t+.3963377774*i+.2158037573*n)**3,o=(t-.1055613458*i-.0638541728*n)**3,s=(t-.0894841775*i-1.291485548*n)**3;return[255*KZ(4.0767416621*r-3.3077115913*o+.2309699292*s),255*KZ(-1.2684380046*r+2.6097574011*o-.3413193965*s),255*KZ(-.0041960863*r-.7034186147*o+1.707614701*s)]},WZ.oklch.oklab=function(e){return WZ.lch.lab(e)},WZ.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const r=i**3,o=t**3,s=n**3;return i=r>qZ?r:(i-16/116)/7.787,t=o>qZ?o:(t-16/116)/7.787,n=s>qZ?s:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},WZ.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let r;r=360*Math.atan2(n,i)/2/Math.PI,r<0&&(r+=360);return[t,Math.sqrt(i*i+n*n),r]},WZ.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},WZ.rgb.ansi16=function(e,t=null){const[i,n,r]=e;let o=null===t?WZ.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===o&&(s+=60),s},WZ.hsv.ansi16=function(e){return WZ.rgb.ansi16(WZ.hsv.rgb(e),e[2])},WZ.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t>>4==i>>4&&i>>4==n>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},WZ.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},WZ.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},WZ.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},WZ.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map(e=>e+e).join(""));const n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},WZ.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),s=r-o;let a;return a=s<=0?0:r===t?(i-n)/s%6:r===i?2+(n-t)/s:4+(t-i)/s,a/=6,a%=1,[360*a,100*s,100*(s<1?o/(1-s):0)]},WZ.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let r=0;return n<1&&(r=(i-.5*n)/(1-n)),[e[0],100*n,100*r]},WZ.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const r=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return l=(1-i)*n,[255*(i*r[0]+l),255*(i*r[1]+l),255*(i*r[2]+l)]},WZ.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},WZ.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},WZ.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},WZ.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},WZ.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},WZ.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},WZ.gray.hsl=function(e){return[0,0,e[0]]},WZ.gray.hsv=WZ.gray.hsl,WZ.gray.hwb=function(e){return[0,100,e[0]]},WZ.gray.cmyk=function(e){return[0,0,0,e[0]]},WZ.gray.lab=function(e){return[e[0],0,0]},WZ.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},WZ.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const nW={},rW=Object.keys(WZ);function oW(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function sW(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let{length:e}=n,t=0;t0){this.model=t||"rgb",n=nW[this.model].channels;const i=Array.prototype.slice.call(e,0,n);this.color=fW(i,n),this.valpha="number"==typeof e[n]?e[n]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const n=t.sort().join("");if(!(n in lW))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=lW[n];const{labels:r}=nW[this.model],o=[];for(i=0;i(e%360+360)%360),saturationl:dW("hsl",1,pW(100)),lightness:dW("hsl",2,pW(100)),saturationv:dW("hsv",1,pW(100)),value:dW("hsv",2,pW(100)),chroma:dW("hcg",1,pW(100)),gray:dW("hcg",2,pW(100)),white:dW("hwb",1,pW(100)),wblack:dW("hwb",2,pW(100)),cyan:dW("cmyk",0,pW(100)),magenta:dW("cmyk",1,pW(100)),yellow:dW("cmyk",2,pW(100)),black:dW("cmyk",3,pW(100)),x:dW("xyz",0,pW(95.047)),y:dW("xyz",1,pW(100)),z:dW("xyz",2,pW(108.833)),l:dW("lab",0,pW(100)),a:dW("lab",1),b:dW("lab",2),keyword(e){return void 0!==e?new uW(e):nW[this.model].keyword(this.color)},hex(e){return void 0!==e?new uW(e):HZ.to.hex(...this.rgb().round().color)},hexa(e){if(void 0!==e)return new uW(e);const t=this.rgb().round().color;let i=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===i.length&&(i="0"+i),HZ.to.hex(...t)+i},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[i,n]of e.entries()){const e=n/255;t[i]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),i=e.luminosity();return t>i?(t+.05)/(i+.05):(i+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return uW.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let i=t.color[0];return i=(i+e)%360,i=i<0?360+i:i,t.color[0]=i,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const i=e.rgb(),n=this.rgb(),r=void 0===t?.5:t,o=2*r-1,s=i.alpha()-n.alpha(),a=((o*s===-1?o:(o+s)/(1+o*s))+1)/2,l=1-a;return uW.rgb(a*i.red()+l*n.red(),a*i.green()+l*n.green(),a*i.blue()+l*n.blue(),i.alpha()*r+n.alpha()*(1-r))}};for(const e of Object.keys(nW)){if(aW.includes(e))continue;const{channels:t}=nW[e];uW.prototype[e]=function(...t){return this.model===e?new uW(this):t.length>0?new uW(t,e):new uW([...(i=nW[this.model][e].raw(this.color),Array.isArray(i)?i:[i]),this.valpha],e);var i},uW[e]=function(...i){let n=i[0];return"number"==typeof n&&(n=fW(i,t)),new uW(n,e)}}function hW(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function dW(e,t,i){e=Array.isArray(e)?e:[e];for(const n of e)(cW[n]||=[])[t]=i;return e=e[0],function(n){let r;return void 0!==n?(i&&(n=i(n)),r=this[e](),r.color[t]=n,r):(r=this[e]().color[t],i&&(r=i(r)),r)}}function pW(e){return function(t){return Math.max(0,Math.min(e,t))}}function fW(e,t){for(let i=0;ii(24,c=e));let u,{id:h}=t,{bearing:d}=t,{center:p}=t,{pitch:f}=t,{showCollisions:m}=t,{showBoundaries:g}=t,{zoom:_}=t,{mapStyle:A}=t,{numberOfMaps:y}=t,{onMapMount:v}=t,{mapRenderer:x}=t;const b=H();let w,T,E,C={},S=null,B=!1,I={};const M=()=>({bearing:T.getBearing(),center:T.getCenter(),pitch:T.getPitch(),zoom:T.getZoom()}),P=(e,t)=>{e&&!ru(M(),I)&&e.jumpTo(t)},R=()=>{o&&T.setProjection({type:o})},L=()=>{const e=T.getStyle(),t=e?.light,i=e?.terrain,{data:n,beforeId:r,light:o,opacity:a}=s;let l,c,u,h,d;if(o){const{ambient:e,directional:t,point:i,camera:n}=o;e&&(e.color||(e.color="rgb(255, 255, 255)"),e.color=uW(e.color).rgb().array(),l=new wv(e)),t&&(t.color||(t.color="rgb(255, 255, 255)"),t.color=uW(t.color).rgb().array(),c=new Bv(t)),i&&(i.color||(i.color="rgb(255, 255, 255)"),i.color=uW(i.color).rgb().array(),u=new ax(i)),n&&(n.color||(n.color="rgb(255, 255, 255)"),n.color=uW(n.color).rgb().array(),h=new lx(n)),d=new Dv({...l&&{ambientLight:l},...c&&{directionalLight:c},...u&&{pointLight:u},...h&&{cameraLight:h}})}else if(t){let{anchor:e,color:i,intensity:n,position:r}=t;i||(i="rgb(255, 255, 255)"),i=uW(i).rgb().array(),l=new wv({color:i,intensity:5*n}),r?(c=new Bv({color:i,intensity:10*n,direction:(p=r,[p[2],(p[1]-90)%180*-1,p[0]])}),d=new Dv({ambientLight:l,directionalLight:c})):d=new Dv({ambientLight:l})}var p;let f,m;if(i){const{source:t,exaggeration:n}=i,r=e?.sources?.[t];f=new PV({id:"terrain",minZoom:0,maxZoom:23,strategy:"no-overlap",elevationDecoder:{rScaler:6553.6*n,gScaler:25.6*n,bScaler:.1*n,offset:-1e4*n},elevationData:r?.url??r?.tiles?.[0],color:[255,255,255,0],operation:"terrain+draw"}),m=new WV}const g=new dV({id:"tile-3d-layer",data:n,loader:NZ,opacity:a??1,onTilesetError:e=>console.log(e),...r&&{beforeId:r},...m&&{extensions:[m]}});E||(E=new US({interleaved:!0,layers:[f,g].filter(Boolean),...d&&{effects:[d]}}),T.addControl(E))};return j(async()=>{await(async()=>{"maplibre-gl"===x?(await Promise.resolve().then(function(){return JX}),u=await Promise.resolve().then(function(){return Xe})):"maptiler-sdk"===x?(await Promise.resolve().then(function(){return YX}),u=await Promise.resolve().then(function(){return c7}),u.config.apiKey=c.maptilerApiKey):(await Promise.resolve().then(function(){return u7}),u=await Promise.resolve().then(function(){return We}),u.accessToken=c.mapboxGlAccessToken,c.mapboxBaseApiUrl&&(u.baseApiUrl=c.mapboxBaseApiUrl))})();const e=u;let t,l="string"==typeof w;if(n){const e=r??n?.options?.default;if(!e)return;if(l&&(t=await vu(w)),!t)return;n&&n?.script&&(t=await n.script(t,e))}i(13,T=new e.Map({container:h,style:t??w,canvasContextAttributes:{preserveDrawingBuffer:!0},preserveDrawingBuffer:!0,maxPitch:85,...I})),s&&a&&T.once("load",L),o&&"maplibre-gl"===x&&T.on("style.load",()=>{setTimeout(R,150)}),v(T);const d=Ct(()=>{document.getElementById(h).querySelector('canvas[tabindex="0"]').focus()},250);document.getElementById(h).addEventListener("wheel",d,{passive:!0});T.on("move",e=>{e?.resize||(({origin:e})=>{document.getElementById(h)?.contains(document.activeElement)&&b("mapMove",{options:M()})})(e)}),T.on("click",t=>{let i=T.queryRenderedFeatures(t.point);i.length&&(B?(S.remove(),S=null):(S=(new e.Popup).setLngLat(t.lngLat).setHTML((e=>{const t=e.reduce((e,t)=>{const{source:i,sourceLayer:n,properties:r}=t,o=e.some(e=>{const t=e.source===i&&e.sourceLayer===n,o=Object.keys(r).every(t=>r[t]===e.properties[t]);return t&&o});return o||e.push(t),e},[]);let i='",i})(i)).setMaxWidth(360).addTo(T),B=!0,S.on("close",()=>{B=!1})))})}),G(()=>{T&&T.remove()}),e.$$set=e=>{"id"in e&&i(0,h=e.id),"bearing"in e&&i(1,d=e.bearing),"center"in e&&i(2,p=e.center),"pitch"in e&&i(3,f=e.pitch),"showCollisions"in e&&i(4,m=e.showCollisions),"showBoundaries"in e&&i(5,g=e.showBoundaries),"zoom"in e&&i(6,_=e.zoom),"mapStyle"in e&&i(7,A=e.mapStyle),"numberOfMaps"in e&&i(8,y=e.numberOfMaps),"onMapMount"in e&&i(9,v=e.onMapMount),"mapRenderer"in e&&i(10,x=e.mapRenderer)},e.$$.update=()=>{128&e.$$.dirty[0]&&i(11,({style:C,url:w,precompile:n,selectedPrecompileOption:r,projection:o,deckGlLayer:s,landmarks3D:a}=A),C,(i(12,w),i(7,A)),(i(18,r),i(7,A)),(i(17,o),i(7,A)),(i(16,s),i(7,A)),(i(15,a),i(7,A))),78&e.$$.dirty[0]&&i(14,I={bearing:d,center:p,pitch:f,zoom:_}),8208&e.$$.dirty[0]&&T&&i(13,T.showCollisionBoxes=m,T),8224&e.$$.dirty[0]&&T&&i(13,T.showTileBoundaries=g,T),24576&e.$$.dirty[0]&&P(T,I),505856&e.$$.dirty[0]&&(async(e,t,i,r,o,s,a)=>{if(!e)return;e.off("style.load",R),E&&(e.removeControl(E),E=null);let l=t;!l&&A?.pattern&&(l=xu(A?.pattern,A?.branch,A?.branchStyle));let c=i;if(n){if(!r)return;if(!i&&"string"==typeof l&&(c=await vu(l)),!c)return;c=await n.script(c,r),e.setStyle(c)}else e.setStyle(l||i);s&&a&&setTimeout(L,150),o&&"maplibre-gl"===x&&setTimeout(R,150)})(T,w,C,r,o,s,a),9473&e.$$.dirty[0]&&T&&y&&"maplibre-gl"!==x&&"maptiler-sdk"!==x&&T.once("render",()=>{const e=document.getElementById(h);if(e){new ResizeObserver(()=>{T.resize({resize:!0})}).observe(e)}})},[h,d,p,f,m,g,_,A,y,v,x,C,w,T,I,a,s,o,r]}class _W extends ge{constructor(e){super(),me(this,e,gW,mW,a,{id:0,bearing:1,center:2,pitch:3,showCollisions:4,showBoundaries:5,zoom:6,mapStyle:7,numberOfMaps:8,onMapMount:9,mapRenderer:10},null,[-1,-1])}}var AW={exports:{}}; + */var j$=null;try{j$=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function G$(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function H$(e){return!0===(e&&e.__isLong__)}function Q$(e){var t=Math.clz32(e&-e);return e?31-t:t}G$.prototype.__isLong__,Object.defineProperty(G$.prototype,"__isLong__",{value:!0}),G$.isLong=H$;var $$={},Z$={};function W$(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=Z$[e])?n:(i=K$(e,0,!0),r&&(Z$[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=$$[e])?n:(i=K$(e,e<0?-1:0,!1),r&&($$[e]=i),i)}function q$(e,t){if(isNaN(e))return t?oZ:rZ;if(t){if(e<0)return oZ;if(e>=tZ)return uZ}else{if(e<=-iZ)return hZ;if(e+1>=iZ)return cZ}return e<0?q$(-e,t).neg():K$(e%eZ|0,e/eZ|0,t)}function K$(e,t,i){return new G$(e,t,i)}G$.fromInt=W$,G$.fromNumber=q$,G$.fromBits=K$;var X$=Math.pow;function J$(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?oZ:rZ;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===n)return J$(e.substring(1),t,i).neg();for(var r=q$(X$(i,8)),o=rZ,s=0;s>>0:this.low},dZ.toNumber=function(){return this.unsigned?(this.high>>>0)*eZ+(this.low>>>0):this.high*eZ+(this.low>>>0)},dZ.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},dZ.getHighBits=function(){return this.high},dZ.getHighBitsUnsigned=function(){return this.high>>>0},dZ.getLowBits=function(){return this.low},dZ.getLowBitsUnsigned=function(){return this.low>>>0},dZ.getNumBitsAbs=function(){if(this.isNegative())return this.eq(hZ)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},dZ.isZero=function(){return 0===this.high&&0===this.low},dZ.eqz=dZ.isZero,dZ.isNegative=function(){return!this.unsigned&&this.high<0},dZ.isPositive=function(){return this.unsigned||this.high>=0},dZ.isOdd=function(){return!(1&~this.low)},dZ.isEven=function(){return!(1&this.low)},dZ.equals=function(e){return H$(e)||(e=Y$(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},dZ.eq=dZ.equals,dZ.notEquals=function(e){return!this.eq(e)},dZ.neq=dZ.notEquals,dZ.ne=dZ.notEquals,dZ.lessThan=function(e){return this.comp(e)<0},dZ.lt=dZ.lessThan,dZ.lessThanOrEqual=function(e){return this.comp(e)<=0},dZ.lte=dZ.lessThanOrEqual,dZ.le=dZ.lessThanOrEqual,dZ.greaterThan=function(e){return this.comp(e)>0},dZ.gt=dZ.greaterThan,dZ.greaterThanOrEqual=function(e){return this.comp(e)>=0},dZ.gte=dZ.greaterThanOrEqual,dZ.ge=dZ.greaterThanOrEqual,dZ.compare=function(e){if(H$(e)||(e=Y$(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},dZ.comp=dZ.compare,dZ.negate=function(){return!this.unsigned&&this.eq(hZ)?hZ:this.not().add(sZ)},dZ.neg=dZ.negate,dZ.add=function(e){H$(e)||(e=Y$(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=r+(65535&e.low))>>>16,c+=(u+=n+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,K$((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},dZ.subtract=function(e){return H$(e)||(e=Y$(e)),this.add(e.neg())},dZ.sub=dZ.subtract,dZ.multiply=function(e){if(this.isZero())return this;if(H$(e)||(e=Y$(e)),j$)return K$(j$.mul(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned);if(e.isZero())return this.unsigned?oZ:rZ;if(this.eq(hZ))return e.isOdd()?hZ:rZ;if(e.eq(hZ))return this.isOdd()?hZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(nZ)&&e.lt(nZ))return q$(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=r*l)>>>16,u+=(h+=n*l)>>>16,h&=65535,u+=(h+=r*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=n*a)>>>16,u&=65535,c+=(u+=r*s)>>>16,c+=t*l+i*a+n*s+r*o,K$((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},dZ.mul=dZ.multiply,dZ.divide=function(e){if(H$(e)||(e=Y$(e)),e.isZero())throw Error("division by zero");var t,i,n;if(j$)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?K$((this.unsigned?j$.div_u:j$.div_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?oZ:rZ;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return oZ;if(e.gt(this.shru(1)))return aZ;n=oZ}else{if(this.eq(hZ))return e.eq(sZ)||e.eq(lZ)?hZ:e.eq(hZ)?sZ:(t=this.shr(1).div(e).shl(1)).eq(rZ)?e.isNegative()?sZ:lZ:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(hZ))return this.unsigned?oZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=rZ}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),o=r<=48?1:X$(2,r-48),s=q$(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=q$(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=sZ),n=n.add(s),i=i.sub(a)}return n},dZ.div=dZ.divide,dZ.modulo=function(e){return H$(e)||(e=Y$(e)),j$?K$((this.unsigned?j$.rem_u:j$.rem_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},dZ.mod=dZ.modulo,dZ.rem=dZ.modulo,dZ.not=function(){return K$(~this.low,~this.high,this.unsigned)},dZ.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},dZ.clz=dZ.countLeadingZeros,dZ.countTrailingZeros=function(){return this.low?Q$(this.low):Q$(this.high)+32},dZ.ctz=dZ.countTrailingZeros,dZ.and=function(e){return H$(e)||(e=Y$(e)),K$(this.low&e.low,this.high&e.high,this.unsigned)},dZ.or=function(e){return H$(e)||(e=Y$(e)),K$(this.low|e.low,this.high|e.high,this.unsigned)},dZ.xor=function(e){return H$(e)||(e=Y$(e)),K$(this.low^e.low,this.high^e.high,this.unsigned)},dZ.shiftLeft=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low<>>32-e,this.unsigned):K$(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):K$(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},dZ.shr=dZ.shiftRight,dZ.shiftRightUnsigned=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):K$(32===e?this.high:this.high>>>e-32,0,this.unsigned)},dZ.shru=dZ.shiftRightUnsigned,dZ.shr_u=dZ.shiftRightUnsigned,dZ.rotateLeft=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),K$(this.high<>>t,this.low<>>t,this.unsigned))},dZ.rotl=dZ.rotateLeft,dZ.rotateRight=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),K$(this.low<>>e,this.high<>>e,this.unsigned))},dZ.rotr=dZ.rotateRight,dZ.toSigned=function(){return this.unsigned?K$(this.low,this.high,!1):this},dZ.toUnsigned=function(){return this.unsigned?this:K$(this.low,this.high,!0)},dZ.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},dZ.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},dZ.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},G$.fromBytes=function(e,t,i){return i?G$.fromBytesLE(e,t):G$.fromBytesBE(e,t)},G$.fromBytesLE=function(e,t){return new G$(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},G$.fromBytesBE=function(e,t){return new G$(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(G$.fromBigInt=function(e,t){return K$(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},G$.fromValue=function(e,t){return"bigint"==typeof e?G$.fromBigInt(e,t):Y$(e,t)},dZ.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function _Z(e){return[gZ(e[0]),gZ(e[1])]}function AZ(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function yZ([e,t,i]){const n=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*fZ,n*fZ]}function vZ(e,t,i,n){if(0===n){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const n=t[0];t[0]=t[1],t[1]=n}}function xZ(e){const{face:t,ij:i,level:n}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-n))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),u=r[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function bZ(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=pZ(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),n=t.substring(0,3),r=t.substring(3,i),o=r.length/2,s=G$.fromString(n,!0,2).toString(10);let a="";if(0!==o)for(a=G$.fromString(r,!0,2).toString(4);a.length=0;e--){o=r-e;const t=n[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);vZ(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function wZ(e){return function(e){const t=_Z(mZ(e.ij,e.level,[.5,.5]));return yZ(AZ(e.face,t))}(bZ(e))}function TZ(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let n=0;ne-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function EZ(e,t){const i=t?.minimumHeight||0,n=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let i=null,n=0;for(let t=0;t<4;t++){const r=xZ(bZ(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*r.length)),i.set(r,n),n+=r.length}t=TZ(i)}else t=TZ(xZ(e));return t}(bZ(e)),o=r.west,s=r.south,a=r.east,l=r.north,c=[];return c.push(new AA(o,l,i)),c.push(new AA(a,l,i)),c.push(new AA(a,s,i)),c.push(new AA(o,s,i)),c.push(new AA(o,l,n)),c.push(new AA(a,l,n)),c.push(new AA(a,s,n)),c.push(new AA(o,s,n)),c}function CZ(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=EZ(t,i),r=wZ(t),o=r[0],s=r[1],a=PO.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new AA(a[0],a[1],a[2]);n.push(l);const c=NR(n);return[...c.center,...c.halfAxes]}const SZ={QUADTREE:4,OCTREE:8};function BZ(e,t,i){if(e?.box){const n=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(G$.fromNumber(2*t+1-4).multiply(i))}(pZ(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}(n),o={...e.s2VolumeInfo};if(o.token=r,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,n=i/2,r=t.minimumHeight+i/2;t.minimumHeight=r-n,t.maximumHeight=r+n}return{box:CZ(o),s2VolumeInfo:o}}}async function IZ(e){const{implicitOptions:t,parentData:i={mortonIndex:0,x:0,y:0,z:0},childIndex:n=0,s2VolumeBox:r,loaderOptions:o}=e;let{subtree:s,level:a=0,globalData:l={level:0,mortonIndex:0,x:0,y:0,z:0}}=e;const{subdivisionScheme:c,subtreeLevels:u,maximumLevel:h,contentUrlTemplate:d,subtreesUriTemplate:p,basePath:f}=t,m={children:[],lodMetricValue:0,contentUrl:""};if(!h)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=a+l.level;if(g>h)return m;const _=SZ[c],A=Math.log2(_),y=1&n,v=n>>1&1,x=n>>2&1,b=(_**a-1)/(_-1);let w=RZ(i.mortonIndex,n,A),T=b+w,E=RZ(i.x,y,1),C=RZ(i.y,v,1),S=RZ(i.z,x,1),B=!1;a>=u&&(B=MZ(s.childSubtreeAvailability,w));const I=RZ(l.x,E,a),M=RZ(l.y,C,a),P=RZ(l.z,S,a);if(B){const e=LZ(`${f}/${p}`,g,I,M,P);s=await dI(e,V$,o),l={mortonIndex:w,x:E,y:C,z:S,level:a},w=0,T=0,E=0,C=0,S=0,a=0}if(!MZ(s.tileAvailability,T))return m;MZ(s.contentAvailability,T)&&(m.contentUrl=LZ(d,g,I,M,P));const R=a+1,L={mortonIndex:w,x:E,y:C,z:S};for(let e=0;e<_;e++){const i=BZ(r,e,c),n=await IZ({subtree:s,implicitOptions:t,loaderOptions:o,parentData:L,childIndex:e,level:R,globalData:{...l},s2VolumeBox:i});if(n.contentUrl||n.children.length){const e=PZ(n,g+1,{childTileX:E,childTileY:C,childTileZ:S},t,r);m.children.push(e)}}return m}function MZ(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),n=e%8;return 1==(t[i]>>n&1)}(t,i.explicitBitstream)}function PZ(e,t,i,n,r){const{basePath:o,refine:s,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=n,d=e.contentUrl&&e.contentUrl.replace(`${o}/`,""),p=u/2**t,f=function(e,t,i){if(t.region){const{childTileX:n,childTileY:r,childTileZ:o}=i,[s,a,l,c,u,h]=t.region,d=2**e,p=(l-s)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[s+p*n,s+p*(n+1)],[A,y]=[a+f*r,a+f*(r+1)],[v,x]=[u+m*o,u+m*(o+1)];return{region:[g,A,_,y,v,x]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}(t,r?.box?{box:r.box}:h,i);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(s),type:c(e),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function RZ(e,t,i){return(e<o[e])}function FZ(e,t=""){if(!t)return cj.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return cj.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return cj.SCENEGRAPH;default:return i||cj.EMPTY}}function kZ(e){switch(e){case"REPLACE":case"replace":return lj.REPLACE;case"ADD":case"add":return lj.ADD;default:return e}}function DZ(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:oj(t,e)}function OZ(e,t){if(!e)return null;let i;if(e.content){const n=e.content.uri||e.content?.url;void 0!==n&&(i=DZ(n,t))}return{...e,id:i,contentUrl:i,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,i),refine:kZ(e.refine)}}async function zZ(e,t,i,n,r){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=n,u=DZ(LZ(c,0,0,0,0),i),h=await dI(u,V$,r),d=e.content?.uri,p=d?DZ(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:CZ(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:hj.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:FZ,getRefine:kZ};return await async function(e,t,i,n,r){if(!e)return null;const{children:o,contentUrl:s}=await IZ({subtree:i,implicitOptions:n,loaderOptions:r});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,a),refine:kZ(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,r)}function UZ(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const NZ={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:dj,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const n=t["3d-tiles"]||{};let r;r="auto"===n.isTileset?i?.url&&-1!==i.url.indexOf(".json"):n.isTileset;return r?async function(e,t,i){const n=JSON.parse((new TextDecoder).decode(e)),r=i?.url||"",o=function(e){return function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}(r),s=await async function(e,t,i){let n=null;const r=UZ(e.root);n=r&&e.root?await zZ(e.root,e,t,r,i):OZ(e.root,t);const o=[];for(o.push(n);o.length>0;){const n=o.pop()||{},r=n.children||[],s=[];for(const n of r){const r=UZ(n);let a;a=r?await zZ(n,e,t,r,i):OZ(n,t),a&&(s.push(a),o.push(a))}n.children=s}return n}(n,o,t||{}),a={...n,shape:"tileset3d",loader:NZ,url:r,queryString:i?.queryString||"",basePath:o,root:s||n.root,type:uj.TILES3D,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const n={content:{shape:"tile3d",featureIds:null}},r=0;return await z$(e,r,t,i,n.content),n.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const VZ={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const e in VZ)Object.freeze(VZ[e]);var jZ=Object.freeze(VZ);const GZ=Object.create(null);for(const e in jZ)Object.hasOwn(jZ,e)&&(GZ[jZ[e]]=e);const HZ={to:{},get:{}};function QZ(e,t,i){return Math.min(Math.max(t,e),i)}function $Z(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}HZ.get=function(e){let t,i;switch(e.slice(0,3).toLowerCase()){case"hsl":t=HZ.get.hsl(e),i="hsl";break;case"hwb":t=HZ.get.hwb(e),i="hwb";break;default:t=HZ.get.rgb(e),i="rgb"}return t?{model:i,value:t}:null},HZ.get.rgb=function(e){if(!e)return null;let t,i,n,r=[0,0,0,1];if(t=e.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(n=t[2],t=t[1],i=0;i<3;i++){const e=2*i;r[i]=Number.parseInt(t.slice(e,e+2),16)}n&&(r[3]=Number.parseInt(n,16)/255)}else if(t=e.match(/^#([a-f\d]{3,4})$/i)){for(t=t[1],n=t[3],i=0;i<3;i++)r[i]=Number.parseInt(t[i]+t[i],16);n&&(r[3]=Number.parseInt(n+n,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(i=0;i<3;i++)r[i]=Number.parseFloat(t[i+1]);t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(t=e.toLowerCase().match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:Object.hasOwn(jZ,t[1])?(r=jZ[t[1]].slice(),r[3]=1,r):null:null;for(i=0;i<3;i++)r[i]=Math.round(2.55*Number.parseFloat(t[i+1]));t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}for(i=0;i<3;i++)r[i]=QZ(r[i],0,255);return r[3]=QZ(r[3],0,1),r},HZ.get.hsl=function(e){if(!e)return null;const t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.get.hwb=function(e){if(!e)return null;const t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.to.hex=function(...e){return"#"+$Z(e[0])+$Z(e[1])+$Z(e[2])+(e[3]<1?$Z(Math.round(255*e[3])):"")},HZ.to.rgb=function(...e){return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},HZ.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),i=Math.round(e[1]/255*100),n=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+i+"%, "+n+"%)":"rgba("+t+"%, "+i+"%, "+n+"%, "+e[3]+")"},HZ.to.hsl=function(...e){return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},HZ.to.hwb=function(...e){let t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},HZ.to.keyword=function(...e){return GZ[e.slice(0,3)]};const ZZ={};for(const e of Object.keys(jZ))ZZ[jZ[e]]=e;const WZ={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},qZ=(6/29)**3;function KZ(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function XZ(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(WZ)){if(!("channels"in WZ[e]))throw new Error("missing channels property: "+e);if(!("labels"in WZ[e]))throw new Error("missing channel labels property: "+e);if(WZ[e].labels.length!==WZ[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=WZ[e];delete WZ[e].channels,delete WZ[e].labels,Object.defineProperty(WZ[e],"channels",{value:t}),Object.defineProperty(WZ[e],"labels",{value:i})}function JZ(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function YZ(e){const t=function(){const e={},t=Object.keys(WZ);for(let{length:i}=t,n=0;n0;){const e=i.pop(),n=Object.keys(WZ[e]);for(let{length:r}=n,o=0;o1&&(r-=1)}return[360*r,100*o,100*c]},WZ.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const r=WZ.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[r,100*o,100*n]},WZ.rgb.oklab=function(e){const t=XZ(e[0]/255),i=XZ(e[1]/255),n=XZ(e[2]/255),r=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*n),o=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*n),s=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(1-t,1-i,1-n);return[100*((1-t-r)/(1-r)||0),100*((1-i-r)/(1-r)||0),100*((1-n-r)/(1-r)||0),100*r]},WZ.rgb.keyword=function(e){const t=ZZ[e];if(t)return t;let i,n=Number.POSITIVE_INFINITY;for(const t of Object.keys(jZ)){const r=JZ(e,jZ[t]);rqZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116,r=r>qZ?r**(1/3):7.787*r+16/116;return[116*n-16,500*(i-n),200*(n-r)]},WZ.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let r,o;if(0===i)return o=255*n,[o,o,o];const s=n<.5?n*(1+i):n+i-n*i,a=2*n-s,l=[0,0,0];for(let e=0;e<3;e++)r=t+1/3*-(e-1),r<0&&r++,r>1&&r--,o=6*r<1?a+6*(s-a)*r:2*r<1?s:3*r<2?a+(s-a)*(2/3-r)*6:a,l[e]=255*o;return l},WZ.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,r=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,r*=o<=1?o:2-o;return[t,100*(0===n?2*r/(o+r):2*i/(n+i)),100*((n+i)/2)]},WZ.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const r=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,r){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},WZ.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,r=Math.max(n,.01);let o,s;s=(2-i)*n;const a=(2-i)*r;return o=i*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},WZ.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const r=i+n;let o;r>1&&(i/=r,n/=r);const s=Math.floor(6*t),a=1-n;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},WZ.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},WZ.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let r,o,s;return r=3.2404542*t+-1.5371385*i+-.4985314*n,o=-.969266*t+1.8760108*i+.041556*n,s=.0556434*t+-.2040259*i+1.0572252*n,r=KZ(r),o=KZ(o),s=KZ(s),[255*r,255*o,255*s]},WZ.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>qZ?t**(1/3):7.787*t+16/116,i=i>qZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},WZ.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*n),o=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*n),s=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.oklab.oklch=function(e){return WZ.lab.lch(e)},WZ.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(.999999998*t+.396337792*i+.215803758*n)**3,o=(1.000000008*t-.105561342*i-.063854175*n)**3,s=(1.000000055*t-.089484182*i-1.291485538*n)**3;return[100*(1.227013851*r-.55779998*o+.281256149*s),100*(-.040580178*r+1.11225687*o-.071676679*s),100*(-.076381285*r-.421481978*o+1.58616322*s)]},WZ.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(t+.3963377774*i+.2158037573*n)**3,o=(t-.1055613458*i-.0638541728*n)**3,s=(t-.0894841775*i-1.291485548*n)**3;return[255*KZ(4.0767416621*r-3.3077115913*o+.2309699292*s),255*KZ(-1.2684380046*r+2.6097574011*o-.3413193965*s),255*KZ(-.0041960863*r-.7034186147*o+1.707614701*s)]},WZ.oklch.oklab=function(e){return WZ.lch.lab(e)},WZ.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const r=i**3,o=t**3,s=n**3;return i=r>qZ?r:(i-16/116)/7.787,t=o>qZ?o:(t-16/116)/7.787,n=s>qZ?s:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},WZ.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let r;r=360*Math.atan2(n,i)/2/Math.PI,r<0&&(r+=360);return[t,Math.sqrt(i*i+n*n),r]},WZ.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},WZ.rgb.ansi16=function(e,t=null){const[i,n,r]=e;let o=null===t?WZ.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===o&&(s+=60),s},WZ.hsv.ansi16=function(e){return WZ.rgb.ansi16(WZ.hsv.rgb(e),e[2])},WZ.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t>>4==i>>4&&i>>4==n>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},WZ.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},WZ.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},WZ.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},WZ.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map(e=>e+e).join(""));const n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},WZ.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),s=r-o;let a;return a=s<=0?0:r===t?(i-n)/s%6:r===i?2+(n-t)/s:4+(t-i)/s,a/=6,a%=1,[360*a,100*s,100*(s<1?o/(1-s):0)]},WZ.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let r=0;return n<1&&(r=(i-.5*n)/(1-n)),[e[0],100*n,100*r]},WZ.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const r=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return l=(1-i)*n,[255*(i*r[0]+l),255*(i*r[1]+l),255*(i*r[2]+l)]},WZ.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},WZ.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},WZ.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},WZ.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},WZ.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},WZ.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},WZ.gray.hsl=function(e){return[0,0,e[0]]},WZ.gray.hsv=WZ.gray.hsl,WZ.gray.hwb=function(e){return[0,100,e[0]]},WZ.gray.cmyk=function(e){return[0,0,0,e[0]]},WZ.gray.lab=function(e){return[e[0],0,0]},WZ.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},WZ.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const nW={},rW=Object.keys(WZ);function oW(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function sW(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let{length:e}=n,t=0;t0){this.model=t||"rgb",n=nW[this.model].channels;const i=Array.prototype.slice.call(e,0,n);this.color=fW(i,n),this.valpha="number"==typeof e[n]?e[n]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const n=t.sort().join("");if(!(n in lW))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=lW[n];const{labels:r}=nW[this.model],o=[];for(i=0;i(e%360+360)%360),saturationl:dW("hsl",1,pW(100)),lightness:dW("hsl",2,pW(100)),saturationv:dW("hsv",1,pW(100)),value:dW("hsv",2,pW(100)),chroma:dW("hcg",1,pW(100)),gray:dW("hcg",2,pW(100)),white:dW("hwb",1,pW(100)),wblack:dW("hwb",2,pW(100)),cyan:dW("cmyk",0,pW(100)),magenta:dW("cmyk",1,pW(100)),yellow:dW("cmyk",2,pW(100)),black:dW("cmyk",3,pW(100)),x:dW("xyz",0,pW(95.047)),y:dW("xyz",1,pW(100)),z:dW("xyz",2,pW(108.833)),l:dW("lab",0,pW(100)),a:dW("lab",1),b:dW("lab",2),keyword(e){return void 0!==e?new uW(e):nW[this.model].keyword(this.color)},hex(e){return void 0!==e?new uW(e):HZ.to.hex(...this.rgb().round().color)},hexa(e){if(void 0!==e)return new uW(e);const t=this.rgb().round().color;let i=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===i.length&&(i="0"+i),HZ.to.hex(...t)+i},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[i,n]of e.entries()){const e=n/255;t[i]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),i=e.luminosity();return t>i?(t+.05)/(i+.05):(i+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return uW.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let i=t.color[0];return i=(i+e)%360,i=i<0?360+i:i,t.color[0]=i,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const i=e.rgb(),n=this.rgb(),r=void 0===t?.5:t,o=2*r-1,s=i.alpha()-n.alpha(),a=((o*s===-1?o:(o+s)/(1+o*s))+1)/2,l=1-a;return uW.rgb(a*i.red()+l*n.red(),a*i.green()+l*n.green(),a*i.blue()+l*n.blue(),i.alpha()*r+n.alpha()*(1-r))}};for(const e of Object.keys(nW)){if(aW.includes(e))continue;const{channels:t}=nW[e];uW.prototype[e]=function(...t){return this.model===e?new uW(this):t.length>0?new uW(t,e):new uW([...(i=nW[this.model][e].raw(this.color),Array.isArray(i)?i:[i]),this.valpha],e);var i},uW[e]=function(...i){let n=i[0];return"number"==typeof n&&(n=fW(i,t)),new uW(n,e)}}function hW(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function dW(e,t,i){e=Array.isArray(e)?e:[e];for(const n of e)(cW[n]||=[])[t]=i;return e=e[0],function(n){let r;return void 0!==n?(i&&(n=i(n)),r=this[e](),r.color[t]=n,r):(r=this[e]().color[t],i&&(r=i(r)),r)}}function pW(e){return function(t){return Math.max(0,Math.min(e,t))}}function fW(e,t){for(let i=0;ii(24,c=e));let u,{id:h}=t,{bearing:d}=t,{center:p}=t,{pitch:f}=t,{showCollisions:m}=t,{showBoundaries:g}=t,{zoom:_}=t,{mapStyle:A}=t,{numberOfMaps:y}=t,{onMapMount:v}=t,{mapRenderer:x}=t;const b=H();let w,T,E,C={},S=null,B=!1,I={};const M=()=>({bearing:T.getBearing(),center:T.getCenter(),pitch:T.getPitch(),zoom:T.getZoom()}),P=(e,t)=>{e&&!ru(M(),I)&&e.jumpTo(t)},R=()=>{o&&T.setProjection({type:o})},L=()=>{const e=T.getStyle(),t=e?.light,i=e?.terrain,{data:n,beforeId:r,light:o,opacity:a}=s;let l,c,u,h,d;if(o){const{ambient:e,directional:t,point:i,camera:n}=o;e&&(e.color||(e.color="rgb(255, 255, 255)"),e.color=uW(e.color).rgb().array(),l=new wv(e)),t&&(t.color||(t.color="rgb(255, 255, 255)"),t.color=uW(t.color).rgb().array(),c=new Bv(t)),i&&(i.color||(i.color="rgb(255, 255, 255)"),i.color=uW(i.color).rgb().array(),u=new ax(i)),n&&(n.color||(n.color="rgb(255, 255, 255)"),n.color=uW(n.color).rgb().array(),h=new lx(n)),d=new Dv({...l&&{ambientLight:l},...c&&{directionalLight:c},...u&&{pointLight:u},...h&&{cameraLight:h}})}else if(t){let{anchor:e,color:i,intensity:n,position:r}=t;i||(i="rgb(255, 255, 255)"),i=uW(i).rgb().array(),l=new wv({color:i,intensity:5*n}),r?(c=new Bv({color:i,intensity:10*n,direction:(p=r,[p[2],(p[1]-90)%180*-1,p[0]])}),d=new Dv({ambientLight:l,directionalLight:c})):d=new Dv({ambientLight:l})}var p;let f,m;if(i){const{source:t,exaggeration:n}=i,r=e?.sources?.[t];f=new PV({id:"terrain",minZoom:0,maxZoom:23,strategy:"no-overlap",elevationDecoder:{rScaler:6553.6*n,gScaler:25.6*n,bScaler:.1*n,offset:-1e4*n},elevationData:r?.url??r?.tiles?.[0],color:[255,255,255,0],operation:"terrain+draw"}),m=new WV}const g=new dV({id:"tile-3d-layer",data:n,loader:NZ,opacity:a??1,onTilesetError:e=>console.log(e),...r&&{beforeId:r},...m&&{extensions:[m]}});E||(E=new US({interleaved:!0,layers:[f,g].filter(Boolean),...d&&{effects:[d]}}),T.addControl(E))};return j(async()=>{await(async()=>{"maplibre-gl"===x?(await Promise.resolve().then(function(){return YX}),u=await Promise.resolve().then(function(){return Xe})):"maptiler-sdk"===x?(await Promise.resolve().then(function(){return eJ}),u=await Promise.resolve().then(function(){return u7}),u.config.apiKey=c.maptilerApiKey):(await Promise.resolve().then(function(){return h7}),u=await Promise.resolve().then(function(){return We}),u.accessToken=c.mapboxGlAccessToken,c.mapboxBaseApiUrl&&(u.baseApiUrl=c.mapboxBaseApiUrl))})();const e=u;let t,l="string"==typeof w;if(n){const e=r??n?.options?.default;if(!e)return;if(l&&(t=await vu(w)),!t)return;n&&n?.script&&(t=await n.script(t,e))}i(13,T=new e.Map({container:h,style:t??w,canvasContextAttributes:{preserveDrawingBuffer:!0},preserveDrawingBuffer:!0,maxPitch:85,...I})),s&&a&&T.once("load",L),o&&"maplibre-gl"===x&&T.on("style.load",()=>{setTimeout(R,150)}),v(T);const d=Ct(()=>{document.getElementById(h).querySelector('canvas[tabindex="0"]').focus()},250);document.getElementById(h).addEventListener("wheel",d,{passive:!0});T.on("move",e=>{e?.resize||(({origin:e})=>{document.getElementById(h)?.contains(document.activeElement)&&b("mapMove",{options:M()})})(e)}),T.on("click",t=>{let i=T.queryRenderedFeatures(t.point);i.length&&(B?(S.remove(),S=null):(S=(new e.Popup).setLngLat(t.lngLat).setHTML((e=>{const t=e.reduce((e,t)=>{const{source:i,sourceLayer:n,properties:r}=t,o=e.some(e=>{const t=e.source===i&&e.sourceLayer===n,o=Object.keys(r).every(t=>r[t]===e.properties[t]);return t&&o});return o||e.push(t),e},[]);let i='",i})(i)).setMaxWidth(360).addTo(T),B=!0,S.on("close",()=>{B=!1})))})}),G(()=>{T&&T.remove()}),e.$$set=e=>{"id"in e&&i(0,h=e.id),"bearing"in e&&i(1,d=e.bearing),"center"in e&&i(2,p=e.center),"pitch"in e&&i(3,f=e.pitch),"showCollisions"in e&&i(4,m=e.showCollisions),"showBoundaries"in e&&i(5,g=e.showBoundaries),"zoom"in e&&i(6,_=e.zoom),"mapStyle"in e&&i(7,A=e.mapStyle),"numberOfMaps"in e&&i(8,y=e.numberOfMaps),"onMapMount"in e&&i(9,v=e.onMapMount),"mapRenderer"in e&&i(10,x=e.mapRenderer)},e.$$.update=()=>{128&e.$$.dirty[0]&&i(11,({style:C,url:w,precompile:n,selectedPrecompileOption:r,projection:o,deckGlLayer:s,landmarks3D:a}=A),C,(i(12,w),i(7,A)),(i(18,r),i(7,A)),(i(17,o),i(7,A)),(i(16,s),i(7,A)),(i(15,a),i(7,A))),78&e.$$.dirty[0]&&i(14,I={bearing:d,center:p,pitch:f,zoom:_}),8208&e.$$.dirty[0]&&T&&i(13,T.showCollisionBoxes=m,T),8224&e.$$.dirty[0]&&T&&i(13,T.showTileBoundaries=g,T),24576&e.$$.dirty[0]&&P(T,I),505856&e.$$.dirty[0]&&(async(e,t,i,r,o,s,a)=>{if(!e)return;e.off("style.load",R),E&&(e.removeControl(E),E=null);let l=t;!l&&A?.pattern&&(l=xu(A?.pattern,A?.branch,A?.branchStyle));let c=i;if(n){if(!r)return;if(!i&&"string"==typeof l&&(c=await vu(l)),!c)return;c=await n.script(c,r),e.setStyle(c)}else e.setStyle(l||i);s&&a&&setTimeout(L,150),o&&"maplibre-gl"===x&&setTimeout(R,150)})(T,w,C,r,o,s,a),9473&e.$$.dirty[0]&&T&&y&&"maplibre-gl"!==x&&"maptiler-sdk"!==x&&T.once("render",()=>{const e=document.getElementById(h);if(e){new ResizeObserver(()=>{T.resize({resize:!0})}).observe(e)}})},[h,d,p,f,m,g,_,A,y,v,x,C,w,T,I,a,s,o,r]}class _W extends ge{constructor(e){super(),me(this,e,gW,mW,a,{id:0,bearing:1,center:2,pitch:3,showCollisions:4,showBoundaries:5,zoom:6,mapStyle:7,numberOfMaps:8,onMapMount:9,mapRenderer:10},null,[-1,-1])}}var AW={exports:{}}; /* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade @@ -58,12 +58,12 @@ function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArr * Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) * Copyright 2024 Fonticons, Inc. - */const CW={prefix:"fas",iconName:"compress",icon:[448,512,[],"f066","M160 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 320c-17.7 0-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0z"]},SW={prefix:"fas",iconName:"camera",icon:[512,512,[62258,"camera-alt"],"f030","M149.1 64.8L138.7 96 64 96C28.7 96 0 124.7 0 160L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64l-74.7 0L362.9 64.8C356.4 45.2 338.1 32 317.4 32L194.6 32c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"]},BW={prefix:"fas",iconName:"link",icon:[640,512,[128279,"chain"],"f0c1","M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"]},IW={prefix:"fas",iconName:"plus",icon:[448,512,[10133,61543,"add"],"2b","M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"]},MW={prefix:"fas",iconName:"expand",icon:[448,512,[],"f065","M32 32C14.3 32 0 46.3 0 64l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96z"]},PW={prefix:"fas",iconName:"xmark",icon:[384,512,[128473,10005,10006,10060,215,"close","multiply","remove","times"],"f00d","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"]},RW={prefix:"fas",iconName:"link-slash",icon:[640,512,["chain-broken","chain-slash","unlink"],"f127","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"]},LW=parseFloat;function FW(e,t=";"){let i;if(Array.isArray(e))i=e.filter(e=>e);else{i=[];for(const t in e)e[t]&&i.push(`${t}:${e[t]}`)}return i.join(t)}function kW(e){let t,i,n,r,o,s,a;function l(e,t){return"string"==typeof e[7][4]?OW:DW}let c=l(e),u=c(e);return{c(){t=w("svg"),i=w("g"),n=w("g"),u.c(),B(n,"transform",e[10]),B(i,"transform",r=`translate(${e[7][0]/2} ${e[7][1]/2})`),B(i,"transform-origin",o=e[7][0]/4+" 0"),B(t,"id",e[0]),B(t,"class",s=g(e[8])+" svelte-1cj2gr0"),B(t,"style",e[9]),B(t,"viewBox",a=`0 0 ${e[7][0]} ${e[7][1]}`),B(t,"aria-hidden","true"),B(t,"role","img"),B(t,"xmlns","http://www.w3.org/2000/svg")},m(e,r){y(e,t,r),A(t,i),A(i,n),u.m(n,null)},p(e,h){c===(c=l(e))&&u?u.p(e,h):(u.d(1),u=c(e),u&&(u.c(),u.m(n,null))),1024&h&&B(n,"transform",e[10]),128&h&&r!==(r=`translate(${e[7][0]/2} ${e[7][1]/2})`)&&B(i,"transform",r),128&h&&o!==(o=e[7][0]/4+" 0")&&B(i,"transform-origin",o),1&h&&B(t,"id",e[0]),256&h&&s!==(s=g(e[8])+" svelte-1cj2gr0")&&B(t,"class",s),512&h&&B(t,"style",e[9]),128&h&&a!==(a=`0 0 ${e[7][0]} ${e[7][1]}`)&&B(t,"viewBox",a)},d(e){e&&v(t),u.d()}}}function DW(e){let t,i,n,r,o,s,a,l,c,u;return{c(){t=w("path"),s=w("path"),B(t,"d",i=e[7][4][0]),B(t,"fill",n=e[3]||e[1]||"currentColor"),B(t,"fill-opacity",r=0!=e[6]?e[4]:e[5]),B(t,"transform",o=`translate(${e[7][0]/-2} ${e[7][1]/-2})`),B(s,"d",a=e[7][4][1]),B(s,"fill",l=e[2]||e[1]||"currentColor"),B(s,"fill-opacity",c=0!=e[6]?e[5]:e[4]),B(s,"transform",u=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)},m(e,i){y(e,t,i),y(e,s,i)},p(e,h){128&h&&i!==(i=e[7][4][0])&&B(t,"d",i),10&h&&n!==(n=e[3]||e[1]||"currentColor")&&B(t,"fill",n),112&h&&r!==(r=0!=e[6]?e[4]:e[5])&&B(t,"fill-opacity",r),128&h&&o!==(o=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(t,"transform",o),128&h&&a!==(a=e[7][4][1])&&B(s,"d",a),6&h&&l!==(l=e[2]||e[1]||"currentColor")&&B(s,"fill",l),112&h&&c!==(c=0!=e[6]?e[5]:e[4])&&B(s,"fill-opacity",c),128&h&&u!==(u=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(s,"transform",u)},d(e){e&&v(t),e&&v(s)}}}function OW(e){let t,i,n,r;return{c(){t=w("path"),B(t,"d",i=e[7][4]),B(t,"fill",n=e[1]||e[2]||"currentColor"),B(t,"transform",r=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)},m(e,i){y(e,t,i)},p(e,o){128&o&&i!==(i=e[7][4])&&B(t,"d",i),6&o&&n!==(n=e[1]||e[2]||"currentColor")&&B(t,"fill",n),128&o&&r!==(r=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(t,"transform",r)},d(e){e&&v(t)}}}function zW(e){let i,n=e[7][4]&&kW(e);return{c(){n&&n.c(),i=C()},m(e,t){n&&n.m(e,t),y(e,i,t)},p(e,[t]){e[7][4]?n?n.p(e,t):(n=kW(e),n.c(),n.m(i.parentNode,i)):n&&(n.d(1),n=null)},i:t,o:t,d(e){n&&n.d(e),e&&v(i)}}}function UW(e,t,i){let n,r,o,s,{class:a=""}=t,{id:l=""}=t,{style:c=""}=t,{icon:u}=t,{size:h=""}=t,{color:d=""}=t,{fw:p=!1}=t,{pull:f=""}=t,{scale:m=1}=t,{translateX:g=0}=t,{translateY:_=0}=t,{rotate:A=""}=t,{flip:y=!1}=t,{spin:v=!1}=t,{pulse:x=!1}=t,{primaryColor:b=""}=t,{secondaryColor:w=""}=t,{primaryOpacity:T=1}=t,{secondaryOpacity:E=.4}=t,{swapOpacity:C=!1}=t;return e.$$set=e=>{"class"in e&&i(11,a=e.class),"id"in e&&i(0,l=e.id),"style"in e&&i(12,c=e.style),"icon"in e&&i(13,u=e.icon),"size"in e&&i(14,h=e.size),"color"in e&&i(1,d=e.color),"fw"in e&&i(15,p=e.fw),"pull"in e&&i(16,f=e.pull),"scale"in e&&i(17,m=e.scale),"translateX"in e&&i(18,g=e.translateX),"translateY"in e&&i(19,_=e.translateY),"rotate"in e&&i(20,A=e.rotate),"flip"in e&&i(21,y=e.flip),"spin"in e&&i(22,v=e.spin),"pulse"in e&&i(23,x=e.pulse),"primaryColor"in e&&i(2,b=e.primaryColor),"secondaryColor"in e&&i(3,w=e.secondaryColor),"primaryOpacity"in e&&i(4,T=e.primaryOpacity),"secondaryOpacity"in e&&i(5,E=e.secondaryOpacity),"swapOpacity"in e&&i(6,C=e.swapOpacity)},e.$$.update=()=>{8192&e.$$.dirty&&i(7,n=u&&u.icon||[0,0,"",[],""]),12584960&e.$$.dirty&&i(8,r=FW([a,"svelte-fa",v&&"spin",x&&"pulse"]," ")),118784&e.$$.dirty&&i(9,o=function(e,t,i,n){let r,o,s,a,l,c="-.125em";return n&&(l="center",o="1.25em"),i&&(r=i),t&&("lg"==t?(a="1.33333em",s=".75em",c="-.225em"):a="xs"==t?".75em":"sm"==t?".875em":t.replace("x","em")),FW([FW({float:r,width:o,height:"1em","line-height":s,"font-size":a,"text-align":l,"vertical-align":c,"transform-origin":"center",overflow:"visible"}),e])}(c,h,f,p)),4063232&e.$$.dirty&&i(10,s=function(e,t,i,n,r,o=1,s="",a=""){let l=1,c=1;return r&&("horizontal"==r?l=-1:"vertical"==r?c=-1:l=c=-1),FW([`translate(${LW(t)*o}${s},${LW(i)*o}${s})`,`scale(${l*LW(e)},${c*LW(e)})`,n&&`rotate(${n}${a})`]," ")}(m,g,_,A,y,512))},[l,d,b,w,T,E,C,n,r,o,s,a,c,u,h,p,f,m,g,_,A,y,v,x]}var NW=class extends ge{constructor(e){super(),me(this,e,UW,zW,a,{class:11,id:0,style:12,icon:13,size:14,color:1,fw:15,pull:16,scale:17,translateX:18,translateY:19,rotate:20,flip:21,spin:22,pulse:23,primaryColor:2,secondaryColor:3,primaryOpacity:4,secondaryOpacity:5,swapOpacity:6})}},VW={exports:{}},jW=VW.exports=function(e,t){if(t||(t=16),void 0===e&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(t),n=2;i===1/0;n*=2)i=Math.log(Math.pow(2,e/n))/Math.log(t)*n;var r=i-Math.floor(i),o="";for(n=0;n=Math.pow(2,e)?jW(e,t):o};jW.rack=function(e,t,i){var n=function(n){var o=0;do{if(o++>10){if(!i)throw new Error("too many ID collisions, use more bits");e+=i}var s=jW(e,t)}while(Object.hasOwnProperty.call(r,s));return r[s]=n,s},r=n.hats={};return n.get=function(e){return n.hats[e]},n.set=function(e,t){return n.hats[e]=t,n},n.bits=e||128,n.base=t||16,n};var GW=VW.exports;const HW=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},QW={name:"Mapbox GL JS",value:"mapbox-gl"},$W=[QW,{name:"Maplibre GL JS",value:"maplibre-gl"},{name:"MapTiler SDK",value:"maptiler-sdk"}],ZW={google:[{name:"Google Maps",value:"google"}],leaflet:[{name:"Leaflet",value:"leaflet"}],tangram:[{name:"Tangram (Leaflet)",value:"tangram"}],"vector-gl":$W,"mapbox-gl":$W,"maplibre-gl":$W,"maptiler-sdk":$W},WW=(e,t)=>{let i=!1;return"mapbox-gl"!==e.type?ZW[e.type]:(e.url&&HW(e.url)?i=!0:t&&(i=Object.values(t).some(e=>HW(e?.url)||(e?.tiles??[]).some(e=>HW(e)))),i?[QW]:ZW[e.type])},qW=(e,t)=>{let i;const n=()=>window.removeEventListener("keydown",i),r=()=>{n(),t&&(i=i=>{!!t.alt==i.altKey&&!!t.shift==i.shiftKey&&!!t.control==(i.ctrlKey||i.metaKey)&&t.code==i.code&&(i.preventDefault(),t.callback?t.callback():e.click())},window.addEventListener("keydown",i))};return r(),{update:r,destroy:n}};function KW(e){let i,n,r,a,l,c,u,h,d,p,f,m=(e[2]??e[3])+"";return{c(){i=b("div"),n=b("div"),r=b("div"),l=E(),c=b("div"),u=b("div"),h=T(m),B(r,"class",a=g(e[1]?`caret-${e[4]}`:"caret-right")+" svelte-1q5ddxk"),B(n,"class","caret-container svelte-1q5ddxk"),B(u,"class","label svelte-1q5ddxk"),B(c,"class","label-container svelte-1q5ddxk"),B(i,"class",d=g(`toggle ${e[1]&&("up"===e[4]?"active-toggle-top":"active-toggle-bottom")}`)+" svelte-1q5ddxk")},m(t,o){y(t,i,o),A(i,n),A(n,r),A(i,l),A(i,c),A(c,u),A(u,h),p||(f=[S(i,"click",function(){s(e[0])&&e[0].apply(this,arguments)}),S(i,"keydown",e[5])],p=!0)},p(t,[n]){e=t,18&n&&a!==(a=g(e[1]?`caret-${e[4]}`:"caret-right")+" svelte-1q5ddxk")&&B(r,"class",a),12&n&&m!==(m=(e[2]??e[3])+"")&&M(h,m),18&n&&d!==(d=g(`toggle ${e[1]&&("up"===e[4]?"active-toggle-top":"active-toggle-bottom")}`)+" svelte-1q5ddxk")&&B(i,"class",d)},i:t,o:t,d(e){e&&v(i),p=!1,o(f)}}}function XW(e,t,i){let{openTopLevel:n}=t,{topLevelOpen:r}=t,{activeLabel:o}=t,{placeholder:s}=t,{direction:a}=t;return e.$$set=e=>{"openTopLevel"in e&&i(0,n=e.openTopLevel),"topLevelOpen"in e&&i(1,r=e.topLevelOpen),"activeLabel"in e&&i(2,o=e.activeLabel),"placeholder"in e&&i(3,s=e.placeholder),"direction"in e&&i(4,a=e.direction)},[n,r,o,s,a,()=>!1]}class JW extends ge{constructor(e){super(),me(this,e,XW,KW,a,{openTopLevel:0,topLevelOpen:1,activeLabel:2,placeholder:3,direction:4})}}function YW(e,t,i){const n=e.slice();return n[16]=t[i],n}function eq(e,t,i){const n=e.slice();return n[19]=t[i],n}function tq(e){let t,i;return t=new JW({props:{openTopLevel:e[7],topLevelOpen:e[4],activeLabel:e[6],direction:e[1],placeholder:e[2]}}),{c(){de(t.$$.fragment)},m(e,n){pe(t,e,n),i=!0},p(e,i){const n={};16&i&&(n.topLevelOpen=e[4]),64&i&&(n.activeLabel=e[6]),2&i&&(n.direction=e[1]),4&i&&(n.placeholder=e[2]),t.$set(n)},i(e){i||(le(t.$$.fragment,e),i=!0)},o(e){ce(t.$$.fragment,e),i=!1},d(e){fe(t,e)}}}function iq(e){let t,i,n=e[3],r=[];for(let t=0;t{o=null}),ae()),e[4]?s?s.p(e,r):(s=iq(e),s.c(),s.m(t,n)):s&&(s.d(1),s=null),"up"===e[1]?a?(a.p(e,r),2&r&&le(a,1)):(a=cq(e),a.c(),le(a,1),a.m(t,null)):a&&(se(),ce(a,1,1,()=>{a=null}),ae())},i(e){r||(le(o),le(a),r=!0)},o(e){ce(o),ce(a),r=!1},d(e){e&&v(t),o&&o.d(),s&&s.d(),a&&a.d()}}}function hq(e,t,i){let n,r,{options:o}=t,{activeValue:s}=t,{onSelect:a}=t,{direction:l="up"}=t,{placeholder:c=""}=t,u=!1,h=null;const d=e=>{i(5,h=h===e?null:e)},p=e=>{a(e),i(4,u=!1),i(5,h=null)};return e.$$set=e=>{"options"in e&&i(11,o=e.options),"activeValue"in e&&i(0,s=e.activeValue),"onSelect"in e&&i(12,a=e.onSelect),"direction"in e&&i(1,l=e.direction),"placeholder"in e&&i(2,c=e.placeholder)},e.$$.update=()=>{2048&e.$$.dirty&&i(3,n=o.map((e,t)=>{let i={...e,id:`${t}`};return i.options&&(i.options=i.options.map((e,i)=>({...e,id:`${t}-${i}`}))),i})),9&e.$$.dirty&&i(6,r=n.filter(e=>!e?.header).map(e=>e?.options?e?.options:e).flat().find(e=>e.value===s)?.label)},[s,l,c,n,u,h,r,()=>{if(i(4,u=!u),u){const e=n.filter(e=>e.options),t=e.find(e=>e.options.some(e=>e.value===s));t&&i(5,h=t.id)}else i(5,h=null)},d,()=>!1,p,o,a,e=>d(e.id),e=>p(e.value),e=>p(e.value)]}class dq extends ge{constructor(e){super(),me(this,e,hq,uq,a,{options:11,activeValue:0,onSelect:12,direction:1,placeholder:2})}}function pq(e){let t,i,n,r;return i=new dq({props:{options:e[4],activeValue:e[0].dropdownId,onSelect:e[1],direction:e[3]}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"id",n=`styles-dropdown-${e[2]}`)},m(e,n){y(e,t,n),pe(i,t,null),r=!0},p(e,[o]){const s={};16&o&&(s.options=e[4]),1&o&&(s.activeValue=e[0].dropdownId),2&o&&(s.onSelect=e[1]),8&o&&(s.direction=e[3]),i.$set(s),(!r||4&o&&n!==(n=`styles-dropdown-${e[2]}`))&&B(t,"id",n)},i(e){r||(le(i.$$.fragment,e),r=!0)},o(e){ce(i.$$.fragment,e),r=!1},d(e){e&&v(t),fe(i)}}}function fq(e,t,i){let n,{dropdownDisplayOptions:r}=t,{dropdownValue:o}=t,{onSelect:s}=t,{index:a}=t,l="up";return j(()=>{const e=document?.body?.clientHeight,t=document?.getElementById(`styles-dropdown-${a}`),n=t?.getBoundingClientRect(),r=n?.top;r&&e&&i(3,l=r{"dropdownDisplayOptions"in e&&i(5,r=e.dropdownDisplayOptions),"dropdownValue"in e&&i(0,o=e.dropdownValue),"onSelect"in e&&i(1,s=e.onSelect),"index"in e&&i(2,a=e.index)},e.$$.update=()=>{32&e.$$.dirty&&i(4,n=Object.entries(r).reduce((e,[t,i])=>{e.push({header:t});for(const t of i)"sublist"===t.type?e.push({label:t.text,options:t.presets.map(e=>({label:e.text,value:e.dropdownId}))}):e.push({label:t.text,value:t.dropdownId});return e},[]))},[o,s,a,l,n,r]}class mq extends ge{constructor(e){super(),me(this,e,fq,pq,a,{dropdownDisplayOptions:5,dropdownValue:0,onSelect:1,index:2})}}function gq(e,t,i){const n=e.slice();return n[31]=t[i],n[33]=i,n}function _q(e){let t,i,n,r,s,a,l,c,u;return{c(){t=b("div"),i=b("input"),r=E(),s=b("button"),a=T("Submit"),B(i,"placeholder",n="branch"===e[7].dropdownType?"enter a branch name":"enter a url to a style"),B(i,"class","svelte-146mfz9"),z(i,"input-error",e[8]),s.disabled=l=e[7]?.url===e[6],B(t,"class","custom-input svelte-146mfz9")},m(n,o){y(n,t,o),A(t,i),P(i,e[6]),A(t,r),A(t,s),A(s,a),c||(u=[S(i,"input",e[19]),S(i,"focus",e[13]),S(i,"blur",e[14]),_(qW.call(null,s,{code:"Enter",callback:e[12]})),S(s,"click",e[11])],c=!0)},p(e,t){128&t[0]&&n!==(n="branch"===e[7].dropdownType?"enter a branch name":"enter a url to a style")&&B(i,"placeholder",n),64&t[0]&&i.value!==e[6]&&P(i,e[6]),256&t[0]&&z(i,"input-error",e[8]),192&t[0]&&l!==(l=e[7]?.url===e[6])&&(s.disabled=l)},d(e){e&&v(t),c=!1,o(u)}}}function Aq(e){let t,i;return{c(){t=b("div"),i=T(e[8]),B(t,"class","error-message svelte-146mfz9")},m(e,n){y(e,t,n),A(t,i)},p(e,t){256&t[0]&&M(i,e[8])},d(e){e&&v(t)}}}function yq(e){let t,i=e[9].values.length&&vq(e);return{c(){i&&i.c(),t=C()},m(e,n){i&&i.m(e,n),y(e,t,n)},p(e,n){e[9].values.length?i?i.p(e,n):(i=vq(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null)},d(e){i&&i.d(e),e&&v(t)}}}function vq(e){let t,i,n,r,o=e[9].values,s=[];for(let t=0;t({label:e.name,value:e.value});function Sq(e,t,i){let n;const r=H();let o,s,{dropdownDisplayOptions:a}=t,{dropdownValue:l}=t,{rendererOptions:c}=t,{rendererValue:u}=t,{activeUrl:h}=t,{index:d}=t,{mapIdIndex:p}=t,f=l?.landmarks3D??!1,m=!1,g=null,_=!0;G(()=>{_=!1}),j(()=>{i(7,o=l),i(6,s=o.defaultText),A(o.url)});const A=e=>{const t=e=>{if(!_||!e||h!==e)return!1;const t=new RegExp("^(?:[a-z+]+:)?//","i");return e.includes("localhost")||!t.test(e)};t(e)&&setTimeout(()=>t(e)&&v(e,!0),3e3)},y=e=>{const t=["dropdownType","selected","defaultText"];let i={...Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)))};"branch"===o.dropdownType&&(i.branch=s),e&&(i.id=e.id??e?.style?.id,i.name=e.name??e?.style?.name),r("updateMapStore",{value:i})},v=async(e,t=!1)=>{let n;try{const i=await vu(e);if(i&&"object"==typeof i)return n=i,A(e),t?r("updateMapStore",{value:{style:n,isPolling:t}}):y({...o,style:n,url:e,isPolling:t}),{status:"200"}}catch(e){const{status:t,message:n}=e;return i(8,g=new Error(n)),{status:t}}},x=async e=>{const{status:t}=await v(e);"200"===t&&(i(7,o.url=e,o),A(e)),r("setUrl",{value:e})},b=async()=>{const{dropdownType:e,pattern:t}=o;let i="branch"===e?xu(t,s,o.id):s;if(o?.url!==i){if(i.includes("localhost")){const[e,t]=i.split("localhost");e||(i=`http://localhost${t}`)}x(i)}},w=e=>{let t=o?.selectedPrecompileOption??[];t=t.includes(e)?t.filter(t=>t!==e):t.concat([e]),i(7,o={...o,selectedPrecompileOption:t}),y(o)};return e.$$set=e=>{"dropdownDisplayOptions"in e&&i(0,a=e.dropdownDisplayOptions),"dropdownValue"in e&&i(1,l=e.dropdownValue),"rendererOptions"in e&&i(2,c=e.rendererOptions),"rendererValue"in e&&i(3,u=e.rendererValue),"activeUrl"in e&&i(17,h=e.activeUrl),"index"in e&&i(4,d=e.index),"mapIdIndex"in e&&i(5,p=e.mapIdIndex)},e.$$.update=()=>{2&e.$$.dirty[0]&&i(9,n=l?.precompile?l?.precompile?.options:null),64&e.$$.dirty[0]&&(e=>{g&&void 0!==e&&i(8,g=null)})(s),2&e.$$.dirty[0]&&(()=>{const e=Object.entries(l).every(e=>{const[t,i]=e;return"url"===t||!(!o||o[t]!==i)||void 0});if(e)return;const t=o?.dropdownType;i(7,o=l),i(8,g=null);const{dropdownType:n}=o;switch(n){case"preset":{const{type:e,url:t}=o;if(["google","leaflet"].includes(e)){y(o);break}x(t);break}case"branch":s&&"branch"===t&&b()}i(6,s=o.defaultText)})()},[a,l,c,u,d,p,s,o,g,n,r,b,()=>{m&&b()},()=>{m=!0},()=>{m=!1,g&&i(6,s=o.defaultText)},w,()=>{f=!f,i(7,o={...o,landmarks3D:f}),y(o)},h,e=>r("selectOption",{dropdownId:e}),function(){s=this.value,i(6,s)},e=>r("selectRenderer",{value:e}),e=>w(e.value)]}class Bq extends ge{constructor(e){super(),me(this,e,Sq,Eq,a,{dropdownDisplayOptions:0,dropdownValue:1,rendererOptions:2,rendererValue:3,activeUrl:17,index:4,mapIdIndex:5},null,[-1,-1])}}function Iq(e,t,i){const n=e.slice();return n[15]=t[i],n[17]=i,n}function Mq(e,t,i){const n=e.slice();return n[18]=t[i],n[20]=i,n}function Pq(e,t,i){const n=e.slice();return n[21]=t[i],n[17]=i,n}function Rq(e,t,i){const n=e.slice();return n[23]=t[i],n[20]=i,n}function Lq(e){let t,i,n,r=e[2].length&&Fq(),o=e[1].length&&kq(e),s=e[5].length&&zq(e);return{c(){r&&r.c(),t=E(),i=b("div"),o&&o.c(),n=E(),s&&s.c(),B(i,"class","controls svelte-1cgcqsn")},m(e,a){r&&r.m(e,a),y(e,t,a),y(e,i,a),o&&o.m(i,null),A(i,n),s&&s.m(i,null)},p(e,a){e[2].length?r||(r=Fq(),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),e[1].length?o?o.p(e,a):(o=kq(e),o.c(),o.m(i,n)):o&&(o.d(1),o=null),e[5].length?s?s.p(e,a):(s=zq(e),s.c(),s.m(i,null)):s&&(s.d(1),s=null)},d(e){r&&r.d(e),e&&v(t),e&&v(i),o&&o.d(),s&&s.d()}}}function Fq(e){let t;return{c(){t=b("div"),t.textContent="Custom actions:",B(t,"class","action-dropdown svelte-1cgcqsn")},m(e,i){y(e,t,i)},d(e){e&&v(t)}}}function kq(e){let t,i,n,r=e[1],s=[];for(let t=0;te[11].call(t))},m(r,o){y(r,t,o);for(let e=0;ei(13,s=e));let a,{mapId:c}=t,{mapIdIndex:u}=t,h=!1;st.subscribe(e=>{const t=u.split("-").pop();i(0,a=e?.[t])});const{customJs:d=[]}=s;let p=null;const f=e=>{if(u.split("-").pop(),!a||!e)return;e(a)()};return e.$$set=e=>{"mapId"in e&&i(9,c=e.mapId),"mapIdIndex"in e&&i(10,u=e.mapIdIndex)},e.$$.update=()=>{if(512&e.$$.dirty&&i(2,n=d.filter(e=>e.mapIds.includes(c))),4&e.$$.dirty&&i(1,r=n.filter(e=>"dropdown"===e.type)),4&e.$$.dirty&&i(5,o=n.filter(e=>"checkbox"===e.type)),2&e.$$.dirty&&(r.length||i(4,p=null)),1&e.$$.dirty&&a){a.isStyleLoaded?.()??!0?i(3,h=!0):a.on("style.load",()=>{i(3,h=!0)})}},[a,r,n,h,p,o,e=>{const{dropdown:t,option:i}=JSON.parse(e.target.value),n=r?.[t]?.options?.[i];if(!a||!n)return;const{script:o}=n;o(a)()},f,e=>{if("boolean"==typeof e)return e;if(!a||!e)return;return e(a)()},c,u,function(){p=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),i(4,p),i(1,r),i(2,n),i(9,c)},e=>f(e?.script)]}class Hq extends ge{constructor(e){super(),me(this,e,Gq,jq,a,{mapId:9,mapIdIndex:10})}}function Qq(e){let t,i;return t=new Bq({props:{dropdownValue:e[6],dropdownDisplayOptions:e[4],rendererOptions:e[7],rendererValue:e[2],index:e[0],mapIdIndex:e[1],activeUrl:e[3]}}),t.$on("setUrl",e[9]),t.$on("selectOption",e[10]),t.$on("selectRenderer",e[11]),t.$on("updateMapStore",e[12]),{c(){de(t.$$.fragment)},m(e,n){pe(t,e,n),i=!0},p(e,i){const n={};64&i&&(n.dropdownValue=e[6]),16&i&&(n.dropdownDisplayOptions=e[4]),128&i&&(n.rendererOptions=e[7]),4&i&&(n.rendererValue=e[2]),1&i&&(n.index=e[0]),2&i&&(n.mapIdIndex=e[1]),8&i&&(n.activeUrl=e[3]),t.$set(n)},i(e){i||(le(t.$$.fragment,e),i=!0)},o(e){ce(t.$$.fragment,e),i=!1},d(e){fe(t,e)}}}function $q(e){let t,i,n,r,o=e[5]&&Qq(e);return n=new Hq({props:{mapId:e[8],mapIdIndex:e[1]}}),{c(){t=b("div"),o&&o.c(),i=E(),de(n.$$.fragment),B(t,"class","map-style-input-wrapper svelte-7abtsv")},m(e,s){y(e,t,s),o&&o.m(t,null),A(t,i),pe(n,t,null),r=!0},p(e,[r]){e[5]?o?(o.p(e,r),32&r&&le(o,1)):(o=Qq(e),o.c(),le(o,1),o.m(t,i)):o&&(se(),ce(o,1,1,()=>{o=null}),ae());const s={};256&r&&(s.mapId=e[8]),2&r&&(s.mapIdIndex=e[1]),n.$set(s)},i(e){r||(le(o),le(n.$$.fragment,e),r=!0)},o(e){ce(o),ce(n.$$.fragment,e),r=!1},d(e){e&&v(t),o&&o.d(),fe(n)}}}function Zq(e,t,i){let n,r,o,s,a,l,{index:c}=t,{stylesheet:u}=t,{mapIdIndex:h}=t;it.subscribe(e=>({branchPatterns:n}=e));let d=[];et.subscribe(e=>{i(14,r=e.find(e=>e.index===c)),r&&(o=r.branch,s=r.renderer,a=r.type,i(3,l=r.url))});let p,f,m={},g=[],_=[];const A=()=>{let e;for(const t of g)if(t?.selected&&(e=t),"sublist"===t?.type)for(const i of t?.presets)i?.selected&&(e=i);if(e){switch(e=je(e),e.dropdownType){case"preset":e={...e,defaultText:""};break;case"branch":e={...e,defaultText:o??""};break;case"custom":e={...e,defaultText:l,url:l}}i(6,p=e)}},y=()=>{i(7,_=WW(p,u?.sources)),v()},v=()=>{let e=s;const t=WW(p,u?.sources).map(e=>e.value);e&&t.includes(e)||(e=t.includes(p.type)?p.type:t[0]),i(2,f=e)},x=()=>{(()=>{if(i(4,m={}),i(5,g=[]),d.length){const e=d.map((e,t)=>{let i,n;return(r.id===e.id||e?.presets?.some(e=>e.id===r.id))&&(i=r?.selectedPrecompileOption,n=!!r?.landmarks3D),{...e,dropdownType:"preset",selected:l===e?.url&&a===e?.type,dropdownId:GW(),...e.precompile&&{selectedPrecompileOption:i??e.precompile.options.default},...e.deckGlLayer&&{landmarks3D:n},..."sublist"===e.type&&{presets:e.presets.map(e=>({...e,dropdownType:"preset",selected:l===e?.url&&a===e?.type,dropdownId:GW(),...e.precompile&&{selectedPrecompileOption:i??e.precompile.options.default},...e.deckGlLayer&&{landmarks3D:n}}))}}});i(5,g=g.concat(e)),i(4,m.Presets=e.map(e=>({text:e.name,..."sublist"!==e.type&&{dropdownId:e.dropdownId},..."sublist"===e.type&&{type:"sublist",presets:e.presets.map(e=>({text:e.name,dropdownId:e.dropdownId}))}})),m)}if(n){let e=[];for(const t of n){let n,s;r.id!==t.id&&r.branchId!==t.id||(n=r?.selectedPrecompileOption,s=r?.landmarks3D);let c={name:t.name??t.id,type:"sublist",dropdownId:GW(),presets:[],...t.precompile&&{precompile:t.precompile,selectedPrecompileOption:n??t.precompile.options.default},...t?.deckGlLayer&&{deckGlLayer:t.deckGlLayer,landmarks3D:s}};if(t?.styles?.length){const e=t?.styles.map(e=>({screenshotName:`${t.name??t.id}: ${e} on`,name:`${t.name??t.id}: ${e} on...`,branchId:t?.id,id:e,branchStyle:e,type:t.type,dropdownType:"branch",selected:!(!o||xu(t.pattern,o,e)!==l||t.type!==a),pattern:t.pattern,dropdownId:GW(),...t?.projection&&{projection:t.projection},...t.precompile&&{precompile:t.precompile,selectedPrecompileOption:n??t.precompile.options.default},...t?.deckGlLayer&&{deckGlLayer:t.deckGlLayer,landmarks3D:s}}));c.presets=c.presets.concat(e)}e.push(c),i(5,g=g.concat(e)),i(4,m["Styles on a branch"]=e.map(e=>({text:e.name,..."sublist"!==e.type&&{dropdownId:e.dropdownId},..."sublist"===e.type&&{type:"sublist",presets:e.presets.map(e=>({text:e.name,dropdownId:e.dropdownId}))}})),m)}}const e=g.some(e=>!!e?.selected||e?.presets?.some(e=>!!e.selected)),t=[{name:"Fetch URL at...",dropdownType:"custom",selected:!e,type:"mapbox-gl",renderer:"mapbox-gl",dropdownId:GW()}];i(5,g=g.concat(t)),i(4,m.Custom=t.map(e=>({text:e.name,dropdownId:e.dropdownId})),m)})(),A()};tt.subscribe(e=>{d=e,x(),y()});let b;return e.$$set=e=>{"index"in e&&i(0,c=e.index),"stylesheet"in e&&i(13,u=e.stylesheet),"mapIdIndex"in e&&i(1,h=e.mapIdIndex)},e.$$.update=()=>{var t;16384&e.$$.dirty&&(!(t=r)||"branch"===p?.dropdownType&&!p?.url&&r.isPolling||t.type===p.type&&t.url===p.url||x()),4&e.$$.dirty&&(e=>{et.update(t=>t.map((t,i)=>i!==c?t:{...t,renderer:e}))})(f),16384&e.$$.dirty&&r&&i(8,b=r?.branchId??r?.id??null)},[c,h,f,l,m,g,p,_,b,e=>{i(6,p.url=e.detail.value,p),y()},e=>{const{dropdownId:t}=e.detail;i(5,g=g.reduce((e,i)=>{let n=i;"sublist"===n?.type?n.presets=n.presets.map(e=>({...e,selected:e.dropdownId===t})):n={...n,selected:i.dropdownId===t},n?.selected&&n?.selectedPrecompileOption&&(n.selectedPrecompileOption=n.precompile.options.default),n?.selected&&n?.landmarks3D&&(n.landmarks3D=!1);const r=n?.presets?.find(e=>e?.selected);return r&&r?.selectedPrecompileOption&&(n={...n,presets:n.presets.map(e=>(e?.selected&&(e.selectedPrecompileOption=e.precompile.options.default),{...e,precompile:e?.precompile}))}),r&&r?.landmarks3D&&(n={...n,presets:n.presets.map(e=>(e?.selected&&(e.landmarks3D=!1),{...e,precompile:e?.precompile}))}),e.push(n),e},[])),A(),y()},e=>{i(2,f=e.detail.value)},e=>{const{value:t}=e.detail;if(t.isPolling)et.update(e=>e.map((e,i)=>i===c?{...e,...t}:e));else{const e={...t,index:c,renderer:s};delete e.dropdownId,et.update(t=>t.map((t,i)=>i===c?e:t))}},u,r]}class Wq extends ge{constructor(e){super(),me(this,e,Zq,$q,a,{index:0,stylesheet:13,mapIdIndex:1})}}function qq(e){let t,i,n,r;const o=e[1].default,s=c(o,e,e[0],null);return{c(){t=b("button"),s&&s.c(),B(t,"class","svelte-d9bm20")},m(o,a){y(o,t,a),s&&s.m(t,null),i=!0,n||(r=S(t,"click",e[2]),n=!0)},p(e,[t]){s&&s.p&&(!i||1&t)&&d(s,o,e,e[0],i?h(o,e[0],t,null):p(e[0]),null)},i(e){i||(le(s,e),i=!0)},o(e){ce(s,e),i=!1},d(e){e&&v(t),s&&s.d(e),n=!1,r()}}}function Kq(e,t,i){let{$$slots:n={},$$scope:r}=t;return e.$$set=e=>{"$$scope"in e&&i(0,r=e.$$scope)},[r,n,function(t){Q.call(this,e,t)}]}class Xq extends ge{constructor(e){super(),me(this,e,Kq,qq,a,{})}}function Jq(e){let t,i,n,r,o,s,a,l,c,u,h,d,p;return a=new Xq({props:{$$slots:{default:[eK]},$$scope:{ctx:e}}}),a.$on("click",e[6]),u=new Xq({props:{$$slots:{default:[tK]},$$scope:{ctx:e}}}),u.$on("click",e[5]),{c(){t=b("div"),i=b("div"),n=T(e[2]),r=E(),o=b("div"),s=b("div"),de(a.$$.fragment),l=E(),c=b("div"),de(u.$$.fragment),B(i,"class","map-state svelte-1nshzal"),B(s,"class","svelte-1nshzal"),B(c,"class","svelte-1nshzal"),B(o,"class","location-actions svelte-1nshzal"),B(t,"class","map-state-container svelte-1nshzal")},m(f,m){y(f,t,m),A(t,i),A(i,n),A(t,r),A(t,o),A(o,s),pe(a,s,null),A(o,l),A(o,c),pe(u,c,null),h=!0,d||(p=S(i,"click",e[5]),d=!0)},p(e,t){(!h||4&t)&&M(n,e[2]);const i={};2097152&t&&(i.$$scope={dirty:t,ctx:e}),a.$set(i);const r={};2097153&t&&(r.$$scope={dirty:t,ctx:e}),u.$set(r)},i(e){h||(le(a.$$.fragment,e),le(u.$$.fragment,e),h=!0)},o(e){ce(a.$$.fragment,e),ce(u.$$.fragment,e),h=!1},d(e){e&&v(t),fe(a),fe(u),d=!1,p()}}}function Yq(e){let i,n,r,s,a;return{c(){i=b("div"),n=b("input"),r=b("label"),r.textContent="enter zoom/lat/lng[/pitch/bearing]",R(n,"height","18px"),B(n,"type","text"),B(r,"class","input-label svelte-1nshzal"),B(i,"class","state-record svelte-1nshzal")},m(t,o){y(t,i,o),A(i,n),P(n,e[3]),e[17](n),A(i,r),s||(a=[S(n,"input",e[15]),S(n,"keydown",e[16]),S(n,"focus",nK)],s=!0)},p(e,t){8&t&&n.value!==e[3]&&P(n,e[3])},i:t,o:t,d(t){t&&v(i),e[17](null),s=!1,o(a)}}}function eK(e){let t;return{c(){t=T("change")},m(e,i){y(e,t,i)},d(e){e&&v(t)}}}function tK(e){let t,i=e[0]?"copied":"copy";return{c(){t=T(i)},m(e,i){y(e,t,i)},p(e,n){1&n&&i!==(i=e[0]?"copied":"copy")&&M(t,i)},d(e){e&&v(t)}}}function iK(e){let t,i,n,r;const o=[Yq,Jq],s=[];function a(e,t){return e[1]?0:1}return i=a(e),n=s[i]=o[i](e),{c(){t=b("div"),n.c()},m(e,n){y(e,t,n),s[i].m(t,null),r=!0},p(e,[r]){let l=i;i=a(e),i===l?s[i].p(e,r):(se(),ce(s[l],1,1,()=>{s[l]=null}),ae(),n=s[i],n?n.p(e,r):(n=s[i]=o[i](e),n.c()),le(n,1),n.m(t,null))},i(e){r||(le(n),r=!0)},o(e){ce(n),r=!1},d(e){e&&v(t),s[i].d()}}}const nK=e=>e.target.select();function rK(e,t,i){let n,r,{bearing:o}=t,{center:s}=t,{pitch:a}=t,{zoom:l}=t;const c=H();let u,h=!1,d=!1,p="",f="";const m=()=>{i(1,d=!1)},g=()=>{i(1,d=!1),i(0,h=!1);const[e,t,n,r,o]=f.split("/"),s=(({zoom:e,lat:t,lng:i,pitch:n,bearing:r})=>{let o=!0;return[e,t,i,n,r].filter(Boolean).every(e=>!isNaN(Number(e)))||(o=!1),(+e<0||+e>24)&&(o=!1),(+t<-90||+t>90)&&(o=!1),(+i<-180||+i>180)&&(o=!1),void 0!==n&&(+n<0||+n>85)&&(o=!1),void 0!==r&&isNaN(+r)&&(o=!1),o})({zoom:e,lat:t,lng:n,pitch:r,bearing:o});if(!s)return;const a={mapStateUpdateOrigin:"controls"};void 0!==e&&(a.zoom=+e),void 0!==t&&void 0!==n&&(a.center={lng:+n,lat:+t}),void 0!==r&&(a.pitch=+r),void 0!==o&&(a.bearing=+o),c("mapState",{options:a})};return e.$$set=e=>{"bearing"in e&&i(9,o=e.bearing),"center"in e&&i(10,s=e.center),"pitch"in e&&i(11,a=e.pitch),"zoom"in e&&i(12,l=e.zoom)},e.$$.update=()=>{1024&e.$$.dirty&&i(14,n=s.lat),1024&e.$$.dirty&&i(13,r=s.lng),31232&e.$$.dirty&&((e,t,n,r,o)=>{let s=[lt(n,2),lt(e,5),lt(t,5)];(r||o)&&(s.push(lt(r,1)),s.push(lt(o,1))),i(2,p=s.join("/")),i(0,h=!1)})(n,r,l,a,o)},[h,d,p,f,u,()=>{i(0,h=!0),navigator.clipboard.writeText(p)},async()=>{i(1,d=!0),i(3,f=p),await(J(),K),u.focus()},m,g,o,s,a,l,r,n,function(){f=this.value,i(3,f)},e=>{"Enter"===e.key&&g(),"Escape"===e.key&&m()},function(e){Z[e?"unshift":"push"](()=>{u=e,i(4,u)})}]}class oK extends ge{constructor(e){super(),me(this,e,rK,iK,a,{bearing:9,center:10,pitch:11,zoom:12})}}function sK(e){let t,i,n,r,o,a,l,c,u,h,d,p,f,m=!e[8]&&Object.keys(e[6]).length;n=new NW({props:{icon:PW}}),u=new Wq({props:{index:e[0],stylesheet:e[4],mapIdIndex:e[5]}});let g=m&&aK(e);return{c(){t=b("div"),i=b("button"),de(n.$$.fragment),r=E(),o=b("div"),a=T(e[1]),l=E(),c=b("div"),de(u.$$.fragment),h=E(),g&&g.c(),B(i,"class","close-button svelte-1mnw17n"),i.disabled=e[3],B(o,"class","map-name svelte-1mnw17n"),B(c,"class","options-container svelte-1mnw17n"),B(t,"class","map-label svelte-1mnw17n")},m(m,_){y(m,t,_),A(t,i),pe(n,i,null),A(t,r),A(t,o),A(o,a),A(t,l),A(t,c),pe(u,c,null),A(c,h),g&&g.m(c,null),d=!0,p||(f=S(i,"click",function(){s(e[2])&&e[2].apply(this,arguments)}),p=!0)},p(t,n){e=t,(!d||8&n)&&(i.disabled=e[3]),(!d||2&n)&&M(a,e[1]);const r={};1&n&&(r.index=e[0]),16&n&&(r.stylesheet=e[4]),32&n&&(r.mapIdIndex=e[5]),u.$set(r),320&n&&(m=!e[8]&&Object.keys(e[6]).length),m?g?(g.p(e,n),320&n&&le(g,1)):(g=aK(e),g.c(),le(g,1),g.m(c,null)):g&&(se(),ce(g,1,1,()=>{g=null}),ae())},i(e){d||(le(n.$$.fragment,e),le(u.$$.fragment,e),le(g),d=!0)},o(e){ce(n.$$.fragment,e),ce(u.$$.fragment,e),ce(g),d=!1},d(e){e&&v(t),fe(n),fe(u),g&&g.d(),p=!1,f()}}}function aK(e){let t,n,r;const o=[e[6]];let s={};for(let e=0;e{n=null}),ae())},i(e){i||(le(n),i=!0)},o(e){ce(n),i=!1},d(e){n&&n.d(e),e&&v(t)}}}function cK(e,t,i){let n,r,o,s;l(e,nt,e=>i(7,o=e)),l(e,rt,e=>i(8,s=e));let a,{index:c}=t,{name:u}=t,{onClose:h}=t,{disableClose:d}=t,{mapState:p}=t,{stylesheet:f}=t,{mapIdIndex:m}=t;return e.$$set=e=>{"index"in e&&i(0,c=e.index),"name"in e&&i(1,u=e.name),"onClose"in e&&i(2,h=e.onClose),"disableClose"in e&&i(3,d=e.disableClose),"mapState"in e&&i(9,p=e.mapState),"stylesheet"in e&&i(4,f=e.stylesheet),"mapIdIndex"in e&&i(5,m=e.mapIdIndex)},e.$$.update=()=>{512&e.$$.dirty&&i(6,({showBoundaries:n,showCollisions:r,...a}=p),a)},[c,u,h,d,f,m,a,o,s,p,function(t){Q.call(this,e,t)}]}class uK extends ge{constructor(e){super(),me(this,e,cK,lK,a,{index:0,name:1,onClose:2,disableClose:3,mapState:9,stylesheet:4,mapIdIndex:5})}}const hK=(e,t)=>{const i=t.some(({type:e})=>"google"===e);return i?e.zoom<12?35:45:85},dK=(e,t)=>{const i={...e};if((e=>e.some(({type:e})=>"google"===e))(t)){const n=hK(e,t);i.pitch>n&&(i.pitch=n)}return i};var pK={exports:{}};!function(e,t){var i="__lodash_hash_undefined__",n=9007199254740991,r="[object Arguments]",o="[object Array]",s="[object Boolean]",a="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",h="[object Number]",d="[object Object]",p="[object Promise]",f="[object RegExp]",m="[object Set]",g="[object String]",_="[object Symbol]",A="[object WeakMap]",y="[object ArrayBuffer]",v="[object DataView]",x=/^\[object .+?Constructor\]$/,b=/^(?:0|[1-9]\d*)$/,w={};w["[object Float32Array]"]=w["[object Float64Array]"]=w["[object Int8Array]"]=w["[object Int16Array]"]=w["[object Int32Array]"]=w["[object Uint8Array]"]=w["[object Uint8ClampedArray]"]=w["[object Uint16Array]"]=w["[object Uint32Array]"]=!0,w[r]=w[o]=w[y]=w[s]=w[v]=w[a]=w[l]=w[c]=w[u]=w[h]=w[d]=w[f]=w[m]=w[g]=w[A]=!1;var T="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,E="object"==typeof self&&self&&self.Object===Object&&self,C=T||E||Function("return this")(),S=t&&!t.nodeType&&t,B=S&&e&&!e.nodeType&&e,I=B&&B.exports===S,M=I&&T.process,P=function(){try{return M&&M.binding&&M.binding("util")}catch(e){}}(),R=P&&P.isTypedArray;function L(e,t){for(var i=-1,n=null==e?0:e.length;++ia))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var u=-1,h=!0,d=2&i?new _e:void 0;for(o.set(e,t),o.set(t,e);++u-1},me.prototype.set=function(e,t){var i=this.__data__,n=ve(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this},ge.prototype.clear=function(){this.size=0,this.__data__={hash:new fe,map:new(ie||me),string:new fe}},ge.prototype.delete=function(e){var t=Be(this,e).delete(e);return this.size-=t?1:0,t},ge.prototype.get=function(e){return Be(this,e).get(e)},ge.prototype.has=function(e){return Be(this,e).has(e)},ge.prototype.set=function(e,t){var i=Be(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this},_e.prototype.add=_e.prototype.push=function(e){return this.__data__.set(e,i),this},_e.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new me,this.size=0},Ae.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Ae.prototype.get=function(e){return this.__data__.get(e)},Ae.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.set=function(e,t){var i=this.__data__;if(i instanceof me){var n=i.__data__;if(!ie||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new ge(n)}return i.set(e,t),this.size=i.size,this};var Me=J?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,r=0,o=[];++i-1&&e%1==0&&e-1&&e%1==0&&e<=n}function Ne(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}var je=R?function(e){return function(t){return e(t)}}(R):function(e){return Ve(e)&&Ue(e.length)&&!!w[xe(e)]};function He(e){return null!=(t=e)&&Ue(t.length)&&!ze(t)?ye(e):Ee(e);var t}e.exports=function(e,t){return we(e,t)}}(pK,pK.exports);var fK=pK.exports;function mK(e){let t,i=(e[0].name??e[0].id)+"";return{c(){t=T(i)},m(e,i){y(e,t,i)},p(e,n){1&n&&i!==(i=(e[0].name??e[0].id)+"")&&M(t,i)},d(e){e&&v(t)}}}function gK(e){let t,i,n,r,o,s,a=(e[0].screenshotName??e[0].name??e[0].id)+"",l=e[0].branch+"";return{c(){t=b("div"),i=T(a),n=E(),r=b("span"),o=T(" "),s=T(l),B(r,"class","screenshot-label-bold svelte-14y9jxq"),B(t,"class","screenshot-text svelte-14y9jxq")},m(e,a){y(e,t,a),A(t,i),A(t,n),A(t,r),A(r,o),A(r,s)},p(e,t){1&t&&a!==(a=(e[0].screenshotName??e[0].name??e[0].id)+"")&&M(i,a),1&t&&l!==(l=e[0].branch+"")&&M(s,l)},d(e){e&&v(t)}}}function _K(e){let t,n,r;const o=[{onMapMount:e[12]},e[8],e[9]];var s=e[7];function a(e){let t={};for(let e=0;e{fe(e,1)}),ae()}s?(n=U(s,a()),n.$on("mapMove",e[11]),de(n.$$.fragment),le(n.$$.fragment,1),pe(n,t,null)):n=null}else s&&n.$set(l);(!r||4&i)&&z(t,"highlight-diff",e[2])},i(e){r||(n&&le(n.$$.fragment,e),r=!0)},o(e){n&&ce(n.$$.fragment,e),r=!1},d(e){e&&v(t),n&&fe(n)}}}function AK(e){let t,i,n,r,o;return i=new uK({props:{index:e[0].index,mapIdIndex:e[6],name:e[0].name,onClose:e[10],disableClose:e[1]<=1,mapState:e[9],stylesheet:e[4]}}),i.$on("mapState",e[11]),{c(){t=b("div"),de(i.$$.fragment),B(t,"id",n=e[0].id),B(t,"class",r=g("map-label-container "+(2===e[1]?`map-label-container-${e[0].index}`:""))+" svelte-14y9jxq"),B(t,"style",e[3])},m(e,n){y(e,t,n),pe(i,t,null),o=!0},p(e,s){const a={};1&s&&(a.index=e[0].index),64&s&&(a.mapIdIndex=e[6]),1&s&&(a.name=e[0].name),2&s&&(a.disableClose=e[1]<=1),512&s&&(a.mapState=e[9]),16&s&&(a.stylesheet=e[4]),i.$set(a),(!o||1&s&&n!==(n=e[0].id))&&B(t,"id",n),(!o||3&s&&r!==(r=g("map-label-container "+(2===e[1]?`map-label-container-${e[0].index}`:""))+" svelte-14y9jxq"))&&B(t,"class",r),(!o||8&s)&&B(t,"style",e[3])},i(e){o||(le(i.$$.fragment,e),o=!0)},o(e){ce(i.$$.fragment,e),o=!1},d(e){e&&v(t),fe(i)}}}function yK(e){let i,n,r,o,s,l=e[5],c=`${e[1]}-${e[0].index}`;function u(e,t){return e[0]?.branch?gK:mK}let h=u(e),d=h(e),p=_K(e),f=AK(e);return{c(){i=b("div"),n=b("div"),d.c(),r=E(),p.c(),o=E(),f.c(),B(n,"class","screenshot-label-transparent svelte-14y9jxq"),B(i,"class","map-container svelte-14y9jxq")},m(e,t){y(e,i,t),A(i,n),d.m(n,null),A(i,r),p.m(i,null),A(i,o),f.m(i,null),s=!0},p(e,[r]){h===(h=u(e))&&d?d.p(e,r):(d.d(1),d=h(e),d&&(d.c(),d.m(n,null))),32&r&&a(l,l=e[5])?(se(),ce(p,1,1,t),ae(),p=_K(e),p.c(),le(p,1),p.m(i,o)):p.p(e,r),3&r&&a(c,c=`${e[1]}-${e[0].index}`)?(se(),ce(f,1,1,t),ae(),f=AK(e),f.c(),le(f,1),f.m(i,null)):f.p(e,r)},i(e){s||(le(p),le(f),s=!0)},o(e){ce(p),ce(f),s=!1},d(e){e&&v(i),d.d(),p.d(e),f.d(e)}}}function vK(e,t,n){let r,o,s,a,c,u;const h=["map","numberOfMaps","highlightDifferences","labelStyle"];let d,p,g,_=m(t,h);l(e,rt,e=>n(17,d=e)),l(e,it,e=>n(18,p=e)),l(e,ot,e=>n(15,g=e));let{map:A}=t,{numberOfMaps:y}=t,{highlightDifferences:v=!1}=t,{labelStyle:x=""}=t;const b=H();let w,T={},E={};const C=e=>{switch(e){case"google":n(7,w=fu);break;case"leaflet":n(7,w=xW);break;case"tangram":n(7,w=EW);break;default:n(7,w=_W),n(8,T.mapRenderer=e,T)}};return e.$$set=e=>{t=i(i({},t),f(e)),n(23,_=m(t,h)),"map"in e&&n(0,A=e.map),"numberOfMaps"in e&&n(1,y=e.numberOfMaps),"highlightDifferences"in e&&n(2,v=e.highlightDifferences),"labelStyle"in e&&n(3,x=e.labelStyle)},e.$$.update=()=>{32769&e.$$.dirty&&(r=g?.[A.index]??{}),1&e.$$.dirty&&n(6,o=`${A.id}-${A.index}`),1&e.$$.dirty&&n(14,s=A?.selectedPrecompileOption),1&e.$$.dirty&&n(13,a=A?.landmarks3D),17&e.$$.dirty&&(fK(E,A?.style)||n(4,E=A?.style)),1&e.$$.dirty&&n(5,c=A.renderer),24658&e.$$.dirty&&((e,t)=>{const i={mapboxKey:p.mapboxGlAccessToken,maptilerKey:p.maptilerApiKey};n(8,T={id:e,mapStyle:{...A,url:_u(A.url,i)},numberOfMaps:t}),C(c)})(o,y),32&e.$$.dirty&&C(c),n(9,u=(e=>{if(d)return e;const{bearing:t,center:i,pitch:n,zoom:o,...s}=e;let a={...s,...{bearing:t,center:i,pitch:n,zoom:o,...r}};return a=dK(a,[A]),a})(_))},[A,y,v,x,E,c,o,w,T,u,()=>{et.update(e=>e.filter((e,t)=>t!==A.index).map((e,t)=>({...e,index:t}))),d||ot.update(e=>e.filter((e,t)=>t!==A.index))},e=>{if(d)b("mapMove",e.detail);else{const{options:t}=e.detail;ot.update(e=>e.map((e,i)=>i===A.index?t:e))}},e=>{st.update(t=>({...t,[A.index]:e}))},a,s,g]}class xK extends ge{constructor(e){super(),me(this,e,vK,yK,a,{map:0,numberOfMaps:1,highlightDifferences:2,labelStyle:3})}}function bK(e,t,i){const n=e.slice();return n[1]=t[i],n}function wK(e,t,i){const n=e.slice();return n[10]=t[i],n}function TK(e){let t,n,r;const o=[{map:e[10]},e[0],{numberOfMaps:e[2]}];let s={};for(let e=0;ece(o[e],1,1,()=>{o[e]=null});return{c(){t=b("div");for(let e=0;ece(s[e],1,1,()=>{s[e]=null});return{c(){t=b("div"),i=b("div");for(let e=0;e{"maps"in e&&i(1,n=e.maps),"mapState"in e&&i(0,r=e.mapState)},e.$$.update=()=>{2&e.$$.dirty&&i(2,s=n.length),4&e.$$.dirty&&i(4,l=a.includes(s)?"row":"column"),2&e.$$.dirty&&(e=>{const t=Math.round(Math.sqrt(s)),n=Math.floor(s/t);let r=je(e),a=[];for(;r.length;)a.push(r.slice(0,n)),r=r.slice(n);i(3,o=a)})(n)},[r,n,s,o,l,function(t){Q.call(this,e,t)}]}class BK extends ge{constructor(e){super(),me(this,e,SK,CK,a,{maps:1,mapState:0})}}function IK(e,t,i){const n=e.slice();return n[3]=t[i],n}function MK(e){let t,n,r,o;const s=[{map:e[3]},e[1],{labelStyle:"position: absolute; margin-top: 48px; left: 0; right: 0; bottom: unset; max-width: unset;"},{numberOfMaps:e[0].length}];let a={};for(let e=0;ece(o[e],1,1,()=>{o[e]=null});return{c(){t=b("div"),i=b("div");for(let e=0;e{"maps"in e&&i(0,n=e.maps),"mapState"in e&&i(1,r=e.mapState)},[n,r,function(t){Q.call(this,e,t)}]}class LK extends ge{constructor(e){super(),me(this,e,RK,PK,a,{maps:0,mapState:1})}}function FK(e,t,i){const n=e.slice();return n[15]=t[i],n}function kK(e){let t,n,r,o;const s=[{map:e[15]},e[1],{numberOfMaps:e[0].length},{highlightDifferences:1===e[15].index&&e[1]?.showDiff},{labelStyle:0===e[15].index?e[7]:e[6]}];let a={};for(let e=0;ece(u[e],1,1,()=>{u[e]=null});return{c(){t=b("div");for(let e=0;ee[14].call(t)),z(t,"dragging",e[4])},m(o,c){y(o,t,c);for(let e=0;e{e.source===i.contentWindow&&t()})):(i.src="about:blank",i.onload=()=>{r=S(i.contentWindow,"resize",t),t()}),A(e,i),()=>{(n||r&&i.contentWindow)&&r(),v(i)}}(t,e[14].bind(t)),s=!0,a||(l=[S(n,"mousedown",e[8]),S(t,"mousemove",e[10]),S(t,"mouseup",e[9])],a=!0)},p(e,[r]){if(239&r){let n;for(c=e[0],n=0;n{"maps"in e&&i(0,c=e.maps),"mapState"in e&&i(1,u=e.mapState)},e.$$.update=()=>{8&e.$$.dirty&&i(2,d=a/2),12&e.$$.dirty&&i(11,n=a-d),2056&e.$$.dirty&&i(12,r=a-n),4096&e.$$.dirty&&i(7,o=`right: unset; margin-right:unset; left:0; margin-left:1em; max-width:calc(${r}px - 6em)`),2048&e.$$.dirty&&i(6,s=`max-width:calc(${n}px - 6em)`)},[c,u,d,a,h,l,s,o,()=>i(4,h=!0),()=>i(4,h=!1),e=>{h&&0!==e.clientX&&i(2,d=e.clientX-OK/2)},n,r,function(t){Q.call(this,e,t)},function(){l=this.clientHeight,a=this.clientWidth,i(5,l),i(3,a)}]}class UK extends ge{constructor(e){super(),me(this,e,zK,DK,a,{maps:0,mapState:1})}}function NK(e){let t,n;const r=[{map:e[8]},e[6],{numberOfMaps:e[7]},{labelStyle:"position: fixed;"}];let o={};for(let e=0;e{V=null}),ae()),(!z||3&t&&n!==(n=`height:${e[0]}px; width:${e[1]}px`))&&B(i,"style",n),4&t&&I(h.value)!==e[2]&&P(h,e[2]),8&t&&I(x.value)!==e[3]&&P(x,e[3]),(!z||12&t&&L!==(L=!e[3]||!e[2]))&&(M.disabled=L),(!z||3&t&&O!==(O="100%"===e[0]&&"100%"===e[1]))&&(k.disabled=O)},i(e){z||(le(V),z=!0)},o(e){ce(V),z=!1},d(e){e&&v(t),V&&V.d(),U=!1,o(N)}}}function jK(e,t,i){let n,r,{maps:o}=t,{mapState:s}=t;const a=H();let l=s.height||"100%",c=s.width||"100%",u=s.height||"",h=s.width||"",d=!1,p=!1,f=s;delete f.width,delete f.height;const m=()=>{i(0,l=u),i(1,c=h),a("mapSetDimensions",{options:{height:l,width:c}})};return e.$$set=e=>{"maps"in e&&i(12,o=e.maps),"mapState"in e&&i(13,s=e.mapState)},e.$$.update=()=>{if(4096&e.$$.dirty&&i(8,n=o[0]),4096&e.$$.dirty&&i(7,r=o?.length??0),8192&e.$$.dirty){let{width:e,height:t,...n}=s;i(6,f=n)}},[l,c,u,h,d,p,f,r,n,()=>{(d||p)&&!(!h||!u)&&m()},m,()=>{i(0,l="100%"),i(1,c="100%"),i(2,u=""),i(3,h=""),a("mapSetDimensions",{options:{height:null,width:null}})},o,s,function(t){Q.call(this,e,t)},function(){u=I(this.value),i(2,u)},()=>i(4,d=!0),()=>i(4,d=!1),function(){h=I(this.value),i(3,h)},()=>i(5,p=!0),()=>i(5,p=!1)]}class GK extends ge{constructor(e){super(),me(this,e,jK,VK,a,{maps:12,mapState:13})}}function HK(e){let t,i,n;var r=e[2];function o(e){return{props:{maps:e[0],mapState:e[1]}}}return r&&(t=U(r,o(e)),t.$on("mapMove",e[3]),t.$on("mapSetDimensions",e[4])),{c(){t&&de(t.$$.fragment),i=C()},m(e,r){t&&pe(t,e,r),y(e,i,r),n=!0},p(e,[n]){const s={};if(1&n&&(s.maps=e[0]),2&n&&(s.mapState=e[1]),4&n&&r!==(r=e[2])){if(t){se();const e=t;ce(e.$$.fragment,1,0,()=>{fe(e,1)}),ae()}r?(t=U(r,o(e)),t.$on("mapMove",e[3]),t.$on("mapSetDimensions",e[4]),de(t.$$.fragment),le(t.$$.fragment,1),pe(t,i.parentNode,i)):t=null}else r&&t.$set(s)},i(e){n||(t&&le(t.$$.fragment,e),n=!0)},o(e){t&&ce(t.$$.fragment,e),n=!1},d(e){e&&v(i),t&&fe(t,e)}}}function QK(e,t,i){let n,r,{maps:o}=t,{mapState:s}=t,{viewMode:a}=t;const l=H();let c;const u=e=>{l("setDimensions",{...e.detail.options})};return e.$$set=e=>{"maps"in e&&i(0,o=e.maps),"mapState"in e&&i(1,s=e.mapState),"viewMode"in e&&i(5,a=e.viewMode)},e.$$.update=()=>{2&e.$$.dirty&&i(7,n=s.height),2&e.$$.dirty&&i(6,r=s.width),32&e.$$.dirty&&(e=>{switch(e){case"phone":i(2,c=LK);break;case"mirror":i(2,c=BK);break;case"responsive":i(2,c=GK);break;default:i(2,c=UK)}})(a),224&e.$$.dirty&&"responsive"!==a&&(n||r)&&u({detail:{options:{height:null,width:null}}})},[o,s,c,e=>{l("mapState",{options:e.detail.options})},u,a,r,n]}class $K extends ge{constructor(e){super(),me(this,e,QK,HK,a,{maps:0,mapState:1,viewMode:5})}}var ZK={exports:{}}; + */const CW={prefix:"fas",iconName:"compress",icon:[448,512,[],"f066","M160 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96zM32 320c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM352 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 320c-17.7 0-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-96 0z"]},SW={prefix:"fas",iconName:"camera",icon:[512,512,[62258,"camera-alt"],"f030","M149.1 64.8L138.7 96 64 96C28.7 96 0 124.7 0 160L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64l-74.7 0L362.9 64.8C356.4 45.2 338.1 32 317.4 32L194.6 32c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"]},BW={prefix:"fas",iconName:"download",icon:[512,512,[],"f019","M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 242.7-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7 288 32zM64 352c-35.3 0-64 28.7-64 64l0 32c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-32c0-35.3-28.7-64-64-64l-101.5 0-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352 64 352zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"]},IW={prefix:"fas",iconName:"link",icon:[640,512,[128279,"chain"],"f0c1","M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"]},MW={prefix:"fas",iconName:"plus",icon:[448,512,[10133,61543,"add"],"2b","M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"]},PW={prefix:"fas",iconName:"expand",icon:[448,512,[],"f065","M32 32C14.3 32 0 46.3 0 64l0 96c0 17.7 14.3 32 32 32s32-14.3 32-32l0-64 64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 96c0 17.7 14.3 32 32 32l96 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-64 0 0-64zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 0 64c0 17.7 14.3 32 32 32s32-14.3 32-32l0-96c0-17.7-14.3-32-32-32l-96 0zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 64-64 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l96 0c17.7 0 32-14.3 32-32l0-96z"]},RW={prefix:"fas",iconName:"xmark",icon:[384,512,[128473,10005,10006,10060,215,"close","multiply","remove","times"],"f00d","M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"]},LW={prefix:"fas",iconName:"link-slash",icon:[640,512,["chain-broken","chain-slash","unlink"],"f127","M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM406.6 416.4L220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3zm-290-228.5L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9z"]},FW=parseFloat;function kW(e,t=";"){let i;if(Array.isArray(e))i=e.filter(e=>e);else{i=[];for(const t in e)e[t]&&i.push(`${t}:${e[t]}`)}return i.join(t)}function DW(e){let t,i,n,r,o,s,a;function l(e,t){return"string"==typeof e[7][4]?zW:OW}let c=l(e),u=c(e);return{c(){t=w("svg"),i=w("g"),n=w("g"),u.c(),B(n,"transform",e[10]),B(i,"transform",r=`translate(${e[7][0]/2} ${e[7][1]/2})`),B(i,"transform-origin",o=e[7][0]/4+" 0"),B(t,"id",e[0]),B(t,"class",s=g(e[8])+" svelte-1cj2gr0"),B(t,"style",e[9]),B(t,"viewBox",a=`0 0 ${e[7][0]} ${e[7][1]}`),B(t,"aria-hidden","true"),B(t,"role","img"),B(t,"xmlns","http://www.w3.org/2000/svg")},m(e,r){y(e,t,r),A(t,i),A(i,n),u.m(n,null)},p(e,h){c===(c=l(e))&&u?u.p(e,h):(u.d(1),u=c(e),u&&(u.c(),u.m(n,null))),1024&h&&B(n,"transform",e[10]),128&h&&r!==(r=`translate(${e[7][0]/2} ${e[7][1]/2})`)&&B(i,"transform",r),128&h&&o!==(o=e[7][0]/4+" 0")&&B(i,"transform-origin",o),1&h&&B(t,"id",e[0]),256&h&&s!==(s=g(e[8])+" svelte-1cj2gr0")&&B(t,"class",s),512&h&&B(t,"style",e[9]),128&h&&a!==(a=`0 0 ${e[7][0]} ${e[7][1]}`)&&B(t,"viewBox",a)},d(e){e&&v(t),u.d()}}}function OW(e){let t,i,n,r,o,s,a,l,c,u;return{c(){t=w("path"),s=w("path"),B(t,"d",i=e[7][4][0]),B(t,"fill",n=e[3]||e[1]||"currentColor"),B(t,"fill-opacity",r=0!=e[6]?e[4]:e[5]),B(t,"transform",o=`translate(${e[7][0]/-2} ${e[7][1]/-2})`),B(s,"d",a=e[7][4][1]),B(s,"fill",l=e[2]||e[1]||"currentColor"),B(s,"fill-opacity",c=0!=e[6]?e[5]:e[4]),B(s,"transform",u=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)},m(e,i){y(e,t,i),y(e,s,i)},p(e,h){128&h&&i!==(i=e[7][4][0])&&B(t,"d",i),10&h&&n!==(n=e[3]||e[1]||"currentColor")&&B(t,"fill",n),112&h&&r!==(r=0!=e[6]?e[4]:e[5])&&B(t,"fill-opacity",r),128&h&&o!==(o=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(t,"transform",o),128&h&&a!==(a=e[7][4][1])&&B(s,"d",a),6&h&&l!==(l=e[2]||e[1]||"currentColor")&&B(s,"fill",l),112&h&&c!==(c=0!=e[6]?e[5]:e[4])&&B(s,"fill-opacity",c),128&h&&u!==(u=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(s,"transform",u)},d(e){e&&v(t),e&&v(s)}}}function zW(e){let t,i,n,r;return{c(){t=w("path"),B(t,"d",i=e[7][4]),B(t,"fill",n=e[1]||e[2]||"currentColor"),B(t,"transform",r=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)},m(e,i){y(e,t,i)},p(e,o){128&o&&i!==(i=e[7][4])&&B(t,"d",i),6&o&&n!==(n=e[1]||e[2]||"currentColor")&&B(t,"fill",n),128&o&&r!==(r=`translate(${e[7][0]/-2} ${e[7][1]/-2})`)&&B(t,"transform",r)},d(e){e&&v(t)}}}function UW(e){let i,n=e[7][4]&&DW(e);return{c(){n&&n.c(),i=C()},m(e,t){n&&n.m(e,t),y(e,i,t)},p(e,[t]){e[7][4]?n?n.p(e,t):(n=DW(e),n.c(),n.m(i.parentNode,i)):n&&(n.d(1),n=null)},i:t,o:t,d(e){n&&n.d(e),e&&v(i)}}}function NW(e,t,i){let n,r,o,s,{class:a=""}=t,{id:l=""}=t,{style:c=""}=t,{icon:u}=t,{size:h=""}=t,{color:d=""}=t,{fw:p=!1}=t,{pull:f=""}=t,{scale:m=1}=t,{translateX:g=0}=t,{translateY:_=0}=t,{rotate:A=""}=t,{flip:y=!1}=t,{spin:v=!1}=t,{pulse:x=!1}=t,{primaryColor:b=""}=t,{secondaryColor:w=""}=t,{primaryOpacity:T=1}=t,{secondaryOpacity:E=.4}=t,{swapOpacity:C=!1}=t;return e.$$set=e=>{"class"in e&&i(11,a=e.class),"id"in e&&i(0,l=e.id),"style"in e&&i(12,c=e.style),"icon"in e&&i(13,u=e.icon),"size"in e&&i(14,h=e.size),"color"in e&&i(1,d=e.color),"fw"in e&&i(15,p=e.fw),"pull"in e&&i(16,f=e.pull),"scale"in e&&i(17,m=e.scale),"translateX"in e&&i(18,g=e.translateX),"translateY"in e&&i(19,_=e.translateY),"rotate"in e&&i(20,A=e.rotate),"flip"in e&&i(21,y=e.flip),"spin"in e&&i(22,v=e.spin),"pulse"in e&&i(23,x=e.pulse),"primaryColor"in e&&i(2,b=e.primaryColor),"secondaryColor"in e&&i(3,w=e.secondaryColor),"primaryOpacity"in e&&i(4,T=e.primaryOpacity),"secondaryOpacity"in e&&i(5,E=e.secondaryOpacity),"swapOpacity"in e&&i(6,C=e.swapOpacity)},e.$$.update=()=>{8192&e.$$.dirty&&i(7,n=u&&u.icon||[0,0,"",[],""]),12584960&e.$$.dirty&&i(8,r=kW([a,"svelte-fa",v&&"spin",x&&"pulse"]," ")),118784&e.$$.dirty&&i(9,o=function(e,t,i,n){let r,o,s,a,l,c="-.125em";return n&&(l="center",o="1.25em"),i&&(r=i),t&&("lg"==t?(a="1.33333em",s=".75em",c="-.225em"):a="xs"==t?".75em":"sm"==t?".875em":t.replace("x","em")),kW([kW({float:r,width:o,height:"1em","line-height":s,"font-size":a,"text-align":l,"vertical-align":c,"transform-origin":"center",overflow:"visible"}),e])}(c,h,f,p)),4063232&e.$$.dirty&&i(10,s=function(e,t,i,n,r,o=1,s="",a=""){let l=1,c=1;return r&&("horizontal"==r?l=-1:"vertical"==r?c=-1:l=c=-1),kW([`translate(${FW(t)*o}${s},${FW(i)*o}${s})`,`scale(${l*FW(e)},${c*FW(e)})`,n&&`rotate(${n}${a})`]," ")}(m,g,_,A,y,512))},[l,d,b,w,T,E,C,n,r,o,s,a,c,u,h,p,f,m,g,_,A,y,v,x]}var VW=class extends ge{constructor(e){super(),me(this,e,NW,UW,a,{class:11,id:0,style:12,icon:13,size:14,color:1,fw:15,pull:16,scale:17,translateX:18,translateY:19,rotate:20,flip:21,spin:22,pulse:23,primaryColor:2,secondaryColor:3,primaryOpacity:4,secondaryOpacity:5,swapOpacity:6})}},jW={exports:{}},GW=jW.exports=function(e,t){if(t||(t=16),void 0===e&&(e=128),e<=0)return"0";for(var i=Math.log(Math.pow(2,e))/Math.log(t),n=2;i===1/0;n*=2)i=Math.log(Math.pow(2,e/n))/Math.log(t)*n;var r=i-Math.floor(i),o="";for(n=0;n=Math.pow(2,e)?GW(e,t):o};GW.rack=function(e,t,i){var n=function(n){var o=0;do{if(o++>10){if(!i)throw new Error("too many ID collisions, use more bits");e+=i}var s=GW(e,t)}while(Object.hasOwnProperty.call(r,s));return r[s]=n,s},r=n.hats={};return n.get=function(e){return n.hats[e]},n.set=function(e,t){return n.hats[e]=t,n},n.bits=e||128,n.base=t||16,n};var HW=jW.exports;const QW=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},$W={name:"Mapbox GL JS",value:"mapbox-gl"},ZW=[$W,{name:"Maplibre GL JS",value:"maplibre-gl"},{name:"MapTiler SDK",value:"maptiler-sdk"}],WW={google:[{name:"Google Maps",value:"google"}],leaflet:[{name:"Leaflet",value:"leaflet"}],tangram:[{name:"Tangram (Leaflet)",value:"tangram"}],"vector-gl":ZW,"mapbox-gl":ZW,"maplibre-gl":ZW,"maptiler-sdk":ZW},qW=(e,t)=>{let i=!1;return"mapbox-gl"!==e.type?WW[e.type]:(e.url&&QW(e.url)?i=!0:t&&(i=Object.values(t).some(e=>QW(e?.url)||(e?.tiles??[]).some(e=>QW(e)))),i?[$W]:WW[e.type])},KW=(e,t)=>{let i;const n=()=>window.removeEventListener("keydown",i),r=()=>{n(),t&&(i=i=>{!!t.alt==i.altKey&&!!t.shift==i.shiftKey&&!!t.control==(i.ctrlKey||i.metaKey)&&t.code==i.code&&(i.preventDefault(),t.callback?t.callback():e.click())},window.addEventListener("keydown",i))};return r(),{update:r,destroy:n}};function XW(e){let i,n,r,a,l,c,u,h,d,p,f,m=(e[2]??e[3])+"";return{c(){i=b("div"),n=b("div"),r=b("div"),l=E(),c=b("div"),u=b("div"),h=T(m),B(r,"class",a=g(e[1]?`caret-${e[4]}`:"caret-right")+" svelte-1q5ddxk"),B(n,"class","caret-container svelte-1q5ddxk"),B(u,"class","label svelte-1q5ddxk"),B(c,"class","label-container svelte-1q5ddxk"),B(i,"class",d=g(`toggle ${e[1]&&("up"===e[4]?"active-toggle-top":"active-toggle-bottom")}`)+" svelte-1q5ddxk")},m(t,o){y(t,i,o),A(i,n),A(n,r),A(i,l),A(i,c),A(c,u),A(u,h),p||(f=[S(i,"click",function(){s(e[0])&&e[0].apply(this,arguments)}),S(i,"keydown",e[5])],p=!0)},p(t,[n]){e=t,18&n&&a!==(a=g(e[1]?`caret-${e[4]}`:"caret-right")+" svelte-1q5ddxk")&&B(r,"class",a),12&n&&m!==(m=(e[2]??e[3])+"")&&M(h,m),18&n&&d!==(d=g(`toggle ${e[1]&&("up"===e[4]?"active-toggle-top":"active-toggle-bottom")}`)+" svelte-1q5ddxk")&&B(i,"class",d)},i:t,o:t,d(e){e&&v(i),p=!1,o(f)}}}function JW(e,t,i){let{openTopLevel:n}=t,{topLevelOpen:r}=t,{activeLabel:o}=t,{placeholder:s}=t,{direction:a}=t;return e.$$set=e=>{"openTopLevel"in e&&i(0,n=e.openTopLevel),"topLevelOpen"in e&&i(1,r=e.topLevelOpen),"activeLabel"in e&&i(2,o=e.activeLabel),"placeholder"in e&&i(3,s=e.placeholder),"direction"in e&&i(4,a=e.direction)},[n,r,o,s,a,()=>!1]}class YW extends ge{constructor(e){super(),me(this,e,JW,XW,a,{openTopLevel:0,topLevelOpen:1,activeLabel:2,placeholder:3,direction:4})}}function eq(e,t,i){const n=e.slice();return n[16]=t[i],n}function tq(e,t,i){const n=e.slice();return n[19]=t[i],n}function iq(e){let t,i;return t=new YW({props:{openTopLevel:e[7],topLevelOpen:e[4],activeLabel:e[6],direction:e[1],placeholder:e[2]}}),{c(){de(t.$$.fragment)},m(e,n){pe(t,e,n),i=!0},p(e,i){const n={};16&i&&(n.topLevelOpen=e[4]),64&i&&(n.activeLabel=e[6]),2&i&&(n.direction=e[1]),4&i&&(n.placeholder=e[2]),t.$set(n)},i(e){i||(le(t.$$.fragment,e),i=!0)},o(e){ce(t.$$.fragment,e),i=!1},d(e){fe(t,e)}}}function nq(e){let t,i,n=e[3],r=[];for(let t=0;t{o=null}),ae()),e[4]?s?s.p(e,r):(s=nq(e),s.c(),s.m(t,n)):s&&(s.d(1),s=null),"up"===e[1]?a?(a.p(e,r),2&r&&le(a,1)):(a=uq(e),a.c(),le(a,1),a.m(t,null)):a&&(se(),ce(a,1,1,()=>{a=null}),ae())},i(e){r||(le(o),le(a),r=!0)},o(e){ce(o),ce(a),r=!1},d(e){e&&v(t),o&&o.d(),s&&s.d(),a&&a.d()}}}function dq(e,t,i){let n,r,{options:o}=t,{activeValue:s}=t,{onSelect:a}=t,{direction:l="up"}=t,{placeholder:c=""}=t,u=!1,h=null;const d=e=>{i(5,h=h===e?null:e)},p=e=>{a(e),i(4,u=!1),i(5,h=null)};return e.$$set=e=>{"options"in e&&i(11,o=e.options),"activeValue"in e&&i(0,s=e.activeValue),"onSelect"in e&&i(12,a=e.onSelect),"direction"in e&&i(1,l=e.direction),"placeholder"in e&&i(2,c=e.placeholder)},e.$$.update=()=>{2048&e.$$.dirty&&i(3,n=o.map((e,t)=>{let i={...e,id:`${t}`};return i.options&&(i.options=i.options.map((e,i)=>({...e,id:`${t}-${i}`}))),i})),9&e.$$.dirty&&i(6,r=n.filter(e=>!e?.header).map(e=>e?.options?e?.options:e).flat().find(e=>e.value===s)?.label)},[s,l,c,n,u,h,r,()=>{if(i(4,u=!u),u){const e=n.filter(e=>e.options),t=e.find(e=>e.options.some(e=>e.value===s));t&&i(5,h=t.id)}else i(5,h=null)},d,()=>!1,p,o,a,e=>d(e.id),e=>p(e.value),e=>p(e.value)]}class pq extends ge{constructor(e){super(),me(this,e,dq,hq,a,{options:11,activeValue:0,onSelect:12,direction:1,placeholder:2})}}function fq(e){let t,i,n,r;return i=new pq({props:{options:e[4],activeValue:e[0].dropdownId,onSelect:e[1],direction:e[3]}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"id",n=`styles-dropdown-${e[2]}`)},m(e,n){y(e,t,n),pe(i,t,null),r=!0},p(e,[o]){const s={};16&o&&(s.options=e[4]),1&o&&(s.activeValue=e[0].dropdownId),2&o&&(s.onSelect=e[1]),8&o&&(s.direction=e[3]),i.$set(s),(!r||4&o&&n!==(n=`styles-dropdown-${e[2]}`))&&B(t,"id",n)},i(e){r||(le(i.$$.fragment,e),r=!0)},o(e){ce(i.$$.fragment,e),r=!1},d(e){e&&v(t),fe(i)}}}function mq(e,t,i){let n,{dropdownDisplayOptions:r}=t,{dropdownValue:o}=t,{onSelect:s}=t,{index:a}=t,l="up";return j(()=>{const e=document?.body?.clientHeight,t=document?.getElementById(`styles-dropdown-${a}`),n=t?.getBoundingClientRect(),r=n?.top;r&&e&&i(3,l=r{"dropdownDisplayOptions"in e&&i(5,r=e.dropdownDisplayOptions),"dropdownValue"in e&&i(0,o=e.dropdownValue),"onSelect"in e&&i(1,s=e.onSelect),"index"in e&&i(2,a=e.index)},e.$$.update=()=>{32&e.$$.dirty&&i(4,n=Object.entries(r).reduce((e,[t,i])=>{e.push({header:t});for(const t of i)"sublist"===t.type?e.push({label:t.text,options:t.presets.map(e=>({label:e.text,value:e.dropdownId}))}):e.push({label:t.text,value:t.dropdownId});return e},[]))},[o,s,a,l,n,r]}class gq extends ge{constructor(e){super(),me(this,e,mq,fq,a,{dropdownDisplayOptions:5,dropdownValue:0,onSelect:1,index:2})}}function _q(e,t,i){const n=e.slice();return n[31]=t[i],n[33]=i,n}function Aq(e){let t,i,n,r,s,a,l,c,u;return{c(){t=b("div"),i=b("input"),r=E(),s=b("button"),a=T("Submit"),B(i,"placeholder",n="branch"===e[7].dropdownType?"enter a branch name":"enter a url to a style"),B(i,"class","svelte-146mfz9"),z(i,"input-error",e[8]),s.disabled=l=e[7]?.url===e[6],B(t,"class","custom-input svelte-146mfz9")},m(n,o){y(n,t,o),A(t,i),P(i,e[6]),A(t,r),A(t,s),A(s,a),c||(u=[S(i,"input",e[19]),S(i,"focus",e[13]),S(i,"blur",e[14]),_(KW.call(null,s,{code:"Enter",callback:e[12]})),S(s,"click",e[11])],c=!0)},p(e,t){128&t[0]&&n!==(n="branch"===e[7].dropdownType?"enter a branch name":"enter a url to a style")&&B(i,"placeholder",n),64&t[0]&&i.value!==e[6]&&P(i,e[6]),256&t[0]&&z(i,"input-error",e[8]),192&t[0]&&l!==(l=e[7]?.url===e[6])&&(s.disabled=l)},d(e){e&&v(t),c=!1,o(u)}}}function yq(e){let t,i;return{c(){t=b("div"),i=T(e[8]),B(t,"class","error-message svelte-146mfz9")},m(e,n){y(e,t,n),A(t,i)},p(e,t){256&t[0]&&M(i,e[8])},d(e){e&&v(t)}}}function vq(e){let t,i=e[9].values.length&&xq(e);return{c(){i&&i.c(),t=C()},m(e,n){i&&i.m(e,n),y(e,t,n)},p(e,n){e[9].values.length?i?i.p(e,n):(i=xq(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null)},d(e){i&&i.d(e),e&&v(t)}}}function xq(e){let t,i,n,r,o=e[9].values,s=[];for(let t=0;t({label:e.name,value:e.value});function Bq(e,t,i){let n;const r=H();let o,s,{dropdownDisplayOptions:a}=t,{dropdownValue:l}=t,{rendererOptions:c}=t,{rendererValue:u}=t,{activeUrl:h}=t,{index:d}=t,{mapIdIndex:p}=t,f=l?.landmarks3D??!1,m=!1,g=null,_=!0;G(()=>{_=!1}),j(()=>{i(7,o=l),i(6,s=o.defaultText),A(o.url)});const A=e=>{const t=e=>{if(!_||!e||h!==e)return!1;const t=new RegExp("^(?:[a-z+]+:)?//","i");return e.includes("localhost")||!t.test(e)};t(e)&&setTimeout(()=>t(e)&&v(e,!0),3e3)},y=e=>{const t=["dropdownType","selected","defaultText"];let i={...Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)))};"branch"===o.dropdownType&&(i.branch=s),e&&(i.id=e.id??e?.style?.id,i.name=e.name??e?.style?.name),r("updateMapStore",{value:i})},v=async(e,t=!1)=>{let n;try{const i=await vu(e);if(i&&"object"==typeof i)return n=i,A(e),t?r("updateMapStore",{value:{style:n,isPolling:t}}):y({...o,style:n,url:e,isPolling:t}),{status:"200"}}catch(e){const{status:t,message:n}=e;return i(8,g=new Error(n)),{status:t}}},x=async e=>{const{status:t}=await v(e);"200"===t&&(i(7,o.url=e,o),A(e)),r("setUrl",{value:e})},b=async()=>{const{dropdownType:e,pattern:t}=o;let i="branch"===e?xu(t,s,o.id):s;if(o?.url!==i){if(i.includes("localhost")){const[e,t]=i.split("localhost");e||(i=`http://localhost${t}`)}x(i)}},w=e=>{let t=o?.selectedPrecompileOption??[];t=t.includes(e)?t.filter(t=>t!==e):t.concat([e]),i(7,o={...o,selectedPrecompileOption:t}),y(o)};return e.$$set=e=>{"dropdownDisplayOptions"in e&&i(0,a=e.dropdownDisplayOptions),"dropdownValue"in e&&i(1,l=e.dropdownValue),"rendererOptions"in e&&i(2,c=e.rendererOptions),"rendererValue"in e&&i(3,u=e.rendererValue),"activeUrl"in e&&i(17,h=e.activeUrl),"index"in e&&i(4,d=e.index),"mapIdIndex"in e&&i(5,p=e.mapIdIndex)},e.$$.update=()=>{2&e.$$.dirty[0]&&i(9,n=l?.precompile?l?.precompile?.options:null),64&e.$$.dirty[0]&&(e=>{g&&void 0!==e&&i(8,g=null)})(s),2&e.$$.dirty[0]&&(()=>{const e=Object.entries(l).every(e=>{const[t,i]=e;return"url"===t||!(!o||o[t]!==i)||void 0});if(e)return;const t=o?.dropdownType;i(7,o=l),i(8,g=null);const{dropdownType:n}=o;switch(n){case"preset":{const{type:e,url:t}=o;if(["google","leaflet"].includes(e)){y(o);break}x(t);break}case"branch":s&&"branch"===t&&b()}i(6,s=o.defaultText)})()},[a,l,c,u,d,p,s,o,g,n,r,b,()=>{m&&b()},()=>{m=!0},()=>{m=!1,g&&i(6,s=o.defaultText)},w,()=>{f=!f,i(7,o={...o,landmarks3D:f}),y(o)},h,e=>r("selectOption",{dropdownId:e}),function(){s=this.value,i(6,s)},e=>r("selectRenderer",{value:e}),e=>w(e.value)]}class Iq extends ge{constructor(e){super(),me(this,e,Bq,Cq,a,{dropdownDisplayOptions:0,dropdownValue:1,rendererOptions:2,rendererValue:3,activeUrl:17,index:4,mapIdIndex:5},null,[-1,-1])}}function Mq(e,t,i){const n=e.slice();return n[15]=t[i],n[17]=i,n}function Pq(e,t,i){const n=e.slice();return n[18]=t[i],n[20]=i,n}function Rq(e,t,i){const n=e.slice();return n[21]=t[i],n[17]=i,n}function Lq(e,t,i){const n=e.slice();return n[23]=t[i],n[20]=i,n}function Fq(e){let t,i,n,r=e[2].length&&kq(),o=e[1].length&&Dq(e),s=e[5].length&&Uq(e);return{c(){r&&r.c(),t=E(),i=b("div"),o&&o.c(),n=E(),s&&s.c(),B(i,"class","controls svelte-1cgcqsn")},m(e,a){r&&r.m(e,a),y(e,t,a),y(e,i,a),o&&o.m(i,null),A(i,n),s&&s.m(i,null)},p(e,a){e[2].length?r||(r=kq(),r.c(),r.m(t.parentNode,t)):r&&(r.d(1),r=null),e[1].length?o?o.p(e,a):(o=Dq(e),o.c(),o.m(i,n)):o&&(o.d(1),o=null),e[5].length?s?s.p(e,a):(s=Uq(e),s.c(),s.m(i,null)):s&&(s.d(1),s=null)},d(e){r&&r.d(e),e&&v(t),e&&v(i),o&&o.d(),s&&s.d()}}}function kq(e){let t;return{c(){t=b("div"),t.textContent="Custom actions:",B(t,"class","action-dropdown svelte-1cgcqsn")},m(e,i){y(e,t,i)},d(e){e&&v(t)}}}function Dq(e){let t,i,n,r=e[1],s=[];for(let t=0;te[11].call(t))},m(r,o){y(r,t,o);for(let e=0;ei(13,s=e));let a,{mapId:c}=t,{mapIdIndex:u}=t,h=!1;st.subscribe(e=>{const t=u.split("-").pop();i(0,a=e?.[t])});const{customJs:d=[]}=s;let p=null;const f=e=>{if(u.split("-").pop(),!a||!e)return;e(a)()};return e.$$set=e=>{"mapId"in e&&i(9,c=e.mapId),"mapIdIndex"in e&&i(10,u=e.mapIdIndex)},e.$$.update=()=>{if(512&e.$$.dirty&&i(2,n=d.filter(e=>e.mapIds.includes(c))),4&e.$$.dirty&&i(1,r=n.filter(e=>"dropdown"===e.type)),4&e.$$.dirty&&i(5,o=n.filter(e=>"checkbox"===e.type)),2&e.$$.dirty&&(r.length||i(4,p=null)),1&e.$$.dirty&&a){a.isStyleLoaded?.()??!0?i(3,h=!0):a.on("style.load",()=>{i(3,h=!0)})}},[a,r,n,h,p,o,e=>{const{dropdown:t,option:i}=JSON.parse(e.target.value),n=r?.[t]?.options?.[i];if(!a||!n)return;const{script:o}=n;o(a)()},f,e=>{if("boolean"==typeof e)return e;if(!a||!e)return;return e(a)()},c,u,function(){p=function(e){const t=e.querySelector(":checked");return t&&t.__value}(this),i(4,p),i(1,r),i(2,n),i(9,c)},e=>f(e?.script)]}class Qq extends ge{constructor(e){super(),me(this,e,Hq,Gq,a,{mapId:9,mapIdIndex:10})}}function $q(e){let t,i;return t=new Iq({props:{dropdownValue:e[6],dropdownDisplayOptions:e[4],rendererOptions:e[7],rendererValue:e[2],index:e[0],mapIdIndex:e[1],activeUrl:e[3]}}),t.$on("setUrl",e[9]),t.$on("selectOption",e[10]),t.$on("selectRenderer",e[11]),t.$on("updateMapStore",e[12]),{c(){de(t.$$.fragment)},m(e,n){pe(t,e,n),i=!0},p(e,i){const n={};64&i&&(n.dropdownValue=e[6]),16&i&&(n.dropdownDisplayOptions=e[4]),128&i&&(n.rendererOptions=e[7]),4&i&&(n.rendererValue=e[2]),1&i&&(n.index=e[0]),2&i&&(n.mapIdIndex=e[1]),8&i&&(n.activeUrl=e[3]),t.$set(n)},i(e){i||(le(t.$$.fragment,e),i=!0)},o(e){ce(t.$$.fragment,e),i=!1},d(e){fe(t,e)}}}function Zq(e){let t,i,n,r,o=e[5]&&$q(e);return n=new Qq({props:{mapId:e[8],mapIdIndex:e[1]}}),{c(){t=b("div"),o&&o.c(),i=E(),de(n.$$.fragment),B(t,"class","map-style-input-wrapper svelte-7abtsv")},m(e,s){y(e,t,s),o&&o.m(t,null),A(t,i),pe(n,t,null),r=!0},p(e,[r]){e[5]?o?(o.p(e,r),32&r&&le(o,1)):(o=$q(e),o.c(),le(o,1),o.m(t,i)):o&&(se(),ce(o,1,1,()=>{o=null}),ae());const s={};256&r&&(s.mapId=e[8]),2&r&&(s.mapIdIndex=e[1]),n.$set(s)},i(e){r||(le(o),le(n.$$.fragment,e),r=!0)},o(e){ce(o),ce(n.$$.fragment,e),r=!1},d(e){e&&v(t),o&&o.d(),fe(n)}}}function Wq(e,t,i){let n,r,o,s,a,l,{index:c}=t,{stylesheet:u}=t,{mapIdIndex:h}=t;it.subscribe(e=>({branchPatterns:n}=e));let d=[];et.subscribe(e=>{i(14,r=e.find(e=>e.index===c)),r&&(o=r.branch,s=r.renderer,a=r.type,i(3,l=r.url))});let p,f,m={},g=[],_=[];const A=()=>{let e;for(const t of g)if(t?.selected&&(e=t),"sublist"===t?.type)for(const i of t?.presets)i?.selected&&(e=i);if(e){switch(e=je(e),e.dropdownType){case"preset":e={...e,defaultText:""};break;case"branch":e={...e,defaultText:o??""};break;case"custom":e={...e,defaultText:l,url:l}}i(6,p=e)}},y=()=>{i(7,_=qW(p,u?.sources)),v()},v=()=>{let e=s;const t=qW(p,u?.sources).map(e=>e.value);e&&t.includes(e)||(e=t.includes(p.type)?p.type:t[0]),i(2,f=e)},x=()=>{(()=>{if(i(4,m={}),i(5,g=[]),d.length){const e=d.map((e,t)=>{let i,n;return(r.id===e.id||e?.presets?.some(e=>e.id===r.id))&&(i=r?.selectedPrecompileOption,n=!!r?.landmarks3D),{...e,dropdownType:"preset",selected:r.id?r.id===e.id:l===e?.url&&a===e?.type,dropdownId:HW(),...e.precompile&&{selectedPrecompileOption:i??e.precompile.options.default},...e.deckGlLayer&&{landmarks3D:n},..."sublist"===e.type&&{presets:e.presets.map(e=>({...e,dropdownType:"preset",selected:r.id?r.id===e.id:l===e?.url&&a===e?.type,dropdownId:HW(),...e.precompile&&{selectedPrecompileOption:i??e.precompile.options.default},...e.deckGlLayer&&{landmarks3D:n}}))}}});i(5,g=g.concat(e)),i(4,m.Presets=e.map(e=>({text:e.name,..."sublist"!==e.type&&{dropdownId:e.dropdownId},..."sublist"===e.type&&{type:"sublist",presets:e.presets.map(e=>({text:e.name,dropdownId:e.dropdownId}))}})),m)}if(n){let e=[];for(const t of n){let n,s;r.id!==t.id&&r.branchId!==t.id||(n=r?.selectedPrecompileOption,s=r?.landmarks3D);let c={name:t.name??t.id,type:"sublist",dropdownId:HW(),presets:[],...t.precompile&&{precompile:t.precompile,selectedPrecompileOption:n??t.precompile.options.default},...t?.deckGlLayer&&{deckGlLayer:t.deckGlLayer,landmarks3D:s}};if(t?.styles?.length){const e=t?.styles.map(e=>({screenshotName:`${t.name??t.id}: ${e} on`,name:`${t.name??t.id}: ${e} on...`,branchId:t?.id,id:e,branchStyle:e,type:t.type,dropdownType:"branch",selected:!(!o||xu(t.pattern,o,e)!==l||t.type!==a),pattern:t.pattern,dropdownId:HW(),...t?.projection&&{projection:t.projection},...t.precompile&&{precompile:t.precompile,selectedPrecompileOption:n??t.precompile.options.default},...t?.deckGlLayer&&{deckGlLayer:t.deckGlLayer,landmarks3D:s}}));c.presets=c.presets.concat(e)}e.push(c),i(5,g=g.concat(e)),i(4,m["Styles on a branch"]=e.map(e=>({text:e.name,..."sublist"!==e.type&&{dropdownId:e.dropdownId},..."sublist"===e.type&&{type:"sublist",presets:e.presets.map(e=>({text:e.name,dropdownId:e.dropdownId}))}})),m)}}const e=g.some(e=>!!e?.selected||e?.presets?.some(e=>!!e.selected)),t=[{name:"Fetch URL at...",dropdownType:"custom",selected:!e,type:"mapbox-gl",renderer:"mapbox-gl",dropdownId:HW()}];i(5,g=g.concat(t)),i(4,m.Custom=t.map(e=>({text:e.name,dropdownId:e.dropdownId})),m)})(),A()};tt.subscribe(e=>{d=e,x(),y()});let b;return e.$$set=e=>{"index"in e&&i(0,c=e.index),"stylesheet"in e&&i(13,u=e.stylesheet),"mapIdIndex"in e&&i(1,h=e.mapIdIndex)},e.$$.update=()=>{var t;16384&e.$$.dirty&&(!(t=r)||"branch"===p?.dropdownType&&!p?.url&&r.isPolling||t.type===p.type&&t.url===p.url||x()),4&e.$$.dirty&&(e=>{et.update(t=>t.map((t,i)=>i!==c?t:{...t,renderer:e}))})(f),16384&e.$$.dirty&&r&&i(8,b=r?.branchId??r?.id??null)},[c,h,f,l,m,g,p,_,b,e=>{i(6,p.url=e.detail.value,p),y()},e=>{const{dropdownId:t}=e.detail;i(5,g=g.reduce((e,i)=>{let n=i;"sublist"===n?.type?n.presets=n.presets.map(e=>({...e,selected:e.dropdownId===t})):n={...n,selected:i.dropdownId===t},n?.selected&&n?.selectedPrecompileOption&&(n.selectedPrecompileOption=n.precompile.options.default),n?.selected&&n?.landmarks3D&&(n.landmarks3D=!1);const r=n?.presets?.find(e=>e?.selected);return r&&r?.selectedPrecompileOption&&(n={...n,presets:n.presets.map(e=>(e?.selected&&(e.selectedPrecompileOption=e.precompile.options.default),{...e,precompile:e?.precompile}))}),r&&r?.landmarks3D&&(n={...n,presets:n.presets.map(e=>(e?.selected&&(e.landmarks3D=!1),{...e,precompile:e?.precompile}))}),e.push(n),e},[])),A(),y()},e=>{i(2,f=e.detail.value)},e=>{const{value:t}=e.detail;if(t.isPolling)et.update(e=>e.map((e,i)=>i===c?{...e,...t}:e));else{const e={...t,index:c,renderer:s};delete e.dropdownId,et.update(t=>t.map((t,i)=>i===c?e:t))}},u,r]}class qq extends ge{constructor(e){super(),me(this,e,Wq,Zq,a,{index:0,stylesheet:13,mapIdIndex:1})}}function Kq(e){let t,i,n,r;const o=e[1].default,s=c(o,e,e[0],null);return{c(){t=b("button"),s&&s.c(),B(t,"class","svelte-d9bm20")},m(o,a){y(o,t,a),s&&s.m(t,null),i=!0,n||(r=S(t,"click",e[2]),n=!0)},p(e,[t]){s&&s.p&&(!i||1&t)&&d(s,o,e,e[0],i?h(o,e[0],t,null):p(e[0]),null)},i(e){i||(le(s,e),i=!0)},o(e){ce(s,e),i=!1},d(e){e&&v(t),s&&s.d(e),n=!1,r()}}}function Xq(e,t,i){let{$$slots:n={},$$scope:r}=t;return e.$$set=e=>{"$$scope"in e&&i(0,r=e.$$scope)},[r,n,function(t){Q.call(this,e,t)}]}class Jq extends ge{constructor(e){super(),me(this,e,Xq,Kq,a,{})}}function Yq(e){let t,i,n,r,o,s,a,l,c,u,h,d,p;return a=new Jq({props:{$$slots:{default:[tK]},$$scope:{ctx:e}}}),a.$on("click",e[6]),u=new Jq({props:{$$slots:{default:[iK]},$$scope:{ctx:e}}}),u.$on("click",e[5]),{c(){t=b("div"),i=b("div"),n=T(e[2]),r=E(),o=b("div"),s=b("div"),de(a.$$.fragment),l=E(),c=b("div"),de(u.$$.fragment),B(i,"class","map-state svelte-1nshzal"),B(s,"class","svelte-1nshzal"),B(c,"class","svelte-1nshzal"),B(o,"class","location-actions svelte-1nshzal"),B(t,"class","map-state-container svelte-1nshzal")},m(f,m){y(f,t,m),A(t,i),A(i,n),A(t,r),A(t,o),A(o,s),pe(a,s,null),A(o,l),A(o,c),pe(u,c,null),h=!0,d||(p=S(i,"click",e[5]),d=!0)},p(e,t){(!h||4&t)&&M(n,e[2]);const i={};2097152&t&&(i.$$scope={dirty:t,ctx:e}),a.$set(i);const r={};2097153&t&&(r.$$scope={dirty:t,ctx:e}),u.$set(r)},i(e){h||(le(a.$$.fragment,e),le(u.$$.fragment,e),h=!0)},o(e){ce(a.$$.fragment,e),ce(u.$$.fragment,e),h=!1},d(e){e&&v(t),fe(a),fe(u),d=!1,p()}}}function eK(e){let i,n,r,s,a;return{c(){i=b("div"),n=b("input"),r=b("label"),r.textContent="enter zoom/lat/lng[/pitch/bearing]",R(n,"height","18px"),B(n,"type","text"),B(r,"class","input-label svelte-1nshzal"),B(i,"class","state-record svelte-1nshzal")},m(t,o){y(t,i,o),A(i,n),P(n,e[3]),e[17](n),A(i,r),s||(a=[S(n,"input",e[15]),S(n,"keydown",e[16]),S(n,"focus",rK)],s=!0)},p(e,t){8&t&&n.value!==e[3]&&P(n,e[3])},i:t,o:t,d(t){t&&v(i),e[17](null),s=!1,o(a)}}}function tK(e){let t;return{c(){t=T("change")},m(e,i){y(e,t,i)},d(e){e&&v(t)}}}function iK(e){let t,i=e[0]?"copied":"copy";return{c(){t=T(i)},m(e,i){y(e,t,i)},p(e,n){1&n&&i!==(i=e[0]?"copied":"copy")&&M(t,i)},d(e){e&&v(t)}}}function nK(e){let t,i,n,r;const o=[eK,Yq],s=[];function a(e,t){return e[1]?0:1}return i=a(e),n=s[i]=o[i](e),{c(){t=b("div"),n.c()},m(e,n){y(e,t,n),s[i].m(t,null),r=!0},p(e,[r]){let l=i;i=a(e),i===l?s[i].p(e,r):(se(),ce(s[l],1,1,()=>{s[l]=null}),ae(),n=s[i],n?n.p(e,r):(n=s[i]=o[i](e),n.c()),le(n,1),n.m(t,null))},i(e){r||(le(n),r=!0)},o(e){ce(n),r=!1},d(e){e&&v(t),s[i].d()}}}const rK=e=>e.target.select();function oK(e,t,i){let n,r,{bearing:o}=t,{center:s}=t,{pitch:a}=t,{zoom:l}=t;const c=H();let u,h=!1,d=!1,p="",f="";const m=()=>{i(1,d=!1)},g=()=>{i(1,d=!1),i(0,h=!1);const[e,t,n,r,o]=f.split("/"),s=(({zoom:e,lat:t,lng:i,pitch:n,bearing:r})=>{let o=!0;return[e,t,i,n,r].filter(Boolean).every(e=>!isNaN(Number(e)))||(o=!1),(+e<0||+e>24)&&(o=!1),(+t<-90||+t>90)&&(o=!1),(+i<-180||+i>180)&&(o=!1),void 0!==n&&(+n<0||+n>85)&&(o=!1),void 0!==r&&isNaN(+r)&&(o=!1),o})({zoom:e,lat:t,lng:n,pitch:r,bearing:o});if(!s)return;const a={mapStateUpdateOrigin:"controls"};void 0!==e&&(a.zoom=+e),void 0!==t&&void 0!==n&&(a.center={lng:+n,lat:+t}),void 0!==r&&(a.pitch=+r),void 0!==o&&(a.bearing=+o),c("mapState",{options:a})};return e.$$set=e=>{"bearing"in e&&i(9,o=e.bearing),"center"in e&&i(10,s=e.center),"pitch"in e&&i(11,a=e.pitch),"zoom"in e&&i(12,l=e.zoom)},e.$$.update=()=>{1024&e.$$.dirty&&i(14,n=s.lat),1024&e.$$.dirty&&i(13,r=s.lng),31232&e.$$.dirty&&((e,t,n,r,o)=>{let s=[lt(n,2),lt(e,5),lt(t,5)];(r||o)&&(s.push(lt(r,1)),s.push(lt(o,1))),i(2,p=s.join("/")),i(0,h=!1)})(n,r,l,a,o)},[h,d,p,f,u,()=>{i(0,h=!0),navigator.clipboard.writeText(p)},async()=>{i(1,d=!0),i(3,f=p),await(J(),K),u.focus()},m,g,o,s,a,l,r,n,function(){f=this.value,i(3,f)},e=>{"Enter"===e.key&&g(),"Escape"===e.key&&m()},function(e){Z[e?"unshift":"push"](()=>{u=e,i(4,u)})}]}class sK extends ge{constructor(e){super(),me(this,e,oK,nK,a,{bearing:9,center:10,pitch:11,zoom:12})}}function aK(e){let t,i,n,r,o,a,l,c,u,h,d,p,f,m=!e[8]&&Object.keys(e[6]).length;n=new VW({props:{icon:RW}}),u=new qq({props:{index:e[0],stylesheet:e[4],mapIdIndex:e[5]}});let g=m&&lK(e);return{c(){t=b("div"),i=b("button"),de(n.$$.fragment),r=E(),o=b("div"),a=T(e[1]),l=E(),c=b("div"),de(u.$$.fragment),h=E(),g&&g.c(),B(i,"class","close-button svelte-1mnw17n"),i.disabled=e[3],B(o,"class","map-name svelte-1mnw17n"),B(c,"class","options-container svelte-1mnw17n"),B(t,"class","map-label svelte-1mnw17n")},m(m,_){y(m,t,_),A(t,i),pe(n,i,null),A(t,r),A(t,o),A(o,a),A(t,l),A(t,c),pe(u,c,null),A(c,h),g&&g.m(c,null),d=!0,p||(f=S(i,"click",function(){s(e[2])&&e[2].apply(this,arguments)}),p=!0)},p(t,n){e=t,(!d||8&n)&&(i.disabled=e[3]),(!d||2&n)&&M(a,e[1]);const r={};1&n&&(r.index=e[0]),16&n&&(r.stylesheet=e[4]),32&n&&(r.mapIdIndex=e[5]),u.$set(r),320&n&&(m=!e[8]&&Object.keys(e[6]).length),m?g?(g.p(e,n),320&n&&le(g,1)):(g=lK(e),g.c(),le(g,1),g.m(c,null)):g&&(se(),ce(g,1,1,()=>{g=null}),ae())},i(e){d||(le(n.$$.fragment,e),le(u.$$.fragment,e),le(g),d=!0)},o(e){ce(n.$$.fragment,e),ce(u.$$.fragment,e),ce(g),d=!1},d(e){e&&v(t),fe(n),fe(u),g&&g.d(),p=!1,f()}}}function lK(e){let t,n,r;const o=[e[6]];let s={};for(let e=0;e{n=null}),ae())},i(e){i||(le(n),i=!0)},o(e){ce(n),i=!1},d(e){n&&n.d(e),e&&v(t)}}}function uK(e,t,i){let n,r,o,s;l(e,nt,e=>i(7,o=e)),l(e,rt,e=>i(8,s=e));let a,{index:c}=t,{name:u}=t,{onClose:h}=t,{disableClose:d}=t,{mapState:p}=t,{stylesheet:f}=t,{mapIdIndex:m}=t;return e.$$set=e=>{"index"in e&&i(0,c=e.index),"name"in e&&i(1,u=e.name),"onClose"in e&&i(2,h=e.onClose),"disableClose"in e&&i(3,d=e.disableClose),"mapState"in e&&i(9,p=e.mapState),"stylesheet"in e&&i(4,f=e.stylesheet),"mapIdIndex"in e&&i(5,m=e.mapIdIndex)},e.$$.update=()=>{512&e.$$.dirty&&i(6,({showBoundaries:n,showCollisions:r,...a}=p),a)},[c,u,h,d,f,m,a,o,s,p,function(t){Q.call(this,e,t)}]}class hK extends ge{constructor(e){super(),me(this,e,uK,cK,a,{index:0,name:1,onClose:2,disableClose:3,mapState:9,stylesheet:4,mapIdIndex:5})}}const dK=(e,t)=>{const i=t.some(({type:e})=>"google"===e);return i?e.zoom<12?35:45:85},pK=(e,t)=>{const i={...e};if((e=>e.some(({type:e})=>"google"===e))(t)){const n=dK(e,t);i.pitch>n&&(i.pitch=n)}return i};var fK={exports:{}};!function(e,t){var i="__lodash_hash_undefined__",n=9007199254740991,r="[object Arguments]",o="[object Array]",s="[object Boolean]",a="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",h="[object Number]",d="[object Object]",p="[object Promise]",f="[object RegExp]",m="[object Set]",g="[object String]",_="[object Symbol]",A="[object WeakMap]",y="[object ArrayBuffer]",v="[object DataView]",x=/^\[object .+?Constructor\]$/,b=/^(?:0|[1-9]\d*)$/,w={};w["[object Float32Array]"]=w["[object Float64Array]"]=w["[object Int8Array]"]=w["[object Int16Array]"]=w["[object Int32Array]"]=w["[object Uint8Array]"]=w["[object Uint8ClampedArray]"]=w["[object Uint16Array]"]=w["[object Uint32Array]"]=!0,w[r]=w[o]=w[y]=w[s]=w[v]=w[a]=w[l]=w[c]=w[u]=w[h]=w[d]=w[f]=w[m]=w[g]=w[A]=!1;var T="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,E="object"==typeof self&&self&&self.Object===Object&&self,C=T||E||Function("return this")(),S=t&&!t.nodeType&&t,B=S&&e&&!e.nodeType&&e,I=B&&B.exports===S,M=I&&T.process,P=function(){try{return M&&M.binding&&M.binding("util")}catch(e){}}(),R=P&&P.isTypedArray;function L(e,t){for(var i=-1,n=null==e?0:e.length;++ia))return!1;var c=o.get(e);if(c&&o.get(t))return c==t;var u=-1,h=!0,d=2&i?new _e:void 0;for(o.set(e,t),o.set(t,e);++u-1},me.prototype.set=function(e,t){var i=this.__data__,n=ve(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this},ge.prototype.clear=function(){this.size=0,this.__data__={hash:new fe,map:new(ie||me),string:new fe}},ge.prototype.delete=function(e){var t=Be(this,e).delete(e);return this.size-=t?1:0,t},ge.prototype.get=function(e){return Be(this,e).get(e)},ge.prototype.has=function(e){return Be(this,e).has(e)},ge.prototype.set=function(e,t){var i=Be(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this},_e.prototype.add=_e.prototype.push=function(e){return this.__data__.set(e,i),this},_e.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.clear=function(){this.__data__=new me,this.size=0},Ae.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Ae.prototype.get=function(e){return this.__data__.get(e)},Ae.prototype.has=function(e){return this.__data__.has(e)},Ae.prototype.set=function(e,t){var i=this.__data__;if(i instanceof me){var n=i.__data__;if(!ie||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new ge(n)}return i.set(e,t),this.size=i.size,this};var Me=J?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,r=0,o=[];++i-1&&e%1==0&&e-1&&e%1==0&&e<=n}function Ne(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Ve(e){return null!=e&&"object"==typeof e}var je=R?function(e){return function(t){return e(t)}}(R):function(e){return Ve(e)&&Ue(e.length)&&!!w[xe(e)]};function He(e){return null!=(t=e)&&Ue(t.length)&&!ze(t)?ye(e):Ee(e);var t}e.exports=function(e,t){return we(e,t)}}(fK,fK.exports);var mK=fK.exports;function gK(e){let t,i=(e[0].name??e[0].id)+"";return{c(){t=T(i)},m(e,i){y(e,t,i)},p(e,n){1&n&&i!==(i=(e[0].name??e[0].id)+"")&&M(t,i)},d(e){e&&v(t)}}}function _K(e){let t,i,n,r,o,s,a=(e[0].screenshotName??e[0].name??e[0].id)+"",l=e[0].branch+"";return{c(){t=b("div"),i=T(a),n=E(),r=b("span"),o=T(" "),s=T(l),B(r,"class","screenshot-label-bold svelte-14y9jxq"),B(t,"class","screenshot-text svelte-14y9jxq")},m(e,a){y(e,t,a),A(t,i),A(t,n),A(t,r),A(r,o),A(r,s)},p(e,t){1&t&&a!==(a=(e[0].screenshotName??e[0].name??e[0].id)+"")&&M(i,a),1&t&&l!==(l=e[0].branch+"")&&M(s,l)},d(e){e&&v(t)}}}function AK(e){let t,n,r;const o=[{onMapMount:e[12]},e[8],e[9]];var s=e[7];function a(e){let t={};for(let e=0;e{fe(e,1)}),ae()}s?(n=U(s,a()),n.$on("mapMove",e[11]),de(n.$$.fragment),le(n.$$.fragment,1),pe(n,t,null)):n=null}else s&&n.$set(l);(!r||4&i)&&z(t,"highlight-diff",e[2])},i(e){r||(n&&le(n.$$.fragment,e),r=!0)},o(e){n&&ce(n.$$.fragment,e),r=!1},d(e){e&&v(t),n&&fe(n)}}}function yK(e){let t,i,n,r,o;return i=new hK({props:{index:e[0].index,mapIdIndex:e[6],name:e[0].name,onClose:e[10],disableClose:e[1]<=1,mapState:e[9],stylesheet:e[4]}}),i.$on("mapState",e[11]),{c(){t=b("div"),de(i.$$.fragment),B(t,"id",n=e[0].id),B(t,"class",r=g("map-label-container "+(2===e[1]?`map-label-container-${e[0].index}`:""))+" svelte-14y9jxq"),B(t,"style",e[3])},m(e,n){y(e,t,n),pe(i,t,null),o=!0},p(e,s){const a={};1&s&&(a.index=e[0].index),64&s&&(a.mapIdIndex=e[6]),1&s&&(a.name=e[0].name),2&s&&(a.disableClose=e[1]<=1),512&s&&(a.mapState=e[9]),16&s&&(a.stylesheet=e[4]),i.$set(a),(!o||1&s&&n!==(n=e[0].id))&&B(t,"id",n),(!o||3&s&&r!==(r=g("map-label-container "+(2===e[1]?`map-label-container-${e[0].index}`:""))+" svelte-14y9jxq"))&&B(t,"class",r),(!o||8&s)&&B(t,"style",e[3])},i(e){o||(le(i.$$.fragment,e),o=!0)},o(e){ce(i.$$.fragment,e),o=!1},d(e){e&&v(t),fe(i)}}}function vK(e){let i,n,r,o,s,l=e[5],c=`${e[1]}-${e[0].index}`;function u(e,t){return e[0]?.branch?_K:gK}let h=u(e),d=h(e),p=AK(e),f=yK(e);return{c(){i=b("div"),n=b("div"),d.c(),r=E(),p.c(),o=E(),f.c(),B(n,"class","screenshot-label-transparent svelte-14y9jxq"),B(i,"class","map-container svelte-14y9jxq")},m(e,t){y(e,i,t),A(i,n),d.m(n,null),A(i,r),p.m(i,null),A(i,o),f.m(i,null),s=!0},p(e,[r]){h===(h=u(e))&&d?d.p(e,r):(d.d(1),d=h(e),d&&(d.c(),d.m(n,null))),32&r&&a(l,l=e[5])?(se(),ce(p,1,1,t),ae(),p=AK(e),p.c(),le(p,1),p.m(i,o)):p.p(e,r),3&r&&a(c,c=`${e[1]}-${e[0].index}`)?(se(),ce(f,1,1,t),ae(),f=yK(e),f.c(),le(f,1),f.m(i,null)):f.p(e,r)},i(e){s||(le(p),le(f),s=!0)},o(e){ce(p),ce(f),s=!1},d(e){e&&v(i),d.d(),p.d(e),f.d(e)}}}function xK(e,t,n){let r,o,s,a,c,u;const h=["map","numberOfMaps","highlightDifferences","labelStyle"];let d,p,g,_=m(t,h);l(e,rt,e=>n(17,d=e)),l(e,it,e=>n(18,p=e)),l(e,ot,e=>n(15,g=e));let{map:A}=t,{numberOfMaps:y}=t,{highlightDifferences:v=!1}=t,{labelStyle:x=""}=t;const b=H();let w,T={},E={};const C=e=>{switch(e){case"google":n(7,w=fu);break;case"leaflet":n(7,w=xW);break;case"tangram":n(7,w=EW);break;default:n(7,w=_W),n(8,T.mapRenderer=e,T)}};return e.$$set=e=>{t=i(i({},t),f(e)),n(23,_=m(t,h)),"map"in e&&n(0,A=e.map),"numberOfMaps"in e&&n(1,y=e.numberOfMaps),"highlightDifferences"in e&&n(2,v=e.highlightDifferences),"labelStyle"in e&&n(3,x=e.labelStyle)},e.$$.update=()=>{32769&e.$$.dirty&&(r=g?.[A.index]??{}),1&e.$$.dirty&&n(6,o=`${A.id}-${A.index}`),1&e.$$.dirty&&n(14,s=A?.selectedPrecompileOption),1&e.$$.dirty&&n(13,a=A?.landmarks3D),17&e.$$.dirty&&(mK(E,A?.style)||n(4,E=A?.style)),1&e.$$.dirty&&n(5,c=A.renderer),24658&e.$$.dirty&&((e,t)=>{const i={mapboxKey:p.mapboxGlAccessToken,maptilerKey:p.maptilerApiKey};n(8,T={id:e,mapStyle:{...A,url:_u(A.url,i)},numberOfMaps:t}),C(c)})(o,y),32&e.$$.dirty&&C(c),n(9,u=(e=>{if(d)return e;const{bearing:t,center:i,pitch:n,zoom:o,...s}=e;let a={...s,...{bearing:t,center:i,pitch:n,zoom:o,...r}};return a=pK(a,[A]),a})(_))},[A,y,v,x,E,c,o,w,T,u,()=>{et.update(e=>e.filter((e,t)=>t!==A.index).map((e,t)=>({...e,index:t}))),d||ot.update(e=>e.filter((e,t)=>t!==A.index))},e=>{if(d)b("mapMove",e.detail);else{const{options:t}=e.detail;ot.update(e=>e.map((e,i)=>i===A.index?t:e))}},e=>{st.update(t=>({...t,[A.index]:e}))},a,s,g]}class bK extends ge{constructor(e){super(),me(this,e,xK,vK,a,{map:0,numberOfMaps:1,highlightDifferences:2,labelStyle:3})}}function wK(e,t,i){const n=e.slice();return n[1]=t[i],n}function TK(e,t,i){const n=e.slice();return n[10]=t[i],n}function EK(e){let t,n,r;const o=[{map:e[10]},e[0],{numberOfMaps:e[2]}];let s={};for(let e=0;ece(o[e],1,1,()=>{o[e]=null});return{c(){t=b("div");for(let e=0;ece(s[e],1,1,()=>{s[e]=null});return{c(){t=b("div"),i=b("div");for(let e=0;e{"maps"in e&&i(1,n=e.maps),"mapState"in e&&i(0,r=e.mapState)},e.$$.update=()=>{2&e.$$.dirty&&i(2,s=n.length),4&e.$$.dirty&&i(4,l=a.includes(s)?"row":"column"),2&e.$$.dirty&&(e=>{const t=Math.round(Math.sqrt(s)),n=Math.floor(s/t);let r=je(e),a=[];for(;r.length;)a.push(r.slice(0,n)),r=r.slice(n);i(3,o=a)})(n)},[r,n,s,o,l,function(t){Q.call(this,e,t)}]}class IK extends ge{constructor(e){super(),me(this,e,BK,SK,a,{maps:1,mapState:0})}}function MK(e,t,i){const n=e.slice();return n[3]=t[i],n}function PK(e){let t,n,r,o;const s=[{map:e[3]},e[1],{labelStyle:"position: absolute; margin-top: 48px; left: 0; right: 0; bottom: unset; max-width: unset;"},{numberOfMaps:e[0].length}];let a={};for(let e=0;ece(o[e],1,1,()=>{o[e]=null});return{c(){t=b("div"),i=b("div");for(let e=0;e{"maps"in e&&i(0,n=e.maps),"mapState"in e&&i(1,r=e.mapState)},[n,r,function(t){Q.call(this,e,t)}]}class FK extends ge{constructor(e){super(),me(this,e,LK,RK,a,{maps:0,mapState:1})}}function kK(e,t,i){const n=e.slice();return n[15]=t[i],n}function DK(e){let t,n,r,o;const s=[{map:e[15]},e[1],{numberOfMaps:e[0].length},{highlightDifferences:1===e[15].index&&e[1]?.showDiff},{labelStyle:0===e[15].index?e[7]:e[6]}];let a={};for(let e=0;ece(u[e],1,1,()=>{u[e]=null});return{c(){t=b("div");for(let e=0;ee[14].call(t)),z(t,"dragging",e[4])},m(o,c){y(o,t,c);for(let e=0;e{e.source===i.contentWindow&&t()})):(i.src="about:blank",i.onload=()=>{r=S(i.contentWindow,"resize",t),t()}),A(e,i),()=>{(n||r&&i.contentWindow)&&r(),v(i)}}(t,e[14].bind(t)),s=!0,a||(l=[S(n,"mousedown",e[8]),S(t,"mousemove",e[10]),S(t,"mouseup",e[9])],a=!0)},p(e,[r]){if(239&r){let n;for(c=e[0],n=0;n{"maps"in e&&i(0,c=e.maps),"mapState"in e&&i(1,u=e.mapState)},e.$$.update=()=>{8&e.$$.dirty&&i(2,d=a/2),12&e.$$.dirty&&i(11,n=a-d),2056&e.$$.dirty&&i(12,r=a-n),4096&e.$$.dirty&&i(7,o=`right: unset; margin-right:unset; left:0; margin-left:1em; max-width:calc(${r}px - 6em)`),2048&e.$$.dirty&&i(6,s=`max-width:calc(${n}px - 6em)`)},[c,u,d,a,h,l,s,o,()=>i(4,h=!0),()=>i(4,h=!1),e=>{h&&0!==e.clientX&&i(2,d=e.clientX-zK/2)},n,r,function(t){Q.call(this,e,t)},function(){l=this.clientHeight,a=this.clientWidth,i(5,l),i(3,a)}]}class NK extends ge{constructor(e){super(),me(this,e,UK,OK,a,{maps:0,mapState:1})}}function VK(e){let t,n;const r=[{map:e[8]},e[6],{numberOfMaps:e[7]},{labelStyle:"position: fixed;"}];let o={};for(let e=0;e{V=null}),ae()),(!z||3&t&&n!==(n=`height:${e[0]}px; width:${e[1]}px`))&&B(i,"style",n),4&t&&I(h.value)!==e[2]&&P(h,e[2]),8&t&&I(x.value)!==e[3]&&P(x,e[3]),(!z||12&t&&L!==(L=!e[3]||!e[2]))&&(M.disabled=L),(!z||3&t&&O!==(O="100%"===e[0]&&"100%"===e[1]))&&(k.disabled=O)},i(e){z||(le(V),z=!0)},o(e){ce(V),z=!1},d(e){e&&v(t),V&&V.d(),U=!1,o(N)}}}function GK(e,t,i){let n,r,{maps:o}=t,{mapState:s}=t;const a=H();let l=s.height||"100%",c=s.width||"100%",u=s.height||"",h=s.width||"",d=!1,p=!1,f=s;delete f.width,delete f.height;const m=()=>{i(0,l=u),i(1,c=h),a("mapSetDimensions",{options:{height:l,width:c}})};return e.$$set=e=>{"maps"in e&&i(12,o=e.maps),"mapState"in e&&i(13,s=e.mapState)},e.$$.update=()=>{if(4096&e.$$.dirty&&i(8,n=o[0]),4096&e.$$.dirty&&i(7,r=o?.length??0),8192&e.$$.dirty){let{width:e,height:t,...n}=s;i(6,f=n)}},[l,c,u,h,d,p,f,r,n,()=>{(d||p)&&!(!h||!u)&&m()},m,()=>{i(0,l="100%"),i(1,c="100%"),i(2,u=""),i(3,h=""),a("mapSetDimensions",{options:{height:null,width:null}})},o,s,function(t){Q.call(this,e,t)},function(){u=I(this.value),i(2,u)},()=>i(4,d=!0),()=>i(4,d=!1),function(){h=I(this.value),i(3,h)},()=>i(5,p=!0),()=>i(5,p=!1)]}class HK extends ge{constructor(e){super(),me(this,e,GK,jK,a,{maps:12,mapState:13})}}function QK(e){let t,i,n;var r=e[2];function o(e){return{props:{maps:e[0],mapState:e[1]}}}return r&&(t=U(r,o(e)),t.$on("mapMove",e[3]),t.$on("mapSetDimensions",e[4])),{c(){t&&de(t.$$.fragment),i=C()},m(e,r){t&&pe(t,e,r),y(e,i,r),n=!0},p(e,[n]){const s={};if(1&n&&(s.maps=e[0]),2&n&&(s.mapState=e[1]),4&n&&r!==(r=e[2])){if(t){se();const e=t;ce(e.$$.fragment,1,0,()=>{fe(e,1)}),ae()}r?(t=U(r,o(e)),t.$on("mapMove",e[3]),t.$on("mapSetDimensions",e[4]),de(t.$$.fragment),le(t.$$.fragment,1),pe(t,i.parentNode,i)):t=null}else r&&t.$set(s)},i(e){n||(t&&le(t.$$.fragment,e),n=!0)},o(e){t&&ce(t.$$.fragment,e),n=!1},d(e){e&&v(i),t&&fe(t,e)}}}function $K(e,t,i){let n,r,{maps:o}=t,{mapState:s}=t,{viewMode:a}=t;const l=H();let c;const u=e=>{l("setDimensions",{...e.detail.options})};return e.$$set=e=>{"maps"in e&&i(0,o=e.maps),"mapState"in e&&i(1,s=e.mapState),"viewMode"in e&&i(5,a=e.viewMode)},e.$$.update=()=>{2&e.$$.dirty&&i(7,n=s.height),2&e.$$.dirty&&i(6,r=s.width),32&e.$$.dirty&&(e=>{switch(e){case"phone":i(2,c=FK);break;case"mirror":i(2,c=IK);break;case"responsive":i(2,c=HK);break;default:i(2,c=NK)}})(a),224&e.$$.dirty&&"responsive"!==a&&(n||r)&&u({detail:{options:{height:null,width:null}}})},[o,s,c,e=>{l("mapState",{options:e.detail.options})},u,a,r,n]}class ZK extends ge{constructor(e){super(),me(this,e,$K,QK,a,{maps:0,mapState:1,viewMode:5})}}var WK={exports:{}}; /*! * html2canvas 1.4.1 * Copyright (c) 2022 Niklas von Hertzen * Released under MIT License - */ZK.exports=function(){ + */WK.exports=function(){ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -78,5 +78,5 @@ function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArr OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),s%1024+56320)),(r+1===i||n.length>16384)&&(o+=String.fromCharCode.apply(String,n),n.length=0)}return o},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="undefined"==typeof Uint8Array?[]:new Uint8Array(256),p=0;p>4,u[l++]=(15&n)<<4|r>>2,u[l++]=(3&r)<<6|63&o;return c},A=function(e){for(var t=e.length,i=[],n=0;n>v,T=(1<>v)+32,C=65536>>x,S=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>v])<>v)])<>x),t=this.index[t],t+=e>>v&S,t=((t=this.index[t])<k?(r.push(!0),s-=k):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return n.push(o),i.push(K);if(s===U||s===Q){if(0===o)return n.push(o),i.push(ue);var a=i[o-1];return-1===Le.indexOf(a)?(n.push(n[o-1]),i.push(a)):(n.push(o),i.push(ue))}return n.push(o),s===he?i.push("strict"===t?te:_e):s===be||s===ce?i.push(ue):s===we?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(_e):i.push(ue):void i.push(s)}),[n,i,r]},Oe=function(e,t,i,n){var r=n[i];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var o=i;o<=n.length;){if((l=n[++o])===t)return!0;if(l!==H)break}if(r===H)for(o=i;o>0;){var s=n[--o];if(Array.isArray(e)?-1!==e.indexOf(s):e===s)for(var a=i;a<=n.length;){var l;if((l=n[++a])===t)return!0;if(l!==H)break}if(s!==H)break}return!1},ze=function(e,t){for(var i=e;i>=0;){var n=t[i];if(n!==H)return n;i--}return 0},Ue=function(e,t,i,n,r){if(0===i[n])return Ce;var o=n-1;if(Array.isArray(r)&&!0===r[o])return Ce;var s=o-1,a=o+1,l=t[o],c=s>=0?t[s]:0,u=t[a];if(l===O&&u===z)return Ce;if(-1!==Me.indexOf(l))return Ee;if(-1!==Me.indexOf(u))return Ce;if(-1!==Pe.indexOf(u))return Ce;if(ze(o,t)===j)return Se;if(Be.get(e[o])===Q)return Ce;if((l===de||l===pe)&&Be.get(e[a])===Q)return Ce;if(l===V||u===V)return Ce;if(l===G)return Ce;if(-1===[H,Z,q].indexOf(l)&&u===G)return Ce;if(-1!==[X,J,Y,re,le].indexOf(u))return Ce;if(ze(o,t)===ie)return Ce;if(Oe(ne,ie,o,t))return Ce;if(Oe([X,J],te,o,t))return Ce;if(Oe($,$,o,t))return Ce;if(l===H)return Se;if(l===ne||u===ne)return Ce;if(u===K||l===K)return Se;if(-1!==[Z,q,te].indexOf(u)||l===W)return Ce;if(c===ge&&-1!==ke.indexOf(l))return Ce;if(l===le&&u===ge)return Ce;if(u===ee)return Ce;if(-1!==Ie.indexOf(u)&&l===oe||-1!==Ie.indexOf(l)&&u===oe)return Ce;if(l===ae&&-1!==[_e,de,pe].indexOf(u)||-1!==[_e,de,pe].indexOf(l)&&u===se)return Ce;if(-1!==Ie.indexOf(l)&&-1!==Re.indexOf(u)||-1!==Re.indexOf(l)&&-1!==Ie.indexOf(u))return Ce;if(-1!==[ae,se].indexOf(l)&&(u===oe||-1!==[ie,q].indexOf(u)&&t[a+1]===oe)||-1!==[ie,q].indexOf(l)&&u===oe||l===oe&&-1!==[oe,le,re].indexOf(u))return Ce;if(-1!==[oe,le,re,X,J].indexOf(u))for(var h=o;h>=0;){if((d=t[h])===oe)return Ce;if(-1===[le,re].indexOf(d))break;h--}if(-1!==[ae,se].indexOf(u))for(h=-1!==[X,J].indexOf(l)?s:o;h>=0;){var d;if((d=t[h])===oe)return Ce;if(-1===[le,re].indexOf(d))break;h--}if(Ae===l&&-1!==[Ae,ye,fe,me].indexOf(u)||-1!==[ye,fe].indexOf(l)&&-1!==[ye,ve].indexOf(u)||-1!==[ve,me].indexOf(l)&&u===ve)return Ce;if(-1!==Fe.indexOf(l)&&-1!==[ee,se].indexOf(u)||-1!==Fe.indexOf(u)&&l===ae)return Ce;if(-1!==Ie.indexOf(l)&&-1!==Ie.indexOf(u))return Ce;if(l===re&&-1!==Ie.indexOf(u))return Ce;if(-1!==Ie.concat(oe).indexOf(l)&&u===ie&&-1===Te.indexOf(e[a])||-1!==Ie.concat(oe).indexOf(u)&&l===J)return Ce;if(l===xe&&u===xe){for(var p=i[o],f=1;p>0&&t[--p]===xe;)f++;if(f%2!=0)return Ce}return l===de&&u===pe?Ce:Se},Ne=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=De(e,t.lineBreak),n=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map(function(e){return-1!==[oe,ue,be].indexOf(e)?_e:e}));var s="keep-all"===t.wordBreak?o.map(function(t,i){return t&&e[i]>=19968&&e[i]<=40959}):void 0;return[n,r,s]},Ve=function(){function e(e,t,i,n){this.codePoints=e,this.required=t===Ee,this.start=i,this.end=n}return e.prototype.slice=function(){return u.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),je=function(e,t){var i=c(e),n=Ne(i,t),r=n[0],o=n[1],s=n[2],a=i.length,l=0,u=0;return{next:function(){if(u>=a)return{done:!0,value:null};for(var e=Ce;u=kt&&e<=57},Zt=function(e){return e>=55296&&e<=57343},Wt=function(e){return $t(e)||e>=Vt&&e<=Gt||e>=Dt&&e<=zt},qt=function(e){return e>=Dt&&e<=Nt},Kt=function(e){return e>=Vt&&e<=Qt},Xt=function(e){return qt(e)||Kt(e)},Jt=function(e){return e>=vt},Yt=function(e){return e===Ze||e===Ke||e===Xe},ei=function(e){return Xt(e)||Jt(e)||e===st},ti=function(e){return ei(e)||$t(e)||e===at},ii=function(e){return e>=Bt&&e<=It||e===Mt||e>=Pt&&e<=Rt||e===Lt},ni=function(e,t){return e===qe&&t!==Ze},ri=function(e,t,i){return e===at?ei(t)||ni(t,i):!!ei(e)||!(e!==qe||!ni(e,t))},oi=function(e,t,i){return e===wt||e===at?!!$t(t)||t===St&&$t(i):$t(e===St?t:e)},si=function(e){var t=0,i=1;e[t]!==wt&&e[t]!==at||(e[t]===at&&(i=-1),t++);for(var n=[];$t(e[t]);)n.push(e[t++]);var r=n.length?parseInt(u.apply(void 0,n),10):0;e[t]===St&&t++;for(var o=[];$t(e[t]);)o.push(e[t++]);var s=o.length,a=s?parseInt(u.apply(void 0,o),10):0;e[t]!==jt&&e[t]!==Ot||t++;var l=1;e[t]!==wt&&e[t]!==at||(e[t]===at&&(l=-1),t++);for(var c=[];$t(e[t]);)c.push(e[t++]);var h=c.length?parseInt(u.apply(void 0,c),10):0;return i*(r+a*Math.pow(10,-s))*Math.pow(10,l*h)},ai={type:2},li={type:3},ci={type:4},ui={type:13},hi={type:8},di={type:21},pi={type:9},fi={type:10},mi={type:11},gi={type:12},_i={type:14},Ai={type:23},yi={type:1},vi={type:25},xi={type:24},bi={type:26},wi={type:27},Ti={type:28},Ei={type:29},Ci={type:31},Si={type:32},Bi=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(c(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Si;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case Je:return this.consumeStringToken(Je);case et:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),n=this.peekCodePoint(2);if(ti(t)||ni(i,n)){var r=ri(t,i,n)?He:Ge;return{type:5,value:this.consumeName(),flags:r}}break;case tt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),ui;break;case nt:return this.consumeStringToken(nt);case rt:return ai;case ot:return li;case bt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),_i;break;case wt:if(oi(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Tt:return ci;case at:var o=e,s=this.peekCodePoint(0),a=this.peekCodePoint(1);if(oi(o,s,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(ri(o,s,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(s===at&&a===ut)return this.consumeCodePoint(),this.consumeCodePoint(),xi;break;case St:if(oi(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case We:if(this.peekCodePoint(0)===bt)for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(l===bt&&(l=this.consumeCodePoint())===We)return this.consumeToken();if(l===Ft)return this.consumeToken()}break;case Et:return bi;case Ct:return wi;case ct:if(this.peekCodePoint(0)===lt&&this.peekCodePoint(1)===at&&this.peekCodePoint(2)===at)return this.consumeCodePoint(),this.consumeCodePoint(),vi;break;case ht:var c=this.peekCodePoint(0),h=this.peekCodePoint(1),d=this.peekCodePoint(2);if(ri(c,h,d))return{type:7,value:this.consumeName()};break;case dt:return Ti;case qe:if(ni(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case pt:return Ei;case ft:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),hi;break;case mt:return mi;case _t:return gi;case Ut:case Ht:var p=this.peekCodePoint(0),f=this.peekCodePoint(1);return p!==wt||!Wt(f)&&f!==gt||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case At:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),pi;if(this.peekCodePoint(0)===At)return this.consumeCodePoint(),di;break;case yt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),fi;break;case Ft:return Si}return Yt(e)?(this.consumeWhiteSpace(),Ci):$t(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):ei(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:u(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Wt(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;t===gt&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(u.apply(void 0,e.map(function(e){return e===gt?kt:e})),16),end:parseInt(u.apply(void 0,e.map(function(e){return e===gt?Gt:e})),16)};var n=parseInt(u.apply(void 0,e),16);if(this.peekCodePoint(0)===at&&Wt(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Wt(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:n,end:parseInt(u.apply(void 0,r),16)}}return{type:30,start:n,end:n}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&this.peekCodePoint(0)===rt?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===rt?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===nt||t===Je){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft||this.peekCodePoint(0)===ot)?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Ai)}for(;;){var n=this.consumeCodePoint();if(n===Ft||n===ot)return{type:22,value:u.apply(void 0,e)};if(Yt(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft||this.peekCodePoint(0)===ot?(this.consumeCodePoint(),{type:22,value:u.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Ai);if(n===Je||n===nt||n===rt||ii(n))return this.consumeBadUrlRemnants(),Ai;if(n===qe){if(!ni(n,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Ai;e.push(this.consumeEscapedCodePoint())}else e.push(n)}},e.prototype.consumeWhiteSpace=function(){for(;Yt(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===ot||e===Ft)return;ni(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t=5e4,i="";e>0;){var n=Math.min(t,e);i+=u.apply(void 0,this._value.splice(0,n)),e-=n}return this._value.shift(),i},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var n=this._value[i];if(n===Ft||void 0===n||n===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(n===Ze)return this._value.splice(0,i),yi;if(n===qe){var r=this._value[i+1];r!==Ft&&void 0!==r&&(r===Ze?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):ni(n,r)&&(t+=this.consumeStringSlice(i),t+=u(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=Qe,i=this.peekCodePoint(0);for(i!==wt&&i!==at||e.push(this.consumeCodePoint());$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var n=this.peekCodePoint(1);if(i===St&&$t(n))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=$e;$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),n=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((i===jt||i===Ot)&&((n===wt||n===at)&&$t(r)||$t(n)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=$e;$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[si(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],n=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return ri(n,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:n===it?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Wt(e)){for(var t=u(e);Wt(this.peekCodePoint(0))&&t.length<6;)t+=u(this.consumeCodePoint());Yt(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||Zt(i)||i>1114111?xt:i}return e===Ft?xt:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(ti(t))e+=u(t);else{if(!ni(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=u(this.consumeEscapedCodePoint())}}},e}(),Ii=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Bi;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||zi(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Si:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Mi=function(e){return 15===e.type},Pi=function(e){return 17===e.type},Ri=function(e){return 20===e.type},Li=function(e){return 0===e.type},Fi=function(e,t){return Ri(e)&&e.value===t},ki=function(e){return 31!==e.type},Di=function(e){return 31!==e.type&&4!==e.type},Oi=function(e){var t=[],i=[];return e.forEach(function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)}),i.length&&t.push(i),t},zi=function(e,t){return 11===t&&12===e.type||28===t&&29===e.type||2===t&&3===e.type},Ui=function(e){return 17===e.type||15===e.type},Ni=function(e){return 16===e.type||Ui(e)},Vi=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},ji={type:17,number:0,flags:Qe},Gi={type:16,number:50,flags:Qe},Hi={type:16,number:100,flags:Qe},Qi=function(e,t,i){var n=e[0],r=e[1];return[$i(n,t),$i(void 0!==r?r:n,i)]},$i=function(e,t){if(16===e.type)return e.number/100*t;if(Mi(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Zi="deg",Wi="grad",qi="rad",Ki="turn",Xi={name:"angle",parse:function(e,t){if(15===t.type)switch(t.unit){case Zi:return Math.PI*t.number/180;case Wi:return Math.PI/200*t.number;case qi:return t.number;case Ki:return 2*Math.PI*t.number}throw new Error("Unsupported angle type")}},Ji=function(e){return 15===e.type&&(e.unit===Zi||e.unit===Wi||e.unit===qi||e.unit===Ki)},Yi=function(e){switch(e.filter(Ri).map(function(e){return e.value}).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ji,ji];case"to top":case"bottom":return en(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ji,Hi];case"to right":case"left":return en(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Hi,Hi];case"to bottom":case"top":return en(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Hi,ji];case"to left":case"right":return en(270)}return 0},en=function(e){return Math.PI*e/180},tn={name:"color",parse:function(e,t){if(18===t.type){var i=un[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var n=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return on(parseInt(n+n,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){n=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var s=t.value.substring(3,4);return on(parseInt(n+n,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(s+s,16)/255)}if(6===t.value.length)return n=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),on(parseInt(n,16),parseInt(r,16),parseInt(o,16),1);if(8===t.value.length)return n=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),s=t.value.substring(6,8),on(parseInt(n,16),parseInt(r,16),parseInt(o,16),parseInt(s,16)/255)}if(20===t.type){var a=dn[t.value.toUpperCase()];if(void 0!==a)return a}return dn.TRANSPARENT}},nn=function(e){return!(255&e)},rn=function(e){var t=255&e,i=255&e>>8,n=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+n+","+i+","+t/255+")":"rgb("+r+","+n+","+i+")"},on=function(e,t,i,n){return(e<<24|t<<16|i<<8|Math.round(255*n))>>>0},sn=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},an=function(e,t){var i=t.filter(Di);if(3===i.length){var n=i.map(sn),r=n[0],o=n[1],s=n[2];return on(r,o,s,1)}if(4===i.length){var a=i.map(sn),l=(r=a[0],o=a[1],s=a[2],a[3]);return on(r,o,s,l)}return 0};function ln(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var cn=function(e,t){var i=t.filter(Di),n=i[0],r=i[1],o=i[2],s=i[3],a=(17===n.type?en(n.number):Xi.parse(e,n))/(2*Math.PI),l=Ni(r)?r.number/100:0,c=Ni(o)?o.number/100:0,u=void 0!==s&&Ni(s)?$i(s,1):1;if(0===l)return on(255*c,255*c,255*c,1);var h=c<=.5?c*(l+1):c+l-c*l,d=2*c-h,p=ln(d,h,a+1/3),f=ln(d,h,a),m=ln(d,h,a-1/3);return on(255*p,255*f,255*m,u)},un={hsl:cn,hsla:cn,rgb:an,rgba:an},hn=function(e,t){return tn.parse(e,Ii.create(t).parseComponentValue())},dn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},pn={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Ri(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},fn={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},mn=function(e,t){var i=tn.parse(e,t[0]),n=t[1];return n&&Ni(n)?{color:i,stop:n}:{color:i,stop:null}},gn=function(e,t){var i=e[0],n=e[e.length-1];null===i.stop&&(i.stop=ji),null===n.stop&&(n.stop=Hi);for(var r=[],o=0,s=0;so?r.push(l):r.push(o),o=l}else r.push(null)}var c=null;for(s=0;se.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e},{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},xn=function(e,t,i,n,r){var o=0,s=0;switch(e.size){case 0:0===e.shape?o=s=Math.min(Math.abs(t),Math.abs(t-n),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-n)),s=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=s=Math.min(yn(t,i),yn(t,i-r),yn(t-n,i),yn(t-n,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-n)),l=vn(n,r,t,i,!0),c=l[0],u=l[1];s=a*(o=yn(c-t,(u-i)/a))}break;case 1:0===e.shape?o=s=Math.max(Math.abs(t),Math.abs(t-n),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-n)),s=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=s=Math.max(yn(t,i),yn(t,i-r),yn(t-n,i),yn(t-n,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-n));var h=vn(n,r,t,i,!1);c=h[0],u=h[1],s=a*(o=yn(c-t,(u-i)/a))}}return Array.isArray(e.size)&&(o=$i(e.size[0],n),s=2===e.size.length?$i(e.size[1],r):o),[o,s]},bn=function(e,t){var i=en(180),n=[];return Oi(t).forEach(function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=Yi(t));if(Ji(o))return void(i=Xi.parse(e,o))}var s=mn(e,t);n.push(s)}),{angle:i,stops:n,type:1}},wn=function(e,t){var i=en(180),n=[];return Oi(t).forEach(function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=Yi(t));if(Ji(o))return void(i=(Xi.parse(e,o)+en(270))%en(360))}var s=mn(e,t);n.push(s)}),{angle:i,stops:n,type:1}},Tn=function(e,t){var i=en(180),n=[],r=1,o=0,s=3,a=[];return Oi(t).forEach(function(t,i){var o=t[0];if(0===i){if(Ri(o)&&"linear"===o.value)return void(r=1);if(Ri(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var s=tn.parse(e,o.values[0]);n.push({stop:ji,color:s})}else if("to"===o.name)s=tn.parse(e,o.values[0]),n.push({stop:Hi,color:s});else if("color-stop"===o.name){var a=o.values.filter(Di);if(2===a.length){s=tn.parse(e,a[1]);var l=a[0];Pi(l)&&n.push({stop:{type:16,number:100*l.number,flags:l.flags},color:s})}}}),1===r?{angle:(i+en(180))%en(360),stops:n,type:r}:{size:s,shape:o,stops:n,position:a,type:r}},En="closest-side",Cn="farthest-side",Sn="closest-corner",Bn="farthest-corner",In="circle",Mn="ellipse",Pn="cover",Rn="contain",Ln=function(e,t){var i=0,n=3,r=[],o=[];return Oi(t).forEach(function(t,s){var a=!0;if(0===s){var l=!1;a=t.reduce(function(e,t){if(l)if(Ri(t))switch(t.value){case"center":return o.push(Gi),e;case"top":case"left":return o.push(ji),e;case"right":case"bottom":return o.push(Hi),e}else(Ni(t)||Ui(t))&&o.push(t);else if(Ri(t))switch(t.value){case In:return i=0,!1;case Mn:return i=1,!1;case"at":return l=!0,!1;case En:return n=0,!1;case Pn:case Cn:return n=1,!1;case Rn:case Sn:return n=2,!1;case Bn:return n=3,!1}else if(Ui(t)||Ni(t))return Array.isArray(n)||(n=[]),n.push(t),!1;return e},a)}if(a){var c=mn(e,t);r.push(c)}}),{size:n,shape:i,stops:r,position:o,type:2}},Fn=function(e,t){var i=0,n=3,r=[],o=[];return Oi(t).forEach(function(t,s){var a=!0;if(0===s?a=t.reduce(function(e,t){if(Ri(t))switch(t.value){case"center":return o.push(Gi),!1;case"top":case"left":return o.push(ji),!1;case"right":case"bottom":return o.push(Hi),!1}else if(Ni(t)||Ui(t))return o.push(t),!1;return e},a):1===s&&(a=t.reduce(function(e,t){if(Ri(t))switch(t.value){case In:return i=0,!1;case Mn:return i=1,!1;case Rn:case En:return n=0,!1;case Cn:return n=1,!1;case Sn:return n=2,!1;case Pn:case Bn:return n=3,!1}else if(Ui(t)||Ni(t))return Array.isArray(n)||(n=[]),n.push(t),!1;return e},a)),a){var l=mn(e,t);r.push(l)}}),{size:n,shape:i,stops:r,position:o,type:2}},kn=function(e){return 1===e.type},Dn=function(e){return 2===e.type},On={name:"image",parse:function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var n=Nn[t.name];if(void 0===n)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return n(e,t.values)}throw new Error("Unsupported image type "+t.type)}};function zn(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Nn[e.name])}var Un,Nn={"linear-gradient":bn,"-moz-linear-gradient":wn,"-ms-linear-gradient":wn,"-o-linear-gradient":wn,"-webkit-linear-gradient":wn,"radial-gradient":Ln,"-moz-radial-gradient":Fn,"-ms-radial-gradient":Fn,"-o-radial-gradient":Fn,"-webkit-radial-gradient":Fn,"-webkit-gradient":Tn},Vn={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter(function(e){return Di(e)&&zn(e)}).map(function(t){return On.parse(e,t)})}},jn={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Ri(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Gn={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Ni)}).map(Vi)}},Hn={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Ri).map(function(e){return e.value}).join(" ")}).map(Qn)}},Qn=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Un||(Un={}));var $n,Zn={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Wn)})}},Wn=function(e){return Ri(e)||Ni(e)},qn=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Kn=qn("top"),Xn=qn("right"),Jn=qn("bottom"),Yn=qn("left"),er=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return Vi(t.filter(Ni))}}},tr=er("top-left"),ir=er("top-right"),nr=er("bottom-right"),rr=er("bottom-left"),or=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},sr=or("top"),ar=or("right"),lr=or("bottom"),cr=or("left"),ur=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Mi(t)?t.number:0}}},hr=ur("top"),dr=ur("right"),pr=ur("bottom"),fr=ur("left"),mr={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},gr={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},_r={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(Ri).reduce(function(e,t){return e|Ar(t.value)},0)}},Ar=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},yr={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},vr={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}($n||($n={}));var xr,br={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?$n.STRICT:$n.NORMAL}},wr={name:"line-height",initialValue:"normal",prefix:!1,type:4},Tr=function(e,t){return Ri(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:Ni(e)?$i(e,t):t},Er={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:On.parse(e,t)}},Cr={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Sr={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Br=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Ir=Br("top"),Mr=Br("right"),Pr=Br("bottom"),Rr=Br("left"),Lr={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(Ri).map(function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})}},Fr={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},kr=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Dr=kr("top"),Or=kr("right"),zr=kr("bottom"),Ur=kr("left"),Nr={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Vr={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},jr={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Fi(t[0],"none")?[]:Oi(t).map(function(t){for(var i={color:dn.TRANSPARENT,offsetX:ji,offsetY:ji,blur:ji},n=0,r=0;r1?1:0],this.overflowWrap=bo(e,Fr,t.overflowWrap),this.paddingTop=bo(e,Dr,t.paddingTop),this.paddingRight=bo(e,Or,t.paddingRight),this.paddingBottom=bo(e,zr,t.paddingBottom),this.paddingLeft=bo(e,Ur,t.paddingLeft),this.paintOrder=bo(e,go,t.paintOrder),this.position=bo(e,Vr,t.position),this.textAlign=bo(e,Nr,t.textAlign),this.textDecorationColor=bo(e,eo,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=bo(e,to,null!==(n=t.textDecorationLine)&&void 0!==n?n:t.textDecoration),this.textShadow=bo(e,jr,t.textShadow),this.textTransform=bo(e,Gr,t.textTransform),this.transform=bo(e,Hr,t.transform),this.transformOrigin=bo(e,Wr,t.transformOrigin),this.visibility=bo(e,qr,t.visibility),this.webkitTextStrokeColor=bo(e,_o,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=bo(e,Ao,t.webkitTextStrokeWidth),this.wordBreak=bo(e,Kr,t.wordBreak),this.zIndex=bo(e,Xr,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return nn(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return ao(this.display,4)||ao(this.display,33554432)||ao(this.display,268435456)||ao(this.display,536870912)||ao(this.display,67108864)||ao(this.display,134217728)},e}(),vo=function(){function e(e,t){this.content=bo(e,lo,t.content),this.quotes=bo(e,po,t.quotes)}return e}(),xo=function(){function e(e,t){this.counterIncrement=bo(e,co,t.counterIncrement),this.counterReset=bo(e,uo,t.counterReset)}return e}(),bo=function(e,t,i){var n=new Bi,r=null!=i?i.toString():t.initialValue;n.write(r);var o=new Ii(n.read());switch(t.type){case 2:var s=o.parseComponentValue();return t.parse(e,Ri(s)?s.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return Xi.parse(e,o.parseComponentValue());case"color":return tn.parse(e,o.parseComponentValue());case"image":return On.parse(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return Ui(a)?a:ji;case"length-percentage":var l=o.parseComponentValue();return Ni(l)?l:ji;case"time":return Jr.parse(e,o.parseComponentValue())}}},wo="data-html2canvas-debug",To=function(e){switch(e.getAttribute(wo)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},Eo=function(e,t){var i=To(e);return 1===i||t===i},Co=function(){function e(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Eo(t,3),this.styles=new yo(e,window.getComputedStyle(t,null)),pa(t)&&(this.styles.animationDuration.some(function(e){return e>0})&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=a(this.context,t),Eo(t,4)&&(this.flags|=16)}return e}(),So="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Io="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Mo=0;Mo>4,u[l++]=(15&n)<<4|r>>2,u[l++]=(3&r)<<6|63&o;return c},Ro=function(e){for(var t=e.length,i=[],n=0;n>Fo,zo=(1<>Fo)+32,No=65536>>ko,Vo=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>Fo])<>Fo)])<>ko),t=this.index[t],t+=e>>Fo&Vo,t=((t=this.index[t])<=55296&&r<=56319&&i>10),s%1024+56320)),(r+1===i||n.length>16384)&&(o+=String.fromCharCode.apply(String,n),n.length=0)}return o},ds=Ho(So),ps="×",fs="÷",ms=function(e){return ds.get(e)},gs=function(e,t,i){var n=i-2,r=t[n],o=t[i-1],s=t[i];if(o===Xo&&s===Jo)return ps;if(o===Xo||o===Jo||o===Yo)return fs;if(s===Xo||s===Jo||s===Yo)return fs;if(o===is&&-1!==[is,ns,os,ss].indexOf(s))return ps;if(!(o!==os&&o!==ns||s!==ns&&s!==rs))return ps;if((o===ss||o===rs)&&s===rs)return ps;if(s===as||s===es)return ps;if(s===ts)return ps;if(o===Ko)return ps;if(o===as&&s===ls){for(;r===es;)r=t[--n];if(r===ls)return ps}if(o===cs&&s===cs){for(var a=0;r===cs;)a++,r=t[--n];if(a%2==0)return ps}return fs},_s=function(e){var t=us(e),i=t.length,n=0,r=0,o=t.map(ms);return{next:function(){if(n>=i)return{done:!0,value:null};for(var e=ps;ns.x||r.y>s.y;return s=r,0===t||a});return e.body.removeChild(t),a},xs=function(){return void 0!==(new Image).crossOrigin},bs=function(){return"string"==typeof(new XMLHttpRequest).responseType},ws=function(e){var t=new Image,i=e.createElement("canvas"),n=i.getContext("2d");if(!n)return!1;t.src="data:image/svg+xml,";try{n.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0},Ts=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},Es=function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var n=t.getContext("2d");if(!n)return Promise.reject(!1);n.fillStyle="rgb(0, 255, 0)",n.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var s=Cs(i,i,0,0,r);return n.fillStyle="red",n.fillRect(0,0,i,i),Ss(s).then(function(t){n.drawImage(t,0,0);var r=n.getImageData(0,0,i,i).data;n.fillStyle="red",n.fillRect(0,0,i,i);var s=e.createElement("div");return s.style.backgroundImage="url("+o+")",s.style.height=i+"px",Ts(r)?Ss(Cs(i,i,0,0,s)):Promise.reject(!1)}).then(function(e){return n.drawImage(e,0,0),Ts(n.getImageData(0,0,i,i).data)}).catch(function(){return!1})},Cs=function(e,t,i,n,r){var o="http://www.w3.org/2000/svg",s=document.createElementNS(o,"svg"),a=document.createElementNS(o,"foreignObject");return s.setAttributeNS(null,"width",e.toString()),s.setAttributeNS(null,"height",t.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",i.toString()),a.setAttributeNS(null,"y",n.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),s.appendChild(a),a.appendChild(r),s},Ss=function(e){return new Promise(function(t,i){var n=new Image;n.onload=function(){return t(n)},n.onerror=i,n.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))})},Bs={get SUPPORT_RANGE_BOUNDS(){var e=ys(document);return Object.defineProperty(Bs,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=Bs.SUPPORT_RANGE_BOUNDS&&vs(document);return Object.defineProperty(Bs,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=ws(document);return Object.defineProperty(Bs,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?Es(document):Promise.resolve(!1);return Object.defineProperty(Bs,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=xs();return Object.defineProperty(Bs,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e=bs();return Object.defineProperty(Bs,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Bs,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Bs,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Is=function(){function e(e,t){this.text=e,this.bounds=t}return e}(),Ms=function(e,t,i,n){var r=ks(t,i),o=[],a=0;return r.forEach(function(t){if(i.textDecorationLine.length||t.trim().length>0)if(Bs.SUPPORT_RANGE_BOUNDS){var r=Rs(n,a,t.length).getClientRects();if(r.length>1){var l=Ls(t),c=0;l.forEach(function(t){o.push(new Is(t,s.fromDOMRectList(e,Rs(n,c+a,t.length).getClientRects()))),c+=t.length})}else o.push(new Is(t,s.fromDOMRectList(e,r)))}else{var u=n.splitText(t.length);o.push(new Is(t,Ps(e,n))),n=u}else Bs.SUPPORT_RANGE_BOUNDS||(n=n.splitText(t.length));a+=t.length}),o},Ps=function(e,t){var i=t.ownerDocument;if(i){var n=i.createElement("html2canvaswrapper");n.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(n,t);var o=a(e,n);return n.firstChild&&r.replaceChild(n.firstChild,n),o}}return s.EMPTY},Rs=function(e,t,i){var n=e.ownerDocument;if(!n)throw new Error("Node has no owner document");var r=n.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Ls=function(e){if(Bs.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map(function(e){return e.segment})}return As(e)},Fs=function(e,t){if(Bs.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map(function(e){return e.segment})}return Os(e,t)},ks=function(e,t){return 0!==t.letterSpacing?Ls(e):Fs(e,t)},Ds=[32,160,4961,65792,65793,4153,4241],Os=function(e,t){for(var i,n=je(e,{lineBreak:t.lineBreak,wordBreak:"break-word"===t.overflowWrap?"break-word":t.wordBreak}),r=[],o=function(){if(i.value){var e=i.value.slice(),t=c(e),n="";t.forEach(function(e){-1===Ds.indexOf(e)?n+=u(e):(n.length&&r.push(n),r.push(u(e)),n="")}),n.length&&r.push(n)}};!(i=n.next()).done;)o();return r},zs=function(){function e(e,t,i){this.text=Us(t.data,i.textTransform),this.textBounds=Ms(e,this.text,i,t)}return e}(),Us=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Ns,Vs);case 2:return e.toUpperCase();default:return e}},Ns=/(^|\s|:|-|\(|\))([a-z])/g,Vs=function(e,t,i){return e.length>0?t+i.toUpperCase():e},js=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.src=i.currentSrc||i.src,n.intrinsicWidth=i.naturalWidth,n.intrinsicHeight=i.naturalHeight,n.context.cache.addImage(n.src),n}return t(i,e),i}(Co),Gs=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.canvas=i,n.intrinsicWidth=i.width,n.intrinsicHeight=i.height,n}return t(i,e),i}(Co),Hs=function(e){function i(t,i){var n=e.call(this,t,i)||this,r=new XMLSerializer,o=a(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),n.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),n.intrinsicWidth=i.width.baseVal.value,n.intrinsicHeight=i.height.baseVal.value,n.context.cache.addImage(n.svg),n}return t(i,e),i}(Co),Qs=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.value=i.value,n}return t(i,e),i}(Co),$s=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.start=i.start,n.reversed="boolean"==typeof i.reversed&&!0===i.reversed,n}return t(i,e),i}(Co),Zs=[{type:15,flags:0,unit:"px",number:3}],Ws=[{type:16,flags:0,number:50}],qs=function(e){return e.width>e.height?new s(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width0)i.textNodes.push(new zs(e,r,i.styles));else if(da(r))if(Ia(r)&&r.assignedNodes)r.assignedNodes().forEach(function(t){return sa(e,t,i,n)});else{var s=aa(e,r);s.styles.isVisible()&&(ca(r,s,n)?s.flags|=4:ua(s.styles)&&(s.flags|=2),-1!==oa.indexOf(r.tagName)&&(s.flags|=8),i.elements.push(s),r.slot,r.shadowRoot?sa(e,r.shadowRoot,s,n):Sa(r)||ya(r)||Ba(r)||sa(e,r,s,n))}},aa=function(e,t){return wa(t)?new js(e,t):xa(t)?new Gs(e,t):ya(t)?new Hs(e,t):ma(t)?new Qs(e,t):ga(t)?new $s(e,t):_a(t)?new ta(e,t):Ba(t)?new ia(e,t):Sa(t)?new na(e,t):Ta(t)?new ra(e,t):new Co(e,t)},la=function(e,t){var i=aa(e,t);return i.flags|=4,sa(e,t,i,i),i},ca=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||va(e)&&i.styles.isTransparent()},ua=function(e){return e.isPositioned()||e.isFloating()},ha=function(e){return e.nodeType===Node.TEXT_NODE},da=function(e){return e.nodeType===Node.ELEMENT_NODE},pa=function(e){return da(e)&&void 0!==e.style&&!fa(e)},fa=function(e){return"object"==typeof e.className},ma=function(e){return"LI"===e.tagName},ga=function(e){return"OL"===e.tagName},_a=function(e){return"INPUT"===e.tagName},Aa=function(e){return"HTML"===e.tagName},ya=function(e){return"svg"===e.tagName},va=function(e){return"BODY"===e.tagName},xa=function(e){return"CANVAS"===e.tagName},ba=function(e){return"VIDEO"===e.tagName},wa=function(e){return"IMG"===e.tagName},Ta=function(e){return"IFRAME"===e.tagName},Ea=function(e){return"STYLE"===e.tagName},Ca=function(e){return"SCRIPT"===e.tagName},Sa=function(e){return"TEXTAREA"===e.tagName},Ba=function(e){return"SELECT"===e.tagName},Ia=function(e){return"SLOT"===e.tagName},Ma=function(e){return e.tagName.indexOf("-")>0},Pa=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach(function(e){return t.counters[e].pop()})},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,n=e.counterReset,r=!0;null!==i&&i.forEach(function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)});var o=[];return r&&n.forEach(function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)}),o},e}(),Ra={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},La={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Fa={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},ka={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Da=function(e,t,i,n,r,o){return ei?qa(e,r,o.length>0):n.integers.reduce(function(t,i,r){for(;e>=i;)e-=i,t+=n.values[r];return t},"")+o},Oa=function(e,t,i,n){var r="";do{i||e--,r=n(e)+r,e/=t}while(e*t>=t);return r},za=function(e,t,i,n,r){var o=i-t+1;return(e<0?"-":"")+(Oa(Math.abs(e),o,n,function(e){return u(Math.floor(e%o)+t)})+r)},Ua=function(e,t,i){void 0===i&&(i=". ");var n=t.length;return Oa(Math.abs(e),n,!1,function(e){return t[Math.floor(e%n)]})+i},Na=1,Va=2,ja=4,Ga=8,Ha=function(e,t,i,n,r,o){if(e<-9999||e>9999)return qa(e,4,r.length>0);var s=Math.abs(e),a=r;if(0===s)return t[0]+a;for(var l=0;s>0&&l<=4;l++){var c=s%10;0===c&&ao(o,Na)&&""!==a?a=t[c]+a:c>1||1===c&&0===l||1===c&&1===l&&ao(o,Va)||1===c&&1===l&&ao(o,ja)&&e>100||1===c&&l>1&&ao(o,Ga)?a=t[c]+(l>0?i[l-1]:"")+a:1===c&&l>0&&(a=i[l-1]+a),s=Math.floor(s/10)}return(e<0?n:"")+a},Qa="十百千萬",$a="拾佰仟萬",Za="マイナス",Wa="마이너스",qa=function(e,t,i){var n=i?". ":"",r=i?"、":"",o=i?", ":"",s=i?" ":"";switch(t){case 0:return"•"+s;case 1:return"◦"+s;case 2:return"◾"+s;case 5:var a=za(e,48,57,!0,n);return a.length<4?"0"+a:a;case 4:return Ua(e,"〇一二三四五六七八九",r);case 6:return Da(e,1,3999,Ra,3,n).toLowerCase();case 7:return Da(e,1,3999,Ra,3,n);case 8:return za(e,945,969,!1,n);case 9:return za(e,97,122,!1,n);case 10:return za(e,65,90,!1,n);case 11:return za(e,1632,1641,!0,n);case 12:case 49:return Da(e,1,9999,La,3,n);case 35:return Da(e,1,9999,La,3,n).toLowerCase();case 13:return za(e,2534,2543,!0,n);case 14:case 30:return za(e,6112,6121,!0,n);case 15:return Ua(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return Ua(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return Ha(e,"零一二三四五六七八九",Qa,"負",r,Va|ja|Ga);case 47:return Ha(e,"零壹貳參肆伍陸柒捌玖",$a,"負",r,Na|Va|ja|Ga);case 42:return Ha(e,"零一二三四五六七八九",Qa,"负",r,Va|ja|Ga);case 41:return Ha(e,"零壹贰叁肆伍陆柒捌玖",$a,"负",r,Na|Va|ja|Ga);case 26:return Ha(e,"〇一二三四五六七八九","十百千万",Za,r,0);case 25:return Ha(e,"零壱弐参四伍六七八九","拾百千万",Za,r,Na|Va|ja);case 31:return Ha(e,"영일이삼사오육칠팔구","십백천만",Wa,o,Na|Va|ja);case 33:return Ha(e,"零一二三四五六七八九","十百千萬",Wa,o,0);case 32:return Ha(e,"零壹貳參四五六七八九","拾百千",Wa,o,Na|Va|ja);case 18:return za(e,2406,2415,!0,n);case 20:return Da(e,1,19999,ka,3,n);case 21:return za(e,2790,2799,!0,n);case 22:return za(e,2662,2671,!0,n);case 22:return Da(e,1,10999,Fa,3,n);case 23:return Ua(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Ua(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return za(e,3302,3311,!0,n);case 28:return Ua(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return Ua(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return za(e,3792,3801,!0,n);case 37:return za(e,6160,6169,!0,n);case 38:return za(e,4160,4169,!0,n);case 39:return za(e,2918,2927,!0,n);case 40:return za(e,1776,1785,!0,n);case 43:return za(e,3046,3055,!0,n);case 44:return za(e,3174,3183,!0,n);case 45:return za(e,3664,3673,!0,n);case 46:return za(e,3872,3881,!0,n);default:return za(e,48,57,!0,n)}},Ka="data-html2canvas-ignore",Xa=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new Pa,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,o=Ya(e,t);if(!o.contentWindow)return Promise.reject("Unable to find iframe window");var s=e.defaultView.pageXOffset,a=e.defaultView.pageYOffset,l=o.contentWindow,c=l.document,u=il(o).then(function(){return n(i,void 0,void 0,function(){var e,i;return r(this,function(n){switch(n.label){case 0:return this.scrolledElements.forEach(al),l&&(l.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||l.scrollY===t.top&&l.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(l.scrollX-t.left,l.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:c.fonts&&c.fonts.ready?[4,c.fonts.ready]:[3,2];case 1:n.sent(),n.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,tl(c)]:[3,4];case 3:n.sent(),n.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then(function(){return e(c,i)}).then(function(){return o})]:[2,o]}})})});return c.open(),c.write(ol(document.doctype)+""),sl(this.referenceElement.ownerDocument,s,a),c.replaceChild(c.adoptNode(this.documentElement),c.documentElement),c.close(),u},e.prototype.createElementClone=function(e){if(Eo(e,2),xa(e))return this.createCanvasClone(e);if(ba(e))return this.createVideoClone(e);if(Ea(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return wa(t)&&(wa(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Ma(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return rl(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce(function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e},""),n=e.cloneNode(!1);return n.textContent=i,n}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var n=e.cloneNode(!1);try{n.width=e.width,n.height=e.height;var r=e.getContext("2d"),o=n.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var s=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(s){var a=s.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return n}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return n},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var n=e.ownerDocument.createElement("canvas");return n.width=e.offsetWidth,n.height=e.offsetHeight,n},e.prototype.appendChildNode=function(e,t,i){da(t)&&(Ca(t)||t.hasAttribute(Ka)||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&da(t)&&Ea(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var n=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(da(r)&&Ia(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach(function(e){return n.appendChildNode(t,e,i)})}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(ha(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&da(e)&&(pa(e)||fa(e))){var n=this.createElementClone(e);n.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),s=i.getComputedStyle(e,":after");this.referenceElement===e&&pa(n)&&(this.clonedReferenceElement=n),va(n)&&pl(n);var a=this.counters.parse(new xo(this.context,r)),l=this.resolvePseudoContent(e,n,o,qo.BEFORE);Ma(e)&&(t=!0),ba(e)||this.cloneChildNodes(e,n,t),l&&n.insertBefore(l,n.firstChild);var c=this.resolvePseudoContent(e,n,s,qo.AFTER);return c&&n.appendChild(c),this.counters.pop(a),(r&&(this.options.copyStyles||fa(e))&&!Ta(e)||t)&&rl(r,n),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([n,e.scrollLeft,e.scrollTop]),(Sa(e)||Ba(e))&&(Sa(n)||Ba(n))&&(n.value=e.value),n}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,n){var r=this;if(i){var o=i.content,s=t.ownerDocument;if(s&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new xo(this.context,i));var a=new vo(this.context,i),l=s.createElement("html2canvaspseudoelement");rl(i,l),a.content.forEach(function(t){if(0===t.type)l.appendChild(s.createTextNode(t.value));else if(22===t.type){var i=s.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var n=t.values.filter(Ri);n.length&&l.appendChild(s.createTextNode(e.getAttribute(n[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(Di),c=o[0],u=o[1];if(c&&Ri(c)){var h=r.counters.getCounterValue(c.value),d=u&&Ri(u)?Sr.parse(r.context,u.value):3;l.appendChild(s.createTextNode(qa(h,d,!1)))}}else if("counters"===t.name){var p=t.values.filter(Di),f=(c=p[0],p[1]);if(u=p[2],c&&Ri(c)){var m=r.counters.getCounterValues(c.value),g=u&&Ri(u)?Sr.parse(r.context,u.value):3,_=f&&0===f.type?f.value:"",A=m.map(function(e){return qa(e,g,!1)}).join(_);l.appendChild(s.createTextNode(A))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(s.createTextNode(fo(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(s.createTextNode(fo(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(s.createTextNode(t.value))}}),l.className=ul+" "+hl;var c=n===qo.BEFORE?" "+ul:" "+hl;return fa(t)?t.className.baseValue+=c:t.className+=c,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(qo||(qo={}));var Ja,Ya=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute(Ka,"true"),e.body.appendChild(i),i},el=function(e){return new Promise(function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()})},tl=function(e){return Promise.all([].slice.call(e.images,0).map(el))},il=function(e){return new Promise(function(t,i){var n=e.contentWindow;if(!n)return i("No window assigned for iframe");var r=n.document;n.onload=e.onload=function(){n.onload=e.onload=null;var i=setInterval(function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))},50)}})},nl=["all","d","content"],rl=function(e,t){for(var i=e.length-1;i>=0;i--){var n=e.item(i);-1===nl.indexOf(n)&&t.style.setProperty(n,e.getPropertyValue(n))}return t},ol=function(e){var t="";return e&&(t+=""),t},sl=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},al=function(e){var t=e[0],i=e[1],n=e[2];t.scrollLeft=i,t.scrollTop=n},ll=":before",cl=":after",ul="___html2canvas___pseudoelement_before",hl="___html2canvas___pseudoelement_after",dl='{\n content: "" !important;\n display: none !important;\n}',pl=function(e){fl(e,"."+ul+ll+dl+"\n ."+hl+cl+dl)},fl=function(e,t){var i=e.ownerDocument;if(i){var n=i.createElement("style");n.textContent=t,e.appendChild(n)}},ml=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),gl=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:wl(e)||vl(e)?((this._cache[e]=this.loadImage(e)).catch(function(){}),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return n(this,void 0,void 0,function(){var t,i,n,o,s=this;return r(this,function(r){switch(r.label){case 0:return t=ml.isSameOrigin(e),i=!xl(e)&&!0===this._options.useCORS&&Bs.SUPPORT_CORS_IMAGES&&!t,n=!xl(e)&&!t&&!wl(e)&&"string"==typeof this._options.proxy&&Bs.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||xl(e)||wl(e)||n||i?(o=e,n?[4,this.proxy(o)]:[3,2]):[2];case 1:o=r.sent(),r.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(e,t){var n=new Image;n.onload=function(){return e(n)},n.onerror=t,(bl(o)||i)&&(n.crossOrigin="anonymous"),n.src=o,!0===n.complete&&setTimeout(function(){return e(n)},500),s._options.imageTimeout>0&&setTimeout(function(){return t("Timed out ("+s._options.imageTimeout+"ms) loading image")},s._options.imageTimeout)})];case 3:return[2,r.sent()]}})})},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var n=e.substring(0,256);return new Promise(function(r,o){var s=Bs.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===s)r(a.response);else{var e=new FileReader;e.addEventListener("load",function(){return r(e.result)},!1),e.addEventListener("error",function(e){return o(e)},!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+n+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+s),"text"!==s&&a instanceof XMLHttpRequest&&(a.responseType=s),t._options.imageTimeout){var c=t._options.imageTimeout;a.timeout=c,a.ontimeout=function(){return o("Timed out ("+c+"ms) proxying "+n)}}a.send()})},e}(),_l=/^data:image\/svg\+xml/i,Al=/^data:image\/.*;base64,/i,yl=/^data:image\/.*/i,vl=function(e){return Bs.SUPPORT_SVG_DRAWING||!Tl(e)},xl=function(e){return yl.test(e)},bl=function(e){return Al.test(e)},wl=function(e){return"blob"===e.substr(0,4)},Tl=function(e){return"svg"===e.substr(-3).toLowerCase()||_l.test(e)},El=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Cl=function(e,t,i){return new El(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},Sl=function(){function e(e,t,i,n){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=n}return e.prototype.subdivide=function(t,i){var n=Cl(this.start,this.startControl,t),r=Cl(this.startControl,this.endControl,t),o=Cl(this.endControl,this.end,t),s=Cl(n,r,t),a=Cl(r,o,t),l=Cl(s,a,t);return i?new e(this.start,n,s,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Bl=function(e){return 1===e.type},Il=function(){function e(e){var t=e.styles,i=e.bounds,n=Qi(t.borderTopLeftRadius,i.width,i.height),r=n[0],o=n[1],s=Qi(t.borderTopRightRadius,i.width,i.height),a=s[0],l=s[1],c=Qi(t.borderBottomRightRadius,i.width,i.height),u=c[0],h=c[1],d=Qi(t.borderBottomLeftRadius,i.width,i.height),p=d[0],f=d[1],m=[];m.push((r+a)/i.width),m.push((p+u)/i.width),m.push((o+f)/i.height),m.push((l+h)/i.height);var g=Math.max.apply(Math,m);g>1&&(r/=g,o/=g,a/=g,l/=g,u/=g,h/=g,p/=g,f/=g);var _=i.width-a,A=i.height-h,y=i.width-u,v=i.height-f,x=t.borderTopWidth,b=t.borderRightWidth,w=t.borderBottomWidth,T=t.borderLeftWidth,E=$i(t.paddingTop,e.bounds.width),C=$i(t.paddingRight,e.bounds.width),S=$i(t.paddingBottom,e.bounds.width),B=$i(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Ml(i.left+T/3,i.top+x/3,r-T/3,o-x/3,Ja.TOP_LEFT):new El(i.left+T/3,i.top+x/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Ml(i.left+_,i.top+x/3,a-b/3,l-x/3,Ja.TOP_RIGHT):new El(i.left+i.width-b/3,i.top+x/3),this.bottomRightBorderDoubleOuterBox=u>0||h>0?Ml(i.left+y,i.top+A,u-b/3,h-w/3,Ja.BOTTOM_RIGHT):new El(i.left+i.width-b/3,i.top+i.height-w/3),this.bottomLeftBorderDoubleOuterBox=p>0||f>0?Ml(i.left+T/3,i.top+v,p-T/3,f-w/3,Ja.BOTTOM_LEFT):new El(i.left+T/3,i.top+i.height-w/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Ml(i.left+2*T/3,i.top+2*x/3,r-2*T/3,o-2*x/3,Ja.TOP_LEFT):new El(i.left+2*T/3,i.top+2*x/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Ml(i.left+_,i.top+2*x/3,a-2*b/3,l-2*x/3,Ja.TOP_RIGHT):new El(i.left+i.width-2*b/3,i.top+2*x/3),this.bottomRightBorderDoubleInnerBox=u>0||h>0?Ml(i.left+y,i.top+A,u-2*b/3,h-2*w/3,Ja.BOTTOM_RIGHT):new El(i.left+i.width-2*b/3,i.top+i.height-2*w/3),this.bottomLeftBorderDoubleInnerBox=p>0||f>0?Ml(i.left+2*T/3,i.top+v,p-2*T/3,f-2*w/3,Ja.BOTTOM_LEFT):new El(i.left+2*T/3,i.top+i.height-2*w/3),this.topLeftBorderStroke=r>0||o>0?Ml(i.left+T/2,i.top+x/2,r-T/2,o-x/2,Ja.TOP_LEFT):new El(i.left+T/2,i.top+x/2),this.topRightBorderStroke=r>0||o>0?Ml(i.left+_,i.top+x/2,a-b/2,l-x/2,Ja.TOP_RIGHT):new El(i.left+i.width-b/2,i.top+x/2),this.bottomRightBorderStroke=u>0||h>0?Ml(i.left+y,i.top+A,u-b/2,h-w/2,Ja.BOTTOM_RIGHT):new El(i.left+i.width-b/2,i.top+i.height-w/2),this.bottomLeftBorderStroke=p>0||f>0?Ml(i.left+T/2,i.top+v,p-T/2,f-w/2,Ja.BOTTOM_LEFT):new El(i.left+T/2,i.top+i.height-w/2),this.topLeftBorderBox=r>0||o>0?Ml(i.left,i.top,r,o,Ja.TOP_LEFT):new El(i.left,i.top),this.topRightBorderBox=a>0||l>0?Ml(i.left+_,i.top,a,l,Ja.TOP_RIGHT):new El(i.left+i.width,i.top),this.bottomRightBorderBox=u>0||h>0?Ml(i.left+y,i.top+A,u,h,Ja.BOTTOM_RIGHT):new El(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=p>0||f>0?Ml(i.left,i.top+v,p,f,Ja.BOTTOM_LEFT):new El(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Ml(i.left+T,i.top+x,Math.max(0,r-T),Math.max(0,o-x),Ja.TOP_LEFT):new El(i.left+T,i.top+x),this.topRightPaddingBox=a>0||l>0?Ml(i.left+Math.min(_,i.width-b),i.top+x,_>i.width+b?0:Math.max(0,a-b),Math.max(0,l-x),Ja.TOP_RIGHT):new El(i.left+i.width-b,i.top+x),this.bottomRightPaddingBox=u>0||h>0?Ml(i.left+Math.min(y,i.width-T),i.top+Math.min(A,i.height-w),Math.max(0,u-b),Math.max(0,h-w),Ja.BOTTOM_RIGHT):new El(i.left+i.width-b,i.top+i.height-w),this.bottomLeftPaddingBox=p>0||f>0?Ml(i.left+T,i.top+Math.min(v,i.height-w),Math.max(0,p-T),Math.max(0,f-w),Ja.BOTTOM_LEFT):new El(i.left+T,i.top+i.height-w),this.topLeftContentBox=r>0||o>0?Ml(i.left+T+B,i.top+x+E,Math.max(0,r-(T+B)),Math.max(0,o-(x+E)),Ja.TOP_LEFT):new El(i.left+T+B,i.top+x+E),this.topRightContentBox=a>0||l>0?Ml(i.left+Math.min(_,i.width+T+B),i.top+x+E,_>i.width+T+B?0:a-T+B,l-(x+E),Ja.TOP_RIGHT):new El(i.left+i.width-(b+C),i.top+x+E),this.bottomRightContentBox=u>0||h>0?Ml(i.left+Math.min(y,i.width-(T+B)),i.top+Math.min(A,i.height+x+E),Math.max(0,u-(b+C)),h-(w+S),Ja.BOTTOM_RIGHT):new El(i.left+i.width-(b+C),i.top+i.height-(w+S)),this.bottomLeftContentBox=p>0||f>0?Ml(i.left+T+B,i.top+v,Math.max(0,p-(T+B)),f-(w+S),Ja.BOTTOM_LEFT):new El(i.left+T+B,i.top+i.height-(w+S))}return e}();!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(Ja||(Ja={}));var Ml=function(e,t,i,n,r){var o=(Math.sqrt(2)-1)/3*4,s=i*o,a=n*o,l=e+i,c=t+n;switch(r){case Ja.TOP_LEFT:return new Sl(new El(e,c),new El(e,c-a),new El(l-s,t),new El(l,t));case Ja.TOP_RIGHT:return new Sl(new El(e,t),new El(e+s,t),new El(l,c-a),new El(l,c));case Ja.BOTTOM_RIGHT:return new Sl(new El(l,t),new El(l,t+a),new El(e+s,c),new El(e,c));case Ja.BOTTOM_LEFT:default:return new Sl(new El(l,c),new El(l-s,c),new El(e,t+a),new El(e,t))}},Pl=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Rl=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},Ll=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Fl=function(){function e(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6}return e}(),kl=function(){function e(e,t){this.path=e,this.target=t,this.type=1}return e}(),Dl=function(){function e(e){this.opacity=e,this.type=2,this.target=6}return e}(),Ol=function(e){return 0===e.type},zl=function(e){return 1===e.type},Ul=function(e){return 2===e.type},Nl=function(e,t){return e.length===t.length&&e.some(function(e,i){return e===t[i]})},Vl=function(e,t,i,n,r){return e.map(function(e,o){switch(o){case 0:return e.add(t,i);case 1:return e.add(t+n,i);case 2:return e.add(t+n,i+r);case 3:return e.add(t,i+r)}return e})},jl=function(){function e(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),Gl=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Il(this.container),this.container.styles.opacity<1&&this.effects.push(new Dl(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Fl(i,n,r))}if(0!==this.container.styles.overflowX){var o=Pl(this.curves),s=Ll(this.curves);Nl(o,s)?this.effects.push(new kl(o,6)):(this.effects.push(new kl(o,2)),this.effects.push(new kl(s,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,n=this.effects.slice(0);i;){var r=i.effects.filter(function(e){return!zl(e)});if(t||0!==i.container.styles.position||!i.parent){if(n.unshift.apply(n,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=Pl(i.curves),s=Ll(i.curves);Nl(o,s)||n.unshift(new kl(s,6))}}else n.unshift.apply(n,r);i=i.parent}return n.filter(function(t){return ao(t.target,e)})},e}(),Hl=function(e,t,i,n){e.container.elements.forEach(function(r){var o=ao(r.flags,4),s=ao(r.flags,2),a=new Gl(r,e);ao(r.styles.display,2048)&&n.push(a);var l=ao(r.flags,8)?[]:n;if(o||s){var c=o||r.styles.isPositioned()?i:t,u=new jl(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var h=r.styles.zIndex.order;if(h<0){var d=0;c.negativeZIndex.some(function(e,t){return h>e.element.container.styles.zIndex.order?(d=t,!1):d>0}),c.negativeZIndex.splice(d,0,u)}else if(h>0){var p=0;c.positiveZIndex.some(function(e,t){return h>=e.element.container.styles.zIndex.order?(p=t+1,!1):p>0}),c.positiveZIndex.splice(p,0,u)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(u)}else r.styles.isFloating()?c.nonPositionedFloats.push(u):c.nonPositionedInlineLevel.push(u);Hl(a,u,o?u:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Hl(a,t,i,l);ao(r.flags,8)&&Ql(r,l)})},Ql=function(e,t){for(var i=e instanceof $s?e.start:1,n=e instanceof $s&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var n=ec(e),r=Ll(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,n.left,n.top,n.width,n.height),this.ctx.restore()}},i.prototype.renderNodeContent=function(e){return n(this,void 0,void 0,function(){var t,n,o,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x;return r(this,function(r){switch(r.label){case 0:this.applyEffects(e.getEffects(4)),t=e.container,n=e.curves,o=t.styles,a=0,l=t.textNodes,r.label=1;case 1:return a0&&T>0&&(A=n.ctx.createPattern(m,"repeat"),n.renderRepeat(v,A,C,S))):Dn(i)&&(y=nc(e,t,[null,null,null]),v=y[0],x=y[1],b=y[2],w=y[3],T=y[4],E=0===i.position.length?[Gi]:i.position,C=$i(E[0],w),S=$i(E[E.length-1],T),B=xn(i,C,S,w,T),I=B[0],M=B[1],I>0&&M>0&&(P=n.ctx.createRadialGradient(x+C,b+S,0,x+C,b+S,I),gn(i.stops,2*I).forEach(function(e){return P.addColorStop(e.stop,rn(e.color))}),n.path(v),n.ctx.fillStyle=P,I!==M?(R=e.bounds.left+.5*e.bounds.width,L=e.bounds.top+.5*e.bounds.height,k=1/(F=M/I),n.ctx.save(),n.ctx.translate(R,L),n.ctx.transform(1,0,0,F,0,0),n.ctx.translate(-R,-L),n.ctx.fillRect(x,k*(b-L)+L,w,T*k),n.ctx.restore()):n.ctx.fill())),r.label=6;case 6:return t--,[2]}})},n=this,o=0,s=e.styles.backgroundImage.slice(0).reverse(),l.label=1;case 1:return o0?2!==c.style?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,s,e.curves,2)]:[3,11]:[3,13];case 4:return r.sent(),[3,11];case 5:return 3!==c.style?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,s,e.curves,3)];case 6:return r.sent(),[3,11];case 7:return 4!==c.style?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,s,e.curves)];case 8:return r.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,s,e.curves)];case 10:r.sent(),r.label=11;case 11:s++,r.label=12;case 12:return a++,[3,3];case 13:return[2]}})})},i.prototype.renderDashedDottedBorder=function(e,t,i,o,s){return n(this,void 0,void 0,function(){var n,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x;return r(this,function(r){return this.ctx.save(),n=Kl(o,i),a=Zl(o,i),2===s&&(this.path(a),this.ctx.clip()),Bl(a[0])?(l=a[0].start.x,c=a[0].start.y):(l=a[0].x,c=a[0].y),Bl(a[1])?(u=a[1].end.x,h=a[1].end.y):(u=a[1].x,h=a[1].y),d=0===i||2===i?Math.abs(l-u):Math.abs(c-h),this.ctx.beginPath(),3===s?this.formatPath(n):this.formatPath(a.slice(0,2)),p=t<3?3*t:2*t,f=t<3?2*t:t,3===s&&(p=t,f=t),m=!0,d<=2*p?m=!1:d<=2*p+f?(p*=g=d/(2*p+f),f*=g):(_=Math.floor((d+f)/(p+f)),A=(d-_*p)/(_-1),f=(y=(d-(_+1)*p)/_)<=0||Math.abs(f-A){};return function(e,t){for(const{type:i,value:n,id:r}of e){if(document.getElementById(r))return void("script"===i&&t());const e=document.createElement(i);e.id=r,"script"===i?(e.async=!0,e.defer=!0,e.src=n,e.onload=()=>t()):(e.rel="stylesheet",e.href=n),document.body.appendChild(e)}}(i,()=>{r=function(e,t){const i=new window.MapboxGeocoder(e);i.addTo(`#${t.id}`),e.value&&i.setInput(e.value);return function(e,t,i,n){const r=[];for(const[o,s]of Object.entries(t)){const t=t=>{const[r,o]=s(e,t,i);n.dispatchEvent(new CustomEvent(r,{detail:o}))};e.on(o,t),r.push([o,t])}return()=>{for(const[t,i]of r)e.off(t,i)}}(i,KK,!1,t)}(t,e)}),{destroy(){r()}}}const KK={results:(e,t)=>["results",t],result:(e,t)=>["result",t],loading:(e,t)=>["loading",t],error:(e,t)=>["error",t],clear:(e,t)=>["clear",t],load:e=>["ready",{geocoder:e}]};function XK(e){let i,n,r;return{c(){i=b("div"),B(i,"id",e[0]),B(i,"class","svelte-1k1b3t4")},m(t,o){y(t,i,o),n||(r=[_(qK.call(null,i,e[1])),S(i,"ready",e[2]),S(i,"results",e[11]),S(i,"result",e[12]),S(i,"loading",e[13]),S(i,"error",e[14]),S(i,"clear",e[15]),S(i,"load",e[16])],n=!0)},p:t,i:t,o:t,d(e){e&&v(i),n=!1,o(r)}}}function JK(e,t,i){let{accessToken:n}=t,{options:r={}}=t,{version:o="v4.5.1"}=t,{types:s=["country","region","postcode","district","place","locality","neighborhood","address"]}=t,{placeholder:a="Search"}=t,{value:l=null}=t,{customStylesheetUrl:c=!1}=t,{geocoder:u}=t;const h=H(),d="bsm-"+Math.random().toString(36).substring(6),p=Object.assign({version:o,accessToken:n,types:s.join(","),placeholder:a,customStylesheetUrl:c,value:l},r);return e.$$set=e=>{"accessToken"in e&&i(4,n=e.accessToken),"options"in e&&i(5,r=e.options),"version"in e&&i(6,o=e.version),"types"in e&&i(7,s=e.types),"placeholder"in e&&i(8,a=e.placeholder),"value"in e&&i(9,l=e.value),"customStylesheetUrl"in e&&i(10,c=e.customStylesheetUrl),"geocoder"in e&&i(3,u=e.geocoder)},[d,p,function({detail:e}){i(3,u=e.geocoder),h("ready")},u,n,r,o,s,a,l,c,function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)}]}class YK extends ge{constructor(e){super(),me(this,e,JK,XK,a,{accessToken:4,options:5,version:6,types:7,placeholder:8,value:9,customStylesheetUrl:10,geocoder:3})}}function eX(e){let t,i,n;return i=new dq({props:{options:e[1].map(tX),activeValue:e[0],onSelect:e[2],direction:"down"}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"class","dropdown-container svelte-1yvkhcz")},m(e,r){y(e,t,r),pe(i,t,null),n=!0},p(e,[t]){const n={};2&t&&(n.options=e[1].map(tX)),1&t&&(n.activeValue=e[0]),4&t&&(n.onSelect=e[2]),i.$set(n)},i(e){n||(le(i.$$.fragment,e),n=!0)},o(e){ce(i.$$.fragment,e),n=!1},d(e){e&&v(t),fe(i)}}}const tX=e=>({label:e,value:e});function iX(e,t,i){let n,r;l(e,rt,e=>i(5,r=e));let{mode:o}=t,{mapsNum:s}=t;const a=H();let c=o??"",u=bu;const h=e=>{1===e&&i(1,u=bu.filter(e=>"swipe"!==e)),2===e&&i(1,u=bu.filter(e=>"responsive"!==e)),e>2&&e<=4&&i(1,u=bu.filter(e=>"swipe"!==e&&"responsive"!==e)),e>4&&i(1,u=bu.filter(e=>"swipe"!==e&&"phone"!==e&&"responsive"!==e)),r||i(1,u=["mirror"]),u.includes(c)||i(0,c=u[0])};return rt.subscribe(()=>{h(s)}),e.$$set=e=>{"mode"in e&&i(3,o=e.mode),"mapsNum"in e&&i(4,s=e.mapsNum)},e.$$.update=()=>{var t;16&e.$$.dirty&&h(s),1&e.$$.dirty&&(e=>{a("viewMode",{mode:e})})(c),8&e.$$.dirty&&(t=o)!==c&&i(0,c=t)},i(2,n=e=>{i(0,c=e)}),[c,u,n,o,s]}class nX extends ge{constructor(e){super(),me(this,e,iX,eX,a,{mode:3,mapsNum:4})}}function rX(e){let t,i,n;return i=new dq({props:{placeholder:"Go to...",options:e[3],activeValue:e[1],onSelect:e[2],direction:"down"}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"class","dropdown-container svelte-1ho45wf")},m(e,r){y(e,t,r),pe(i,t,null),n=!0},p(e,t){const n={};8&t&&(n.options=e[3]),2&t&&(n.activeValue=e[1]),4&t&&(n.onSelect=e[2]),i.$set(n)},i(e){n||(le(i.$$.fragment,e),n=!0)},o(e){ce(i.$$.fragment,e),n=!1},d(e){e&&v(t),fe(i)}}}function oX(e){let t,i,n=e[0]&&rX(e);return{c(){n&&n.c(),t=C()},m(e,r){n&&n.m(e,r),y(e,t,r),i=!0},p(e,[i]){e[0]?n?(n.p(e,i),1&i&&le(n,1)):(n=rX(e),n.c(),le(n,1),n.m(t.parentNode,t)):n&&(se(),ce(n,1,1,()=>{n=null}),ae())},i(e){i||(le(n),i=!0)},o(e){ce(n),i=!1},d(e){n&&n.d(e),e&&v(t)}}}function sX(e,t,i){let n,r,{bearing:o}=t,{center:s}=t,{pitch:a}=t,{zoom:l}=t;const c=H();let u;it.subscribe(e=>i(0,({gazetteer:u}=e),u));const h=(e,t)=>Number.parseFloat(e).toFixed(t),d=e=>{if(!u)return"";const t=Object.keys(u).reduce((e,t)=>e=e.concat(u[t]),[]).find(t=>{const i=Object.values(t)[0];return Object.keys(i).every(t=>{if("center"===t&&e.center){const{lng:t,lat:n}=i.center,{lng:r,lat:o}=e.center;return h(t,4)===h(r,4)&&h(n,4)===h(o,4)}return h(i[t],2)===h(e[t],2)})});return t?JSON.stringify(t):""};let p=d({zoom:l,center:s,pitch:a,bearing:o});const f=()=>{const{options:e}=(e=>{if(!e)return{};try{const t=JSON.parse(e),i=Object.keys(t)[0],n=t[i];return c("mapState",{options:n}),{label:i,options:n}}catch(e){return console.error(e),{}}})(p);e&&c("mapState",{options:e})};return e.$$set=e=>{"bearing"in e&&i(4,o=e.bearing),"center"in e&&i(5,s=e.center),"pitch"in e&&i(6,a=e.pitch),"zoom"in e&&i(7,l=e.zoom)},e.$$.update=()=>{240&e.$$.dirty&&(e=>{const t=d(e);p!==t&&i(1,p=t??"")})({zoom:l,center:s,pitch:a,bearing:o}),2&e.$$.dirty&&f(),1&e.$$.dirty&&i(3,n=Object.entries(u).reduce((e,[t,i])=>{e.push({header:t});for(const t of i){let[i,n]=Object.entries(t)[0];e.push({label:i,value:JSON.stringify(t)})}return e},[]))},i(2,r=e=>{i(1,p=e)}),[u,p,r,n,o,s,a,l]}class aX extends ge{constructor(e){super(),me(this,e,sX,oX,a,{bearing:4,center:5,pitch:6,zoom:7})}}function lX(e){let t,i;return{c(){t=b("div"),i=T(e[0]),R(t,"top",e[3]+"px"),R(t,"left",e[2]+"px"),B(t,"class","tooltip svelte-1qc780y")},m(e,n){y(e,t,n),A(t,i)},p(e,n){1&n&&M(i,e[0]),8&n&&R(t,"top",e[3]+"px"),4&n&&R(t,"left",e[2]+"px")},d(e){e&&v(t)}}}function cX(e){let t,i,n,r,s,a;const l=e[8].default,u=c(l,e,e[7],null);let f=e[1]&&lX(e);return{c(){t=b("div"),u&&u.c(),i=E(),f&&f.c(),n=C()},m(o,l){y(o,t,l),u&&u.m(t,null),y(o,i,l),f&&f.m(o,l),y(o,n,l),r=!0,s||(a=[S(t,"mouseover",e[4]),S(t,"mouseleave",e[6]),S(t,"mousemove",e[5])],s=!0)},p(e,[t]){u&&u.p&&(!r||128&t)&&d(u,l,e,e[7],r?h(l,e[7],t,null):p(e[7]),null),e[1]?f?f.p(e,t):(f=lX(e),f.c(),f.m(n.parentNode,n)):f&&(f.d(1),f=null)},i(e){r||(le(u,e),r=!0)},o(e){ce(u,e),r=!1},d(e){e&&v(t),u&&u.d(e),e&&v(i),f&&f.d(e),e&&v(n),s=!1,o(a)}}}function uX(e,t,i){let n,r,{$$slots:o={},$$scope:s}=t,{title:a=""}=t,l=!1;return e.$$set=e=>{"title"in e&&i(0,a=e.title),"$$scope"in e&&i(7,s=e.$$scope)},[a,l,n,r,function(e){i(1,l=!0),i(2,n=e.pageX+5),i(3,r=e.pageY+5)},function(e){i(2,n=e.pageX+5),i(3,r=e.pageY+5)},function(){i(1,l=!1)},s,o]}class hX extends ge{constructor(e){super(),me(this,e,uX,cX,a,{title:0})}}function dX(e,t,i){const n=e.slice();return n[27]=t[i],n}function pX(e){let i,n,r,s,a;return n=new NW({props:{icon:CW}}),{c(){i=b("button"),de(n.$$.fragment),B(i,"class","fullscreen-btn show-ui svelte-1g6kozd"),B(i,"title","Show UI")},m(t,o){y(t,i,o),pe(n,i,null),r=!0,s||(a=[S(i,"click",e[13]),_(qW.call(null,i,{shift:!0,control:!0,code:"KeyF",callback:e[13]}))],s=!0)},p:t,i(e){r||(le(n.$$.fragment,e),r=!0)},o(e){ce(n.$$.fragment,e),r=!1},d(e){e&&v(i),fe(n),s=!1,o(a)}}}function fX(e){let t,n,r,s,a,l,c,u,h,d,p,f,m,g,x,w,C,I,M,P,L,F,k,D,O,z,U,N,V,j,G,H,Q,$,Z,W,q,K,X,J,Y,ee,te,ie,ne,re,oe,me,ge,_e;a=new NW({props:{icon:e[8]?BW:RW}});let Ae=e[8]&&mX(e);d=new nX({props:{mode:e[4],mapsNum:e[5].length}}),d.$on("viewMode",e[21]);let ye=e[3]&&gX(e);const ve=[e[6]];let xe={};for(let e=0;e0&&yX(e);return{c(){t=b("div"),n=b("div"),r=b("div"),s=b("div"),de(a.$$.fragment),c=E(),Ae&&Ae.c(),u=E(),h=b("div"),de(d.$$.fragment),p=E(),f=b("div"),ye&&ye.c(),m=E(),g=b("div"),de(x.$$.fragment),w=E(),C=b("div"),I=b("div"),M=b("label"),P=b("span"),P.innerHTML='Label Collisions',L=E(),F=b("input"),k=E(),D=b("label"),O=b("span"),O.innerHTML='Tile Boundaries',z=E(),U=b("input"),N=E(),be&&be.c(),V=E(),j=b("div"),G=b("div"),H=b("button"),de(Q.$$.fragment),$=T(" Add map"),q=E(),K=b("button"),de(X.$$.fragment),J=T("\n Copy image"),te=E(),ie=b("div"),ne=b("button"),de(re.$$.fragment),oe=E(),we&&we.c(),B(s,"class","link-button svelte-1g6kozd"),R(s,"margin-right","6px"),B(s,"title",l=e[8]?"Unlink locations":"Link locations"),B(r,"class","control-section svelte-1g6kozd"),B(h,"class","control-section svelte-1g6kozd"),B(f,"class","control-section svelte-1g6kozd"),B(g,"class","control-section svelte-1g6kozd"),B(P,"class","checkbox-label svelte-1g6kozd"),B(F,"type","checkbox"),B(M,"class","checkbox-container svelte-1g6kozd"),B(O,"class","checkbox-label svelte-1g6kozd"),B(U,"type","checkbox"),B(D,"class","checkbox-container svelte-1g6kozd"),B(I,"class","checkboxes svelte-1g6kozd"),B(C,"class","control-section svelte-1g6kozd"),R(H,"margin-right","6px"),H.disabled=Z=e[5].length>=8,B(H,"title",W=e[5].length>=8?"Maximum of 8 maps allowed.":""),K.disabled=Y="swipe"===e[4],B(K,"title",ee="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"),B(G,"class","buttons svelte-1g6kozd"),B(j,"class","control-section svelte-1g6kozd"),B(ne,"class","fullscreen-btn svelte-1g6kozd"),B(ne,"title","Hide UI"),B(ie,"class","control-section svelte-1g6kozd"),B(n,"class","control-row svelte-1g6kozd"),B(t,"class","map-controls svelte-1g6kozd")},m(i,o){y(i,t,o),A(t,n),A(n,r),A(r,s),pe(a,s,null),A(r,c),Ae&&Ae.m(r,null),A(n,u),A(n,h),pe(d,h,null),A(n,p),A(n,f),ye&&ye.m(f,null),A(n,m),A(n,g),pe(x,g,null),A(n,w),A(n,C),A(C,I),A(I,M),A(M,P),A(M,L),A(M,F),F.checked=e[0],A(I,k),A(I,D),A(D,O),A(D,z),A(D,U),U.checked=e[1],A(I,N),be&&be.m(I,null),A(n,V),A(n,j),A(j,G),A(G,H),pe(Q,H,null),A(H,$),A(G,q),A(G,K),pe(X,K,null),A(K,J),A(n,te),A(n,ie),A(ie,ne),pe(re,ne,null),A(t,oe),we&&we.m(t,null),me=!0,ge||(_e=[S(s,"click",e[14]),S(F,"change",e[23]),S(U,"change",e[24]),S(H,"click",e[11]),S(K,"click",e[12]),S(ne,"click",e[13]),_(qW.call(null,ne,{shift:!0,control:!0,code:"KeyF",callback:e[13]}))],ge=!0)},p(e,i){const n={};256&i&&(n.icon=e[8]?BW:RW),a.$set(n),(!me||256&i&&l!==(l=e[8]?"Unlink locations":"Link locations"))&&B(s,"title",l),e[8]?Ae?(Ae.p(e,i),256&i&&le(Ae,1)):(Ae=mX(e),Ae.c(),le(Ae,1),Ae.m(r,null)):Ae&&(se(),ce(Ae,1,1,()=>{Ae=null}),ae());const o={};16&i&&(o.mode=e[4]),32&i&&(o.mapsNum=e[5].length),d.$set(o),e[3]?ye?(ye.p(e,i),8&i&&le(ye,1)):(ye=gX(e),ye.c(),le(ye,1),ye.m(f,null)):ye&&(se(),ce(ye,1,1,()=>{ye=null}),ae());const c=64&i?ue(ve,[he(e[6])]):{};x.$set(c),1&i&&(F.checked=e[0]),2&i&&(U.checked=e[1]),"swipe"===e[4]?be?(be.p(e,i),16&i&&le(be,1)):(be=_X(e),be.c(),le(be,1),be.m(I,null)):be&&(se(),ce(be,1,1,()=>{be=null}),ae()),(!me||32&i&&Z!==(Z=e[5].length>=8))&&(H.disabled=Z),(!me||32&i&&W!==(W=e[5].length>=8?"Maximum of 8 maps allowed.":""))&&B(H,"title",W),(!me||16&i&&Y!==(Y="swipe"===e[4]))&&(K.disabled=Y),(!me||16&i&&ee!==(ee="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"))&&B(K,"title",ee),e[7].length>0?we?we.p(e,i):(we=yX(e),we.c(),we.m(t,null)):we&&(we.d(1),we=null)},i(e){me||(le(a.$$.fragment,e),le(Ae),le(d.$$.fragment,e),le(ye),le(x.$$.fragment,e),le(be),le(Q.$$.fragment,e),le(X.$$.fragment,e),le(re.$$.fragment,e),me=!0)},o(e){ce(a.$$.fragment,e),ce(Ae),ce(d.$$.fragment,e),ce(ye),ce(x.$$.fragment,e),ce(be),ce(Q.$$.fragment,e),ce(X.$$.fragment,e),ce(re.$$.fragment,e),me=!1},d(e){e&&v(t),fe(a),Ae&&Ae.d(),fe(d),ye&&ye.d(),fe(x),be&&be.d(),fe(Q),fe(X),fe(re),we&&we.d(),ge=!1,o(_e)}}}function mX(e){let t,n;const r=[e[6]];let o={};for(let e=0;eDifferences',n=E(),r=b("input"),B(i,"class","checkbox-label svelte-1g6kozd"),B(r,"type","checkbox"),B(t,"class","checkbox-container svelte-1g6kozd")},m(a,l){y(a,t,l),A(t,i),A(t,n),A(t,r),r.checked=e[2],o||(s=S(r,"change",e[25]),o=!0)},p(e,t){4&t&&(r.checked=e[2])},d(e){e&&v(t),o=!1,s()}}}function yX(e){let t,i=e[7],n=[];for(let t=0;t{l[o]=null}),ae(),i=l[t],i?i.p(e,r):(i=l[t]=a[t](e),i.c()),le(i,1),i.m(n.parentNode,n))},i(e){r||(le(i),r=!0)},o(e){ce(i),r=!1},d(e){l[t].d(e),e&&v(n),o=!1,s()}}}function bX(e,t,i){let n,r;l(e,rt,e=>i(8,n=e)),l(e,nt,e=>i(9,r=e));let{bearing:o}=t,{center:s}=t,{mapboxGlAccessToken:a}=t,{pitch:c}=t,{showCollisions:u}=t,{showBoundaries:h}=t,{showDiff:d}=t,{viewMode:p}=t,{zoom:f}=t;const m=H();let g,_=[],A=[];et.subscribe(e=>i(5,_=e));return e.$$set=e=>{"bearing"in e&&i(16,o=e.bearing),"center"in e&&i(17,s=e.center),"mapboxGlAccessToken"in e&&i(3,a=e.mapboxGlAccessToken),"pitch"in e&&i(18,c=e.pitch),"showCollisions"in e&&i(0,u=e.showCollisions),"showBoundaries"in e&&i(1,h=e.showBoundaries),"showDiff"in e&&i(2,d=e.showDiff),"viewMode"in e&&i(4,p=e.viewMode),"zoom"in e&&i(19,f=e.zoom)},e.$$.update=()=>{983040&e.$$.dirty&&i(6,g={bearing:o,center:s,pitch:c,zoom:f}),96&e.$$.dirty&&i(7,A=((e,t)=>{const i=[],n=hK(e,t);return e.pitch>=n&&i.push({type:"warning",message:`Pitch capped at ${n} as that is the maximum for this zoom level.`}),i})(g,_)),20&e.$$.dirty&&"swipe"!==p&&d&&i(2,d=!1),7&e.$$.dirty&&m("mapState",{options:{showCollisions:u,showBoundaries:h,showDiff:d}})},[u,h,d,a,p,_,g,A,n,r,({detail:e})=>{const{result:t}=e,i={center:{lat:t.center[1],lng:t.center[0]},zoom:17};t.bbox&&(i.zoom=14),m("mapState",{options:i})},()=>{et.update(e=>{let t=e[e.length-1];t={...t,index:t.index+1};return e.concat([t])}),n||ot.update(e=>[...e,{...e[e.length-1]}])},async()=>{const e=document.getElementsByClassName("maps")[0];let t=[...document.getElementsByClassName("screenshot-label-transparent")];t.forEach(e=>{e.classList.remove("screenshot-label-transparent"),e.classList.add("screenshot-label")});let i=[];"mirror"===p&&(i=[...document.getElementsByClassName("map-container-border")],i.forEach(e=>{e.classList.remove("map-container-border"),e.classList.add("map-container-border-transparent")}));WK(e,{ignoreElements:e=>!(!e.className||"string"!=typeof e.className)&&e.className.includes("map-label")}).then(e=>{e.toBlob(e=>navigator.clipboard.write([new ClipboardItem({"image/png":e})]))}),t.forEach(e=>{e.classList.remove("screenshot-label"),e.classList.add("screenshot-label-transparent")}),"mirror"===p&&i.forEach(e=>{e.classList.remove("map-container-border-transparent"),e.classList.add("map-container-border")})},()=>{nt.update(e=>!e)},()=>{rt.update(e=>!e)},function(e){"input"!==e.target.tagName.toLowerCase()&&("c"!==e.key&&"C"!==e.key||i(0,u=!u),"t"!==e.key&&"T"!==e.key||i(1,h=!h),"d"!==e.key&&"D"!==e.key||i(2,d=!d))},o,s,c,f,function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(){u=this.checked,i(0,u)},function(){h=this.checked,i(1,h)},function(){d=this.checked,i(2,d),i(4,p)}]}class wX extends ge{constructor(e){super(),me(this,e,bX,xX,a,{bearing:16,center:17,mapboxGlAccessToken:3,pitch:18,showCollisions:0,showBoundaries:1,showDiff:2,viewMode:4,zoom:19})}}let TX;rt.subscribe(e=>TX=e);const EX=["locations"],CX=["showCollisions","showBoundaries","showDiff"],SX=["bearing","center","pitch","zoom"],BX=["bearing","lat","lng","pitch","zoom"],IX=["map","stylePresets"];const MX=(e,t)=>{const i=[...t.filter(e=>"sublist"!==e.type),...t.filter(e=>"sublist"===e.type).flatMap(e=>e.presets)];return i.find(t=>t.id===e)},PX=(e,t)=>{const i=t.find(t=>t.id===e.branchId);return i?{...i,url:xu(i.pattern,e.branch,e.branchStyle)}:null},RX=(e,t)=>{const i=JSON.parse(e).map(e=>{let i=MX(e.id,t?.stylePresets??[]);return i||(i=PX(e,t?.branchPatterns??[])),i?(i=je(i),e?.selectedPrecompileOption&&(i.selectedPrecompileOption=e?.selectedPrecompileOption),e?.landmarks3D&&(i.landmarks3D=e?.landmarks3D),{...i,...e}):e}).filter(e=>e);return i},LX=({zoom:e,center:t,pitch:i,bearing:n})=>[lt(e,2),lt(t.lat,4),lt(t.lng,4),lt(i??0,1),lt(n??0,1)].join("/"),FX=e=>{const[t,i,n,r,o]=e.split("/");return{bearing:o,center:{lat:i,lng:n},pitch:r,zoom:t}};const kX=(e,t)=>{let i=Object.fromEntries(Object.entries(e).filter(([e,t])=>!SX.includes(e)&&"locations"!==e).map(([e,i])=>{let n=i;return"maps"===e?n=((e,t)=>{const i=e.map(e=>{let i,n={id:e.id};if(e.branchId?(i=PX(e,t?.branchPatterns??[]),n={branchId:i.id,branchStyle:e.branchStyle,branch:e.branch}):i=MX(e.id,t.stylePresets),!i)return Object.fromEntries(Object.entries(e).filter(([e])=>"style"!==e));if(e.renderer!==i.renderer&&(n.renderer=e.renderer),e?.selectedPrecompileOption){const t=e.selectedPrecompileOption??[],r=i?.precompile?.options?.default??[];t.every(e=>r.includes(e))&&r.every(e=>t.includes(e))||(n.selectedPrecompileOption=e.selectedPrecompileOption)}return e?.landmarks3D&&(n.landmarks3D=e.landmarks3D),n});return JSON.stringify(i)})(i,t):EX.includes(e)&&(n=JSON.stringify(i)),[e,n]}));i=(e=>{let t=Object.keys(e).reduce((t,i)=>{const n=e[i];return CX.includes(i)&&!n||null!==n&&(t[i]=n),t},{});return t})(i);const n=DX(window.location.hash,t),r=Object.entries(i).some(e=>{let[t,i]=e;if(IX.includes(t))return!1;try{i=JSON.parse(i)}catch(e){}return!fK(i,n?.[t])});let o={...i};o=TX?{map:LX(e),...o}:{locations:JSON.stringify(e.locations.map(e=>LX(e))),...o};const s=function(e){let t=e.map?`map=${e.map}`:"";return Object.entries(e).forEach(([e,i],n)=>{if(IX.includes(e))return;let r=encodeURIComponent(i);t=`${t}${""!==t?"&":""}${e}=${r}`}),t}(o);return{nextHash:s,requiresHistoryItem:r}};function DX(e,t){let i=Object.fromEntries(Object.entries(function(e){const t=e.split("#")[1];if(!t)return{};let i=Object.fromEntries(t.split("&").map(e=>e.split("=").map(decodeURIComponent)));return i.map&&(i={...i,...FX(i.map)}),i.locations&&(i.locations=JSON.stringify(JSON.parse(i.locations).map(e=>FX(e)))),i}(e)).filter(([e,t])=>!!t).map(([e,i])=>"maps"===e?[e,RX(i,t)]:EX.includes(e)?[e,JSON.parse(i)]:CX.includes(e)?[e,"true"===i]:BX.includes(e)?[e,+i||0]:[e,i]));return i.map&&delete i.map,i}const OX=e=>{const{mapState:t,maps:i,viewMode:n,stylePresets:r}=e;return{...t,viewMode:n,maps:i,stylePresets:r,...DX(window.location.hash,e)}};var zX={};Object.defineProperty(zX,"__esModule",{value:!0}),zX.updateStyle=ZX=zX.addLink=void 0;var UX={};Object.defineProperty(UX,"__esModule",{value:!0}),UX.stamenSvg=void 0;function NX(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return VX(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return VX(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function VX(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i\n\n\n\n\n\n';var jX=function(e,t){Object.entries(t).forEach(function(t){var i=NX(t,2),n=i[0],r=i[1];e.style[n]=r})},GX=document.createElement("img");GX.src="data:image/svg+xml;charset=utf-8,".concat(UX.stamenSvg);var HX=document.createElement("a");HX.href="https://stamen.com";var QX=document.createElement("div");jX(GX,{height:"24px",position:"absolute",bottom:"-1px"});jX(HX,{width:"110px",position:"relative"});jX(QX,{position:"fixed",bottom:"0px",right:"12px",zIndex:1e4,display:"flex",flexDirection:"row-reverse"}),HX.appendChild(GX),QX.appendChild(HX),document.body.appendChild(QX);zX.updateStyle=function(e){for(var t=0,i=Object.entries(e);ti(9,n=e)),ZX("https://stamen.com/blog/","Learn more"),ZX("https://github.com/stamen/maperture","Fork on Github");let{localConfig:r}=t;const o=(e=>{const t=[{id:"mapbox-streets",name:"Mapbox Streets",type:"mapbox-gl",url:"mapbox://styles/mapbox/streets-v11"},{id:"mapbox-light",name:"Mapbox Light",type:"mapbox-gl",url:"mapbox://styles/mapbox/light-v10"}].map((t,i)=>e?.stylePresets?.[i]??t);return{maps:t,mapState:{bearing:0,center:{lng:-73.92169,lat:40.83962},pitch:0,showCollisions:!1,showBoundaries:!1,showDiff:!1,zoom:13.25},viewMode:"swipe",gazetteer:{Scenarios:[{"Zoomed out":{pitch:0,zoom:10}},{"Zoomed in/Tilted":{pitch:45,zoom:16}}],Locations:[{"San Francisco, CA":{zoom:18,center:{lng:-122.4193,lat:37.7648}}},{"Washington DC":{zoom:12,center:{lng:-77.0435,lat:38.9098}}}]},branchPatterns:[{pattern:"",styles:[]}],stylePresetUrls:[],...e}})(r),{mapboxGlAccessToken:s,stylePresetUrls:a}=o;it.set(o);let c=OX(o),u={},h=!1;const d=()=>location.hash.slice(1)!==kX(c,o)?.nextHash;et.set(c.maps.map((e,t)=>({...e,index:t}))),tt.set(c.stylePresets),ot.set(c?.locations??null),n&&n.length&&rt.set(!1);let p=[];j(()=>{a.length>0&&a.forEach(async e=>{const t=await(async e=>{const t=await fetch(e),i=await t.json();return at(i)?i:(console.warn(`Style presets at ${e} is not valid, check the format`),[])})(e);tt.update(e=>[...e,...t])})}),window.addEventListener("hashchange",()=>{if(!h&&d()){const e=OX(o);if(i(0,c=e),c.maps.length){const e=c.maps.map((e,t)=>({...e,index:t}));et.set(e)}}h=!1}),et.subscribe(e=>{const t=je(e).map(e=>(delete e.isPolling,e));i(0,c={...c,maps:t})}),ot.subscribe(e=>{i(0,c={...c,locations:e})}),rt.subscribe(e=>{if(!e&&!n){const e=p.map(()=>u);ot.set(e)}e&&n&&ot.set(null)});const f=Ct(()=>{d()&&(h=!0,function(e,t){const{nextHash:i,requiresHistoryItem:n}=kX(e,t);n?window.location.hash=i:window.location.replace(`${window.location.pathname}#${i}`)}(c,o))},250);return"unavailable"===Ze.getRTLTextPluginStatus()&&Ze.setRTLTextPlugin("https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js"),"unavailable"===Ke.getRTLTextPluginStatus()&&Ke.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js"),e.$$set=e=>{"localConfig"in e&&i(7,r=e.localConfig)},e.$$.update=()=>{5&e.$$.dirty&&(fK(p,c.maps)||i(2,p=c.maps)),6&e.$$.dirty&&i(1,u=dK(u,p)),1&e.$$.dirty&&c&&f(),1&e.$$.dirty&&(c||height||width)&&i(1,u=(()=>{const{bearing:e,center:t,pitch:i,showCollisions:n,showBoundaries:r,showDiff:o,zoom:s,height:a,width:l}=c;return{bearing:e,center:t,pitch:i,showCollisions:n,showBoundaries:r,showDiff:o,zoom:s,...a&&{height:a},...l&&{width:l}}})())},[c,u,p,s,e=>{let t={...u,...e.detail.options};i(0,c={...c,...dK(t,p)})},e=>{i(0,c={...c,viewMode:e.detail.mode})},e=>{i(0,c={...c,...e.detail})},r]}class KX extends ge{constructor(e){super(),me(this,e,qX,WX,a,{localConfig:7})}}const XX=(e,t)=>new KX({target:e,props:t});var JX=Object.freeze({__proto__:null,default:undefined}),YX=Object.freeze({__proto__:null,default:undefined}),eJ={exports:{}};eJ.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function F(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";function oe(){return new Error(re)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(n=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new ce(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;if(i.signal.aborted)throw oe();return{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var n;return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(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 n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)fe(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof ge&&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 Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},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:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},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,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},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,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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)}function tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,nt=.82521,rt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,n]){let r,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?r=o=s:(r=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+rt}function ft([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*gt(r),o=it*gt(o),s=nt*gt(s),[mt(3.1338561*o-1.6168667*r-.4906146*s),mt(-.9787684*o+1.9161415*r+.033454*s),mt(.0719453*o-.2289914*r+1.4052427*s),n]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-rt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,n)=>Tt(e,t[n],i))}class Ct{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+r,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=ut(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=ht(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?ut(Math.atan2(n,i)*ct):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Et(e.rgb,t.rgb,i);return new Ct(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:Tt(r,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(n,r,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class St{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}}const Bt=["bottom","center","top"];class It{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof St||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof St)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let n=Vt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Gt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Ht[i],n++}else r=Ve;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],n++}i=qe(r,o)}else{if(!Ht[r])throw new Error(`Types doesn't contain name = ${r}`);i=Ht[r]}const o=[];for(;ne.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{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];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=$t[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Pt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Lt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new qt;try{n=new Gt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}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 n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{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 n=1;n=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,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,Ve),n=t.parse(e[2],2,Ve);return i&&n?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,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,Ve),n=t.parse(e[2],2,Ve);if(!i||!n)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ti(i,n,r):null}return new ti(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,Vt(e)))return null}else i=Vt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(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()}}class ni{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class ri{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}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,Ve),n=t.parse(e[2],2,ke);if(!i||!n)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ri(i.type,i,n,r):null}return new ri(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,n).join("");if(et(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new si(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[oi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ci=1,li=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=pi(t,e.base,i,n);else if("linear"===e.name)r=pi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new hi(o[0],o[1],o[2],o[3]).solve(pi(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,ke),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,n,r,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=oi(t,n),s=di.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>Je(n,e.type));return new mi(o?Ve:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,n){return 0===n.compare(t,i)}function Ai(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(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,je),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!_i(0,t,i,n)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(n,r,o)}evaluate(e){return new St(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}}class Ci{constructor(e,t,i,n,r){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,De),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,De),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,ke),!a)?null:new Ci(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ge,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Bt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Si(n)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Bi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,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 ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Mi),Math.round(n*r*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Mi+t.x)/i,360*r-180),(n=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Di(e,t,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!ji(e,t,i,n)||!ji(i,n,e,t));var r,o}function Oi(e,t,i){for(const n of i)for(let i=0;i(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Li(t,e)}function $i(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Qi(n,t,i,r),s.push(n)}return s}function Zi(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Qi(n,t,i,r)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=Ji){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Xi(e,i,t),r(e[n],o)>0&&Xi(e,i,n);s0;)a--}0===r(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Xi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=tn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function an(e,t){return t[0]-e[0]}function ln(e){return e[1]-e[0]+1}function cn(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ln(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function hn(e,t){if(!cn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Li(i,e[n]);return i}function dn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function pn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fn(e,t,i){if(!pn(e)||!pn(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(Fi(r,o)){if(xn(e,t))return 0}else if(xn(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(ln(l)<=c){if(!cn(l,e.length))return NaN;if(t){const t=vn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=yn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=un(l,t);wn(s,o,n,e,a,i[0]),wn(s,o,n,e,a,i[1])}}return o}function Cn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],an);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(ln(l)<=u&&ln(c)<=h){if(!cn(l,e.length)&&cn(c,i.length))return NaN;let o;if(t&&n)o=_n(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=mn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=mn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=An(e,l,i,c,r),s=Math.min(s,o)}else{const o=un(l,t),u=un(c,n);Tn(a,s,r,e,i,o[0],u[0]),Tn(a,s,r,e,i,o[0],u[1]),Tn(a,s,r,e,i,o[1],u[0]),Tn(a,s,r,e,i,o[1],u[1])}}return s}function Sn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Bn{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Bn(t,t.features.map(e=>Sn(e.geometry)).flat());if("Feature"===t.type)return new Bn(t,Sn(t.geometry));if("type"in t&&"coordinates"in t)return new Bn(t,Sn(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new sn(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,En([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,En(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,bn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class In{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new In(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Mn={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ni,coalesce:mi,collator:Ei,format:Si,image:Bi,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ri,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Bn,"global-state":In};class Pn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Pn.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Dn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i{i=t?i&&Dn(e):i&&e instanceof Gt}),!!i&&On(e)&&Un(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function On(e){if(e instanceof Pn){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 Wi)return!1;if(e instanceof Bn)return!1;let t=!0;return e.eachChild(e=>{t&&!On(e)&&(t=!1)}),t}function zn(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!zn(e)&&(t=!1)}),t}function Un(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Un(e,t)&&(i=!1)}),i}function Nn(e){return{result:"success",value:e}}function Vn(e){return{result:"error",value:e}}function jn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hn(e){return!!e.expression&&e.expression.interpolated}function Qn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function $n(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function Zn(e){return e}function Wn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||(Hn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Jn;case"interval":return Xn;case"categorical":return Kn;case"identity":return Yn;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Jn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?qn(e.default,t.default):a(e,t,r,l,c)}}}function qn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return qn(typeof i===r?n[i]:void 0,e.default,t.default)}function Xn(e,t,i){if("number"!==Qn(i))return qn(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 r=oi(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Jn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Qn(i))return qn(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 o=oi(e.stops.map(e=>e[0]),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||Zn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Yn(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return qn(i,e.default,t.default)}Pn.register(Mn,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[ze,[ke,ke,ke],Rn],rgba:[ze,[ke,ke,ke,ke],Rn],has:{type:Oe,overloads:[[[De],(e,[t])=>Ln(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Ln(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,kn(ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[ke,kn(ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,kn(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,kn(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,kn(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class er{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&$n(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 Ft(`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 tr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mn}function ir(e,t){const i=new Kt(Mn,Dn,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?Nn(new er(n,t)):Vn(i.errors)}class nr{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class rr{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function or(e,t){const i=ir(e,t);if("error"===i.result)return i;const n=i.value.expression,r=On(n);if(!r&&!jn(t))return Vn([new Re("","data expressions not supported")]);const o=Un(n,["zoom"]);if(!o&&!Gn(t))return Vn([new Re("","zoom expressions not supported")]);const s=ar(n);return s||o?s instanceof Re?Vn([s]):s instanceof di&&!Hn(t)?Vn([new Re("",'"interpolate" expressions cannot be used with this property')]):Nn(s?new rr(r?"camera":"composite",i.value,s.labels,s instanceof di?s.interpolation:void 0):new nr(r?"constant":"source",i.value)):Vn([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sr{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Wn(this._parameters,this._specification))}static deserialize(e){return new sr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ar(e){let t=null;if(e instanceof Xt)t=ar(e.result);else if(e instanceof mi){for(const i of e.args)if(t=ar(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=ar(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function lr(e,t=new Set){return e instanceof In&&t.add(e.key),e.eachChild(e=>{lr(e,t)}),t}function cr(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(!cr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const ur={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function hr(e){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};cr(e)||(e=fr(e));const t=ir(e,ur);if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,i,n)=>t.value.evaluate(e,i,{},n),needGeometry:pr(e),getGlobalStateRefs:()=>lr(t.value.expression)}}function dr(e,t){return et?1:0}function pr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?mr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(fr))):"all"===t?["all"].concat(e.slice(1).map(fr)):"none"===t?["all"].concat(e.slice(1).map(fr).map(Ar)):"in"===t?gr(e[1],e.slice(2)):"!in"===t?Ar(gr(e[1],e.slice(2))):"has"===t?_r(e[1]):"!has"!==t||Ar(_r(e[1]));var i}function mr(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 gr(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(dr)]]:["filter-in-small",e,["literal",t]]}}function _r(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ar(e){return["!",e]}function yr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${yr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new Me(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Sr(e){const t=e.valueSpec,i=br(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Qn(e.value.stops)&&"array"===Qn(e.value.stops[0])&&"object"===Qn(e.value.stops[0][0]),u=Tr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Er({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Qn(n)&&0===n.length&&t.push(new Me(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Hn(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jn(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!Gn(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Qn(n))return[new Me(a,n,`array expected, ${Qn(n)} found`)];if(2!==n.length)return[new Me(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Qn(n[0]))return[new Me(a,n,`object expected, ${Qn(n[0])} found`)];if(void 0===n[0].zoom)return[new Me(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Me(a,n,"object stop key must have value")];if(o&&o>br(n[0].zoom))return[new Me(a,n[0].zoom,"stop zoom values must appear in ascending order")];br(n[0].zoom)!==o&&(o=br(n[0].zoom),r=void 0,s={}),i=i.concat(Tr({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Cr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return tr(wr(n[1]))?i.concat([new Me(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Qn(e.value),l=br(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return jn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew Me(`${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 Me(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&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Un(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!On(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ir(e){const t=e.key,i=e.value,n=Qn(i);return"string"!==n?[new Me(t,i,`color expected, ${n} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Mr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(br(i))&&r.push(new Me(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(br(i))&&r.push(new Me(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Pr(e){return cr(wr(e.value))?Br(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Rr(e)}function Rr(e){const t=e.value,i=e.key;if("array"!==Qn(t))return[new Me(i,t,`array expected, ${Qn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Mr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),br(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===br(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Qn(t[1]),"string"!==r&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new Me(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{br(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(n,i.ref,"ref cannot reference another ref layer")):s=br(e.type):t.push(new Me(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&br(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(n,i.source,`source "${i.source}" not found`))}else t.push(new Me(n,i,'missing required property "source"'));return t=t.concat(Tr({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Pr,layout:e=>Tr({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kr(Pe({layerType:s},e))}}),paint:e=>Tr({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Fr(Pe({layerType:s},e))}})}})),t}function Or(e){const t=e.value,i=e.key,n=Qn(t);return"string"!==n?[new Me(i,t,`string expected, ${n} found`)]:[]}const zr={promoteId:function({key:e,value:t}){if("string"===Qn(t))return Or({key:e,value:t});{const i=[];for(const n in t)i.push(...Or({key:`${e}.${n}`,value:t[n]}));return i}}};function Ur(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=br(t.type);let a;switch(s){case"vector":case"raster":return a=Tr({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:zr,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Qn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Me("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===br(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Me(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Me(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=Tr({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:zr}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Br({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Br({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Tr({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return Tr({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Mr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Nr(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function Vr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function jr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Gr(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Me(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(Tr({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Or({key:n,value:i})}function Hr(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Qn(e.value)} found`)];var t}const Qr={"*":()=>[],array:Er,boolean:function(e){const t=e.value,i=e.key,n=Qn(t);return"boolean"!==n?[new Me(i,t,`boolean expected, ${n} found`)]:[]},number:Cr,color:Ir,constants:xr,enum:Mr,filter:Pr,function:Sr,layer:Dr,object:Tr,source:Ur,light:Nr,sky:Vr,terrain:jr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Qn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Me(t,i,`projection expected, invalid type "${n}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Or,formatted:function(e){return 0===Or(e).length?[]:Br(e)},resolvedImage:function(e){return 0===Or(e).length?[]:Br(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Qn(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(xr({key:"constants",value:e.constants}))),Kr(i)}function qr(e){return function(t){return e({...t,validateSpec:$r})}}function Kr(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Xr(e){return function(...t){return Kr(e.apply(this,t))}}Wr.source=Xr(qr(Ur)),Wr.sprite=Xr(qr(Gr)),Wr.glyphs=Xr(qr(Zr)),Wr.light=Xr(qr(Nr)),Wr.sky=Xr(qr(Vr)),Wr.terrain=Xr(qr(jr)),Wr.state=Xr(qr(Hr)),Wr.layer=Xr(qr(Dr)),Wr.filter=Xr(qr(Pr)),Wr.paintProperty=Xr(qr(Fr)),Wr.layoutProperty=Xr(qr(kr));const Jr=Wr,Yr=Jr.light,eo=Jr.sky,to=Jr.paintProperty,io=Jr.layoutProperty;function no(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new ge(new Error(n.message))),i=!0;return i}class ro{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e=c[l+0]&&n>=c[l+1])?(s[h]=!0,o.push(r[h])):s[h]=!1}}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[n];r[n]=oo[i].shallow.indexOf(n)>=0?o:uo(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function ho(e){if(co(e))return e;if(Array.isArray(e))return e.map(ho);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=lo(e)||"Object";if(!oo[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=oo[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=oo[t].shallow.indexOf(i)>=0?r:ho(r)}return n}class po{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoome>=128&&e<=255,"Hangul Jamo":e=>e>=4352&&e<=4607,Khmer:e=>e>=6016&&e<=6143,"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,"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,Kanbun:e=>e>=12688&&e<=12703,"CJK Strokes":e=>e>=12736&&e<=12783,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Hangul Syllables":e=>e>=44032&&e<=55215,"Private Use Area":e=>e>=57344&&e<=63743,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function mo(e){for(const t of e)if(xo(t.charCodeAt(0)))return!0;return!1}function go(e){for(const t of e)if(!yo(t.charCodeAt(0)))return!1;return!0}function _o(e){const t=e.map(e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const Ao=_o(["Arab","Dupl","Mong","Ougr","Syrc"]);function yo(e){return!Ao.test(String.fromCodePoint(e))}const vo=_o(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function xo(e){return!(746!==e&&747!==e&&(e<4352||!(fo["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||fo["CJK Compatibility"](e)||fo["CJK Strokes"](e)||!(!fo["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||fo["Enclosed CJK Letters and Months"](e)||fo["Ideographic Description Characters"](e)||fo.Kanbun(e)||fo.Katakana(e)&&12540!==e||!(!fo["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)||!(!fo["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||fo["Vertical Forms"](e)||fo["Yijing Hexagram Symbols"](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||vo.test(String.fromCodePoint(e)))))}function bo(e){return!(xo(e)||function(e){return!!(fo["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||fo["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)||fo["Letterlike Symbols"](e)||fo["Number Forms"](e)||fo["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)||fo["Control Pictures"](e)&&9251!==e||fo["Optical Character Recognition"](e)||fo["Enclosed Alphanumerics"](e)||fo["Geometric Shapes"](e)||fo["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||fo["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||fo["CJK Symbols and Punctuation"](e)||fo.Katakana(e)||fo["Private Use Area"](e)||fo["CJK Compatibility Forms"](e)||fo["Small Form Variants"](e)||fo["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}const wo=_o(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function To(e){return wo.test(String.fromCodePoint(e))}function Eo(e,t){return!(!t&&To(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||fo.Khmer(e))}function Co(e){for(const t of e)if(To(t.charCodeAt(0)))return!0;return!1}const So=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(So.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Bo{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new po,this.transition=t.transition||{},this.globalState=t.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new po,this.transition={},this.globalState={})}isSupportedScript(e){return function(e,t){for(const i of e)if(!Eo(i.charCodeAt(0),t))return!1;return!0}(e,"loaded"===So.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class Io{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if($n(e))return new sr(e,t);if(tr(e)){const i=or(e,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return i.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Mo{constructor(e){this.property=e,this.value=new Io(e,void 0)}transitioned(e,t){return new Ro(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Ro(this.property,this.value,null,{},0)}}class Po{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mo(this._values[e].property)),this._values[e].value=new Io(this._values[e].property,null===t?void 0:j(t))}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mo(this._values[e].property)),this._values[e].transition=j(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 n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n)}return e}transitioned(e,t){const i=new Lo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Lo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Ro{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nn.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class No{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Bo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Bo(Math.floor(t.zoom),t)),e.expression.evaluate(new Bo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Vo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class jo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Io(i,void 0),r=this.defaultTransitionablePropertyValues[t]=new Mo(i);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}so("DataDrivenProperty",zo),so("DataConstantProperty",Oo),so("CrossFadedDataDrivenProperty",Uo),so("CrossFadedProperty",No),so("ColorRampProperty",Vo);const Go="-transition";class Ho extends _e{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=hr(e.filter)),t.layout&&(this._unevaluatedLayout=new Fo(t.layout)),t.paint)){this._transitionablePaint=new Po(t.paint);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._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Do(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=hr(e)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}setLayoutProperty(e,t,i={}){null!=t&&this._validate(io,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Go)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(to,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Go))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&no(this,e.call(Jr,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ko&&jn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}const Qo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class $o{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 Zo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(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")}}function Wo(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=Qo[e.type].BYTES_PER_ELEMENT,o=i=qo(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:qo(i,Math.max(n,t)),alignment:t}}function qo(e,t){return Math.ceil(e/t)*t}class Ko extends Zo{_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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}Ko.prototype.bytesPerElement=4,so("StructArrayLayout2i4",Ko);class Xo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Xo.prototype.bytesPerElement=6,so("StructArrayLayout3i6",Xo);class Jo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}Jo.prototype.bytesPerElement=8,so("StructArrayLayout4i8",Jo);class Yo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}Yo.prototype.bytesPerElement=12,so("StructArrayLayout2i4i12",Yo);class es extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}es.prototype.bytesPerElement=8,so("StructArrayLayout2i4ub8",es);class ts extends Zo{_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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}ts.prototype.bytesPerElement=8,so("StructArrayLayout2f8",ts);class is extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}is.prototype.bytesPerElement=20,so("StructArrayLayout10ui20",is);class ns extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,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]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}ns.prototype.bytesPerElement=24,so("StructArrayLayout4i4ui4i24",ns);class rs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}rs.prototype.bytesPerElement=12,so("StructArrayLayout3f12",rs);class os extends Zo{_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}}os.prototype.bytesPerElement=4,so("StructArrayLayout1ul4",os);class ss extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ss.prototype.bytesPerElement=20,so("StructArrayLayout6i1ul2ui20",ss);class as extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}as.prototype.bytesPerElement=12,so("StructArrayLayout2i2i2i12",as);class ls extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ls.prototype.bytesPerElement=16,so("StructArrayLayout2f1f2i16",ls);class cs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}cs.prototype.bytesPerElement=16,so("StructArrayLayout2ub2f2i16",cs);class us extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}us.prototype.bytesPerElement=6,so("StructArrayLayout3ui6",us);class hs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=n,this.uint16[A+3]=r,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}hs.prototype.bytesPerElement=48,so("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",hs);class ds extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=n,this.int16[I+3]=r,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=S,this.uint16[I+31]=B,e}}ds.prototype.bytesPerElement=64,so("StructArrayLayout8i15ui1ul2f2ui64",ds);class ps extends Zo{_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}}ps.prototype.bytesPerElement=4,so("StructArrayLayout1f4",ps);class fs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}fs.prototype.bytesPerElement=12,so("StructArrayLayout1ui2f12",fs);class ms extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}ms.prototype.bytesPerElement=8,so("StructArrayLayout1ul2ui8",ms);class gs extends Zo{_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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}gs.prototype.bytesPerElement=4,so("StructArrayLayout2ui4",gs);class _s extends Zo{_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}}_s.prototype.bytesPerElement=2,so("StructArrayLayout1ui2",_s);class As extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}As.prototype.bytesPerElement=16,so("StructArrayLayout4f16",As);class ys extends $o{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}ys.prototype.size=20;class vs extends ss{get(e){return new ys(this,e)}}so("CollisionBoxArray",vs);class xs extends $o{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}xs.prototype.size=48;class bs extends hs{get(e){return new xs(this,e)}}so("PlacedSymbolArray",bs);class ws extends $o{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}ws.prototype.size=64;class Ts extends ds{get(e){return new ws(this,e)}}so("SymbolInstanceArray",Ts);class Es extends ps{getoffsetX(e){return this.float32[1*e+0]}}so("GlyphOffsetArray",Es);class Cs extends Xo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}so("SymbolLineVertexArray",Cs);class Ss extends $o{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Ss.prototype.size=12;class Bs extends fs{get(e){return new Ss(this,e)}}so("TextAnchorOffsetArray",Bs);class Is extends $o{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]}}Is.prototype.size=8;class Ms extends ms{get(e){return new Is(this,e)}}so("FeatureIndexArray",Ms);class Ps extends Ko{}class Rs extends Ko{}class Ls extends Ko{}class Fs extends Yo{}class ks extends es{}class Ds extends ts{}class Os extends is{}class zs extends ns{}class Us extends rs{}class Ns extends os{}class Vs extends as{}class js extends cs{}class Gs extends us{}class Hs extends gs{}const Qs=Wo([{name:"a_pos",components:2,type:"Int16"}],4),{members:$s}=Qs;class Zs{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return e>Zs.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${Zs.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Zs.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>Zs.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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,n){return new Zs([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Ws(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}Zs.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,so("SegmentVector",Zs);const qs=Wo([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ks,Xs,Js,Ys={exports:{}},ea={exports:{}},ta={exports:{}},ia=function(){if(Js)return Ys.exports;Js=1;var e=(Ks||(Ks=1,ea.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>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:r^=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 r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ea.exports),t=(Xs||(Xs=1,ta.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=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),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ta.exports);return Ys.exports=e,Ys.exports.murmur3=e,Ys.exports.murmur2=t,Ys.exports}(),na=n(ia);class ra{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(oa(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=oa(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return sa(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new ra;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function oa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:na(String(e))}function sa(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;aa(e,o,s),aa(t,3*o,3*s),aa(t,3*o+1,3*s+1),aa(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new ha(e,t):new ca(e,t)}}class ma{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setUniform(e,t,i,n){const r="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;r&&e.set(r)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)?new ua(e,t):new ca(e,t)}}class ga{constructor(e,t,i,n){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 n}populatePaintArray(e,t,i,n,r){const o=this.paintVertexArray.length,s=this.expression.evaluate(new Bo(0),t,{},n,[],r);this.paintVertexArray.resize(e),this._setPaintValue(o,e,s)}updatePaintArray(e,t,i,n){const r=this.expression.evaluate({zoom:0},i,n);this._setPaintValue(e,t,r)}_setPaintValue(e,t,i){if("color"===this.type){const n=pa(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=r,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,n,r){const o=this.expression.evaluate(new Bo(this.zoom),t,{},n,[],r),s=this.expression.evaluate(new Bo(this.zoom+1),t,{},n,[],r),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,o,s)}updatePaintArray(e,t,i,n){const r=this.expression.evaluate({zoom:this.zoom},i,n),o=this.expression.evaluate({zoom:this.zoom+1},i,n);this._setPaintValue(e,t,r,o)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=pa(i),o=pa(n);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof ga||i instanceof _a)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new ya(n,t,i);this.needsUpload=!1,this._featureMap=new ra,this._bufferOffset=0}populatePaintArrays(e,t,i,n,r,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,o);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||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()}}function xa(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function ba(e,t,i){const n={color:{source:ts,composite:As},number:{source:ps,composite:ts}},r=function(e){return{"line-pattern":{source:Os,composite:Os},"fill-pattern":{source:Os,composite:Os},"fill-extrusion-pattern":{source:Os,composite:Os}}[e]}(e);return r&&r[i]||n[t][i]}so("ConstantBinder",fa),so("CrossFadedConstantBinder",ma),so("SourceExpressionBinder",ga),so("CrossFadedCompositeBinder",Aa),so("CompositeExpressionBinder",_a),so("ProgramConfiguration",ya,{omit:["_buffers"]}),so("ProgramConfigurationSet",va);const wa=Math.pow(2,14)-1,Ta=-wa-1;function Ea(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Ca(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ea(e):[]}}const Sa=-32768;function Ba(e,t,i,n,r){e.emplaceBack(Sa+8*t+n,Sa+8*i+r)}class Ia{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Rs,this.indexArray=new Gs,this.segments=new Zs,this.programConfigurations=new va(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ca(t,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ea(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$s),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())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=I||n<0||n>=I)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e1){if(Fa(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function za(e,t){let i,n,r,o=!1;for(let s=0;st.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function Ua(e,t){let i=!1;for(let n=0,r=e.length-1;nt.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 Na(e,t,i){const n=i[0],r=i[2];if(e.xr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Va(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function ja(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ga(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(let t=0;tWa(e,t,i,n))}(l,r,s,a),d=u?c*o:c;for(const e of n)for(const t of e){const e=u?t:Wa(t,r,s,a);let i=d;const n=r.projectTileCoordinates(t.x,t.y,s,a).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=n/r.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=r.cameraToCenterDistance/n),Pa(h,e,i))return!0}return!1}}function Wa(e,t,n,r){const o=t.projectTileCoordinates(e.x,e.y,n,r).point;return new i((.5*o.x+.5)*t.width,(.5*-o.y+.5)*t.height)}class qa extends Ia{}let Ka;so("HeatmapBucket",qa,{omit:["layers"]});var Xa={get paint(){return Ka=Ka||new jo({"heatmap-radius":new zo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new zo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Oo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Vo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Oo(Ae.paint_heatmap["heatmap-opacity"])})}};function Ja(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError(`mismatched image size. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function Ya(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=Ja({},{width:t,height:i},n);el(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function el(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return pl(e,this.getUnpackVector())}getPixels(){return new il({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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;t0)for(let r=t;r=t;r-=n)o=Vl(r/n|0,e[r],e[r+1],o);return o&&kl(o,o.next)&&(jl(o),o=o.next),o}function vl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!kl(n,n.next)&&0!==Fl(n.prev,n,n.next))n=n.next;else{if(jl(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function xl(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Il(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?wl(e,n,r,o):bl(e))t.push(l.i,e.i,c.i),jl(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?xl(e=Tl(vl(e),t),t,i,n,r,o,2):2===s&&El(e,t,i,n,r,o):xl(vl(e),t,i,n,r,o,1);break}}}function bl(e){const t=e.prev,i=e,n=e.next;if(Fl(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Rl(r,a,o,l,s,c,f.x,f.y)&&Fl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function wl(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Fl(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Il(p,f,t,i,n),A=Il(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Rl(a,u,l,h,c,d,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Rl(a,u,l,h,c,d,v.x,v.y)&&Fl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Rl(a,u,l,h,c,d,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Rl(a,u,l,h,c,d,v.x,v.y)&&Fl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Tl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!kl(n,r)&&Dl(n,i,i.next,r)&&Ul(n,r)&&Ul(r,n)&&(t.push(n.i,i.i,r.i),jl(i),jl(i.next),i=e=r),i=i.next}while(i!==e);return vl(i)}function El(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Ll(s,e)){let a=Nl(s,e);return s=vl(s,s.next),a=vl(a,a.next),xl(s,t,i,n,r,o,0),void xl(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function Cl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Sl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(kl(e,i))return i;do{if(kl(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Pl(ro.x||i.x===o.x&&Bl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=Nl(i,e);return vl(n,n.next),vl(i,i.next)}function Bl(e,t){return Fl(e.prev,e,t.prev)<0&&Fl(t.next,e,e.next)<0}function Il(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ml(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Rl(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Pl(e,t,i,n,r,o,s,a)}function Ll(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Dl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Ul(e,t)&&Ul(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Fl(e.prev,e,t.prev)||Fl(e,t.prev,t))||kl(e,t)&&Fl(e.prev,e,e.next)>0&&Fl(t.prev,t,t.next)>0)}function Fl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function kl(e,t){return e.x===t.x&&e.y===t.y}function Dl(e,t,i,n){const r=zl(Fl(e,t,i)),o=zl(Fl(e,t,n)),s=zl(Fl(i,n,e)),a=zl(Fl(i,n,t));return r!==o&&s!==a||!(0!==r||!Ol(e,i,t))||!(0!==o||!Ol(e,n,t))||!(0!==s||!Ol(i,e,n))||!(0!==a||!Ol(i,t,n))}function Ol(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 zl(e){return e>0?1:e<0?-1:0}function Ul(e,t){return Fl(e.prev,e,e.next)<0?Fl(e,t,e.next)>=0&&Fl(e,e.prev,t)>=0:Fl(e,t,e.prev)<0||Fl(e,e.next,t)<0}function Nl(e,t){const i=Gl(e.i,e.x,e.y),n=Gl(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Vl(e,t,i,n){const r=Gl(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function jl(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 Gl(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Hl{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n=1||y<=0)||m&&(ar)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),_=n+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=Kl(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;er!=(o===$l)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return xl(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let n=0;n0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(A-e),r=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?n/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function Jl(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(cZs.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=Yl(s,n,o,a,d,m,c),y=Yl(s,n,o,a,p,g,c),v=Yl(s,n,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;eZs.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=Yl(s,n,o,a,r,f,c),_=Yl(s,n,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Yl(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class ec{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ls,this.indexArray=new Gs,this.indexArray2=new Hs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.segments2=new Zs,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasPattern=_l("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ca(s,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Ea(s),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Al("fill",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gl),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,n,r,o){for(const e of Yi(t,500)){const t=ql(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;Jl((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,n)}}let tc,ic;so("FillBucket",ec,{omit:["layers","patternFeatures"]});var nc={get paint(){return ic=ic||new jo({"fill-antialias":new Oo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new zo(Ae.paint_fill["fill-opacity"]),"fill-color":new zo(Ae.paint_fill["fill-color"]),"fill-outline-color":new zo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Oo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Oo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Uo(Ae.paint_fill["fill-pattern"])})},get layout(){return tc=tc||new jo({"fill-sort-key":new zo(Ae.layout_fill["fill-sort-key"])})}};class rc extends Ho{constructor(e){super(e,nc)}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 ec(e)}queryRadius(){return ja(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ra(Ga(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const oc=Wo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),sc=Wo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ac}=oc;class lc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(cc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new lc(this._pbf,t,this.extent,this._keys,this._values)}}function dc(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){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class pc{constructor(e,t){this.layers=e.readFields(fc,{},t)}}function fc(e,t,i){if(3===e){const e=new hc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const mc=Math.pow(2,13);function gc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*mc)+s,r*mc*2,o*mc*2,Math.round(a))}class _c{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Fs,this.centroidVertexArray=new Ps,this.indexArray=new Gs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasPattern=_l("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Ca(n,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Ea(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Al("fill-extrusion",this.layers,l,this.zoom,t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ac),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,sc.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{gc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;nZs.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),gc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),gc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,gc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),gc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Ac(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function vc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let xc;so("FillExtrusionBucket",_c,{omit:["layers","features"]});var bc={get paint(){return xc=xc||new jo({"fill-extrusion-opacity":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Uo(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class wc extends Ho{constructor(e){super(e,bc)}createBucket(e){return new _c(e)}queryRadius(){return ja(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=Ga(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,n.push(C)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ra(i,t)&&(n=Ec(i,t[0]));for(let r=0;re.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ks,this.layoutVertexArray2=new Ds,this.indexArray=new Gs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasPattern=_l("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ca(t,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ea(t),patterns:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Al("line",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}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,Ic)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Sc),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&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap"),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,u,n,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,n)}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Kl(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":n;if(w&&"round"===T&&(yr&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>Pc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Pc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}let Lc,Fc;so("LineBucket",Rc,{omit:["layers","patternFeatures"]});var kc={get paint(){return Fc=Fc||new jo({"line-opacity":new zo(Ae.paint_line["line-opacity"]),"line-color":new zo(Ae.paint_line["line-color"]),"line-translate":new Oo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Oo(Ae.paint_line["line-translate-anchor"]),"line-width":new zo(Ae.paint_line["line-width"]),"line-gap-width":new zo(Ae.paint_line["line-gap-width"]),"line-offset":new zo(Ae.paint_line["line-offset"]),"line-blur":new zo(Ae.paint_line["line-blur"]),"line-dasharray":new No(Ae.paint_line["line-dasharray"]),"line-pattern":new Uo(Ae.paint_line["line-pattern"]),"line-gradient":new Vo(Ae.paint_line["line-gradient"])})},get layout(){return Lc=Lc||new jo({"line-cap":new Oo(Ae.layout_line["line-cap"]),"line-join":new zo(Ae.layout_line["line-join"]),"line-miter-limit":new Oo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Oo(Ae.layout_line["line-round-limit"]),"line-sort-key":new zo(Ae.layout_line["line-sort-key"])})}};class Dc extends zo{possiblyEvaluate(e,t){return t=new Bo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let Oc;class zc extends Ho{constructor(e){super(e,kc),this.gradientVersion=0,Oc||(Oc=new Dc(kc.paint.properties["line-width"].specification),Oc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Oc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Rc(e)}queryRadius(e){const t=e,i=Uc(Va("line-width",this,t),Va("line-gap-width",this,t)),n=Va("line-offset",this,t);return i/2+Math.abs(n)+ja(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=Ga(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*Uc(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(let r=0;r=3)for(let t=0;t0?t+2*e:e}const Nc=Wo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Vc=Wo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Wo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const jc=Wo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Wo([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Gc=Wo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Hc=Wo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Qc(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),So.applyArabicShaping&&(e=So.applyArabicShaping(e)),e}(e.text,t,i)}),e}Wo([{name:"triangle",components:3,type:"Uint16"}]),Wo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),Wo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Wo([{type:"Float32",name:"offsetX"}]),Wo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Wo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const $c={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zc=24;const Wc=4294967296,qc=1/Wc,Kc="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Xc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Wc;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wc;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Jc(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Kc?Kc.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Yc(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Yc(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,eu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,tu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,ru,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,iu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,nu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,ou,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,su,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,au,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,lu,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Jc(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Yc(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function eu(e,t){for(let i=0;it.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e=0&&i>=e&&yu[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 _u;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)}getMaxImageSize(e){let t=0,i=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Au(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=_u.fromFeature(t,o);let _;d===e.ao.vertical&&g.verticalizePunctuation();const{processBidirectionalText:A,processStyledBidirectionalText:y}=So;if(A&&1===g.sections.length){_=[];const e=A(g.toString(),Su(g,u,s,i,r,f));for(const t of e){const e=new _u;e.text=t,e.sections=g.sections;for(let i=0;i=0;let c=0;for(let i=0;ic){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function Ou(e,t,i,n,r,o){const s=e.image;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 u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}const zu=128,Uu=32640;function Nu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Bo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;re.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Nu(this.zoom,i["text-size"]),this.iconSizeData=Nu(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==Vu(n,"text-overlap","text-allow-overlap")||"never"!==Vu(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ao[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new $u(new va(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new $u(new va(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Es,this.lineVertexArray=new Cs,this.symbolInstances=new Ts,this.textAnchorOffsets=new Bs}calculateGlyphDependencies(e,t,i,n,r){for(let o=0;o0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Bo(this.zoom,{globalState:this.globalState});for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,_=Ca(i,t);if(!r._featureFilter.filter(m,_,n))continue;let A,y;if(t||(_.geometry=Ea(i)),c){const e=r.getValueAndResolveTokens("text-field",_,n,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||Qu(t);(!i||"unavailable"===So.getRTLTextPluginStatus()||i&&So.isParsed())&&(A=Qc(t,r,_))}if(u){const e=r.getValueAndResolveTokens("icon-image",_,n,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},n):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:lc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ao.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const n=mo(A.toString()),r=e.fontStack||t,o=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,o,i,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i))}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.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let qu,Ku;so("SymbolBucket",Wu,{omit:["layers","collisionBoxArray","features","compareText"]}),Wu.MAX_GLYPHS=65535,Wu.addDynamicAttributes=Hu;var Xu={get paint(){return Ku=Ku||new jo({"icon-opacity":new zo(Ae.paint_symbol["icon-opacity"]),"icon-color":new zo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new zo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new zo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new zo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Oo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Oo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new zo(Ae.paint_symbol["text-opacity"]),"text-color":new zo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new zo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new zo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new zo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Oo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Oo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return qu=qu||new jo({"symbol-placement":new Oo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Oo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Oo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new zo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Oo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Oo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Oo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Oo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Oo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Oo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new zo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Oo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Oo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new zo(Ae.layout_symbol["icon-image"]),"icon-rotate":new zo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new zo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Oo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new zo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new zo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Oo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Oo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Oo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new zo(Ae.layout_symbol["text-field"]),"text-font":new zo(Ae.layout_symbol["text-font"]),"text-size":new zo(Ae.layout_symbol["text-size"]),"text-max-width":new zo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Oo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new zo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new zo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new zo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Oo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new zo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new zo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Oo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Oo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new zo(Ae.layout_symbol["text-rotate"]),"text-padding":new Oo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Oo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new zo(Ae.layout_symbol["text-transform"]),"text-offset":new zo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Oo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Oo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Oo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Oo(Ae.layout_symbol["text-optional"])})}};class Ju{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}so("FormatSectionOverride",Ju,{omit:["defaultValue"]});class Yu extends Ho{constructor(e){super(e,Xu)}recalculate(e,t){if(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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||tr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new Wu(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Xu.paint.overridableProperties){if(!Yu.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Ju(t),n=new er(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new nr("source",n):new rr("composite",n,t.value.zoomStops),this.paint._values[e]=new ko(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Yu.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Xu.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Mt)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let eh;var th={get paint(){return eh=eh||new jo({"background-color":new Oo(Ae.paint_background["background-color"]),"background-pattern":new No(Ae.paint_background["background-pattern"]),"background-opacity":new Oo(Ae.paint_background["background-opacity"])})}};class ih extends Ho{constructor(e){super(e,th)}}let nh;var rh={get paint(){return nh=nh||new jo({"raster-opacity":new Oo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Oo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Oo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Oo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Oo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Oo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Oo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Oo(Ae.paint_raster["raster-fade-duration"])})}};class oh extends Ho{constructor(e){super(e,rh)}}class sh extends Ho{constructor(e){super(e,{}),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class ah{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const lh={once:!0},ch=6371008.8;class uh{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 uh(O(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return ch*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof uh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new uh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new uh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const hh=2*Math.PI*ch;function dh(e){return hh*Math.cos(e*Math.PI/180)}function ph(e){return(180+e)/360}function fh(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function mh(e,t){return e/dh(t)}function gh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function _h(e,t){return e*dh(gh(t))}class Ah{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=uh.convert(e);return new Ah(ph(i.lng),fh(i.lat),mh(t,i.lat))}toLngLat(){return new uh(360*this.x-180,gh(this.y))}toAltitude(){return _h(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/hh*(e=gh(this.y),1/Math.cos(e*Math.PI/180));var e}}function yh(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class vh{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=wh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=yh(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=yh(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class xh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=wh(e,t.z,t.z,t.x,t.y)}}class bh{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new vh(i,+n,+r),this.key=wh(t,e,i,n,r)}clone(){return new bh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new bh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?wh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):wh(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>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new bh(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,n=2*this.canonical.y;return[new bh(t,this.wrap,t,i,n),new bh(t,this.wrap,t,i+1,n),new bh(t,this.wrap,t,i,n+1),new bh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Eh;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Eh;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Ch{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Sh{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=n,this.properties=e.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Bh{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ro(I,16,0),this.grid3D=new ro(I,16,0),this.featureIndexArray=new Ms,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new pc(new Xc(this.rawTileData)).layers,this.sourceLayerCoder=new Ch(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=hr(o.filter),l=e.queryGeometry,c=e.queryPadding*s,u=Eh.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Eh.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(Ua(e,t))return!0;for(let t=0;t(d||(d=Ea(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=Ca(p,!0);if(!r.filter(new Bo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new Bo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof Do?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s})}function Mh(e,t){return t-e}function Ph(e,t,n,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}so("FeatureIndex",Bh,{omit:["rawTileData","sourceLayerCoder"]});class Rh extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new Rh(this.x,this.y,this.angle,this.segment)}}function Lh(e,t,i,n,r){if(void 0===t.segment||0===i)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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Fh(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(n.x,r.x,u),d=fi.number(n.y,r.y,u),p=new Rh(h,d,r.angleTo(n),i);return p._round(),!s||Lh(e,p,a,s,t)?p:void 0}l+=o}}function zh(e,t,i,n,r,o,s,a,l){const c=kh(n,o,s),u=Dh(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Rh(_,A,m,t);i._round(),n&&!Lh(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=Uh(e,h/2,i,n,r,o,s,!0,l)),p}function Nh(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=Du(e)),A=Vh(h,0,t[0]),v=Vh(d,0,t[1]),y=Vh(h,t[0],t[2]),x=Vh(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=n-x}const C=u.x1,S=u.y1,B=u.x2-C,I=u.y2-S,M=(e,r,o,l)=>{const c=Gh(e.stretch-A,y,B,C),u=Hh(e.fixed-b,w,e.stretch,f),h=Gh(r.stretch-v,x,I,S),d=Hh(r.fixed-T,E,r.stretch,m),p=Gh(o.stretch-A,y,B,C),g=Hh(o.fixed-b,w,o.stretch,f),_=Gh(l.stretch-v,x,I,S),M=Hh(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=r.stretch+r.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/B,minFontScaleY:E/a/I,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=jh(h,g,f),t=jh(d,_,m);for(let i=0;i0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?Du(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class $h{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function Zh(e,t=1,n=!1){const r=Eh.fromPoints(e[0]),o=Math.min(r.width(),r.height());let s=o/2;const a=new $h([],Wh),{minX:l,minY:c,maxX:u,maxY:h}=r;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,n&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new qh(i.p.x-s,i.p.y-s,s,e)),a.push(new qh(i.p.x+s,i.p.y-s,s,e)),a.push(new qh(i.p.x-s,i.p.y+s,s,e)),a.push(new qh(i.p.x+s,i.p.y+s,s,e)),p+=4)}return n&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Wh(e,t){return t.max-e.max}function qh(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Oa(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Kh;e.aE=void 0,(Kh=e.aE||(e.aE={}))[Kh.center=1]="center",Kh[Kh.left=2]="left",Kh[Kh.right=3]="right",Kh[Kh.top=4]="top",Kh[Kh.bottom=5]="bottom",Kh[Kh["top-left"]=6]="top-left",Kh[Kh["top-right"]=7]="top-right",Kh[Kh["bottom-left"]=8]="bottom-left",Kh[Kh["bottom-right"]=9]="bottom-right";const Xh=Number.POSITIVE_INFINITY;function Jh(e,t){return t[1]!==Xh?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Yh(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*Zc);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Dt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*Zc,Xh]:r.get("text-offset").evaluate(t,{},i).map(e=>e*Zc);const o=[];for(const e of s)o.push(e,Jh(e,n));return new Dt(o)}return null}function ed(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 td(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=nd(n.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=r&&r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),S=f.get("symbol-placement"),B=x/2,M=f.get("icon-text-fit");let P;r&&"none"!==M&&(t.allowVerticalPlacement&&n.vertical&&(P=Ou(r,n.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(r=Ou(r,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,n);let S,B,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=na("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new Qh(c,i,u,h,d,r.vertical,p,f,m,e),a&&(M=new Qh(c,i,u,h,d,a,_,A,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{}),r="none"!==l.layout.get("icon-text-fit"),s=Nh(o,n,w,r),p=a?Nh(a,n,w,r):void 0;B=new Qh(c,i,u,h,d,o,_,A,!1,n),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[zu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Uu&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[zu*b.compositeIconSizes[0].evaluate(x,{},T),zu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Uu||m[1]>Uu)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ao.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ao.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(r.horizontal);for(const n of U){const o=r.horizontal[n];if(!S){z=na(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);S=new Qh(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=id(t,i,o,s,l,m,x,g,C,r.vertical?e.ao.horizontal:e.ao.horizontalOnly,a?U:[n],O,k,b,T),a)break}r.vertical&&(F+=id(t,i,r.vertical,s,l,m,x,g,C,e.ao.vertical,["vertical"],O,D,b,T));const N=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=B?B.boxStartIndex:t.collisionBoxArray.length,$=B?B.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(S,q),q=K(I,q),q=K(B,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/Zc),t.glyphOffsetArray.length>=Wu.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Yh(l,x,T),[Y,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,n,r,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===S)for(const e of Ph(i.geometry,0,0,I,I)){const i=Kl(e,R),o=zh(i,x,T,n.vertical||g,r,24,y,t.overscaling,I);for(const e of o)g&&rd(t,g.text,B,e)||L(i,e)}else if("line-center"===S){for(const e of i.geometry)if(e.length>1){const t=Kl(e,R),i=Oh(t,T,n.vertical||g,r,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Zh(e,16);L(Kl(e[0],R,!0),new Rh(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=Kl(e,R);L(t,new Rh(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Rh(t.x,t.y,0))}function id(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(Zc-r.metrics.width*r.scale)/2:(r.scale-1)*Zc)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[r.x+g,r.y]:[0,0];let A=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=r.metrics.isDoubleResolution?2:1,x=(r.metrics.left-h)*r.scale-g+A[0],b=(-r.metrics.top-h)*r.scale+A[1],w=x+s.w/v*r.scale/p,T=b+s.h/v*r.scale/p,E=new i(x,b),C=new i(w,b),S=new i(x,T),B=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),S._matMult(i),B._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:S,br:B,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[zu*o.layout.get("text-size").evaluate(a,{})],A[0]>Uu&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[zu*f.compositeTextSizes[0].evaluate(a,{},m),zu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Uu||A[1]>Uu)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function nd(e){for(const t in e)return e[t];return null}function rd(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=od[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new sd(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=od.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 ad(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)hd(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];hd(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function ad(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;ld(e,t,s,n,r,o),ad(e,t,i,n,s-1,1-o),ad(e,t,i,s+1,r,1-o)}function ld(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);ld(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(cd(e,t,n,i),t[2*r+o]>s&&cd(e,t,n,r);as;)l--}t[2*n+o]===s?cd(e,t,n,l):(l++,cd(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function cd(e,t,i,n){ud(e,i,n),ud(t,2*i,2*n),ud(t,2*i+1,2*n+1)}function ud(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function hd(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}var dd;e.cx=void 0,(dd=e.cx||(e.cx={})).create="create",dd.load="load",dd.fullLoad="fullLoad";let pd=null,fd=[];const md=1e3/60,gd="loadTime",_d="fullLoadTime",Ad={mark(e){performance.mark(e)},frame(e){const t=e;null!=pd&&fd.push(t-pd),pd=t},clearMetrics(){pd=null,fd=[],performance.clearMeasures(gd),performance.clearMeasures(_d);for(const t in e.cx)performance.clearMarks(e.cx[t])},getPerformanceMetrics(){performance.measure(gd,e.cx.create,e.cx.load),performance.measure(_d,e.cx.create,e.cx.fullLoad);const t=performance.getEntriesByName(gd)[0].duration,i=performance.getEntriesByName(_d)[0].duration,n=fd.length,r=1/(fd.reduce((e,t)=>e+t,0)/n/1e3),o=fd.filter(e=>e>md).reduce((e,t)=>e+(t-md)/md,0);return{loadTime:t,fullLoadTime:i,fps:r,percentDroppedFrames:o/(n+o)*100,totalFrames:n}}};e.$=I,e.A=p,e.B=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.C=fi,e.D=Oo,e.E=_e,e.F=Bo,e.G=eo,e.H=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.I=pu,e.J=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ah(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},lh):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:uo(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(ho(i.error)):t.resolve(ho(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=ho(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?uo(t):null,data:uo(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.K=le,e.L=function(){var e=new p(16);return p!=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},e.M=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.N=function(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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},e.O=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.P=i,e.Q=function(e,t){const i={};for(let n=0;n[e.id,e]));s.add=Array.from(i.values())}if(t.update){const e=new Map(null===(i=s.update)||void 0===i?void 0:i.map(e=>[e.id,e]));for(const i of t.update){const t=null!==(n=e.get(i.id))&&void 0!==n?n:{id:i.id};i.newGeometry&&(t.newGeometry=i.newGeometry),i.addOrUpdateProperties&&(t.addOrUpdateProperties=(null!==(r=t.addOrUpdateProperties)&&void 0!==r?r:[]).concat(i.addOrUpdateProperties)),i.removeProperties&&(t.removeProperties=(null!==(o=t.removeProperties)&&void 0!==o?o:[]).concat(i.removeProperties)),i.removeAllProperties&&(t.removeAllProperties=!0),e.set(i.id,t)}s.update=Array.from(e.values())}return s},e.a1=Ah,e.a2=Eh,e.a3=25,e.a4=vh,e.a5=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.a6=Me,e.a7=function(){return U++},e.a8=vs,e.a9=Wu,e.aA=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return[t,i,n,r]},e.aB=Zc,e.aC=M,e.aD=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians: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]}return[r?i[0]:M(t,i[0],e.zoom),r?i[1]:M(t,i[1],e.zoom)]},e.aF=Vu,e.aG=ed,e.aH=Bu,e.aI=sd,e.aJ=Wo,e.aK=Ql,e.aL=Ps,e.aM=Zs,e.aN=Gs,e.aO=O,e.aP=te,e.aQ=_h,e.aR=v,e.aS=y,e.aT=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.aU=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.aV=function(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.aW=x,e.aX=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.aY=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},e.aZ=_,e.a_=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.aa=hr,e.ab=Ca,e.ac=Sh,e.ad=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;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},e.ae=ee,e.af=function(e){return Math.pow(2,e)},e.ag=m,e.ah=D,e.ai=85.051129,e.aj=mh,e.ak=function(e){return Math.log(e)/Math.LN2},e.al=function(e){var t=e[0],i=e[1];return t*t+i*i},e.am=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i},e.an=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?D(di.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.ap=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/zu:"composite"===e.kind?fi.number(n/zu,r/zu,i):t},e.aq=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.ar=S,e.as=function(e){return Math.hypot(e[0],e[1])},e.at=function(e){return e[0]=0,e[1]=0,e},e.au=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.av=Hu,e.aw=T,e.ax=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.ay=Ph,e.az=Ma,e.b=W,e.b$=class extends ls{},e.b0=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},e.b1=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.b2=xh,e.b3=wh,e.b4=function(e,t,i,n,r){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!=r&&r!==1/0?(e[10]=(r+n)*(o=1/(n-r)),e[14]=2*r*n*o):(e[10]=-1,e[14]=-2*n),e},e.b5=function(e){var t=new p(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},e.b6=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e},e.b7=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e},e.b8=function(){const e=new Float32Array(16);return m(e),e},e.b9=function(){const e=new Float64Array(16);return m(e),e},e.bA=function(e,t){const i=P(e,360),n=P(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)0?s:-s},e.bD=function(e,t){const i=P(e,2*Math.PI),n=P(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bE=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const n=Ae.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bF=po,e.bG=ue,e.bH=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Be),r=t.map(Be),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bd=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),_=(a=n[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.be=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bf=Ct,e.bg=ca,e.bh=$l,e.bi=Zl,e.bj=Hl,e.bk=R,e.bl=L,e.bm=zt,e.bn=function(e,t,i,n,r){return R(n,r,D((e-t)/(i-t),0,1))},e.bo=P,e.bp=function(){return new Float64Array(3)},e.bq=function(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e},e.br=C,e.bs=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,d=r*h-o*u,p=o*c-n*h,f=n*u-r*c,m=2*i[3];return u*=m,h*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+u+p,e[2]=l+h+f,e},e.bt=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/n),f},e.bu=ch,e.bv=function(){return new Float64Array(4)},e.bw=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bx=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.by=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bz=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.c=oe,e.c0=Hc,e.c1=class extends us{},e.c2=rl,e.c3=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.c4=nl,e.c5=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.c6=class extends Jo{},e.c7=class extends _s{},e.c8=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.c9=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],S=t[8],B=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=d*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-S)<=d*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-B)<=d*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.cA=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cB=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cC=function(e,t){const i={};for(let n=0;ne*Zc)}let y=a?"center":n.get("text-justify").evaluate(r,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(r,{},t.canonical)*Zc:1/0,x=()=>{t.bucket.allowVerticalPlacement&&mo(o)&&(f.vertical=Au(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ao.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((i.newGeometry||i.removeAllProperties||a)&&(t=Object.assign({},t),e.set(i.id,t),a&&(t.properties=Object.assign({},t.properties))),i.newGeometry&&(t.geometry=i.newGeometry),i.removeAllProperties)t.properties={};else if((null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0)for(const e of i.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0)for(const{key:e,value:n}of i.addOrUpdateProperties)t.properties[e]=n}},e.cX=So,e.ca=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},e.cb=e=>"symbol"===e.type,e.cc=e=>"circle"===e.type,e.cd=e=>"heatmap"===e.type,e.ce=e=>"line"===e.type,e.cf=e=>"fill"===e.type,e.cg=e=>"fill-extrusion"===e.type,e.ch=e=>"hillshade"===e.type,e.ci=e=>"color-relief"===e.type,e.cj=e=>"raster"===e.type,e.ck=e=>"background"===e.type,e.cl=e=>"custom"===e.type,e.cm=F,e.cn=function(e,t,i){const n=B(t.x-i.x,t.y-i.y),r=B(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.co=k,e.cp=function(e,t){return ne[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cq=function(e,t){return ie[t]&&"touches"in e},e.cr=function(e){return ie[e]||ne[e]},e.cs=function(e,t,i){var n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e},e.ct=function(e,t){const{x:i,y:n}=Ah.fromLngLat(t);return!(e<0||e>25||n<0||n>=1||i<0||i>=1)},e.cu=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},e.cv=class extends Xo{},e.cw=Ad,e.cy=function(e){return e.message===re},e.cz=ce,e.d=de,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>{n.src=q})},n.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 r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new Xc(e).readFields(cu,[])},e.p=du,e.q=tl,e.r=jo,e.s=Y,e.t=Po,e.u=fo,e.v=Ae,e.w=H,e.x=Yr,e.y=no,e.z=Jr}),i("worker",["./shared"],function(e){class t{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,i){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bJ(i);t._featureFilter=e.aa(t.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=e.cC(Object.values(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map(e=>this._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.q({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.q.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cD("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.Z(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[],this.globalState=t.globalState}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a8;const l=new e.cE(Object.keys(t.layers).sort()),c=new e.cF(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;e=i.maxzoom||"none"!==i.visibility&&(r(t,this.zoom,o),(u[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source,globalState:this.globalState})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map(e=>e.id)))}}const p=e.bN(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const[y,v,x]=yield Promise.all([f,g,A]),b=new i(y),w=new e.cG(v,x);for(const t in u){const i=u[t];i instanceof e.a9?(r(i.layers,this.zoom,o),e.cH({bucket:i,glyphMap:y,glyphPositions:b.positions,imageMap:v,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasPattern&&(i instanceof e.cI||i instanceof e.cJ||i instanceof e.cK)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?y:null,iconMap:this.returnDependencies?v:null,glyphPositions:this.returnDependencies?b.positions:null}})}}function r(t,i,n){const r=new e.F(i);for(const e of t)e.recalculate(r,n)}class o{constructor(e,t,i){this.actor=e,this.layerIndex=t,this.availableImages=i,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(t,i){return e._(this,void 0,void 0,function*(){const n=yield e.n(t.request,i);try{return{vectorTile:new e.cL(new e.cM(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires}}catch(e){const i=new Uint8Array(n.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}})}loadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cN(t.request),o=new n(t);this.loading[i]=o;const s=new AbortController;o.abort=s;try{const n=yield this.loadVectorTile(t,s);if(delete this.loading[i],!n)return null;const a=n.rawData,l={};n.expires&&(l.expires=n.expires),n.cacheControl&&(l.cacheControl=n.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)))}o.vectorTile=n.vectorTile;const u=o.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[i]=o,this.fetching[i]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[i]}}catch(e){throw delete this.loading[i],o.status="done",this.loaded[i]=o,e}})}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[i];if(n.showCollisionBoxes=t.showCollisionBoxes,n.globalState=t.globalState,"parsing"===n.status){const r=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:t,cacheControl:n,resourceTiming:s}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:t.slice(0)},r,n,s)}else o=r;return o}if("done"===n.status&&n.vectorTile)return n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class s{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cO(r,-1,-1,c,u)):r,d=new e.cP(i,h,n,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var a,l,c=function(){if(l)return a;function e(e,i){if(0!==e.length){t(e[0],i);for(var n=1;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}return l=1,a=function t(i,n){var r,o=i&&i.type;if("FeatureCollection"===o)for(r=0;r>31}function A(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(g(1,i));const a=3===n?s.length-1:s.length;for(let e=0;ee},x=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;class w{constructor(e){this.options=Object.assign(Object.create(v),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(C(i),S(o),C(r),S(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?T(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?T(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=E(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=C(n),u=S(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function T(e,t,i){return{type:"Feature",id:e[t+3],properties:E(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),B(e[t+1])]}};var n}function E(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function C(e){return e/360+.5}function S(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function B(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function I(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&I(e,t,s,n),e[s+2]=r,i-s>3&&I(e,s,i,n))}function M(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function P(e,t,i,n){const r={id:null==e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)R(r,i);else if("Polygon"===t)R(r,i[0]);else if("MultiLineString"===t)for(const e of i)R(r,e);else if("MultiPolygon"===t)for(const e of i)R(r,e[0]);return r}function R(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,I(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function D(e,t,i,n){for(let r=0;r1?1:i}function U(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)N(e,u,i,n,r);else if("LineString"===o)V(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)G(e,u,i,n,r,!1);else if("Polygon"===o)G(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];G(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(P(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(P(t.id,o,u,t.tags))}}return l.length?l:null}function N(e,t,i,n,r){for(let o=0;o=i&&s<=n&&H(t,e[o],e[o+1],e[o+2])}}function V(e,t,i,n,r,o,s){let a=j(e);const l=0===r?Q:$;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=j(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&H(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&H(a,a[0],a[1],a[2]),a.length&&t.push(a)}function j(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function G(e,t,i,n,r,o){for(const s of e)V(s,t,i,n,r,o,!1)}function H(e,t,i,n){e.push(t,i,n)}function Q(e,t,i,n,r,o){const s=(o-t)/(n-t);return H(e,o,i+(r-i)*s,1),s}function $(e,t,i,n,r,o){const s=(o-i)/(r-i);return H(e,t+(n-t)*s,o,1),s}function Z(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=X(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=U(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=U(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=U(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=U(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=U(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=U(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ie(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?q(this.tiles[a],r):null):null}}function ie(e,t,i){return 32*((1<{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(t)).load(i.features):function(e,t){return new te(e,t)}(i,t.geojsonVtOptions),this.loaded={};const r={data:i};if(n){const e=n.finish();e&&(r.resourceTiming={},r.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}return r}catch(t){if(delete this._pendingRequest,e.cy(t))return{abandoned:!0};throw t}})}getData(){return e._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,i){return e._(this,void 0,void 0,function*(){let n=yield this.loadGeoJSON(t,i);if(delete this._pendingRequest,"object"!=typeof n)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(n,!0),t.filter){const i=e.cT(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=n.features.filter(e=>i.value.evaluate({zoom:0},e));n={type:"FeatureCollection",features:r}}return n})}loadGeoJSON(t,i){return e._(this,void 0,void 0,function*(){const{promoteId:n}=t;if(t.request){const r=yield e.j(t.request,i);return this._dataUpdateable=e.cV(r.data,n)?e.cU(r.data,n):void 0,r.data}if("string"==typeof t.data)try{const i=JSON.parse(t.data);return this._dataUpdateable=e.cV(i,n)?e.cU(i,n):void 0,i}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return e.cW(this._dataUpdateable,t.dataDiff,n),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class re{constructor(t){this.self=t,this.actor=new e.J(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cA,this.self.removeProtocol=e.cB,this.self.registerRTLTextPlugin=t=>{e.cX.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t]})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds)})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i)}))}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.cX.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new o(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new ne(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new s),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new re(self)),re}),i("index",["exports","./shared"],function(e,t){var i="5.6.2";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,n){const r=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(r),n(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)}};class a{static testProp(e){if(!a.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",a.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=a.getScale(e);return a.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=a.getScale(e);for(let r=0;r{c&&p(c),c=null,d=!0},u.onerror=()=>{h=!0,c=null},u.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:l}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?c(i,l):t.m(i,l);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},c=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(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."))},o.src=s})}(f||(f={})),f.resetRequestQueue();class m{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function g(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:n,url:r}))}}return t}function _(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function A(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,r&&r.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,r&&r.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const n of e){let e=this.getImage(n);e||(this.fire(new t.l("styleimagemissing",{id:n})),e=this.getImage(n)),e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${n}" 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.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),A(e)&&this.updateImage(i,e)}}}const v=1e20;function x(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=v}for(let a=0,l=0;a65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[r])return{stack:e,id:i,glyph:n};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[r]){const i=w.loadGlyphRange(e,r,this.url,this.requestManager);t.requests[r]=i}const o=yield t.requests[r];for(const e in o)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=o[+e]);return t.ranges[r]=!0,{stack:e,id:i,glyph:o[i]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,n){const r=this.localIdeographFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(n))return;let o=e.tinySDF;if(!o){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),o=e.tinySDF=new w.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:t})}const s=o.draw(String.fromCharCode(n));return{id:n,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}w.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},w.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(v,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}x(_,0,0,c,u,c,this.f,this.v,this.z),x(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[M]}numActive(){return Object.keys(this.active).length}}const R=Math.floor(s.hardwareConcurrency/2);let L,F;function k(){return L||(L=new P),L}P.workerCount=t.H(globalThis)?Math.max(Math.min(R,3),1):1;class D{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}}function O(){return F||(F=new D(k(),t.K),F.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),F}function z(e,i){const n=t.L();return t.M(n,n,[1,1,0]),t.N(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.O(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function U(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(N);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e._state,n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,z(e.transform,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])V(n,t);return e}(function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function N(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function V(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function j(e,i,n){return t._(this,void 0,void 0,function*(){let r=e;if(e.url?r=(yield t.j(i.transformRequest(e.url,"Source"),n)).data:yield s.frameAsync(n),!r)return null;const o=t.Q(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map(e=>e.id)),o})}class G{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(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 t.S?new t.S(e.lng,e.lat):t.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.S?new t.S(e.lng,e.lat):t.S.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.S)r=e,o=e;else{if(!(e instanceof G))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(G.convert(e)):this.extend(t.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.S.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.S(r.lng,r.lat),this._ne=new t.S(o.lng,o.lat)),this}getCenter(){return new t.S((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 t.S(this.getWest(),this.getNorth())}getSouthEast(){return new t.S(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:i,lat:n}=t.S.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return e instanceof G?e:e?new G(e):e}static fromLngLat(e,i=0){const n=360*i/40075017,r=n/Math.cos(Math.PI/180*e.lat);return new G(new t.S(e.lng-r,e.lat-n),new t.S(e.lng+r,e.lat+n))}adjustAntiMeridian(){const e=new t.S(this._sw.lng,this._sw.lat),i=new t.S(this._ne.lng,this._ne.lat);return new G(e,e.lng>i.lng?new t.S(i.lng+360,i.lat):i)}}class H{constructor(e,t,i){this.bounds=G.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 i=Math.pow(2,e.z),n=Math.floor(t.V(this.bounds.getWest())*i),r=Math.floor(t.U(this.bounds.getNorth())*i),o=Math.ceil(t.V(this.bounds.getEast())*i),s=Math.ceil(t.U(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class $ extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,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=t.e({type:"raster"},i),t.e(this,t.Q(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield j(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new H(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield f.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Z extends ${constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield f.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.W()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.X()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.Y(e,-1,-1,i,n))}catch(e){}}return s.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.Z(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.Z(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Z(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.Z(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Z(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,function*(){const e=new G,t=yield this.getData();let i;switch(t.type){case"FeatureCollection":i=t.features.map(e=>this.getCoordinatesFromGeometry(e.geometry)).flat(1/0);break;case"Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t)}if(0==i.length)return e;for(let t=0;t0&&t.e(r,{resourceTiming:i}),this.fire(new t.l("data",Object.assign(Object.assign({},r),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},r),{sourceDataType:"content"})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}})}loaded(){return!this._isUpdatingWorker&&void 0===this._pendingWorkerUpdate.data&&void 0===this._pendingWorkerUpdate.diff}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const n=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(n,this.map.painter,"RT"===t)})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class q extends t.E{constructor(e,t,i,n){super(),this.flippedWindingOrder=!1,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.setEventedParent(n),this.options=t}load(e){return t._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield f.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.a1.fromLngLat);var n;return this.tileID=function(e){const i=t.a2.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.a4(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.a2.fromPoints(e),s={};for(let e=0;e<=t.a3;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class K extends q{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a5(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.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,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class X extends q{constructor(e,i,n,r){super(e,i,n,r),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 t.k(new t.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a6(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a6(`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 t.k(new t.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(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 i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0});let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}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}}const J={},Y=e=>{switch(e){case"geojson":return W;case"image":return q;case"raster":return $;case"raster-dem":return Z;case"vector":return Q;case"video":return K;case"canvas":return X}return J[e]},ee="RTLPluginLoaded";class te extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(ee))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let ie=null;function ne(){return ie||(ie=new te),ie}class re{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a7(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a9){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a9&&i.hasRTLText){this.hasRTLText=!0,ne().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new t.a8}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=r._geojsonTileLayer||r[o];if(!s)return;const a=t.aa(i&&i.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,n){const r=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},t.e(this.stateChanges[e][r],n),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])n[t]||(this.deletedStates[e][r][t]=null)}else for(const t in n)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 n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,i){const n=String(i),r=t.e({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,i){const n={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const n in this.stateChanges[e])this.state[e][n]||(this.state[e][n]={}),t.e(this.state[e][n],this.stateChanges[e][n]),i[n]=this.state[e][n];n[e]=i}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t]}n[e]=n[e]||{},t.e(n[e],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const t in e)e[t].setFeatureState(n,i)}}const ae=89.25;function le(e,i){const n=t.ah(i.lat,-t.ai,t.ai);return new t.P(t.V(i.lng)*e,t.U(n)*e)}function ce(e,i){return new t.a1(i.x/e,i.y/e).toLngLat()}function ue(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ae(90-e.pitch)),Math.tan(t.ae(ae-e.pitch)))}function he(e,i){const n=e.canonical,r=i/t.af(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,s=t.ag(new Float64Array(16));return t.M(s,s,[o*r,n.y*r,0]),t.N(s,s,[r/t.$,r/t.$,1]),s}function de(e,i,n,r,o){const s=t.a1.fromLngLat(e,i),a=o*t.aj(1,e.lat),l=a*Math.cos(t.ae(n)),c=Math.sqrt(a*a-l*l),u=c*Math.sin(t.ae(-r)),h=c*Math.cos(t.ae(-r));return new t.a1(s.x+u,s.y+h,s.z+l)}function pe(e,t,i){const n=t.intersectsFrustum(e);if(!i||0===n)return n;const r=t.intersectsPlane(i);return 0===r?0:2===n&&2===r?2:1}function fe(e,t,i){let n=0;const r=(i-t)/10;for(let o=0;o<10;o++)n+=r*Math.pow(Math.cos(t+(o+.5)/10*(i-t)),e);return n}function me(e,i){return function(n,r,o,s,a){const l=2*((e-1)/t.ak(Math.cos(t.ae(ae-a))/Math.cos(t.ae(ae)))-1),c=Math.acos(o/s),u=2*fe(l-1,0,t.ae(a/2)),h=Math.min(t.ae(ae),c+t.ae(a/2)),d=fe(l-1,Math.min(h,c-t.ae(a/2)),h),p=Math.atan(r/o),f=Math.hypot(r,o);let m=n;return m+=t.ak(s/f/Math.max(.5,Math.cos(t.ae(a/2)))),m+=l*t.ak(Math.cos(p))/2,m-=t.ak(Math.max(1,d/u/i))/2,m}}const ge=me(9.314,3);function _e(e,i){const n=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ak(e.tileSize/i.tileSize));return Math.max(0,n)}function Ae(e,i){const n=e.getCameraFrustum(),r=e.getClippingPlane(),o=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.a1.fromLngLat(e.center,e.elevation);o.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const a=e.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(e,i),c=_e(e,i),u=i.minzoom||0,h=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),h),p=Math.pow(2,d),f=[p*o.x,p*o.y,0],m=[p*s.x,p*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),_=Math.abs(s.z-o.z),A=Math.hypot(g,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=pe(n,T,r);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||ge)(e.zoom+t.ak(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const S=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=S){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const ye=t.a2.fromPoints([new t.P(0,0),new t.P(t.$,t.$)]);class ve extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(Y(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,t,i,this),this._tiles={},this._cache=new oe(0,e=>this._unloadTile(e)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new se,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)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,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,n)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}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)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(xe).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const n=e.tileID,r=i.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(xe).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)e?this._reloadTile(t,"expired"):"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n){e.timeAdded=s.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!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]||e[a.canonical.key]){n[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),n=this._getLoadedTile(t);if(n)return n}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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])}}_updateCoveredAndRetainedTiles(e,t,i,n,r,o){const a={},l={},c=Object.keys(e),u=s.now();for(const i of c){const n=e[i],r=this._tiles[i];if(!r||0!==r.fadeEndTime&&r.fadeEndTime<=u)continue;const o=this.findLoadedParent(n,t),s=this.findLoadedSibling(n),c=o||s||null;c&&(this._addTile(c.tileID),a[c.tileID.key]=c.tileID),l[i]=n}this._retainLoadedChildren(l,n,i,e);for(const t in a)e[t]||(this._coveredTiles[t]=!0,e[t]=a[t]);if(o){const t={},i={};for(const e of r)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const n in i){const r=i[n].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=e[r[0].key]=r[0],t[r[1].key]=e[r[1].key]=r[1],t[r[2].key]=e[r[2].key]=r[2],t[r[3].key]=e[r[3].key]=r[3],delete i[n])}for(const n in i){const r=i[n],o=this.findLoadedParent(r,this._source.minzoom),s=this.findLoadedSibling(r),a=o||s||null;if(a){t[a.tileID.key]=e[a.tileID.key]=a.tileID;for(const e in t)t[e].isChildOf(a.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.Z(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ae(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[];const r=_e(e,this._source),o=Math.max(r-ve.maxOverzooming,this._source.minzoom),s=Math.max(r+ve.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of n)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const n=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[n.key]=n}n=n.concat(Object.values(e))}const a=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(n,r);be(this._source.type)&&this._updateCoveredAndRetainedTiles(l,o,s,r,n,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.am(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n={},r={},o=Math.max(t-ve.maxOverzooming,this._source.minzoom),s=Math.max(t+ve.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);n[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){n[e.key]=e;continue}}else{const e=s.children(this._source.maxzoom);if(n[e[0].key]&&n[e[1].key]&&n[e[2].key]&&n[e[3].key])continue}let a=e.wasRequested();for(let t=s.overscaledZ-1;t>=o;--t){const o=s.scaledTo(t);if(r[o.key])break;if(r[o.key]=!0,e=this.getTile(o),!e&&a&&(e=this._addTile(o)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||a)&&(n[o.key]=o),a=e.wasRequested(),t)break}}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const n=i;return i||(i=new re(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,n||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_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))}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_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))))}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.a2.fromPoints(u);for(let e=0;ee.getTilePoint(new t.a1(i.x,i.y)));if(i.expandBy(p),i.intersects(ye)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.a2.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.a2.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.a1(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(be(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)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 n=this._tiles[e];n&&n.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))}}function xe(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function be(e){return"raster"===e||"image"===e||"video"===e}ve.maxOverzooming=10,ve.maxUnderzooming=3;class we{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Te(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ee{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e0}hitTestCircle(e,t,i,n,r){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!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=r[h+2]&&t<=r[h+3]&&i>=r[h+0]&&n>=r[h+1]&&(!a||a(d))&&(!c||!Te(u,d.overlapMode))&&(o.push({key:d,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const d=this.circleCells[r];if(null!==d){const r=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Te(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Te(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Te(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Ce(e,i,r){const o=t.L();if(!e){const{vecSouth:e,vecEast:t}=Be(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.N(o,o,[1/r,1/r,1]),o}function Se(e,i,n,r){if(e){const e=t.L();if(!i){const{vecSouth:t,vecEast:i}=Be(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.N(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function Be(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.ar();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.as(a);l<1e-9?t.at(a):t.au(a,a,1/l);const c=t.ar();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.as(c);return u<1e-9?t.at(c):t.au(c,c,1/u),{vecEast:c,vecSouth:a}}function Ie(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aw(o,o,n)):(o=[e,i,0,1],$e(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Me(e,t){return.5+e/t*.5}function Pe(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Re(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.an(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let n=0;nMath.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ao.vertical?i.yn.x)?{needsFlipping:!0}:null}function ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=Le(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=Ue(c.first.point.x,c.first.point.y,i,n),_=Ue(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Fe(r.writingMode,g,_,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n0?a.point:De(i.tileAnchorPoint,s,e,1,i),c=Ue(e.x,e.y,i,n),h=Ue(l.x,l.y,i,n),d=Fe(r.writingMode,c,h,u);if(d)return d}const e=Ge(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.av(c,e.point,e.angle);return{}}function De(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=ze(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function Oe(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=ze(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded=r.anyProjectionOccluded||s.isOccluded,s.point;const a=e-n.direction;return De(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function ze(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=Ie(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function Ue(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aw(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function Ne(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ve(e,t,i){return e._unit()._perp()._mult(t*i)}function je(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=Oe(e+c.direction,l,c),d=Ve(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.ax(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ge(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=ze(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=Oe(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const n=g.sub(_);t=0===n.mag()?Ve(Oe(p+u,a,e).sub(g),i,u):Ve(n,i,u),m||(m=_.add(t)),f=je(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const He=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Qe(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.xr.x||i.yr.y?[]:t.ay([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=Ie(e.x,e.y,n,i.getElevation),r=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height,r})}(e,i);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;oi&&(i=r,t=n));return e.slice(t,t+i)}(n)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.a2;for(const r of e){const e=new t.P(r.x+Ze,r.y+Ze);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.az(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));I=e.some(e=>!e.isOccluded),B=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aA(B),allPointsOccluded:!I}}}class qe{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,t,i,n,r){this.text=new qe(e?e.text:null,t,i,r),this.icon=new qe(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Xe{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class Je{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class Ye{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 et(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aH(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class tt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new We(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Ye(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.$,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aC(n,1,this.transform.zoom),m=t.aD(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aD(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Ce(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new Je(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.an(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aE[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=et(x,n,r,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:r,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aF(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aF(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!r.hasIconData()||g),C=v&&(A||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const S=this.retainedQueryData[r.bucketInstanceId].tileID,B=this._getTerrainElevationFunc(S),I=this.transform.getFastPathSimpleProjectionMatrix(S),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new Xe(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let n=t.ao.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ao.vertical?(k=n(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,u,S,l,b,x,s,f.predicate,B,void 0,I);return n&&n.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(G,t.ao.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ao.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aE[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ao.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ao.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.ap(r.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,b,f.predicate,e.collisionCircleDiameter,u,s,B),z.circles.length&&z.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,S,l,b,x,a,f.predicate,B,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),r.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),r.bucketInstanceId,N,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Xe((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ao.horizontal||i===t.ao.horizontalOnly?i:0,o=i===t.ao.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new Ke(o,n,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Ke(null,n,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Ke(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new Ke(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new Ke(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n0,A=this.placedOrientations[r.crossTileID],y=A===t.ao.vertical,v=A===t.ao.horizontal||A===t.ao.horizontalOnly;if(o>0||s>0){const t=ut(c.text);m(e.text,o,y?ht:t),m(e.text,s,v?ht:t);const i=c.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(e,n.anchor,r,A);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(e,"left",r,a),this.markUsedOrientation(e,a,r))}if(_){const t=ut(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:ht),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?ht:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=et(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=y),n.verticalTextBox&&(r=v),it(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,x.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!v&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),it(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),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.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function it(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-Ze,a=n[1]-Ze,l=n[2]-Ze,c=n[3]-Ze;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const nt=Math.pow(2,25),rt=Math.pow(2,24),ot=Math.pow(2,17),st=Math.pow(2,16),at=Math.pow(2,9),lt=Math.pow(2,8),ct=Math.pow(2,1);function ut(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*nt+t*rt+i*ot+t*st+i*at+t*lt+i*ct+t}const ht=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&s.now()-n>2;for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new dt(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const ft=512/t.$/2;class mt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*ft),y:Math.floor(e.anchorY*ft)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aI(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=ft/Math.pow(2,l-o),u=(a*t.$+e.anchorY)*c,h=r*t.$*ft;return{x:Math.floor((s*t.$+e.anchorX)*c-n*t.$*ft),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.ze)}}class gt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class _t{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var yt="void main() {fragColor=vec4(1.0);}";const vt={prelude:xt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:xt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:xt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:xt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:xt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:xt("in 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\nvoid 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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out 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\nvoid 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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:xt(yt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:xt("uniform 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:xt("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:xt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:xt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:xt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:xt(yt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:xt("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:xt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:xt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:xt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:xt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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:xt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:xt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;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 float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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\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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:xt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\nvoid main() {\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\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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.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_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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#ifdef GLOBE\nout float v_depth;\n#endif\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\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_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:xt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\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);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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 floorwidth\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:xt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;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;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:xt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:xt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;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\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\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 inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:xt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;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\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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;if (u_is_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);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:xt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:xt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:xt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:xt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:xt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:xt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function xt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class bt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var wt=t.aJ([{name:"a_pos",type:"Int16",components:2}]);const Tt="#define PROJECTION_MERCATOR",Et="mercator";class Ct{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Et}get shaderDefine(){return Tt}get shaderPreludeCode(){return vt.projectionMercator}get vertexShaderPreludeCode(){return vt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aL;s.emplaceBack(0,0),s.emplaceBack(t.$,0),s.emplaceBack(0,t.$),s.emplaceBack(t.$,t.$);const a=e.createVertexBuffer(s,wt.members),l=t.aM.simpleSegment(0,0,4,2),c=new t.aN;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new bt(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class St{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.C.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.C.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.C.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.C.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.ah((this.left+e-this.right)/2,0,e),r=t.ah((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new St(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Bt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function It(e){return Math.max(0,Math.floor(e))}class Mt{constructor(e,i,n,r,o,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==o?60:o,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new St,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.af(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new St(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aO(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aP(this._fovInRadians)}setFov(e){e=t.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.af(i),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new G([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.ai,t.ai])}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.a2.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ag(new Float64Array(16));t.N(e,e,[this._width/2,-this._height/2,1]),t.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ag(new Float64Array(16)),t.N(e,e,[1,-1,1]),t.M(e,e,[-1,-1,0]),t.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,a=t.a1.fromLngLat(e,i),l=-Math.cos(t.ae(s)),c=Math.sin(t.ae(s)),u=c*Math.sin(t.ae(o)),h=-c*Math.cos(t.ae(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aQ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.a1(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.ak(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aj(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/i,r=t.a1.fromLngLat(this.center,this.elevation),o=de(this.center,this.elevation,this.pitch,this.bearing,n);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aQ(o.z,r.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aj(1,this.center.lat)*this.worldSize;return de(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Rt{distanceToTile2d(e,t,i,n){const r=n.distanceX([e,t]),o=n.distanceY([e,t]);return Math.hypot(r,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.Z(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Lt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),l=[[-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(n=>function(e,i,n,r){const o=t.aw([],e,i),s=1/o[3]/n*r;return t.aY(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.aU([],e[i+s],e[i+o]),r=t.aZ(n);t.aR(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.a_(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.aU([],e[i[0]],e[i[1]]),r=t.aU([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.aV(o,t.aW([],n,r)),o[3]=-t.aX(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.a$(e),r=t.b0([],e,1/n),o=t.aU([],i,t.aR([],r,t.aX(i,r))),s=t.a$(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.aR([],r,-r[3]),a=t.aS([],n,t.aR([],o,e/s));return t.b1(i,a)}return null}(n,u);if(null!==h){const e=h/t.aX(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.aU([],l[e[0]],l[e[1]]),n=t.aU([],l[e[2]],l[e[1]]),r=t.aV([],t.aW([],i,n)),o=-t.aX(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Lt(l,c,new Pt(u,h))}}class Ft{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,n,r){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,n,r),this._coveringTilesDetailsProvider=new Rt}clone(){const e=new Ft;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.b2(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.b2(n,e))}return i}getCameraFrustum(){return Lt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.aj(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.a1.fromLngLat(e),a=new t.a1(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.a1.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.a1.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aw(r,r,this._pixelMatrixInverse),t.aw(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.a1(t.C.number(r[0]/s,o[0]/a,d)/this.worldSize,t.C.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aw(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ue(this));return(new G).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ue(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=he(e,this.worldSize);t.O(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=he(e,this.worldSize);return t.O(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}getConstrained(e,i){i=t.ah(+i,this.minZoom,this.maxZoom);const n={center:new t.S(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.af(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.U(e[1])*o,a=t.U(e[0])*o,a-sa&&(_=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.aO(f,e-o/2,e+o/2));const n=d/2;i-nc&&(g=c-n)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);n.center=ce(o,e).wrap()}return n}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ae(this.fov)*(Math.abs(Math.cos(t.ae(this.roll)))*this.height+Math.abs(Math.sin(t.ae(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.ah(Math.PI-a-l,.01,Math.PI-.01)),u=ue(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ae(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.ah(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=le(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.aj(1,this.center.lat)*this.worldSize;const o=t.ae(Math.min(this.pitch,ae)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.b4(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aq(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.b5(a),t.N(a,a,[1,-1,1]),t.M(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.b6(a,a,-this.rollInRadians),t.b7(a,a,this.pitchInRadians),t.b6(a,a,-this.bearingInRadians),t.M(a,a,[-n,-r,0]),this._mercatorMatrix=t.N([],a,[this.worldSize,this.worldSize,this.worldSize]),t.N(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.M(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aq([],a);const l=[0,0,-1,1];t.aw(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.M(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+h*c+d*u,f=r-Math.round(r)+h*u+d*c,m=new Float64Array(a);if(t.M(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aq(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aw(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aj(1,this.center.lat)*this.worldSize;return de(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.a1.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aw(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&r?i.terrainRttPosMatrix32f:s||t.b8(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aw(s,s,o)):(s=[e,i,0,1],$e(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.a1.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.b9();return t.M(o,o,[n.x,n.y,n.z]),t.b6(o,o,Math.PI),t.b7(o,o,Math.PI/2),t.N(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.Z(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=he(i,this.worldSize);t.O(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.$,t.$,this.worldSize/this._helper.pixelsPerMeter],s=t.ba();return t.N(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Dt(e){if(e.useSlerp)if(e.k<1){const i=t.bb(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bb(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bc(r,i,n,e.k);const o=t.bd(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ot(e,i,n,r,o){const s=o.padding,a=le(o.worldSize,n.getNorthWest()),l=le(o.worldSize,n.getNorthEast()),c=le(o.worldSize,n.getSouthEast()),u=le(o.worldSize,n.getSouthWest()),h=t.ae(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void kt();const x=Math.min(t.ak(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ae(r)),T=b.add(w).mult(o.scale/t.af(x));return{center:ce(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:r}}class zt{get useGlobeControls(){return!1}handlePanInertia(e,t){return{easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Ot(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.S.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.getConstrained(t.S.convert(i.center||d),null!=u?u:n);Bt(e,p);const m=le(e.worldSize,d),g=le(e.worldSize,p).sub(m),_=t.af(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.C.number(n,f,a)),t.be(o,s)||Dt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.af(e.zoom-n),r=f>n?Math.min(2,_):Math.max(.5,_),o=Math.pow(r,1-a),s=ce(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.getConstrained(t.S.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;Bt(e,s);const l=le(e.worldSize,i.locationAtOffset),c=le(e.worldSize,s).sub(l),u=c.mag(),h=t.af(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.getConstrained(s,n).zoom;d=t.af(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.ak(n));const h=1===i?s:ce(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class Ut{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Ut.Replace=[1,0],Ut.disabled=new Ut(Ut.Replace,t.bf.transparent,[!1,!1,!1,!1]),Ut.unblended=new Ut(Ut.Replace,t.bf.transparent,[!0,!0,!0,!0]),Ut.alphaBlended=new Ut([1,771],t.bf.transparent,[!0,!0,!0,!0]);const Nt=2305;class Vt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Vt.disabled=new Vt(!1,1029,Nt),Vt.backCCW=new Vt(!0,1029,Nt),Vt.frontCCW=new Vt(!0,1028,Nt);class jt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}jt.ReadOnly=!1,jt.ReadWrite=!0,jt.disabled=new jt(519,jt.ReadOnly,[0,1]);const Gt=7680;class Ht{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Ht.disabled=new Ht({func:519,mask:0},0,0,Gt,Gt,Gt);const Qt=new WeakMap;function $t(e){var t;if(Qt.has(e))return Qt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Qt.set(e,i),i}}class Zt{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aL;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aN;o.emplaceBack(0,1,2),this._fullscreenTriangle=new bt(i.createVertexBuffer(r,wt.members),i.createIndexBuffer(o),t.aM.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),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.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),$t(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,jt.disabled,Ht.disabled,Ut.unblended,Vt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&$t(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&$t(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Zt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const Wt=t.$/128;function qt(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.$;-1===r&&(o=-Wt),r===n+1&&(o=t.$+Wt);let s=i/n*t.$;-1===i&&(s=e.extendToNorthPole?t.bh:-Wt),i===n+1&&(s=e.extendToSouthPole?t.bi:t.$+Wt),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ei(e){const t=ni(e.worldSize,e.center.lat);return 2*Math.PI*t}function ti(e,i,n,r,o){const s=1/(1<1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.S(t.aO(s,-180,180),i)}return new t.S(0,i)}function oi(e){return Math.cos(e*Math.PI/180)}function si(e,i){const n=oi(e),r=oi(i);return t.ak(r/n)}function ai(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+si(i.center.lat,0),o=t.bk(1/oi(i.center.lat),1/oi(Math.min(Math.abs(i.center.lat),60)),t.bn(r,7,3,0,1)),s=360/ei({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.S(i.center.lng-n.x*s*o,t.ah(i.center.lat+n.y*s,-t.ai,t.ai))}function li(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function ci(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=li(s+r*(a-s)),c=li(s),u=li(a);return new t.S(e.lng+i*((l-c)/(u-c)),o)}return new t.S(e.lng+i*r,o)}class ui{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class hi{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new hi(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.br([],n[0],n[1],n[2]),o=t.bs([],[i[0],0,0],r),s=t.bs([],[0,i[1],0],r),a=t.bs([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.aS(n,n,t.aR([],o,1&~i?-1:1)),t.aS(n,n,t.aR([],s,1==(i>>1&1)?1:-1)),t.aS(n,n,t.aR([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new hi(u,[[...o,-t.aX(o,u[0])],[...s,-t.aX(s,u[0])],[...a,-t.aX(a,u[0])],[-o[0],-o[1],-o[2],-t.aX(o,u[7])],[-s[0],-s[1],-s[2],-t.aX(s,u[7])],[-a[0],-a[1],-a[2],-t.aX(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n=0&&o++}if(0===o)return 0;o=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n=0&&i++}return i===t?2:0===i?0:1}}function di(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function pi(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>1?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,di(t,n,r))}class fi{constructor(){this._boundingVolumeCache=new ui(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.Z(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bu,l/=t.bu,a+=1,l+=1,e.z<=0)return hi.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return hi.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[ti(0,0,e.x,e.y,e.z),ti(t.$,0,e.x,e.y,e.z),ti(t.$,t.$,e.x,e.y,e.z),ti(0,t.$,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.aR([],e,l));if(l!==a)for(const e of i)n.push(t.aR([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<=(1<{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new fi}clone(){const e=new gi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bw(u,u,[0,0,0],-this.bearingInRadians),t.bx(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.by(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.aZ(u);return t.aR(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.aW(a,s,o),t.aV(s,s),t.aV(a,a);const l=[0,0,0];return t.aV(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<o&&(o=i),na&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new G(u)}getConstrained(e,i){const n=t.ah(e.lat,-t.ai,t.ai),r=t.ah(+i,this.minZoom+si(0,n),this.maxZoom);return{center:new t.S(e.lng,n),zoom:r}}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=ii(this.unprojectScreenPoint(i)),r=ii(e),o=t.bp();t.bB(o);const s=t.bp();t.by(s,n,o,-this.center.lng*Math.PI/180),t.bx(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bD(h,e)+t.bD(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bv();return t.aw(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const n=t.aX(e,i),r=t.bp(),o=t.bp();t.aR(o,i,n),t.aU(r,e,o);const s=1-t.aX(r,r);if(s<0)return null;const a=t.aX(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.bp();t.aS(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.bp();return t.aV(o,e),ri(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.b1(o,i)/s,l=t.bp();if(a>0)t.aS(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.bp();t.aS(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.b1(this._cachedClippingPlane,e);t.aU(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.bp();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return ri(function(e,i,n){const r=t.bp();t.aU(r,n,e);const o=t.bp();return t.bq(o,e,r,i/t.a$(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.S.convert(e),r=1/t.bu,o=t.b9();return t.bz(o,o,n.lng/180*Math.PI),t.b7(o,o,-n.lat/180*Math.PI),t.M(o,o,[0,0,1+i/t.bu]),t.b7(o,o,.5*Math.PI),t.N(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Z(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class _i{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Ft,this._verticalPerspectiveTransform=new gi}clone(){const e=new _i;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bk(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ai{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=ai(e,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bA(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bA(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.aX(h,u),p=t.bp();t.aS(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.aZ(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ni(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bn(g,.9,.5,1,.25),A=(1-t.af(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.S(i.center.lng+l*A,t.ah(i.center.lat+c*A,-t.ai,t.ai));i.setLocationAtPoint(r,n);const b=i.center,w=t.bn(Math.abs(a),45,85,0,1),T=t.bn(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bA(b.lng,x.lng),S=t.bA(b.lat,x.lat);i.setCenter(new t.S(b.lng+C*E,b.lat+S*E).wrap()),i.setZoom(v+si(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(ai(e.panDelta,t).wrap()),t.setZoom(r+si(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Ot(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bA(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bA(d,p),_=f+.5*t.bA(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ii(n.getNorthWest()),ii(n.getNorthEast()),ii(n.getSouthWest()),ii(n.getSouthEast()),ii(new t.S(p,_)),ii(new t.S(d,_)),ii(new t.S(g,f)),ii(new t.S(g,m))],x=ii(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.ak(b),s;kt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.getConstrained(i.center?t.S.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+si(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.S.convert(i.center):r,d=e.getConstrained(h,n).center;Bt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+si(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.ah(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ah(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+si(r.lat,m.lat),_=n+si(r.lat,0),A=g+si(m.lat,0),y=t.bA(r.lng,m.lng),v=t.bA(r.lat,m.lat),x=t.af(A-_);return u=g!==n,{easeFunc:n=>{if(t.be(s,a)||Dt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-n),o=ci(r,y,v,n*i);e.setCenter(o.wrap())}if(u){const i=t.C.number(_,A,n)+si(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.S.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+si(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.ah(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ah(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;Bt(e,d);const p=function(e,i,n){const r=ii(i),o=ii(n),s=t.aX(r,o),a=Math.acos(s),l=ei(e);return a/(2*Math.PI)*l}(e,r,d),f=o+si(r.lat,0),m=c+si(d.lat,0),g=t.af(m-f);let _;if("number"==typeof i.minZoom){const n=+i.minZoom+si(d.lat,0),r=Math.min(n,f,m)+si(0,d.lat),o=e.getConstrained(d,r).zoom+si(d.lat,0);_=t.af(o-f)}const A=t.bA(r.lng,d.lng),y=t.bA(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=ci(r,A,y,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.ak(o);e.setZoom(1===n?c:m+si(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.y(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),xi=t.bE();class bi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new D(k(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.imageManager=new y,this.imageManager.setEventedParent(this),this.glyphManager=new w(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new I(256,512),this.crossTileSymbolIndex=new At,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",t.bG()),ne().on(ee,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bH(s,this._globalState[e]))return this;this._globalState[e]=s;const a=this._findGlobalStateAffectedSources([e]);for(const e in this.sourceCaches)a.has(e)&&(this._reloadSource(e),this._changed=!0)}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bH(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);const n=this._findGlobalStateAffectedSources(i);for(const e in this.sourceCaches)n.has(e)&&(this._reloadSource(e),this._changed=!0)}_findGlobalStateAffectedSources(e){if(0===e.length)return new Set;const t=new Set;for(const i in this._layers){const n=this._layers[i],r=n.getLayoutAffectingGlobalStateRefs();for(const i of e)r.has(i)&&t.add(n.source)}return t}loadURL(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const r=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(r,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,n)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(xi,{validate:!1})}_load(e,i,n){var r,o,s;const a=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!vi(this,t.z(a))){this._loaded=!0,this.stylesheet=a;for(const e in a.sources)this.addSource(e,a.sources[e],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new C(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new B(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.setGlobalState(null!==(s=this.stylesheet.state)&&void 0!==s?s:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){const e=t.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bJ(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e}}_loadSprite(e,i=!1,n=void 0){let r;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=g(e),a=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=i.transformRequest(_(n,a,".json"),"SpriteJSON");l[e]=t.j(o,r);const s=i.transformRequest(_(n,a,".png"),"SpriteImage");c[e]=f.getImage(s,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=s.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,r=e,this.fire(new t.k(r))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),n&&n(r)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(n))&&this.fire(new t.k(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bK(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bK(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())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}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const e in n){const i=this.sourceCaches[e];!!n[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&vi(this,t.z(e)))return!1;(e=t.bK(e)).layers=t.bI(e.layers);const o=t.bL(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.z.source,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=this.sourceCaches[e]=new ve(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.k(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(vi(this,t.bM(e)))return;o=t.bJ(e)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bK(e),e=t.e(e,{source:r})),this._validate(t.z.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bJ(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bH(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.z.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bK(i)),this._updateLayer(r)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bK(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bH(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bH(o.getPaintProperty(i),n)||(o.setPaintProperty(i,n,r)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.sourceCaches[n];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.sourceCaches[n];if(void 0===r)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.sourceCaches[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bN(this.sourceCaches,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bO({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const n in e)for(const r of e[n])V(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.z.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.sourceCaches[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((r=r||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new pt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.z.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...g(this.stylesheet.sprite),...o];this._validate(t.z.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=g(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.z.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}}var wi=t.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ti{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bf.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bf.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Ci={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Si(e){const t=[];for(let i=0;i({u_depth:new t.bP(e,i.u_depth),u_terrain:new t.bP(e,i.u_terrain),u_terrain_dim:new t.bg(e,i.u_terrain_dim),u_terrain_matrix:new t.bR(e,i.u_terrain_matrix),u_terrain_unpack:new t.bS(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bg(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bR(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bS(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bS(e,i.u_projection_clipping_plane),u_projection_transition:new t.bg(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bR(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=n?n.getUniforms(e,E):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Ci[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const n=i.vaos||(i.vaos={});(n[c]||(n[c]=new Ti)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Ii(e,i,n){const r=1/t.aC(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Mi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.bV();"viewport"===o.properties.get("anchor")&&t.bW(l,e.transform.bearingInRadians),t.bX(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},Pi=(e,i,n,r,o,s,a)=>t.e(Mi(e,i,n,r),Ii(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ri=(e,i,n,r)=>t.e(Ii(i,e,n),{u_fill_translate:r}),Li=(e,t)=>({u_world:e,u_fill_translate:t}),Fi=(e,i,n,r,o)=>t.e(Ri(e,i,n,o),{u_world:r}),ki=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aC(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.$*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Oi=e=>({u_viewport_size:[e.width,e.height]}),zi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Ui=(e,i,n,r)=>{const o=t.aC(e,1,i)/(t.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aC(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},Ni=(e,i,n,r)=>{const o=t.L();t.bY(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},Vi=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t{const n=i.stride,r=t.L();return t.bY(r,0,t.$,-t.$,0,0,1),t.M(r,r,[0,-t.$,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Gi(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.a1(0,r/n).toLngLat().lat,new t.a1(0,(r+1)/n).toLngLat().lat]}const Hi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Qi=(e,i,n,r)=>{const o=e.transform;return{u_translation:Ki(e,i,n),u_ratio:r/t.aC(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},$i=(e,i,n,r,o)=>t.e(Qi(e,i,n,r),{u_image:0,u_image_height:o}),Zi=(e,i,n,r,o)=>{const s=e.transform,a=qi(i,s);return{u_translation:Ki(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aC(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Wi=(e,i,n,r,o,s)=>{const a=e.lineAtlas,l=qi(i,e.transform),c="round"===n.layout.get("line-cap"),u=a.getDash(o.from,c),h=a.getDash(o.to,c),d=u.width*s.fromScale,p=h.width*s.toScale;return t.e(Qi(e,i,n,r),{u_patternscale_a:[l/d,-u.height/2],u_patternscale_b:[l/p,-h.height/2],u_sdfgamma:a.width/(256*Math.min(d,p)*e.pixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:h.y,u_mix:s.t})};function qi(e,i){return 1/t.aC(e,1,i.tileZoom)}function Ki(e,i,n){return t.aD(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Xi=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Ji(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function Ji(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]}const Yi=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{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:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},en=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(Yi(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},tn=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(en(e,i,n,r,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),nn=(e,t)=>({u_opacity:e,u_color:t}),rn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aC(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),on=(e,t)=>{},sn={fillExtrusion:(e,i)=>({u_lightpos:new t.bT(e,i.u_lightpos),u_lightpos_globe:new t.bT(e,i.u_lightpos_globe),u_lightintensity:new t.bg(e,i.u_lightintensity),u_lightcolor:new t.bT(e,i.u_lightcolor),u_vertical_gradient:new t.bg(e,i.u_vertical_gradient),u_opacity:new t.bg(e,i.u_opacity),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bT(e,i.u_lightpos),u_lightpos_globe:new t.bT(e,i.u_lightpos_globe),u_lightintensity:new t.bg(e,i.u_lightintensity),u_lightcolor:new t.bT(e,i.u_lightcolor),u_vertical_gradient:new t.bg(e,i.u_vertical_gradient),u_height_factor:new t.bg(e,i.u_height_factor),u_opacity:new t.bg(e,i.u_opacity),u_fill_translate:new t.bU(e,i.u_fill_translate),u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bU(e,i.u_world),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bU(e,i.u_world),u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade),u_fill_translate:new t.bU(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bP(e,i.u_scale_with_map),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_extrude_scale:new t.bU(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bg(e,i.u_globe_extrude_scale),u_translate:new t.bU(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bU(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bU(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bQ(e,i.u_color),u_overlay:new t.bP(e,i.u_overlay),u_overlay_scale:new t.bg(e,i.u_overlay_scale)}),depth:on,clippingMask:on,heatmap:(e,i)=>({u_extrude_scale:new t.bg(e,i.u_extrude_scale),u_intensity:new t.bg(e,i.u_intensity),u_globe_extrude_scale:new t.bg(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bR(e,i.u_matrix),u_world:new t.bU(e,i.u_world),u_image:new t.bP(e,i.u_image),u_color_ramp:new t.bP(e,i.u_color_ramp),u_opacity:new t.bg(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bP(e,i.u_image),u_latrange:new t.bU(e,i.u_latrange),u_exaggeration:new t.bg(e,i.u_exaggeration),u_altitudes:new t.b_(e,i.u_altitudes),u_azimuths:new t.b_(e,i.u_azimuths),u_accent:new t.bQ(e,i.u_accent),u_method:new t.bP(e,i.u_method),u_shadows:new t.bZ(e,i.u_shadows),u_highlights:new t.bZ(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bR(e,i.u_matrix),u_image:new t.bP(e,i.u_image),u_dimension:new t.bU(e,i.u_dimension),u_zoom:new t.bg(e,i.u_zoom),u_unpack:new t.bS(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bP(e,i.u_image),u_unpack:new t.bS(e,i.u_unpack),u_dimension:new t.bU(e,i.u_dimension),u_elevation_stops:new t.bP(e,i.u_elevation_stops),u_color_stops:new t.bP(e,i.u_color_stops),u_color_ramp_size:new t.bP(e,i.u_color_ramp_size),u_opacity:new t.bg(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_image:new t.bP(e,i.u_image),u_image_height:new t.bg(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_texsize:new t.bU(e,i.u_texsize),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_image:new t.bP(e,i.u_image),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_patternscale_a:new t.bU(e,i.u_patternscale_a),u_patternscale_b:new t.bU(e,i.u_patternscale_b),u_sdfgamma:new t.bg(e,i.u_sdfgamma),u_image:new t.bP(e,i.u_image),u_tex_y_a:new t.bg(e,i.u_tex_y_a),u_tex_y_b:new t.bg(e,i.u_tex_y_b),u_mix:new t.bg(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bU(e,i.u_tl_parent),u_scale_parent:new t.bg(e,i.u_scale_parent),u_buffer_scale:new t.bg(e,i.u_buffer_scale),u_fade_t:new t.bg(e,i.u_fade_t),u_opacity:new t.bg(e,i.u_opacity),u_image0:new t.bP(e,i.u_image0),u_image1:new t.bP(e,i.u_image1),u_brightness_low:new t.bg(e,i.u_brightness_low),u_brightness_high:new t.bg(e,i.u_brightness_high),u_saturation_factor:new t.bg(e,i.u_saturation_factor),u_contrast_factor:new t.bg(e,i.u_contrast_factor),u_spin_weights:new t.bT(e,i.u_spin_weights),u_coords_top:new t.bS(e,i.u_coords_top),u_coords_bottom:new t.bS(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texture:new t.bP(e,i.u_texture),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texture:new t.bP(e,i.u_texture),u_gamma_scale:new t.bg(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_is_halo:new t.bP(e,i.u_is_halo),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texsize_icon:new t.bU(e,i.u_texsize_icon),u_texture:new t.bP(e,i.u_texture),u_texture_icon:new t.bP(e,i.u_texture_icon),u_gamma_scale:new t.bg(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_is_halo:new t.bP(e,i.u_is_halo),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bg(e,i.u_opacity),u_color:new t.bQ(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bg(e,i.u_opacity),u_image:new t.bP(e,i.u_image),u_pattern_tl_a:new t.bU(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bU(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bU(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bU(e,i.u_pattern_br_b),u_texsize:new t.bU(e,i.u_texsize),u_mix:new t.bg(e,i.u_mix),u_pattern_size_a:new t.bU(e,i.u_pattern_size_a),u_pattern_size_b:new t.bU(e,i.u_pattern_size_b),u_scale_a:new t.bg(e,i.u_scale_a),u_scale_b:new t.bg(e,i.u_scale_b),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bg(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bP(e,i.u_texture),u_ele_delta:new t.bg(e,i.u_ele_delta),u_fog_matrix:new t.bR(e,i.u_fog_matrix),u_fog_color:new t.bQ(e,i.u_fog_color),u_fog_ground_blend:new t.bg(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bg(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bQ(e,i.u_horizon_color),u_horizon_fog_blend:new t.bg(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bg(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bg(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bP(e,i.u_texture),u_terrain_coords_id:new t.bg(e,i.u_terrain_coords_id),u_ele_delta:new t.bg(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bg(e,i.u_input),u_output_expected:new t.bg(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bT(e,i.u_sun_pos),u_atmosphere_blend:new t.bg(e,i.u_atmosphere_blend),u_globe_position:new t.bT(e,i.u_globe_position),u_globe_radius:new t.bg(e,i.u_globe_radius),u_inv_proj_matrix:new t.bR(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bQ(e,i.u_sky_color),u_horizon_color:new t.bQ(e,i.u_horizon_color),u_horizon:new t.bU(e,i.u_horizon),u_horizon_normal:new t.bU(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bg(e,i.u_sky_horizon_blend),u_sky_blend:new t.bg(e,i.u_sky_blend)})};class an{constructor(e,t,i){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||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const ln={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class cn{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,jt.disabled,Ht.disabled,e.colorModeForRenderPass(),Vt.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.b$;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:B,angle:I})}else Qe(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===n.layout.get("text-rotation-alignment");Re(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?Xn:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?tn(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):en(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):Yi(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:B,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aM([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,nr(i.buffers,t.segments,n,e,i.program,w,h,d,r,i.projectionData,t.terrainData)),r.u_is_halo=0}nr(i.buffers,t.segments,n,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function nr(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,Vt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function rr(e,i,n,r,o){const s=e.context,a=s.gl,l=Ht.disabled,c=new Ut([a.ONE,a.ONE],t.bf.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=sr(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bf.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,jt.disabled,l,c,Vt.disabled,Ui(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function or(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=ar(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,jt.disabled,Ht.disabled,e.colorModeForRenderPass(),Vt.disabled,Ni(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function sr(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ar(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function lr(e,t,i,n,r){if(!i||!n||!n.imageAtlas)return;const o=n.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const e=r.getPaintProperty(t);s=o[e],a=o[e]}s&&a&&e.setConstantPatternPositions(s,a)}function cr(e,i,n,r,o,s,a,l){const c=e.context.gl,u="fill-pattern",h=n.paint.get(u),d=h&&h.constantOr(1),p=n.getCrossfadeParameters();let f,m,g,_,A;const y=e.transform,v=n.paint.get("fill-translate"),x=n.paint.get("fill-translate-anchor");a?(m=d&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const b=h.constantOr(null);for(const h of r){const r=i.getTile(h);if(d&&!r.patternsLoaded())continue;const w=r.getBucket(n);if(!w)continue;const T=w.programConfigurations.get(n.id),E=e.useProgram(m,T),C=e.style.map.terrain&&e.style.map.terrain.getTerrainData(h);d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),T.updatePaintBuffers(p)),lr(T,u,b,r,n);const S=y.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),B=t.aD(y,r,v,x);if(a){_=w.indexBuffer2,A=w.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===m&&d?Fi(e,p,r,t,B):Li(t,B)}else _=w.indexBuffer,A=w.segments,g=d?Ri(e,p,r,B):{u_fill_translate:B};const I=e.stencilModeForClipping(h);E.draw(e.context,f,o,I,s,Vt.backCCW,g,C,S,n.id,w.layoutVertexBuffer,_,A,n.paint,e.transform.zoom,T)}}function ur(e,i,n,r,o,s,a,l){const c=e.context,u=c.gl,h="fill-extrusion-pattern",d=n.paint.get(h),p=d.constantOr(1),f=n.getCrossfadeParameters(),m=n.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),_=e.transform;for(const d of r){const r=i.getTile(d),A=r.getBucket(n);if(!A)continue;const y=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),v=A.programConfigurations.get(n.id),x=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),v.updatePaintBuffers(f));const b=_.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});lr(v,h,g,r,n);const w=t.aD(_,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),T=n.paint.get("fill-extrusion-vertical-gradient"),E=p?Pi(e,T,m,w,d,f,r):Mi(e,T,m,w);x.draw(c,c.gl.TRIANGLES,o,s,a,Vt.backCCW,E,y,b,n.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,n.paint,e.transform.zoom,v,e.style.map.terrain&&A.centroidVertexBuffer)}}function hr(e,t,i,n,r,o,s,a,l){var c;const u=e.style.projection,h=e.context,d=e.transform,p=h.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,f),g=!e.options.moving;for(const f of n){const n=t.getTile(f),_=n.fbo;if(!_)continue;const A=u.getMeshFromTileID(h,f.canonical,a,!0,"raster"),y=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);h.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,_.colorAttachment.get());const v=d.getProjectionData({overscaledTileID:f,aligned:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(h,p.TRIANGLES,o,r[f.overscaledZ],s,Vt.backCCW,Vi(e,n,i),y,v,i.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function dr(e,i,n,r,o,s,a,l,c){var u;const h=e.style.projection,d=e.context,p=e.transform,f=d.gl,m=e.useProgram("colorRelief"),g=!e.options.moving;let _=!0,A=0;for(const y of r){const r=i.getTile(y),v=r.dem;if(_){const e=f.getParameter(f.MAX_TEXTURE_SIZE),{elevationTexture:t,colorTexture:i}=n.getColorRampTextures(d,e,v.getUnpackVector());d.activeTexture.set(f.TEXTURE1),t.bind(f.NEAREST,f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE4),i.bind(f.LINEAR,f.CLAMP_TO_EDGE),_=!1,A=t.size[0]}if(!v||!v.data)continue;const x=v.stride,b=v.getPixels();if(d.activeTexture.set(f.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||e.getTileTexture(x),r.demTexture){const e=r.demTexture;e.update(b,{premultiply:!1}),e.bind(f.LINEAR,f.CLAMP_TO_EDGE)}else r.demTexture=new t.T(d,b,f.RGBA,{premultiply:!1}),r.demTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const w=h.getMeshFromTileID(d,y.canonical,l,!0,"raster"),T=null===(u=e.style.map.terrain)||void 0===u?void 0:u.getTerrainData(y),E=p.getProjectionData({overscaledTileID:y,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(d,f.TRIANGLES,s,o[y.overscaledZ],a,Vt.backCCW,Hi(n,r.dem,A),T,E,n.id,w.vertexBuffer,w.indexBuffer,w.segments)}}const pr=[new t.P(0,0),new t.P(t.$,0),new t.P(t.$,t.$),new t.P(0,t.$)];function fr(e,t,i,n,r,o,s,a,l=!1,c=!1){const u=n[n.length-1].overscaledZ,h=e.context,d=h.gl,p=e.useProgram("raster"),f=e.transform,m=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving;for(const A of n){const n=e.getDepthModeForSublayer(A.overscaledZ-u,1===i.paint.get("raster-opacity")?jt.ReadWrite:jt.ReadOnly,d.LESS),y=t.getTile(A);y.registerFadeDuration(i.paint.get("raster-fade-duration"));const v=t.findLoadedParent(A,0),x=t.findLoadedSibling(A),b=mr(y,v||x||null,t,i,e.transform,e.style.map.terrain);let w,T;const E="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;h.activeTexture.set(d.TEXTURE0),y.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),h.activeTexture.set(d.TEXTURE1),v?(v.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),w=Math.pow(2,v.tileID.overscaledZ-y.tileID.overscaledZ),T=[y.tileID.canonical.x*w%1,y.tileID.canonical.y*w%1]):y.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),y.texture.useMipmap&&h.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const C=e.style.map.terrain&&e.style.map.terrain.getTerrainData(A),S=f.getProjectionData({overscaledTileID:A,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),B=Xi(T||[0,0],w||1,b,i,a),I=m.getMeshFromTileID(h,A.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,n,r?r[A.overscaledZ]:Ht.disabled,g,l?Vt.frontCCW:Vt.backCCW,B,C,S,i.id,I.vertexBuffer,I.indexBuffer,I.segments)}}function mr(e,i,n,r,o,a){const l=r.paint.get("raster-fade-duration");if(!a&&l>0){const r=s.now(),a=(r-e.timeAdded)/l,c=i?(r-i.timeAdded)/l:-1,u=n.getSource(),h=_e(o,{tileSize:u.tileSize,roundZoom:u.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),p=d&&e.refreshedUponExpiration?1:t.ah(d?a:1-c,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const gr=new t.bf(1,0,0,1),_r=new t.bf(0,1,0,1),Ar=new t.bf(0,0,1,1),yr=new t.bf(1,0,1,1),vr=new t.bf(0,1,1,1);function xr(e,t,i,n){wr(e,0,t+i/2,e.transform.width,i,n)}function br(e,t,i,n){wr(e,t-i/2,0,i,e.transform.height,n)}function wr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Tr(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("debug"),a=jt.disabled,l=Ht.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(n).tileSize,m=512/Math.min(f,512)*(n.overscaledZ/e.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,o.TRIANGLES,a,l,Ut.alphaBlended,Vt.disabled,zi(t.bf.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(r,o.LINE_STRIP,a,l,c,Vt.disabled,zi(t.bf.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Er(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Ei(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Ht.disabled,l,Vt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Cr(e,i){if(!i.mesh){const n=new t.aL;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aN;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new bt(e.createVertexBuffer(n,wt.members),e.createIndexBuffer(r),t.aM.simpleSegment(0,0,n.length,r.length))}return i.mesh}class Sr{constructor(e,i){this.context=new Wn(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ve.maxUnderzooming+ve.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new At}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aL;i.emplaceBack(0,0),i.emplaceBack(t.$,0),i.emplaceBack(0,t.$),i.emplaceBack(t.$,t.$),this.tileExtentBuffer=e.createVertexBuffer(i,wt.members),this.tileExtentSegments=t.aM.simpleSegment(0,0,4,2);const n=new t.aL;n.emplaceBack(0,0),n.emplaceBack(t.$,0),n.emplaceBack(0,t.$),n.emplaceBack(t.$,t.$),this.debugBuffer=e.createVertexBuffer(n,wt.members),this.debugSegments=t.aM.simpleSegment(0,0,4,5);const r=new t.c6;r.emplaceBack(0,0,0,0),r.emplaceBack(t.$,0,t.$,0),r.emplaceBack(0,t.$,0,t.$),r.emplaceBack(t.$,t.$,t.$,t.$),this.rasterBoundsBuffer=e.createVertexBuffer(r,wi.members),this.rasterBoundsSegments=t.aM.simpleSegment(0,0,4,2);const o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(t.$,0),o.emplaceBack(0,t.$),o.emplaceBack(t.$,t.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,wt.members),this.rasterBoundsSegmentsPosOnly=t.aM.simpleSegment(0,0,4,5);const s=new t.aL;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,wt.members),this.viewportSegments=t.aM.simpleSegment(0,0,4,2);const a=new t.c7;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aN;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Ht({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new bt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.L();t.bY(n,0,this.width,this.height,0,0,1),t.N(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,jt.disabled,this.stencilClearMode,Ut.disabled,Vt.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode(Ut.disabled),n.setDepthMode(jt.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){const r=this.context,o=r.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,jt.disabled,new Ht({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),Ut.disabled,i?Vt.disabled:Vt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,n=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ae(n,{tileSize:n.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=n.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,t.TRIANGLES,o,Ht.disabled,Ut.disabled,Vt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Ht({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Ht({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i0};for(const e in a){const t=a[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bf.black:t.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=ue(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new jt(n.LEQUAL,jt.ReadWrite,[0,1]),s=Ht.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Cr(i,t);l.draw(i,n.TRIANGLES,o,s,a,Vt.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=a[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Cr(r,i);s.draw(r,o.TRIANGLES,a,Ht.disabled,Ut.alphaBlended,Vt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let n=0;nh.getElevation(o,e,t):null;er(s,d,p,c,u,g,i,f,_,t.aD(u,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&ir(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&ir(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(Kn(e,i,n,r,!0),Kn(e,i,n,r,!1))}(e,i,n,r,this.style.placement.variableOffsets,o):t.cc(n)?function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,jt.ReadOnly),m=Ht.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,d.TRIANGLES,f,m,g,Vt.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}}(e,i,n,r,o):t.cd(n)?function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?rr(e,r,n,t,l):"translucent"===e.renderPass&&or(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=Ht.disabled,c=new Ut([s.ONE,s.ONE],t.bf.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.c2);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=sr(e,i.width/4,i.height/4),n.heatmapFbos.set(t.c2,o))})(o,e,n),o.clear({color:t.bf.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=i?vt.projectionMercator:o.shaderPreludeCode,a=i?Tt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Et:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Bi(this.context,vt[e],t,sn[e],this._showOverdrawInspector,r,s,a,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Br(e,t){let i,n=!1,r=null,o=null;const s=()=>{r=null,n&&(e.apply(o,i),r=setTimeout(s,t),n=!1)};return(...e)=>(n=!0,o=this,i=e,r||s(),r)}class Ir{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Br(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.S(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Mr={linearity:.3,easing:t.cm(0,0,.3,1)},Pr=t.e({deceleration:2500,maxSpeed:1400},Mr),Rr=t.e({deceleration:20,maxSpeed:1400},Mr),Lr=t.e({deceleration:1e3,maxSpeed:360},Mr),Fr=t.e({deceleration:1e3,maxSpeed:90},Mr),kr=t.e({deceleration:1e3,maxSpeed:360},Mr);class Dr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=zr(i.pan.mag(),n,t.e({},Pr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,Or(r,o)}if(i.zoom){const e=zr(i.zoom,n,Rr);r.zoom=this._map.transform.zoom+e.amount,Or(r,e)}if(i.bearing){const e=zr(i.bearing,n,Lr);r.bearing=this._map.transform.bearing+t.ah(e.amount,-179,179),Or(r,e)}if(i.pitch){const e=zr(i.pitch,n,Fr);r.pitch=this._map.transform.pitch+e.amount,Or(r,e)}if(i.roll){const e=zr(i.roll,n,kr);r.roll=this._map.transform.roll+t.ah(e.amount,-179,179),Or(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(r,{noMoveStart:!0})}}function Or(e,t){(!e.duration||e.durationi.unproject(e)),l=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:n}),this._defaultPrevented=!1}}class Vr extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class jr{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Vr(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Ur(e.type,this._map,e))}mouseup(e){this._map.fire(new Ur(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Ur(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Ur(e.type,this._map,e))}mouseover(e){this._map.fire(new Ur(e.type,this._map,e))}mouseout(e){this._map.fire(new Ur(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Nr(e.type,this._map,e))}touchmove(e){this._map.fire(new Nr(e.type,this._map,e))}touchend(e){this._map.fire(new Nr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Nr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Gr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Ur(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ur("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Ur(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Hr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Qr{constructor(e,t){this._map=e,this._tr=new Hr(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&&(a.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function $r(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=$r(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=$r(i,t);for(const e in this.touches){const t=n[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 Wr{constructor(e){this.singleTap=new Zr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class qr{constructor(e){this._tr=new Hr(e),this._zoomIn=new Wr({numTouches:1,numTaps:2}),this._zoomOut=new Wr({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(r)},{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}}class Kr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)!0}),t=new to){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const no=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class ro{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=$r(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class po extends oo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,ho(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return ho(e)&&ho(t)&&o}}const fo={panStep:100,bearingStep:15,pitchStep:10};class mo{constructor(e){this._tr=new Hr(e);const t=fo;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:go,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:a.center},{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 go(e){return e*(2-e)}const _o=4.000244140625,Ao=1/450;class yo{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Hr(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Ao}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)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%_o==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_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 i=a.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.S.convert(n.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>_o?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.ak(r*n)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,a=!1;if("wheel"===this._type&&n&&r){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=r(l);o=t.C.number(n,i,c),l<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.co;if(this._prevEase){const e=this._prevEase,n=(s.now()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,a=Math.sqrt(.0729-o*o);i=t.cm(o,a,.25,1)}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class vo{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 xo{constructor(e){this._tr=new Hr(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bo{constructor(){this._tap=new Wr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wo{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class To{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Eo{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Co{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=a.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(a.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const So=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Bo extends t.l{}function Io(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Mo{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:l,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;if(this._blockedByActive(s,u,l))c.reset();else if(c[i||e.type]){if(t.cp(e,i||e.type)){const t=a.mousePos(this._map.getCanvas(),e);h=c[i||e.type](e,t)}else if(t.cq(e,i||e.type)){const t=this._getMapTouches(e.touches),n=a.touchPos(this._map.getCanvas(),t);h=c[i||e.type](e,n,t)}else t.cr(i||e.type)||(h=c[i||e.type](e));this.mergeHandlerResult(r,o,h,l,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||c.isActive())&&(s[l]=c)}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=n);this._previousActiveHandlers=s,(Object.keys(l).length||Io(r))&&(this._changes.push([r,o,l]),this._triggerRenderFrame()),(Object.keys(s).length||Io(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=r;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Dr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)a.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)a.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new jr(i,e));const r=i.boxZoom=new Qr(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Co(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new qr(i),l=new xo(i);i.doubleClickZoom=new vo(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new bo;this._add("tapDragZoom",c);const u=i.touchPitch=new po(i);this._add("touchPitch",u),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const l=new eo({checkCorrectEvent:e=>0===a.mouseButton(e)&&e.ctrlKey||2===a.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cn(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y0===a.mouseButton(e)&&e.ctrlKey||2===a.mouseButton(e)});return new Kr({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:no})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new eo({checkCorrectEvent:e=>2===a.mouseButton(e)&&e.ctrlKey});return new Kr({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y0===a.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:no})}(e),g=new ro(e,i);i.dragPan=new wo(n,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new uo,A=new lo;i.touchZoomRotate=new Eo(n,A,_,c),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const y=i.scrollZoom=new yo(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new mo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Gr(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=[]}}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 Boolean(So(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(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),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(Io(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||n.transform.centerPoint,o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);o?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,r),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?r.setCenter(r.screenPointToLocation(r.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(p,r,f):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,r,f))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,r),this._map.cameraHelper.handleMapControlsPan(p,r,f)),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,i,n){const r=So(this._eventsInProgress),o=So(e),a={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(a[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=So(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Bo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Po extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.l("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new t.l("zoomend",e)),r&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const n=t.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(n,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.co},e);const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,a=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,a):a,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(n.width,n.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},S=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},B=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(B)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*B/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==a,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(s=>{const m=s*B,_=1/C(m),A=S(m);this._rotating&&n.setBearing(t.C.number(r,c,s)),this._pitching&&n.setPitch(t.C.number(o,u,s)),this._rolling&&n.setRoll(t.C.number(a,h,s)),this._padding&&(n.interpolatePadding(l,d,s),f=n.centerPoint.add(p)),g.easeFunc(s,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.aO(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class Lo{constructor(e=Ro){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.sourceCaches;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=a.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Fo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=a.create("div","maplibregl-ctrl");const t=a.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ko{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){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var Do=t.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Oo extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ae(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.bY(r.terrainRttPosMatrix32f,0,t.$,t.$,0,0,1),this._tiles[r.key]=new re(r,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.ba();if(r.canonical.equals(e.canonical))t.bY(s,0,t.$,t.$,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<>i<>i;t.bY(s,0,a,a,0,0,1),t.M(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bY(s,0,t.$,t.$,0,0,1),t.M(s,s,[n*a,o*a,0]),t.N(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.ba();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,n=e.canonical.y-o.canonical.y;t.bY(a,0,t.$,t.$,0,0,1),t.M(a,a,[i*t.$,n*t.$,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.$>>i;t.bY(a,0,c,c,0,0,1),t.M(a,a,[-n*c+s*t.$,-r*c+l*t.$,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.$<i.maxzoom&&(n=i.maxzoom),n=i.minzoom&&(!r||!r.dem);)r=this.sourceCache.getTileByID(e.scaledTo(n--).key);return r}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class zo{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Oo(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,n,r=t.$){var o;if(!(i>=0&&i=0&&ne.canonical.z&&(e.canonical.z>=n?r=e.canonical.z-n:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>r<>r<>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.sourceCache.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const No={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Vo{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Uo(e.context,30,t.sourceCache.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),n=e.sourceCaches[t].getSource(),r=n instanceof q?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,r);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],n=i.source;if(No[i.type]&&!this._coordsAscendingStr[n]){this._coordsAscendingStr[n]={};for(const e in this._coordsAscending[n])this._coordsAscendingStr[n][e]=this._coordsAscending[n][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(No[r]&&(this._prevType&&No[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(No[this._prevType]||No[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(Er(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bf.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,a.mousePos(this.element,e)),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,a.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),a.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const r=new io;this._rotatePitchHandler=new Kr({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cn(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),a.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;a.removeEventListener(e,"mousedown",this.mousedown),a.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend),a.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend)}}let Zo;function Wo(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.S(e.lng,e.lat);if(e=new t.S(e.lng,e.lat),i){const r=new t.S(e.lng-360,e.lat),o=new t.S(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const qo={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%)"};function Ko(e,t,i){const n=e.classList;for(const e in qo)n.remove(`maplibregl-${i}-anchor-${e}`);n.add(`maplibregl-${i}-anchor-${t}`)}class Xo extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Wo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),a.setTransform(this._element,`${qo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`),s.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},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._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=a.create("div");const i=a.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=a.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=a.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=a.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=a.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t)}const u=a.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"fill",this._color);const h=a.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),u.appendChild(h);const d=a.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=a.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=a.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=a.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=a.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=a.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(l),s.appendChild(u),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),Ko(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),a.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,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,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.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 this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Jo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Yo=0,es=!1;const ts={maxWidth:100,unit:"metric"};function is(e,t,i){const n=i&&i.maxWidth||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?ns(t,c,i/5280,e._getUIString("ScaleControl.Miles")):ns(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?ns(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?ns(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):ns(t,c,u,e._getUIString("ScaleControl.Meters"))}function ns(e,t,i,n){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}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r} ${n}`}const rs={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},os=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ss(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ss(new t.P(0,0))}const as=i;e.AJAXError=t.cz,e.Event=t.l,e.Evented=t.E,e.LngLat=t.S,e.MercatorCoordinate=t.a1,e.Point=t.P,e.addProtocol=t.cA,e.config=t.a,e.removeProtocol=t.cB,e.AttributionControl=Lo,e.BoxZoomHandler=Qr,e.CanvasSource=X,e.CooperativeGesturesHandler=Co,e.DoubleClickZoomHandler=vo,e.DragPanHandler=wo,e.DragRotateHandler=To,e.EdgeInsets=St,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){a.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=a.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);a.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=W,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.S(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=G.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.S(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&es)return;this.options.trackUserLocation&&this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=a.create("button","maplibregl-ctrl-geolocate",this._container),a.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=a.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Xo({element:this._dotElement}),this._circleElement=a.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Xo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},Jo,e)}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==Zo&&!e)return Zo;if(void 0===window.navigator.permissions)return Zo=!!window.navigator.geolocation,Zo;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Zo="denied"!==e.state}catch(e){Zo=!!window.navigator.geolocation}return Zo})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),a.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Yo=0,es=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),n=t.distanceTo(i),r=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}trigger(){if(!this._setup)return t.w("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 t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Yo--,es=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Yo++,Yo>1?(e={maximumAge:6e5,timeout:0},es=!0):(e=this.options.positionOptions,es=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=a.create("button","maplibregl-ctrl-globe",this._container),a.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=Ir,e.ImageSource=q,e.KeyboardHandler=mo,e.LngLatBounds=G,e.LogoControl=Fo,e.Map=class extends Po{constructor(e){var i,n;t.cw.mark(t.cx.create);const r=Object.assign(Object.assign(Object.assign({},Ho),e),{canvasContextAttributes:Object.assign(Object.assign({},Ho.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Ft,s=new zt;if(void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),super(o,s,{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ko,this._controls=[],this._mapId=t.a7(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},jo),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this.transformCameraUpdate=r.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=f.addThrottleControl(()=>this.isMoving()),this._requestManager=new m(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Br(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Mo(this,r),this._hash=r.hash&&new Ir("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const a="string"==typeof r.style||!("globe"===(null===(n=null===(i=r.style)||void 0===i?void 0:i.projection)||void 0===n?void 0:n.type));this.resize(null,a),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new Lo("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Fo,r.logoPosition),this.on("style.load",()=>{if(a||this._resizeTransform(),this.transform.unmodified){const e=t.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){const[n,r]=this._containerDimensions(),o=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,o),this.painter.resize(n,r,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,t),this.painter.resize(n,r,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(G.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),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.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.S.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new Ur(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new Ur(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new Ur(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const n=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:e)||{},o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(null===(n=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const n=this._requestManager.transformRequest(e,"Style");t.j(n,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new zo(this.painter,i,e),this.painter.renderToTexture=new Vo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=me(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=me(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.sourceCaches[e];if(!n)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.a4(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(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`")));{const{width:n,height:s,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:s},new Uint8Array(d)),pixelRatio:r,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:o,height:a,data:l}=r;if(void 0===o||void 0===a)return this.fire(new t.k(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`")));if(o!==n.data.width||a!==n.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return f.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=a.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=a.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=a.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=a.create("div",`maplibregl-ctrl-${e} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Sr(i,this.transform),l.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(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)}_render(e){var i,n,r,o,a;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const n=new t.F(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(u=!0,this._crossFadingFactor=r),this.style.update(n)}const h=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==c;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(a=this.style.projection)||void 0===a?void 0:a.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cw.mark(t.cx.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cw.mark(t.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),f.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),a.remove(this._canvasContainer),a.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cw.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,e=>{t.cw.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cy(e)&&!function(e){return e.message===$n}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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 version(){return Go}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Ur,e.MapTouchEvent=Nr,e.MapWheelEvent=Vr,e.Marker=Xo,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},Qo,e),this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),a.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),a.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=a.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new $o(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){a.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=a.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&a.remove(this._content),this._container&&(a.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=a.create("div","maplibregl-popup",this._map.getContainer()),this._tip=a.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Wo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const n=ss(this.options.offset);if(!i){const e=this._container.offsetWidth,r=this._container.offsetHeight;let o;o=t.y+n.bottom.ythis._map.transform.height-r?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let r=t.add(n[i]);this.options.subpixelPositioning||(r=r.round()),a.setTransform(this._container,`${qo[i]} translate(${r.x}px,${r.y}px)`),Ko(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(rs),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.S.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=a.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=a.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(os);e&&e.focus()}},e.RasterDEMTileSource=Z,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{is(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,is(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ts),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){a.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=yo,e.Style=bi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=a.create("button","maplibregl-ctrl-terrain",this._container),a.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){a.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=po,e.TwoFingersTouchRotateHandler=uo,e.TwoFingersTouchZoomHandler=lo,e.TwoFingersTouchZoomRotateHandler=Eo,e.VectorTileSource=Q,e.VideoSource=K,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(Y(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(M),L=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()"))},e.createTileMesh=qt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ne().getRTLTextPluginStatus()},e.getVersion=function(){return as},e.getWorkerCount=function(){return P.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){k().acquire(M)},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setRTLTextPlugin=function(e,t){return ne().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){P.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var n=e;return n}();var tJ=He(eJ.exports);const iJ="function"==typeof Buffer,nJ=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder,Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),rJ=(()=>{let e={};return nJ.forEach((t,i)=>e[t]=i),e})(),oJ=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,sJ=String.fromCharCode.bind(String),aJ=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),e=>e.replace(/=/g,"").replace(/[+\/]/g,e=>"+"==e?"-":"_")),lJ=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),cJ=e=>{let t,i,n,r,o="";const s=e.length%3;for(let s=0;s255||(n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=i<<16|n<<8|r,o+=nJ[t>>18&63]+nJ[t>>12&63]+nJ[t>>6&63]+nJ[63&t]}return s?o.slice(0,s-3)+"===".substring(s):o},uJ="function"==typeof btoa?e=>btoa(e):iJ?e=>Buffer.from(e,"binary").toString("base64"):cJ,hJ=iJ?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let i=0,n=e.length;it?aJ(hJ(e)):hJ(e),pJ=e=>{if(e=e.replace(/\s+/g,""),!oJ.test(e))throw new TypeError("malformed base64.");let t,i,n;e+="==".slice(2-(3&e.length));let r=[];for(let o=0;o>16&255)):64===n?r.push(sJ(t>>16&255,t>>8&255)):r.push(sJ(t>>16&255,t>>8&255,255&t));return r.join("")},fJ=dJ;var mJ,gJ={exports:{}},_J="object"==typeof Reflect?Reflect:null,AJ=_J&&"function"==typeof _J.apply?_J.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};mJ=_J&&"function"==typeof _J.ownKeys?_J.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var yJ=Number.isNaN||function(e){return e!=e};function vJ(){vJ.init.call(this)}gJ.exports=vJ,gJ.exports.once=function(e,t){return new Promise(function(i,n){function r(i){e.removeListener(t,o),n(i)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}MJ(e,t,o,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&MJ(e,"error",t,i)}(e,r,{once:!0})})},vJ.EventEmitter=vJ,vJ.prototype._events=void 0,vJ.prototype._eventsCount=0,vJ.prototype._maxListeners=void 0;var xJ=10;function bJ(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function wJ(e){return void 0===e._maxListeners?vJ.defaultMaxListeners:e._maxListeners}function TJ(e,t,i,n){var r,o,s,a;if(bJ(i),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),s=o[t]),void 0===s)s=o[t]=i,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(r=wJ(e))>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return e}function EJ(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function CJ(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=EJ.bind(n);return r.listener=i,n.wrapFn=r,r}function SJ(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=r[e];if(void 0===a)return!1;if("function"==typeof a)AJ(a,this,t);else{var l=a.length,c=IJ(a,l);for(i=0;i=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},vJ.prototype.listeners=function(e){return SJ(this,e,!0)},vJ.prototype.rawListeners=function(e){return SJ(this,e,!1)},vJ.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):BJ.call(e,t)},vJ.prototype.listenerCount=BJ,vJ.prototype.eventNames=function(){return this._eventsCount>0?mJ(this._events):[]};var PJ=gJ.exports;class RJ extends Map{#e=0;#t=new Map;#i=new Map;#n;#r;#o;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.#n=e.maxSize,this.#r=e.maxAge||Number.POSITIVE_INFINITY,this.#o=e.onEviction}get __oldCache(){return this.#i}#s(e){if("function"==typeof this.#o)for(const[t,i]of e)this.#o(t,i.value)}#a(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.#o&&this.#o(e,t.value),this.delete(e))}#l(e,t){if(!1===this.#a(e,t))return t.value}#c(e,t){return t.expiry?this.#l(e,t):t.value}#u(e,t){const i=t.get(e);return this.#c(e,i)}#h(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#n&&(this.#e=0,this.#s(this.#i),this.#i=this.#t,this.#t=new Map)}#d(e,t){this.#i.delete(e),this.#h(e,t)}*#p(){for(const e of this.#i){const[t,i]=e;if(!this.#t.has(t)){!1===this.#a(t,i)&&(yield e)}}for(const e of this.#t){const[t,i]=e;!1===this.#a(t,i)&&(yield e)}}get(e){if(this.#t.has(e)){const t=this.#t.get(e);return this.#c(e,t)}if(this.#i.has(e)){const t=this.#i.get(e);if(!1===this.#a(e,t))return this.#d(e,t),t.value}}set(e,t,{maxAge:i=this.#r}={}){const n="number"==typeof i&&i!==Number.POSITIVE_INFINITY?Date.now()+i:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:n}):this.#h(e,{value:t,expiry:n}),this}has(e){return this.#t.has(e)?!this.#a(e,this.#t.get(e)):!!this.#i.has(e)&&!this.#a(e,this.#i.get(e))}peek(e){return this.#t.has(e)?this.#u(e,this.#t):this.#i.has(e)?this.#u(e,this.#i):void 0}expiresIn(e){const t=this.#t.get(e)??this.#i.get(e);if(t)return t.expiry?t.expiry-Date.now():Number.POSITIVE_INFINITY}delete(e){const t=this.#t.delete(e);return t&&this.#e--,this.#i.delete(e)||t}clear(){this.#t.clear(),this.#i.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this.#p()],i=t.length-e;i<0?(this.#t=new Map(t),this.#i=new Map,this.#e=t.length):(i>0&&this.#s(t.slice(0,i)),this.#i=new Map(t.slice(i)),this.#t=new Map,this.#e=0),this.#n=e}evict(e=1){const t=Number(e);if(!t||t<=0)return;const i=[...this.#p()],n=Math.trunc(Math.min(t,Math.max(i.length-1,0)));n<=0||(this.#s(i.slice(0,n)),this.#i=new Map(i.slice(n)),this.#t=new Map,this.#e=0)}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.#t){const[t,i]=e;!1===this.#a(t,i)&&(yield[t,i.value])}for(const e of this.#i){const[t,i]=e;if(!this.#t.has(t)){!1===this.#a(t,i)&&(yield[t,i.value])}}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){const i=e[t],[n,r]=i;!1===this.#a(n,r)&&(yield[n,r.value])}e=[...this.#i];for(let t=e.length-1;t>=0;--t){const i=e[t],[n,r]=i;if(!this.#t.has(n)){!1===this.#a(n,r)&&(yield[n,r.value])}}}*entriesAscending(){for(const[e,t]of this.#p())yield[e,t.value]}get size(){if(!this.#e)return this.#i.size;let e=0;for(const t of this.#i.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#r}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[i,n]of this.entriesAscending())e.call(t,n,i,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}const LJ=new class{constructor(){this._apiKey="",this._fetch="undefined"!=typeof self?fetch.bind(self):"undefined"!=typeof global&&global.fetch?global.fetch:null,this.tileCacheSize=200}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}},FJ={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1},ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!0},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!0},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!0},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!0},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!0},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!0},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!0},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!0},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!0},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!0},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!0},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!0},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!0},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!0},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}};function kJ(e,t=FJ){return e in t?e[e]:null}function DJ(e,t=FJ){for(const i of Object.values(t))if(i.code===e)return i;return null}function OJ(e,t=FJ){for(const i of Object.values(t))if(i.flag===e)return i;return null}function zJ(){if("undefined"==typeof navigator){return DJ(Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0])??FJ.ENGLISH}const e=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>DJ(e)).filter(e=>e);return e[0]??FJ.ENGLISH}function UJ(e){return null!==e&&"object"==typeof e&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&("string"==typeof e.code||null===e.code)&&"string"==typeof e.flag&&"string"==typeof e.name&&"boolean"==typeof e.latin&&"boolean"==typeof e.isMode&&"boolean"==typeof e.geocoding}function NJ(e,t=FJ){return UJ(e)?OJ(e.flag,t):"string"!=typeof e?null:kJ(e,t)||DJ(e,t)||OJ(e,t)||null}async function VJ(e,t={}){if(null===LJ.fetch)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(""===new URL(e).searchParams.get("key").trim())throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return LJ.fetch(e,t)}const jJ={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(jJ);class GJ extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}const HJ={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function QJ(e,t){const{language:i}=t;if(void 0===i)return;const n=(Array.isArray(i)?i:[i]).map(e=>function(e){const t=e===FJ.AUTO.flag?zJ():"string"==typeof e?DJ(e):UJ(e)?e.flag===FJ.AUTO.flag?zJ():OJ(e.flag):null;return t?.geocoding?t.code:null}(e)).filter(e=>e),r=Array.from(new Set(n)).join(",");e.set("language",r)}function $J(e,t){const{apiKey:i,limit:n,types:r,excludeTypes:o}=t;e.set("key",i??LJ.apiKey),void 0!==n&&e.set("limit",String(n)),void 0!==r&&e.set("types",r.join(",")),void 0!==o&&e.set("excludeTypes",String(o)),QJ(e,t)}function ZJ(e,t){$J(e,t);const{bbox:i,proximity:n,country:r,fuzzyMatch:o,autocomplete:s}=t;void 0!==i&&e.set("bbox",i.join(",")),void 0!==n&&e.set("proximity","ip"===n?n:n.join(",")),void 0!==r&&e.set("country",r.join(",")),void 0!==o&&e.set("fuzzyMatch",o?"true":"false"),void 0!==s&&e.set("autocomplete",s?"true":"false")}const WJ={forward:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,jJ.maptilerApiURL);ZJ(i.searchParams,t);const n=await VJ(i.toString());if(!n.ok)throw new GJ(n,HJ[n.status]??"");return await n.json()},reverse:async function(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,jJ.maptilerApiURL);$J(i.searchParams,t);const n=await VJ(i.toString());if(!n.ok)throw new GJ(n,HJ[n.status]??"");return await n.json()},byId:async function(e,t={}){const i=new URL(`geocoding/${e}.json`,jJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??LJ.apiKey),QJ(i.searchParams,t);const n=await VJ(i.toString());if(!n.ok)throw new GJ(n,HJ[n.status]??"");return await n.json()},batch:async function(e,t={}){if(!e.length)return[];const i=e.map(e=>encodeURIComponent(e)).join(";"),n=new URL(`geocoding/${i}.json`,jJ.maptilerApiURL);ZJ(n.searchParams,t);const r=await VJ(n.toString());if(!r.ok)throw new GJ(r,HJ[r.status]??"");const o=await r.json();return 1===e.length?[o]:o}},qJ={403:"Key is missing, invalid or restricted"};const KJ={info:async function(e={}){const t=new URL("geolocation/ip.json",jJ.maptilerApiURL);t.searchParams.set("key",e.apiKey??LJ.apiKey),"elevation"in e&&t.searchParams.set("elevation",e.elevation?"true":"false");const i=t.toString(),n=await VJ(i);if(!n.ok)throw new GJ(n,n.status in qJ?qJ[n.status]:"");return await n.json()}},XJ={403:"Key is missing, invalid or restricted"};const JJ={search:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,jJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??LJ.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const n=i.toString(),r=await VJ(n);if(!r.ok)throw new GJ(r,r.status in XJ?XJ[r.status]:"");return await r.json()},transform:async function(e,t={}){const i=(Array.isArray(e[0])?e:[e]).map(e=>`${e[0]},${e[1]}`).join(";"),n=new URL(`coordinates/transform/${i}.json`,jJ.maptilerApiURL);n.searchParams.set("key",t.apiKey??LJ.apiKey),"sourceCrs"in t&&n.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&n.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&n.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const r=n.toString(),o=await VJ(r);if(!o.ok)throw new GJ(o,o.status in XJ?XJ[o.status]:"");return await o.json()}},YJ={403:"Key is missing, invalid or restricted"};const eY={get:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,jJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??LJ.apiKey);const n=i.toString(),r=await VJ(n);if(!r.ok)throw new GJ(r,r.status in YJ?YJ[r.status]:"");return await r.json()}};function tY(e){let t;const i=e.trim();let n;return n=i.startsWith("http://")||i.startsWith("https://")?i:null!==(t=/^maptiler:\/\/(.*)/.exec(i))?`https://api.maptiler.com/maps/${t[1]}/style.json`:`https://api.maptiler.com/maps/${i}/style.json`,n}class iY{constructor(e,t,i,n,r,o,s=!1,a){this.name=e,this.variantType=t,this.id=i,this.referenceStyle=n,this.description=r,this.imageURL=o,this.deprecated=s,this.deprecationMessage=a}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(e){return this.referenceStyle.hasVariant(e)}getVariant(e){const t=this.referenceStyle.getVariant(e);return this.warnIfDeprecated(t),t}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this).map(e=>(this.warnIfDeprecated(e),e))}getImageURL(){return this.imageURL}getExpandedStyleURL(){return tY(this.getId())}warnIfDeprecated(e=this){if(!e.deprecated)return e;if(e.deprecationMessage)console.warn(e.deprecationMessage);else{const t=e.getFullName();console.warn(`Style "${t}" is deprecated and will be removed in a future version.`)}return e}}class nY{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0].warnIfDeprecated()}}const rY=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default v2",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark v2",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light v2",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night v2",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel v2",variantType:"PASTEL",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-pastel" is deprecated, use "streets-v4-pastel" instead'}]},{referenceStyleID:"STREETS_V4",name:"Streets",description:"",variants:[{id:"streets-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v4-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"BASE_V4",name:"Base",description:"",variants:[{id:"base-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"base-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"base-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"base-v4-ai",name:"Base AI",variantType:"NIGHT",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC_V2",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"basic-v2" is deprecated, use "basic-v4" instead'},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",deprecated:!0,variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",deprecated:!0,variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",deprecated:!0,variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",deprecated:!0,variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",deprecated:!0,variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",deprecated:!0,description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",deprecated:!0,description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"AQUARELLE",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"aquarelle-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"aquarelle-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"LANDSCAPE_V2",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape" is deprecated, use "landscape-v4" instead'},{id:"landscape-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-dark" is deprecated, use "landscape-v4-dark" instead'},{id:"landscape-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead'}]},{referenceStyleID:"LANDSCAPE_V4",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"landscape-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"landscape-v4-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]}];function oY(e){return new Proxy(e,{get(t,i,n){if(t.hasVariant(i))return t.getVariant(i);if(i.toString().toUpperCase()===i)return e.getDefaultVariant();return Reflect.get(t,i,n)}})}function sY(e){return e?"string"==typeof e||e instanceof String?e.trim().toLowerCase():e instanceof iY?e.getId():e instanceof nY?e.getDefaultVariant().getId():void 0:aY[rY[0].referenceStyleID].getDefaultVariant().getId()}Object.entries({STREETS:"STREETS_V2",BASIC:"BASIC_V2",LANDSCAPE:"LANDSCAPE_V2"}).forEach(([e,t])=>{!function(e,t){rY.find(t=>t.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const i=rY.find(e=>e.referenceStyleID===t);if(!i)throw new Error(`Versioned map style not found for reference style: ${t}`);const n={...i,referenceStyleID:e};rY.push(n)}(e,t)});const aY=function(){const e={};for(let t=0;t1?(n=i[0],r=i[1]):t>0&&(n+=o*t,r+=s*t)}return o=e[0]-n,s=e[1]-r,o*o+s*s}function cY(e,t,i,n,r){let o,s=n;for(let n=t+1;ns&&(o=n,s=r)}s>n&&(o-t>1&&cY(e,t,o,n,r),r.push(e[o]),i-o>1&&cY(e,o,i,n,r))}function uY(e,t){const i=e.length-1,n=[e[0]];return cY(e,0,i,t,n),n.push(e[i]),n}const hY={extractLineStrings:function(e){const t=[];function i(e){"LineString"!==e.type&&"MultiLineString"!==e.type||t.push(e)}function n(e){e.geometry&&i(e.geometry)}return"Feature"===e.type?n(e):"FeatureCollection"===e.type?function e(t){for(const i of t.features)"Feature"===i.type?n(i):"FeatureCollection"===i.type&&e(i)}(e):i(e),t},simplify:function(e,t){return e.length<=2?e:uY(e,void 0!==t?t*t:1)}};function dY(e,t=!0){let i=`${e[0]},${e[1]}`;return 3===e.length&&t&&(i+=`,${e[2]}`),i}function pY(e,t=3e3){let i=e.map(e=>e.join(",")).join("|"),n=5e-6;for(;i.length>t;){i=hY.simplify(e,n).map(e=>`${e[0]},${e[1]}`).join("|"),n+=1e-5}return i}const fY={centered:function(e,t,i={}){const n=sY(i.style),r=i.hiDPI?"@2x":"",o=i.format??"png";let s=~~(i.width??1024),a=~~(i.height??1024);i.hiDPI&&(s=~~(s/2),a=~~(a/2));const l=new URL(`maps/${encodeURIComponent(n)}/static/${e[0]},${e[1]},${t}/${s}x${a}${r}.${o}`,jJ.maptilerApiURL);if("attribution"in i&&l.searchParams.set("attribution",i.attribution.toString()),"markers"in i){let e="";const t="markerIcon"in i;t&&(e+=`icon:${i.markerIcon}|`),t&&"markerAnchor"in i&&(e+=`anchor:${i.markerAnchor}|`),t&&i.hiDPI&&(e+="scale:2|");e+=(Array.isArray(i.markers[0])?i.markers:[i.markers]).map(e=>dY(e,!t)).join("|"),l.searchParams.set("markers",e)}if("path"in i){let e="";if(e+=`fill:${i.pathFillColor??"none"}|`,"pathStrokeColor"in i&&(e+=`stroke:${i.pathStrokeColor}|`),"pathWidth"in i){e+=`width:${(i.pathWidth/(i.hiDPI?2:1)).toString()}|`}e+=pY(i.path),l.searchParams.set("path",e)}return l.searchParams.set("key",i.apiKey??LJ.apiKey),l.toString()},bounded:function(e,t={}){const i=sY(t.style),n=t.hiDPI?"@2x":"",r=t.format??"png";let o=~~(t.width??1024),s=~~(t.height??1024);t.hiDPI&&(o=~~(o/2),s=~~(s/2));const a=new URL(`maps/${encodeURIComponent(i)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${o}x${s}${n}.${r}`,jJ.maptilerApiURL);if("attribution"in t&&a.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&a.searchParams.set("padding",t.padding.toString()),"markers"in t){let e="";const i="markerIcon"in t;i&&(e+=`icon:${t.markerIcon}|`),i&&"markerAnchor"in t&&(e+=`anchor:${t.markerAnchor}|`),i&&t.hiDPI&&(e+="scale:2|");e+=(Array.isArray(t.markers[0])?t.markers:[t.markers]).map(e=>dY(e,!i)).join("|"),a.searchParams.set("markers",e)}if("path"in t){let e="";if(e+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(e+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){e+=`width:${(t.pathWidth/(t.hiDPI?2:1)).toString()}|`}e+=pY(t.path),a.searchParams.set("path",e)}return a.searchParams.set("key",t.apiKey??LJ.apiKey),a.toString()},automatic:function(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const t=sY(e.style),i=e.hiDPI?"@2x":"",n=e.format??"png";let r=~~(e.width??1024),o=~~(e.height??1024);e.hiDPI&&(r=~~(r/2),o=~~(o/2));const s=new URL(`maps/${encodeURIComponent(t)}/static/auto/${r}x${o}${i}.${n}`,jJ.maptilerApiURL);if("attribution"in e&&s.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&s.searchParams.set("padding",e.padding.toString()),"markers"in e){let t="";const i="markerIcon"in e;i&&(t+=`icon:${e.markerIcon}|`),i&&"markerAnchor"in e&&(t+=`anchor:${e.markerAnchor}|`),i&&e.hiDPI&&(t+="scale:2|");t+=(Array.isArray(e.markers[0])?e.markers:[e.markers]).map(e=>dY(e,!i)).join("|"),s.searchParams.set("markers",t)}if("path"in e){let t="";if(t+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(t+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){t+=`width:${(e.pathWidth/(e.hiDPI?2:1)).toString()}|`}t+=pY(e.path),s.searchParams.set("path",t)}return s.searchParams.set("key",e.apiKey??LJ.apiKey),s.toString()}},mY=6371008.8,gY=2*Math.PI*mY;function _Y(e){return(180+e)/360}function AY(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function yY(e){const t=wY(e);return[_Y(t[0]),AY(t[1])]}function vY(e){return 360*e-180}function xY(e){const t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function bY(e,t){const i=Math.PI/180,n=e[1]*i,r=t[1]*i,o=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t[0]-e[0])*i);return mY*Math.acos(Math.min(o,1))}function wY(e){const t=((e[0]+180)%360+360)%360-180;return[-180===t?180:t,e[1]]}function TY(e){return gY*Math.cos(e*Math.PI/180)}function EY(e,t,i=!0){const n=2**t,r=[e[0]*n,e[1]*n];return i?[~~r[0],~~r[1]]:r}function CY(e){return e*Math.PI/180}function SY(e){return 180*e/Math.PI}const BY={EARTH_RADIUS:mY,EARTH_CIRCUMFERENCE:gY,longitudeToMercatorX:_Y,latitudeToMercatorY:AY,wgs84ToMercator:yY,mercatorXToLongitude:vY,mercatorYToLatitude:xY,mercatorToWgs84:function(e){return[vY(e[0]),xY(e[1])]},haversineDistanceWgs84:bY,wrapWgs84:wY,circumferenceAtLatitude:TY,mercatorToTileIndex:EY,wgs84ToTileIndex:function(e,t,i=!0){return EY(yY(e),t,i)},toRadians:CY,toDegrees:SY,haversineIntermediateWgs84:function(e,t,i){const n=bY(e,t),r=CY(e[0]),o=CY(e[1]),s=CY(t[0]),a=CY(t[1]),l=n/mY,c=Math.sin((1-i)*l)/Math.sin(l),u=Math.sin(i*l)/Math.sin(l),h=c*Math.cos(o)*Math.cos(r)+u*Math.cos(a)*Math.cos(s),d=c*Math.cos(o)*Math.sin(r)+u*Math.cos(a)*Math.sin(s),p=c*Math.sin(o)+u*Math.sin(a),f=Math.atan2(p,Math.sqrt(h*h+d*d));return[SY(Math.atan2(d,h)),SY(f)]},haversineCumulatedDistanceWgs84:function(e){const t=Array(e.length);t[0]=0;const i=t.length;for(let n=1;ns||a<0)&&(a=s);const l=e.map(e=>BY.wgs84ToTileIndex(e,a,!1)),c=l.map(e=>[~~e[0],~~e[1]]),u=c.map(e=>`terrain_${a.toString()}_${e[0].toString()}_${e[1].toString()}`),h=Array.from(new Set(u.filter(e=>!o.has(e)))).map(e=>e.split("_").slice(1)),d=h.map(e=>r.replace("{x}",e[1].toString()).replace("{y}",e[2].toString()).replace("{z}",e[0].toString())).map(e=>VJ(e)),p=(await Promise.allSettled(d)).map(e=>"fulfilled"===e.status?e.value:null).filter(e=>e),f=p.filter(e=>!e.ok);if(p.length!==d.length)throw new Error("Some tiles could not be fetched.");if(f.length)throw new GJ(f[0],kY[f[0].status]??"");const m=await Promise.all(p.map(e=>e.arrayBuffer()));if(!m.every(e=>e.byteLength>0))throw new Error("Some tiles are not available.");(await Promise.all(m.map(e=>n(e)))).forEach((e,t)=>{const i=h[t],n=`terrain_${i[0].toString()}_${i[1].toString()}_${i[2].toString()}`;o.set(n,e)});const g=e.map((e,t)=>{const i=u[t],n=l[t],r=o.get(i),s=Math.min(Math.round(r.width*(n[0]%1)),r.width-1),a=(Math.min(Math.round(r.height*(n[1]%1)),r.height-1)*r.width+s)*r.components,c=.1*(256*r.pixels[a]*256+256*r.pixels[a+1]+r.pixels[a+2])-1e4;return[e[0],e[1],~~(1e3*c)/1e3]});return g}(e,i,t.zoom):await async function(e,t){e.length>1e3&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const i=Math.ceil(e.length/50),n=Array.from({length:i},()=>null).map((i,n)=>{const r=50*n,o=e.slice(r,r+50).map(e=>e.join(",")).join(";"),s=new URL(`elevation/${o}.json`,jJ.maptilerApiURL);return s.searchParams.set("key",t),VJ(s.toString())}),r=await Promise.allSettled(n);return(await Promise.all(r.map(async e=>{if("rejected"===e.status)throw new Error(`Some segments could not be fetched, error: ${e.reason}`);if(!e.value.ok)throw new Error(`Some segments could not be fetched, response: ${e.value.status} ${await e.value.text()}, url: ${e.value.url}`);return e.value.json()}))).flat()}(e,i);if(t.smoothingKernelSize){const e=2*~~(t.smoothingKernelSize/2)+1,i=n.map(e=>e[2]),r=~~(e/2);for(let t=r;te.length),r=i.coordinates.flat(),o=await DY(r,t),s=[];let a=0;for(const e of n)s.push(o.slice(a,a+e)),a+=e;return i.coordinates=s,i}},zY=[];for(let e=0;e<256;++e)zY.push((e+256).toString(16).slice(1));let UY;const NY=new Uint8Array(16);var VY={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var jY=Object.defineProperty,GY=e=>{throw TypeError(e)},HY=(e,t,i)=>((e,t,i)=>t in e?jY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),QY=(e,t,i)=>t.has(e)||GY("Cannot "+i),$Y=(e,t,i)=>(QY(e,t,"read from private field"),i?i.call(e):t.get(e)),ZY=(e,t,i)=>t.has(e)?GY("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),WY=(e,t,i,n)=>(QY(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),qY=(e,t,i)=>(QY(e,t,"access private method"),i);let KY=class extends tJ.Marker{addTo(e){return super.addTo(e)}};class XY extends tJ.Popup{addTo(e){return super.addTo(e)}}class JY extends tJ.Style{constructor(e,t={}){super(e,t)}}class YY extends tJ.CanvasSource{onAdd(e){super.onAdd(e)}}class e0 extends tJ.GeoJSONSource{onAdd(e){super.onAdd(e)}}class t0 extends tJ.ImageSource{onAdd(e){super.onAdd(e)}}class i0 extends tJ.RasterTileSource{onAdd(e){super.onAdd(e)}}class n0 extends tJ.RasterDEMTileSource{onAdd(e){super.onAdd(e)}}class r0 extends tJ.VectorTileSource{onAdd(e){super.onAdd(e)}}class o0 extends tJ.VideoSource{onAdd(e){super.onAdd(e)}}class s0 extends tJ.NavigationControl{onAdd(e){return super.onAdd(e)}}class a0 extends tJ.GeolocateControl{onAdd(e){return super.onAdd(e)}}class l0 extends tJ.AttributionControl{onAdd(e){return super.onAdd(e)}}class c0 extends tJ.LogoControl{onAdd(e){return super.onAdd(e)}}class u0 extends tJ.ScaleControl{onAdd(e){return super.onAdd(e)}}class h0 extends tJ.FullscreenControl{onAdd(e){return super.onAdd(e)}}class d0 extends tJ.TerrainControl{onAdd(e){return super.onAdd(e)}}class p0 extends tJ.BoxZoomHandler{constructor(e,t){super(e,t)}}class f0 extends tJ.ScrollZoomHandler{constructor(e,t){super(e,t)}}class m0 extends tJ.CooperativeGesturesHandler{constructor(e,t){super(e,t)}}class g0 extends tJ.KeyboardHandler{constructor(e){super(e)}}class _0 extends tJ.TwoFingersTouchPitchHandler{constructor(e){super(e)}}class A0 extends tJ.MapWheelEvent{constructor(e,t,i){super(e,t,i)}}class y0 extends tJ.MapTouchEvent{constructor(e,t,i){super(e,t,i)}}class v0 extends tJ.MapMouseEvent{constructor(e,t,i,n={}){super(e,t,i,n)}}const x0={VISITOR:{code:null,flag:"visitor",name:"Visitor",latin:!0,isMode:!0,geocoding:!1},VISITOR_ENGLISH:{code:null,flag:"visitor_en",name:"Visitor English",latin:!0,isMode:!0,geocoding:!1},STYLE:{code:null,flag:"style",name:"Style",latin:!1,isMode:!0,geocoding:!1},STYLE_LOCK:{code:null,flag:"style_lock",name:"Style Lock",latin:!1,isMode:!0,geocoding:!1},...FJ};function b0(){if(typeof navigator>"u"){return DJ(Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0])||x0.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>DJ(e)).filter(e=>e)[0]??x0.LOCAL}const w0={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",telemetryURL:"https://api.maptiler.com/metrics",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:x0.STYLE,secondaryLanguage:x0.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(w0);const T0=function(e,t,i){if(VY.randomUUID&&!t&&!e)return VY.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!UY){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");UY=crypto.getRandomValues.bind(crypto)}return UY(NY)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((i=i||0)<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(zY[e[t+0]]+zY[e[t+1]]+zY[e[t+2]]+zY[e[t+3]]+"-"+zY[e[t+4]]+zY[e[t+5]]+"-"+zY[e[t+6]]+zY[e[t+7]]+"-"+zY[e[t+8]]+zY[e[t+9]]+"-"+zY[e[t+10]]+zY[e[t+11]]+zY[e[t+12]]+zY[e[t+13]]+zY[e[t+14]]+zY[e[t+15]]).toLowerCase()}(n)}();class E0 extends PJ{constructor(){super(...arguments),HY(this,"primaryLanguage",w0.primaryLanguage),HY(this,"secondaryLanguage"),HY(this,"session",!0),HY(this,"caching",!0),HY(this,"telemetry",!0),HY(this,"_unit","metric"),HY(this,"_apiKey","")}set unit(e){this._unit=e,this.emit("unit",e)}get unit(){return this._unit}set apiKey(e){this._apiKey=e,LJ.apiKey=e,this.emit("apiKey",e)}get apiKey(){return this._apiKey}set fetch(e){LJ.fetch=e}get fetch(){return LJ.fetch}}const C0=new E0;class S0 extends c0{constructor(e={}){super(e),HY(this,"logoURL",""),HY(this,"linkURL",""),this.logoURL=e.logoURL??w0.maptilerLogoURL,this.linkURL=e.linkURL??w0.maptilerURL}onAdd(e){this._map=e,this._compact=this.options.compact??!1,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const t=window.document.createElement("a");return t.style.backgroundRepeat="no-repeat",t.style.cursor="pointer",t.style.display="block",t.style.height="23px",t.style.margin="0 0 -4px -4px",t.style.overflow="hidden",t.style.width="88px",t.style.backgroundImage=`url(${this.logoURL})`,t.style.backgroundSize="100px 30px",t.style.width="100px",t.style.height="30px",t.target="_blank",t.rel="noopener",t.href=this.linkURL,t.setAttribute("aria-label","MapTiler logo"),t.setAttribute("rel","noopener"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}const B0="localcache_source",I0="localcache",M0=typeof caches<"u",{addProtocol:P0}=tJ;function R0(e,t){if(M0&&C0.caching&&C0.session&&e.host===w0.maptilerApiHost){if("Source"===t&&e.href.includes("tiles.json"))return e.href.replace("https://",`${B0}://`);if("Tile"===t||"Glyphs"===t)return e.href.replace("https://",`${I0}://`)}return e.href}let L0;async function F0(){return L0||(L0=await caches.open("maptiler_sdk")),L0}let k0=0;function D0(){P0(B0,async(e,t)=>{if(!e.url)throw new Error("");e.url=e.url.replace(`${B0}://`,"https://");const i=e;i.signal=t.signal;const n=await fetch(e.url,i),r=await n.json();return r.tiles&&r.tiles.length>0&&(r.tiles[0]+=`&last-modified=${n.headers.get("Last-Modified")}`),{data:r,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}),P0(I0,async(e,t)=>{if(!e.url)throw new Error("");e.url=e.url.replace(`${I0}://`,"https://");const i=new URL(e.url),n=new URL(i);n.searchParams.delete("mtsid"),n.searchParams.delete("key");const r=n.toString(),o=new URL(i);o.searchParams.delete("last-modified");const s=o.toString(),a=async e=>({data:await e.arrayBuffer(),cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires")}),l=await F0(),c=await l.match(r);if(c)return a(c);const u=e;u.signal=t.signal;const h=await fetch(s,u);return h.status>=200&&h.status<300&&(l.put(r,h.clone()).catch(()=>{}),++k0>100&&(async function(){const e=await F0(),t=await e.keys(),i=t.slice(0,Math.max(t.length-1e3,0));for(const t of i)e.delete(t)}(),k0=0)),a(h)})}function O0(e,t){let i=null;try{i=new URL(e)}catch{return{url:e}}return i.host===w0.maptilerApiHost&&(i.searchParams.has("key")||i.searchParams.append("key",C0.apiKey),C0.session&&i.searchParams.append("mtsid",T0)),{url:R0(i,t)}}function z0(e){return(t,i)=>{if(null!=e){const n=e(t,i),r=O0((null==n?void 0:n.url)??"",i);return{...n,...r}}return O0(t,i)}}function U0(){return Math.random().toString(36).substring(2)}function N0(e){return/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(e)}function V0(){return document.createElement("canvas").getContext("webgl2")?null:typeof WebGL2RenderingContext<"u"?"Graphic rendering with WebGL2 has been disabled or is not supported by your graphic card. The map cannot be displayed.":"Your browser does not support graphic rendering with WebGL2. The map cannot be displayed."}function j0(e,t){return!(!Array.isArray(e)||2!==e.length||"get"!==e[0]||"string"!=typeof e[1]||t&&!e[1].startsWith("name:")||!t&&"name"!==e[1])}function G0(e,t,i){const n=structuredClone(e),r=e=>{if("string"!=typeof e)for(let n=0;ni===r.length-1?[e]:[e,t])]}function $0(e){var t;const i=/\{name(?::(?\S+))?\}/g,n=[];for(;;){const r=i.exec(e);if(!r)break;const o=(null==(t=r.groups)?void 0:t.language)??null;n.push(o)}return n}function Z0(e){return Array.isArray(e)&&2===e.length&&"get"===e[0]&&"string"==typeof e[1]?"name"===e[1].trim()?{isLanguage:!0,localization:null}:e[1].trim().startsWith("name:")?{isLanguage:!0,localization:e[1].trim().split(":").pop()}:null:null}function W0(e){const t=[],i=structuredClone(e),n=e=>{if("string"!=typeof e)for(let i=0;i":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};class K0{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function X0(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class J0 extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Y0{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Y0(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)}}const e1={kind:"null"},t1={kind:"number"},i1={kind:"string"},n1={kind:"boolean"},r1={kind:"color"},o1={kind:"projectionDefinition"},s1={kind:"object"},a1={kind:"value"},l1={kind:"collator"},c1={kind:"formatted"},u1={kind:"padding"},h1={kind:"colorArray"},d1={kind:"numberArray"},p1={kind:"resolvedImage"},f1={kind:"variableAnchorOffsetCollection"};function m1(e,t){return{kind:"array",itemType:e,N:t}}function g1(e){if("array"===e.kind){const t=g1(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const _1=[e1,t1,i1,n1,r1,o1,c1,s1,m1(a1),u1,d1,h1,p1,f1];function A1(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!A1(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 _1)if(!A1(e,t))return null}return`Expected ${g1(e)} but found ${g1(t)} instead.`}function y1(e,t){return t.some(t=>t.kind===e.kind)}function v1(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)}function x1(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const b1=.96422,w1=.82521,T1=4/29,E1=6/29,C1=3*E1*E1,S1=E1*E1*E1,B1=Math.PI/180,I1=180/Math.PI;function M1(e){return(e%=360)<0&&(e+=360),e}function P1([e,t,i,n]){let r,o;const s=L1((.2225045*(e=R1(e))+.7168786*(t=R1(t))+.0606169*(i=R1(i)))/1);e===t&&t===i?r=o=s:(r=L1((.4360747*e+.3850649*t+.1430804*i)/b1),o=L1((.0139322*e+.0971045*t+.7141733*i)/w1));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function R1(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function L1(e){return e>S1?Math.pow(e,1/3):e/C1+T1}function F1([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*D1(r),o=b1*D1(o),s=w1*D1(s),[k1(3.1338561*o-1.6168667*r-.4906146*s),k1(-.9787684*o+1.9161415*r+.033454*s),k1(.0719453*o-.2289914*r+1.4052427*s),n]}function k1(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function D1(e){return e>E1?e*e*e:C1*(e-T1)}const O1=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function z1(e,t){return O1(e,t)?e[t]:void 0}function U1(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=z1(H1,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[N1(e.slice(i,i+=t)),N1(e.slice(i,i+=t)),N1(e.slice(i,i+=t)),N1(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/,i=e.match(t);if(i){const[e,t,n,r,o,s,a,l,c,u,h,d]=i,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),i="%%%"===e?100:""===e?255:0;if(i){const e=[j1(+t/i,0,1),j1(+o/i,0,1),j1(+l/i,0,1),h?V1(+h,d):1];if(G1(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,j1(+r,0,100),j1(+s,0,100),l?V1(+l,c):1];if(G1(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=M1(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}function N1(e){return parseInt(e.padEnd(2,e),16)/255}function V1(e,t){return j1(t?e/100:e,0,1)}function j1(e,t,i){return Math.min(Math.max(t,e),i)}function G1(e){return!e.some(Number.isNaN)}const H1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Q1(e,t,i){return e+i*(t-e)}function $1(e,t,i){return e.map((e,n)=>Q1(e,t[n],i))}class Z1{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Z1)return e;if("string"!=typeof e)return;const t=U1(e);return t?new Z1(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=P1(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?M1(Math.atan2(n,i)*I1):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",P1(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=$1(e.rgb,t.rgb,i);return new Z1(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,(1===o||0===o)&&(d=l)):(h=n,(1===c||0===c)&&(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*B1,F1([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,d??Q1(r,l,i),Q1(o,c,i),Q1(s,u,i)]);return new Z1(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=F1($1(e.lab,t.lab,i));return new Z1(n,r,o,s,!1)}}}}Z1.black=new Z1(0,0,0,1),Z1.white=new Z1(1,1,1,1),Z1.transparent=new Z1(0,0,0,0),Z1.red=new Z1(1,0,0,1);class W1{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}}const q1=["bottom","center","top"];class K1{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class X1{constructor(e){this.sections=e}static fromString(e){return new X1([new K1(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof X1?e:X1.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class J1{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof J1)return e;if("number"==typeof e)return new J1([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new J1(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new J1($1(e.values,t.values,i))}}class Y1{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Y1)return e;if("number"==typeof e)return new Y1([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Y1(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Y1($1(e.values,t.values,i))}}class e2{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof e2)return e;if("string"==typeof e){const t=Z1.parse(e);return t?new e2([t]):void 0}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Z1.parse(i);if(!e)return;t.push(e)}return new e2(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?typeof n>"u"||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function a2(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof o2||e instanceof Z1||e instanceof W1||e instanceof X1||e instanceof J1||e instanceof Y1||e instanceof e2||e instanceof n2||e instanceof r2)return!0;if(Array.isArray(e)){for(const t of e)if(!a2(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!a2(e[t]))return!1;return!0}return!1}function l2(e){if(null===e)return e1;if("string"==typeof e)return i1;if("boolean"==typeof e)return n1;if("number"==typeof e)return t1;if(e instanceof Z1)return r1;if(e instanceof o2)return o1;if(e instanceof W1)return l1;if(e instanceof X1)return c1;if(e instanceof J1)return u1;if(e instanceof Y1)return d1;if(e instanceof e2)return h1;if(e instanceof n2)return f1;if(e instanceof r2)return p1;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=l2(t);if(i){if(i===e)continue;i=a1;break}i=e}return m1(i||a1,t)}return s1}function c2(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Z1||e instanceof o2||e instanceof X1||e instanceof J1||e instanceof Y1||e instanceof e2||e instanceof n2||e instanceof r2?e.toString():JSON.stringify(e)}class u2{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(!a2(e[1]))return t.error("invalid value");const i=e[1];let n=l2(i);const r=t.expectedType;return"array"===n.kind&&0===n.N&&r&&"array"===r.kind&&("number"!=typeof r.N||0===r.N)&&(n=r),new u2(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const h2={string:i1,number:t1,boolean:n1,object:s1};class d2{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in h2)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=h2[i],n++}else r=a1;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],n++}i=m1(r,o)}else{if(!h2[r])throw new Error(`Types doesn't contain name = ${r}`);i=h2[r]}const o=[];for(;ne.outputDefined())}}const p2={"to-boolean":n1,"to-color":r1,"to-number":t1,"to-string":i1};class f2{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];if(!p2[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=p2[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:s2(t[0],t[1],t[2],t[3]),!i))return new Z1(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new t2(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=J1.parse(t);if(n)return n}throw new t2(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Y1.parse(t);if(n)return n}throw new t2(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=e2.parse(t);if(n)return n}throw new t2(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=n2.parse(t);if(n)return n}throw new t2(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new t2(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return X1.fromString(c2(this.args[0].evaluate(e)));case"resolvedImage":return r2.fromString(c2(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return c2(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const m2=["Unknown","Point","LineString","Polygon"];class g2{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?m2[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Z1.parse(e),this._parseColorCache.set(e,t)),t}}class _2{constructor(e,t,i=[],n,r=new Y0,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new d2(t,[e]):"coerce"===i?new f2(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof u2)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new g2;try{n=new u2(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return typeof e>"u"?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new _2(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new J0(i,e))}checkSubtype(e,t){const i=A1(e,t);return i&&this.error(i),i}}class A2{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 n=1;n=i.length)throw new t2(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new t2(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class x2{constructor(e,t){this.type=n1,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,a1),n=t.parse(e[2],2,a1);return i&&n?y1(i.type,[n1,i1,t1,e1,a1])?new x2(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${g1(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!v1(t,["boolean","string","number","null"]))throw new t2(`Expected first argument to be of type boolean, string, number or null, but found ${g1(l2(t))} instead.`);if(!v1(i,["string","array"]))throw new t2(`Expected second argument to be of type array or string, but found ${g1(l2(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class b2{constructor(e,t,i){this.type=t1,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,a1),n=t.parse(e[2],2,a1);if(!i||!n)return null;if(!y1(i.type,[n1,i1,t1,e1,a1]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${g1(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,t1);return r?new b2(i,n,r):null}return new b2(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!v1(t,["boolean","string","number","null"]))throw new t2(`Expected first argument to be of type boolean, string, number or null, but found ${g1(l2(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),v1(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(v1(i,["array"]))return i.indexOf(t,n);throw new t2(`Expected second argument to be of type array or string, but found ${g1(l2(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class w2{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,l2(e)))return null}else i=l2(e);if(typeof r[String(e)]<"u")return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,a1);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return!a||"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new w2(i,n,s,r,o,a)}evaluate(e){const t=this.input.evaluate(e);return(l2(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()}}class T2{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class E2{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}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,a1),n=t.parse(e[2],2,t1);if(!i||!n)return null;if(!y1(i.type,[m1(a1),i1,a1]))return t.error(`Expected first argument to be of type array or string, but found ${g1(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,t1);return r?new E2(i.type,i,n,r):null}return new E2(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),v1(t,["string"]))return[...t].slice(i,n).join("");if(v1(t,["array"]))return t.slice(i,n);throw new t2(`Expected first argument to be of type array or string, but found ${g1(l2(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function C2(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new t2("Input is not a number.");s=a-1}return 0}class S2{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,t1);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new S2(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);return i[C2(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function B2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I2,M2;var P2=function(){if(M2)return I2;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return M2=1,I2=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},I2}(),R2=B2(P2);class L2{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=F2(t,e.base,i,n);else if("linear"===e.name)r=F2(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new R2(o[0],o[1],o[2],o[3]).solve(F2(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,t1),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==h1?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=r1;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return x1(a,t1)||x1(a,o1)||x1(a,r1)||x1(a,u1)||x1(a,d1)||x1(a,h1)||x1(a,f1)||x1(a,m1(t1))?new L2(a,i,n,r,s):t.error(`Type ${g1(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=C2(t,n),s=t[o],a=t[o+1],l=L2.interpolationFactor(this.interpolation,n,s,a),c=i[o].evaluate(e),u=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Q1(c,u,l);case"color":return Z1.interpolate(c,u,l);case"padding":return J1.interpolate(c,u,l);case"colorArray":return e2.interpolate(c,u,l);case"numberArray":return Y1.interpolate(c,u,l);case"variableAnchorOffsetCollection":return n2.interpolate(c,u,l);case"array":return $1(c,u,l);case"projectionDefinition":return o2.interpolate(c,u,l)}case"interpolate-hcl":switch(this.type.kind){case"color":return Z1.interpolate(c,u,l,"hcl");case"colorArray":return e2.interpolate(c,u,l,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Z1.interpolate(c,u,l,"lab");case"colorArray":return e2.interpolate(c,u,l,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function F2(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}Z1.interpolate,J1.interpolate,Y1.interpolate,e2.interpolate,n2.interpolate;class k2{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");return n&&r.some(e=>A1(n,e.type))?new k2(a1,r):new k2(i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof r2&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function D2(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 O2(e,t,i,n){return 0===n.compare(t,i)}function z2(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=n1,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,a1);if(!o)return null;if(!D2(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${g1(o.type)}'.`);let s=t.parse(e[2],2,a1);if(!s)return null;if(!D2(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${g1(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${g1(o.type)}' and '${g1(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new d2(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new d2(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,l1),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=l2(o),i=l2(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new t2(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=l2(o),i=l2(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const U2=z2("==",function(e,t,i){return t===i},O2),N2=z2("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!O2(0,t,i,n)}),V2=z2("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),G2=z2("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),H2=z2(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Q2{constructor(e,t,i){this.type=l1,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,n1);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,n1);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,i1),!o)?null:new Q2(n,r,o)}evaluate(e){return new W1(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}}class $2{constructor(e,t,i,n,r){this.type=i1,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,t1);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,i1),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,i1),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,t1),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,t1),!a)?null:new $2(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Z2{constructor(e){this.type=c1,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,t1),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,m1(i1)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,r1),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!q1.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,i1),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,a1);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Z2(n)}evaluate(e){return new X1(this.sections.map(t=>{const i=t.content.evaluate(e);return l2(i)===p1?new K1("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new K1(c2(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class W2{constructor(e){this.type=p1,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,i1);return i?new W2(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=r2.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class q2{constructor(e){this.type=t1,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 ${g1(i.type)} instead.`):new q2(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 t2(`Expected value to be of type string or array, but found ${g1(l2(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const K2=8192;function X2(e,t){const i=function(e){return(180+e)/360}(e[0]),n=function(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}(e[1]),r=Math.pow(2,t.z);return[Math.round(i*r*K2),Math.round(n*r*K2)]}function J2(e,t){const i=Math.pow(2,t.z),n=(e[0]/K2+t.x)/i,r=(e[1]/K2+t.y)/i;return[Y2(n),e3(r)]}function Y2(e){return 360*e-180}function e3(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function t3(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 i3(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function n3(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function r3(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r===0&&n*o<=0&&r*s<=0}function o3(e,t,i,n){const r=[t[0]-e[0],t[1]-e[1]];return 0!==function(e,t){return e[0]*t[1]-e[1]*t[0]}([n[0]-i[0],n[1]-i[1]],r)&&!(!h3(e,t,i,n)||!h3(i,n,e,t))}function s3(e,t,i){for(const n of i)for(let i=0;i0&&h<0||u<0&&h>0}function d3(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}t3(t,e)}function m3(e,t,i,n){const r=Math.pow(2,n.z)*K2,o=[n.x*K2,n.y*K2],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];f3(n,t,i,r),s.push(n)}return s}function g3(e,t,i,n){const r=Math.pow(2,n.z)*K2,o=[n.x*K2,n.y*K2],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];t3(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){!function(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}(t);for(const e of s)for(const n of e)f3(n,t,i,r)}return s}class _3{constructor(e,t){this.type=n1,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(a2(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length){return new _3(t,{type:"MultiPolygon",coordinates:e})}}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new _3(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new _3(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=d3(t.coordinates,n,r),s=m3(e.geometry(),i,n,r);if(!i3(i,n))return!1;for(const e of s)if(!a3(e,o))return!1}if("MultiPolygon"===t.type){const o=p3(t.coordinates,n,r),s=m3(e.geometry(),i,n,r);if(!i3(i,n))return!1;for(const e of s)if(!l3(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=d3(t.coordinates,n,r),s=g3(e.geometry(),i,n,r);if(!i3(i,n))return!1;for(const e of s)if(!c3(e,o))return!1}if("MultiPolygon"===t.type){const o=p3(t.coordinates,n,r),s=g3(e.geometry(),i,n,r);if(!i3(i,n))return!1;for(const e of s)if(!u3(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class A3{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function y3(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function T3(e,t){return t[0]-e[0]}function E3(e){return e[1]-e[0]+1}function C3(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=E3(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function B3(e,t){if(!C3(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)t3(i,e[n]);return i}function I3(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)t3(t,e);return t}function M3(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function P3(e,t,i){if(!M3(e)||!M3(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(i3(r,o)){if(z3(e,t))return 0}else if(z3(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(E3(l)<=c){if(!C3(l,e.length))return NaN;if(t){const t=O3(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=D3(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=S3(l,t);N3(s,o,n,e,a,i[0]),N3(s,o,n,e,a,i[1])}}return o}function G3(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new A3([[0,[0,e.length-1],[0,i.length-1]]],T3);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(E3(l)<=u&&E3(c)<=h){if(!C3(l,e.length)&&C3(c,i.length))return NaN;let o;if(t&&n)o=F3(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=R3(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=R3(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=k3(e,l,i,c,r),s=Math.min(s,o)}else{const o=S3(l,t),u=S3(c,n);V3(a,s,r,e,i,o[0],u[0]),V3(a,s,r,e,i,o[0],u[1]),V3(a,s,r,e,i,o[1],u[0]),V3(a,s,r,e,i,o[1],u[1])}}return s}function H3(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=function(e){if(e.length<=1)return[e];const t=[];let i,n;for(const r of e){const e=y3(r);0!==e&&(r.area=Math.abs(e),void 0===n&&(n=e<0),n===e<0?(i&&t.push(i),i=[r]):i.push(r))}return i&&t.push(i),t}(i).map(t=>t.map(t=>t.map(t=>J2([t.x,t.y],e.canonical)))),r=new w3(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,j3([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,j3(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,U3(t,e.coordinates,r,o))}if(0===o)return o}return o}function Q3(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class $3{constructor(e,t){this.type=t1,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(a2(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new $3(t,t.features.map(e=>Q3(e.geometry)).flat());if("Feature"===t.type)return new $3(t,Q3(t.geometry));if("type"in t&&"coordinates"in t)return new $3(t,Q3(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>J2([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new w3(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,G3(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,G3(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,j3(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>J2([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new w3(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,G3(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,G3(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,j3(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return H3(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Z3{constructor(e){this.type=a1,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Z3(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?z1(i,this.key):null}eachChild(){}outputDefined(){return!1}}const W3={"==":U2,"!=":N2,">":j2,"<":V2,">=":H2,"<=":G2,array:d2,at:v2,boolean:d2,case:T2,coalesce:k2,collator:Q2,format:Z2,image:W2,in:x2,"index-of":b2,interpolate:L2,"interpolate-hcl":L2,"interpolate-lab":L2,length:q2,let:A2,literal:u2,match:w2,number:d2,"number-format":$2,object:d2,slice:E2,step:S2,string:d2,"to-boolean":f2,"to-color":f2,"to-number":f2,"to-string":f2,var:y2,within:_3,distance:$3,"global-state":Z3};class q3{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=q3.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new _2(t.registry,e4,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;tfunction(e){return Array.isArray(e)?`(${e.map(g1).join(", ")})`:`(${g1(e.type)}...)`}(e)).join(" | "),n=[];for(let i=1;i"u"?null:i}function Y3(e){return{type:e}}function e4(e){if(e instanceof y2)return e4(e.boundExpression);if(e instanceof q3&&"error"===e.name)return!1;if(e instanceof Q2)return!1;if(e instanceof _3)return!1;if(e instanceof $3)return!1;if(e instanceof Z3)return!1;const t=e instanceof f2||e instanceof d2;let i=!0;return e.eachChild(e=>{i=t?i&&e4(e):i&&e instanceof u2}),!!i&&(t4(e)&&n4(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]))}function t4(e){if(e instanceof q3){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 _3||e instanceof $3)return!1;let t=!0;return e.eachChild(e=>{t&&!t4(e)&&(t=!1)}),t}function i4(e){if(e instanceof q3&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!i4(e)&&(t=!1)}),t}function n4(e,t){if(e instanceof q3&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!n4(e,t)&&(i=!1)}),i}function r4(e){return{result:"success",value:e}}function o4(e){return{result:"error",value:e}}function s4(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function a4(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function l4(e){return!!e.expression&&e.expression.interpolated}function c4(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function u4(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&l2(e)===s1}q3.register(W3,{error:[{kind:"error"},[i1],(e,[t])=>{throw new t2(t.evaluate(e))}],typeof:[i1,[a1],(e,[t])=>g1(l2(t.evaluate(e)))],"to-rgba":[m1(t1,4),[r1],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[r1,[t1,t1,t1],K3],rgba:[r1,[t1,t1,t1,t1],K3],has:{type:n1,overloads:[[[i1],(e,[t])=>X3(t.evaluate(e),e.properties())],[[i1,s1],(e,[t,i])=>X3(t.evaluate(e),i.evaluate(e))]]},get:{type:a1,overloads:[[[i1],(e,[t])=>J3(t.evaluate(e),e.properties())],[[i1,s1],(e,[t,i])=>J3(t.evaluate(e),i.evaluate(e))]]},"feature-state":[a1,[i1],(e,[t])=>J3(t.evaluate(e),e.featureState||{})],properties:[s1,[],e=>e.properties()],"geometry-type":[i1,[],e=>e.geometryType()],id:[a1,[],e=>e.id()],zoom:[t1,[],e=>e.globals.zoom],"heatmap-density":[t1,[],e=>e.globals.heatmapDensity||0],elevation:[t1,[],e=>e.globals.elevation||0],"line-progress":[t1,[],e=>e.globals.lineProgress||0],accumulated:[a1,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[t1,Y3(t1),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[t1,Y3(t1),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:t1,overloads:[[[t1,t1],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[t1],(e,[t])=>-t.evaluate(e)]]},"/":[t1,[t1,t1],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[t1,[t1,t1],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[t1,[],()=>Math.LN2],pi:[t1,[],()=>Math.PI],e:[t1,[],()=>Math.E],"^":[t1,[t1,t1],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[t1,[t1],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[t1,[t1],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[t1,[t1],(e,[t])=>Math.log(t.evaluate(e))],log2:[t1,[t1],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[t1,[t1],(e,[t])=>Math.sin(t.evaluate(e))],cos:[t1,[t1],(e,[t])=>Math.cos(t.evaluate(e))],tan:[t1,[t1],(e,[t])=>Math.tan(t.evaluate(e))],asin:[t1,[t1],(e,[t])=>Math.asin(t.evaluate(e))],acos:[t1,[t1],(e,[t])=>Math.acos(t.evaluate(e))],atan:[t1,[t1],(e,[t])=>Math.atan(t.evaluate(e))],min:[t1,Y3(t1),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[t1,Y3(t1),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[t1,[t1],(e,[t])=>Math.abs(t.evaluate(e))],round:[t1,[t1],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[t1,[t1],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[t1,[t1],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[n1,[i1,a1],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[n1,[a1],(e,[t])=>e.id()===t.value],"filter-type-==":[n1,[i1],(e,[t])=>e.geometryType()===t.value],"filter-<":[n1,[i1,a1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[n1,[i1,a1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[n1,[a1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[n1,[i1,a1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[n1,[a1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[n1,[i1,a1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[n1,[a1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[n1,[a1],(e,[t])=>t.value in e.properties()],"filter-has-id":[n1,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[n1,[m1(i1)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[n1,[m1(a1)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[n1,[i1,m1(a1)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[n1,[i1,m1(a1)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:n1,overloads:[[[n1,n1],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Y3(n1),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:n1,overloads:[[[n1,n1],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Y3(n1),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[n1,[n1],(e,[t])=>!t.evaluate(e)],"is-supported-script":[n1,[i1],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[i1,[i1],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[i1,[i1],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[i1,Y3(a1),(e,t)=>t.map(t=>c2(t.evaluate(e))).join("")],"resolved-locale":[i1,[l1],(e,[t])=>t.evaluate(e).resolvedLocale()]});class h4{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new g2,this._defaultValue=t?function(e){if("color"===e.type&&u4(e.default))return new Z1(0,0,0,0);switch(e.type){case"color":return Z1.parse(e.default)||null;case"padding":return J1.parse(e.default)||null;case"numberArray":return Y1.parse(e.default)||null;case"colorArray":return e2.parse(e.default)||null;case"variableAnchorOffsetCollection":return n2.parse(e.default)||null;case"projectionDefinition":return o2.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 t2(`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,typeof console<"u"&&console.warn(e.message)),this._defaultValue}}}function d4(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in W3}function p4(e,t){const i=new _2(W3,e4,[],t?function(e){const t={color:r1,string:i1,number:t1,enum:i1,boolean:n1,formatted:c1,padding:u1,numberArray:d1,colorArray:h1,projectionDefinition:o1,resolvedImage:p1,variableAnchorOffsetCollection:f1};return"array"===e.type?m1(t[e.value]||a1,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?r4(new h4(n,t)):o4(i.errors)}class f4{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!i4(t.expression),this.globalStateRefs=A4(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class m4{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!i4(t.expression),this.globalStateRefs=A4(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?L2.interpolationFactor(this.interpolationType,e,t,i):0}}function g4(e,t){const i=p4(e,t);if("error"===i.result)return i;const n=i.value.expression,r=t4(n);if(!r&&!s4(t))return o4([new J0("","data expressions not supported")]);const o=n4(n,["zoom"]);if(!o&&!a4(t))return o4([new J0("","zoom expressions not supported")]);const s=_4(n);if(!s&&!o)return o4([new J0("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof J0)return o4([s]);if(s instanceof L2&&!l4(t))return o4([new J0("",'"interpolate" expressions cannot be used with this property')]);if(!s)return r4(new f4(r?"constant":"source",i.value));const a=s instanceof L2?s.interpolation:void 0;return r4(new m4(r?"camera":"composite",i.value,s.labels,a))}function _4(e){let t=null;if(e instanceof A2)t=_4(e.result);else if(e instanceof k2){for(const i of e.args)if(t=_4(i),t)break}else(e instanceof S2||e instanceof L2)&&e.input instanceof q3&&"zoom"===e.input.name&&(t=e);return t instanceof J0||e.eachChild(e=>{const i=_4(e);i instanceof J0?t=i:!t&&i?t=new J0("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new J0("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function A4(e,t=new Set){return e instanceof Z3&&t.add(e.key),e.eachChild(e=>{A4(e,t)}),t}function y4(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(!y4(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function v4(e){const t=e.key,i=e.value;return i?[new K0(t,i,"constants have been deprecated as of v8")]:[]}function x4(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function b4(e){if(Array.isArray(e))return e.map(b4);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=b4(e[i]);return t}return x4(e)}function w4(e){const t=e.key,i=e.value,n=e.valueSpec||{},r=e.objectElementValidators||{},o=e.style,s=e.styleSpec,a=e.validateSpec;let l=[];const c=c4(i);if("object"!==c)return[new K0(t,i,`object expected, ${c} found`)];for(const e in i){const c=e.split(".")[0],u=z1(n,c)||n["*"];let h;if(z1(r,c))h=r[c];else if(z1(n,c))h=a;else if(r["*"])h=r["*"];else{if(!n["*"]){l.push(new K0(t,i[e],`unknown property "${e}"`));continue}h=a}l=l.concat(h({key:(t&&`${t}.`)+e,value:i[e],valueSpec:u,style:o,styleSpec:s,object:i,objectKey:e,validateSpec:a},i))}for(const e in n)r[e]||n[e].required&&void 0===n[e].default&&void 0===i[e]&&l.push(new K0(t,i,`missing required property "${e}"`));return l}function T4(e){const t=e.value,i=e.valueSpec,n=e.validateSpec,r=e.style,o=e.styleSpec,s=e.key,a=e.arrayElementValidator||n;if("array"!==c4(t))return[new K0(s,t,`array expected, ${c4(t)} found`)];if(i.length&&t.length!==i.length)return[new K0(s,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.lengthn.maximum?[new K0(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function C4(e){const t=e.valueSpec,i=x4(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===c4(e.value.stops)&&"array"===c4(e.value.stops[0])&&"object"===c4(e.value.stops[0][0]),u=w4({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new K0(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(T4({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===c4(n)&&0===n.length&&t.push(new K0(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new K0(e.key,e.value,'missing required property "property"')),"identity"!==i&&!e.value.stops&&u.push(new K0(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!l4(e.valueSpec)&&u.push(new K0(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!s4(e.valueSpec)?u.push(new K0(e.key,e.value,"property functions not supported")):a&&!a4(e.valueSpec)&&u.push(new K0(e.key,e.value,"zoom functions not supported"))),("categorical"===i||c)&&void 0===e.value.property&&u.push(new K0(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==c4(n))return[new K0(a,n,`array expected, ${c4(n)} found`)];if(2!==n.length)return[new K0(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==c4(n[0]))return[new K0(a,n,`object expected, ${c4(n[0])} found`)];if(void 0===n[0].zoom)return[new K0(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new K0(a,n,"object stop key must have value")];if(o&&o>x4(n[0].zoom))return[new K0(a,n[0].zoom,"stop zoom values must appear in ascending order")];x4(n[0].zoom)!==o&&(o=x4(n[0].zoom),r=void 0,s={}),i=i.concat(w4({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:E4,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return d4(b4(n[1]))?i.concat([new K0(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=c4(e.value),l=x4(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new K0(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new K0(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return s4(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new K0(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew K0(`${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 K0(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&&!i4(i))return[new K0(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!i4(i))return[new K0(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!n4(i,["zoom","feature-state"]))return[new K0(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!t4(i))return[new K0(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function B4(e){const t=e.key,i=e.value,n=c4(i);return"string"!==n?[new K0(t,i,`color expected, ${n} found`)]:Z1.parse(String(i))?[]:[new K0(t,i,`color expected, "${i}" found`)]}function I4(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(x4(i))&&r.push(new K0(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(x4(i))&&r.push(new K0(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function M4(e){return y4(b4(e.value))?S4(X0({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):P4(e)}function P4(e){const t=e.value,i=e.key;if("array"!==c4(t))return[new K0(i,t,`array expected, ${c4(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new K0(i,t,"filter array must have at least 1 element")];switch(o=o.concat(I4({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),x4(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===x4(t[1])&&o.push(new K0(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new K0(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=c4(t[1]),"string"!==r&&o.push(new K0(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new K0(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{x4(t.id)===a&&(e=t)}),e?e.ref?t.push(new K0(n,i.ref,"ref cannot reference another ref layer")):s=x4(e.type):t.push(new K0(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&x4(e.type);e?"vector"===o&&"raster"===s?t.push(new K0(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new K0(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new K0(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new K0(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===s&&i.paint&&i.paint["line-gradient"]&&("geojson"!==o||!e.lineMetrics)&&t.push(new K0(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new K0(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new K0(n,i.source,`source "${i.source}" not found`))}else t.push(new K0(n,i,'missing required property "source"'));return t=t.concat(w4({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:M4,layout:e=>w4({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>F4(X0({layerType:s},e))}}),paint:e=>w4({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>L4(X0({layerType:s},e))}})}})),t}function D4(e){const t=e.value,i=e.key,n=c4(t);return"string"!==n?[new K0(i,t,`string expected, ${n} found`)]:[]}const O4={promoteId:function({key:e,value:t}){if("string"===c4(t))return D4({key:e,value:t});{const i=[];for(const n in t)i.push(...D4({key:`${e}.${n}`,value:t[n]}));return i}}};function z4(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new K0(i,t,'"type" is required')];const s=x4(t.type);let a;switch(s){case"vector":case"raster":return a=w4({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:O4,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=c4(n);if(void 0===n)return a;if("object"!==l)return a.push(new K0("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===x4(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new K0(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new K0(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=w4({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:O4}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...S4({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...S4({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return w4({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return w4({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new K0(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return I4({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function U4(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=c4(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new K0("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=a&&n[a[1]]&&n[a[1]].transition?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i})):n[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i})):o.concat([new K0(s,t[s],`unknown property "${s}"`)])}return o}function N4(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=c4(t);if(void 0===t)return[];if("object"!==o)return[new K0("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=n[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i})):s.concat([new K0(o,t[o],`unknown property "${o}"`)]);return s}function V4(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=c4(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new K0("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=n[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i})):o.concat([new K0(s,t[s],`unknown property "${s}"`)]);return o}function j4(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i){i[s].id&&r.includes(i[s].id)&&t.push(new K0(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new K0(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url);const a={id:{type:"string",required:!0},url:{type:"string",required:!0}};t=t.concat(w4({key:`${n}[${s}]`,value:i[s],valueSpec:a,validateSpec:e.validateSpec}))}return t}return D4({key:n,value:i})}function G4(e){return function(e){return!!e&&e.constructor===Object}(e.value)?[]:[new K0(e.key,e.value,`object expected, ${c4(e.value)} found`)]}const H4={"*":()=>[],array:T4,boolean:function(e){const t=e.value,i=e.key,n=c4(t);return"boolean"!==n?[new K0(i,t,`boolean expected, ${n} found`)]:[]},number:E4,color:B4,constants:v4,enum:I4,filter:M4,function:C4,layer:k4,object:w4,source:z4,light:U4,sky:N4,terrain:V4,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=c4(t);if(void 0===t)return[];if("object"!==o)return[new K0("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=n[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i})):s.concat([new K0(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=c4(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new K0(t,i,`projection expected, invalid type "${n}" found`)]:[new K0(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:D4,formatted:function(e){return 0===D4(e).length?[]:S4(e)},resolvedImage:function(e){return 0===D4(e).length?[]:S4(e)},padding:function(e){const t=e.key,i=e.value;if("array"===c4(i)){if(i.length<1||i.length>4)return[new K0(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(v4({key:"constants",value:e.constants}))),q4(i)}function W4(e){return function(t){return e({...t,validateSpec:Q4})}}function q4(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function K4(e){return function(...t){return q4(e.apply(this,t))}}function X4(e){if(!e)return{style:aY[rY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0};if("string"==typeof e){const t=function(e){try{const t=JSON.parse(e),i=Z4(t);return{isValidJSON:!0,isValidStyle:0===i.length,styleObject:0===i.length?t:null}}catch{return{isValidJSON:!1,isValidStyle:!1,styleObject:null}}}(e);return t.isValidStyle?{style:t.styleObject,requiresUrlMonitoring:!1,isFallback:!1}:t.isValidJSON?{style:aY[rY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0}:e.startsWith("http")?{style:e,requiresUrlMonitoring:!0,isFallback:!1}:e.toLowerCase().includes(".json")?{style:J4(e),requiresUrlMonitoring:!0,isFallback:!1}:{style:tY(e),requiresUrlMonitoring:!0,isFallback:!1}}return e instanceof iY?{style:e.getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!1}:e instanceof nY?{style:e.getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!1}:0===Z4(e).length?{style:e,requiresUrlMonitoring:!1,isFallback:!1,isJSON:!0}:{style:aY[rY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0}}function J4(e){try{return new URL(e).href}catch{}return new URL(e,location.origin).href}function Y4(e,t,i){const n=window.document.createElement(e);return void 0!==t&&(n.className=t),i&&i.appendChild(n),n}function e5(e){e.parentNode&&e.parentNode.removeChild(e)}Z4.source=K4(W4(z4)),Z4.sprite=K4(W4(j4)),Z4.glyphs=K4(W4($4)),Z4.light=K4(W4(U4)),Z4.sky=K4(W4(N4)),Z4.terrain=K4(W4(V4)),Z4.state=K4(W4(G4)),Z4.layer=K4(W4(k4)),Z4.filter=K4(W4(M4)),Z4.paintProperty=K4(W4(L4)),Z4.layoutProperty=K4(W4(F4));class t5{constructor(){HY(this,"_map"),HY(this,"_container"),HY(this,"_terrainButton"),function(e,t){for(const i of e)"function"==typeof t[i]&&(t[i]=t[i].bind(t))}(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(e){return this._map=e,this._container=Y4("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=Y4("button","maplibregl-ctrl-terrain",this._container),Y4("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){e5(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){i5(this._map),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))}}function i5(e){e.hasTerrain()?e.disableTerrain():e.enableTerrain()}class n5 extends s0{constructor(e={}){super({showCompass:e.showCompass??!0,showZoom:e.showZoom??!0,visualizePitch:e.visualizePitch??!0}),HY(this,"_rotateCompassArrow",()=>{const e=this._map.getBearing(),t=this._map.getPitch(),i=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.cos(t*(Math.PI/180))**.5)}) rotateX(${Math.min(70,t)}deg) rotateZ(${-e}deg)`:`rotate(${-e}deg)`;this._compassIcon.style.transform=i}),this._compass&&(this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",e=>{0===this._map.getPitch()?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}))}_createButton(e,t){const i=super._createButton(e,t);return i.clickFunction=t,i}}const r5=tJ.Marker,o5=tJ.LngLat,s5=tJ.LngLatBounds;class a5 extends a0{constructor(){super(...arguments),HY(this,"lastUpdatedCenter",new o5(0,0)),HY(this,"_updateCamera",e=>{var t;const i=new o5(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r={bearing:this._map.getBearing(),...this.options.fitBoundsOptions,linear:!0},o=this._map.getZoom();o>((null==(t=this.options.fitBoundsOptions)?void 0:t.maxZoom)??30)&&(r.zoom=o),this._map.fitBounds(s5.fromLngLat(i,n),r,{geolocateSource:!0});let s=!1;const a=()=>{s=!0};this._map.once("click",a),this._map.once("dblclick",a),this._map.once("dragstart",a),this._map.once("mousedown",a),this._map.once("touchstart",a),this._map.once("wheel",a),this._map.once("moveend",()=>{this._map.off("click",a),this._map.off("dblclick",a),this._map.off("dragstart",a),this._map.off("mousedown",a),this._map.off("touchstart",a),this._map.off("wheel",a),!s&&(this.lastUpdatedCenter=this._map.getCenter())})}),HY(this,"_finishSetupUI",e=>{if(this._map){if(!1===e){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=Y4("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new r5({element:this._dotElement}),this._circleElement=Y4("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new r5({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const t=e.originalEvent&&"resize"===e.originalEvent.type,i=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&"ACTIVE_LOCK"===this._watchState&&!t&&i>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}}),HY(this,"_onZoom",()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()})}_updateCircleRadius(){if("BACKGROUND"!==this._watchState&&"ACTIVE_LOCK"!==this._watchState)return;const e=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],t=this._map.project(e),i=this._map.unproject([t.x,t.y]),n=this._map.unproject([t.x+20,t.y]),r=i.distanceTo(n)/20,o=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}}var l5,c5,u5,h5,d5;class p5{constructor(e,t,i){if(ZY(this,l5),ZY(this,c5),ZY(this,u5),ZY(this,h5),ZY(this,d5),"string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error(`No element has been found with selector "${e}" when creating an external control.`);WY(this,c5,t)}else WY(this,c5,e);t&&WY(this,u5,e=>{t($Y(this,l5),$Y(this,c5),e)}),i&&WY(this,h5,e=>{i($Y(this,l5),$Y(this,c5),e)}),WY(this,d5,$Y(this,c5).parentElement)}onAdd(e){return WY(this,l5,e),$Y(this,u5)&&$Y(this,c5).addEventListener("click",$Y(this,u5)),$Y(this,h5)&&$Y(this,l5).on("render",$Y(this,h5)),e5($Y(this,c5)),$Y(this,c5)}onRemove(){$Y(this,u5)&&$Y(this,c5).removeEventListener("click",$Y(this,u5)),$Y(this,h5)&&$Y(this,l5).off("render",$Y(this,h5)),$Y(this,d5)?$Y(this,d5).appendChild($Y(this,c5)):e5($Y(this,c5))}}l5=new WeakMap,c5=new WeakMap,u5=new WeakMap,h5=new WeakMap,d5=new WeakMap;class f5{constructor(){HY(this,"map"),HY(this,"container"),HY(this,"projectionButton")}onAdd(e){return this.map=e,this.container=Y4("div","maplibregl-ctrl maplibregl-ctrl-group"),this.projectionButton=Y4("button","maplibregl-ctrl-projection",this.container),Y4("span","maplibregl-ctrl-icon",this.projectionButton).setAttribute("aria-hidden","true"),this.projectionButton.type="button",this.projectionButton.addEventListener("click",this.toggleProjection.bind(this)),e.on("projectiontransition",this.updateProjectionIcon.bind(this)),this.updateProjectionIcon(),this.container}onRemove(){e5(this.container),this.map.off("projectiontransition",this.updateProjectionIcon),this.map=void 0}toggleProjection(){m5(this.map),this.updateProjectionIcon()}updateProjectionIcon(){this.projectionButton.classList.remove("maplibregl-ctrl-projection-globe"),this.projectionButton.classList.remove("maplibregl-ctrl-projection-mercator"),this.map.isGlobeProjection()?(this.projectionButton.classList.add("maplibregl-ctrl-projection-mercator"),this.projectionButton.title="Enable Mercator projection"):(this.projectionButton.classList.add("maplibregl-ctrl-projection-globe"),this.projectionButton.title="Enable Globe projection")}}function m5(e){void 0===e.getProjection()&&e.setProjection({type:"mercator"}),e.isGlobeProjection()?e.enableMercatorProjection():e.enableGlobeProjection()}const g5={"zoom-in":e=>e.zoomIn(),"zoom-out":e=>e.zoomOut(),"toggle-projection":m5,"toggle-terrain":i5,"reset-view":e=>{0===e.getPitch()?e.easeTo({pitch:Math.min(e.getMaxPitch(),80)}):e.resetNorthPitch()},"reset-bearing":e=>{e.rotateTo(0)},"reset-pitch":e=>{e.setPitch(0)},"reset-roll":e=>{e.setRoll(0)}};var _5,A5,y5,v5,x5,b5,w5,T5,E5,C5,S5,B5;class I5 extends p5{constructor(e,t){if(t&&!(t in g5))throw new Error(`data-maptiler-control value "${t}" is invalid.`);super(e,t&&g5[t]),ZY(this,_5),ZY(this,A5,new Map)}onAdd(e){return WY(this,_5,e),super.onAdd(e)}onRemove(){for(const[e,t]of $Y(this,A5)){const i=e.deref();i&&i.removeEventListener("click",t)}$Y(this,A5).clear(),super.onRemove()}configureGroupItem(e,t){if(!t)return;if(!(t in g5))throw new Error(`data-maptiler-control value "${t}" is invalid.`);const i=i=>{g5[t]($Y(this,_5),e,i)};e.addEventListener("click",i),$Y(this,A5).set(new WeakRef(e),i)}}_5=new WeakMap,A5=new WeakMap,HY(I5,"controlCallbacks",g5);class M5{constructor(e,t){ZY(this,E5),ZY(this,y5),HY(this,"map"),ZY(this,v5),ZY(this,x5),ZY(this,b5),ZY(this,w5,!1),ZY(this,T5),void 0!==e.style&&WY(this,w5,!0),WY(this,y5,{zoomAdjust:-4,position:"top-right",...t,forceNoAttributionControl:!0,attributionControl:!1,navigationControl:!1,geolocateControl:!1,maptilerLogo:!1,minimap:!1,hash:!1,pitchAdjust:!1,...e,containerStyle:{border:"1px solid #000",width:"400px",height:"300px",...e.containerStyle??{}}}),void 0!==e.lockZoom&&($Y(this,y5).minZoom=e.lockZoom,$Y(this,y5).maxZoom=e.lockZoom)}setStyle(e,t){$Y(this,w5)||this.map.setStyle(e,t),qY(this,E5,S5).call(this)}addLayer(e,t){return $Y(this,w5)||this.map.addLayer(e,t),qY(this,E5,S5).call(this),this.map}moveLayer(e,t){return $Y(this,w5)||this.map.moveLayer(e,t),qY(this,E5,S5).call(this),this.map}removeLayer(e){return $Y(this,w5)||this.map.removeLayer(e),qY(this,E5,S5).call(this),this}setLayerZoomRange(e,t,i){return $Y(this,w5)||this.map.setLayerZoomRange(e,t,i),qY(this,E5,S5).call(this),this}setFilter(e,t,i){return $Y(this,w5)||this.map.setFilter(e,t,i),qY(this,E5,S5).call(this),this}setPaintProperty(e,t,i,n){return $Y(this,w5)||this.map.setPaintProperty(e,t,i,n),qY(this,E5,S5).call(this),this}setLayoutProperty(e,t,i,n){return $Y(this,w5)||this.map.setLayoutProperty(e,t,i,n),qY(this,E5,S5).call(this),this}setGlyphs(e,t){return $Y(this,w5)||this.map.setGlyphs(e,t),qY(this,E5,S5).call(this),this}onAdd(e){WY(this,v5,e),WY(this,x5,Y4("div","maplibregl-ctrl maplibregl-ctrl-group"));for(const[e,t]of Object.entries($Y(this,y5).containerStyle))$Y(this,x5).style.setProperty(e,t);return $Y(this,y5).container=$Y(this,x5),$Y(this,y5).zoom=e.getZoom()+$Y(this,y5).zoomAdjust,this.map=new F6($Y(this,y5)),this.map.once("style.load",()=>{this.map.resize()}),this.map.once("load",()=>{qY(this,E5,C5).call(this,$Y(this,y5).parentRect),WY(this,T5,qY(this,E5,B5).call(this))}),$Y(this,x5)}onRemove(){var e;null==(e=$Y(this,T5))||e.call(this),e5($Y(this,x5))}}y5=new WeakMap,v5=new WeakMap,x5=new WeakMap,b5=new WeakMap,w5=new WeakMap,T5=new WeakMap,E5=new WeakSet,C5=function(e){void 0===e||void 0===e.linePaint&&void 0===e.fillPaint||(WY(this,b5,{type:"Feature",properties:{name:"parentRect"},geometry:{type:"Polygon",coordinates:[[[],[],[],[],[]]]}}),this.map.addSource("parentRect",{type:"geojson",data:$Y(this,b5)}),(void 0!==e.lineLayout||void 0!==e.linePaint)&&this.map.addLayer({id:"parentRectOutline",type:"line",source:"parentRect",layout:{...e.lineLayout},paint:{"line-color":"#FFF","line-width":1,"line-opacity":.85,...e.linePaint}}),void 0!==e.fillPaint&&this.map.addLayer({id:"parentRectFill",type:"fill",source:"parentRect",layout:{},paint:{"fill-color":"#08F","fill-opacity":.135,...e.fillPaint}}),qY(this,E5,S5).call(this))},S5=function(){if(void 0===$Y(this,b5))return;const{devicePixelRatio:e}=window,t=$Y(this,v5).getCanvas(),i=t.width/e,n=t.height/e,r=$Y(this,v5).unproject.bind($Y(this,v5)),o=r([0,0]),s=r([i,0]),a=r([0,n]),l=r([i,n]);$Y(this,b5).geometry.coordinates=[[a.toArray(),l.toArray(),s.toArray(),o.toArray(),a.toArray()]];const c=this.map.getSource("parentRect");void 0!==c&&c.setData($Y(this,b5))},B5=function(){const{pitchAdjust:e}=$Y(this,y5),t=()=>{o("parent")},i=()=>{o("minimap")},n=()=>{$Y(this,v5).on("move",t),this.map.on("move",i)},r=()=>{$Y(this,v5).off("move",t),this.map.off("move",i)},o=t=>{r();const i="parent"===t?$Y(this,v5):this.map,o="parent"===t?this.map:$Y(this,v5),s=i.getCenter(),a=i.getZoom()+$Y(this,y5).zoomAdjust*("parent"===t?1:-1),l=i.getBearing(),c=i.getPitch();o.jumpTo({center:s,zoom:a,bearing:l,pitch:e?c:0}),qY(this,E5,S5).call(this),n()};return n(),()=>{r()}};class P5{constructor(e,t=2e3){HY(this,"map"),HY(this,"registeredModules",new Set),HY(this,"viewerType"),this.map=e,this.viewerType="Map",setTimeout(async()=>{if(!C0.telemetry)return;const e=this.preparePayload();try{(await fetch(e,{method:"POST"})).ok||console.warn("The metrics could not be sent to MapTiler Cloud")}catch(e){console.warn("The metrics could not be sent to MapTiler Cloud",e)}},Math.max(1e3,t))}registerModule(e,t){this.registeredModules.add(`${e}:${t}`)}registerViewerType(e="Map"){this.viewerType=e}preparePayload(){const e=new URL(w0.telemetryURL);return e.searchParams.append("sdk","3.9.0"),e.searchParams.append("key",C0.apiKey),e.searchParams.append("mtsid",T0),e.searchParams.append("session",C0.session?"1":"0"),e.searchParams.append("caching",C0.caching?"1":"0"),e.searchParams.append("lang-updated",this.map.isLanguageUpdated()?"1":"0"),e.searchParams.append("terrain",this.map.getTerrain()?"1":"0"),e.searchParams.append("globe",this.map.isGlobeProjection()?"1":"0"),e.searchParams.append("viewerType",this.viewerType),this.registeredModules.size>0&&e.searchParams.append("modules",Array.from(this.registeredModules).join("|")),e.href}}var R5=typeof Float32Array<"u"?Float32Array:Array;function L5(){var e=new R5(16);return R5!=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}function F5(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function k5(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}var D5,O5,z5,U5,N5,V5,j5,G5,H5=function(e,t,i,n,r){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=r&&r!==1/0){var s=1/(n-r);e[10]=(r+n)*s,e[14]=2*r*n*s}else e[10]=-1,e[14]=-2*n;return e};function Q5(){var e=new R5(3);return R5!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function $5(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Z5(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}function W5(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function q5(){if(U5)return z5;U5=1;const e=(O5||(O5=1,D5={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),D5),t={};for(const i of Object.keys(e))t[e[i]]=i;const i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};z5=i;for(const e of Object.keys(i)){if(!("channels"in i[e]))throw new Error("missing channels property: "+e);if(!("labels"in i[e]))throw new Error("missing channel labels property: "+e);if(i[e].labels.length!==i[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=i[e];delete i[e].channels,delete i[e].labels,Object.defineProperty(i[e],"channels",{value:t}),Object.defineProperty(i[e],"labels",{value:n})}function n(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}return i.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(t,i,n),o=Math.max(t,i,n),s=o-r;let a,l;o===r?a=0:t===o?a=(i-n)/s:i===o?a=2+(n-t)/s:n===o&&(a=4+(t-i)/s),a=Math.min(60*a,360),a<0&&(a+=360);const c=(r+o)/2;return l=o===r?0:c<=.5?s/(o+r):s/(2-o-r),[a,100*l,100*c]},i.rgb.hsv=function(e){let t,i,n,r,o;const s=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(s,a,l),u=c-Math.min(s,a,l),h=function(e){return(c-e)/6/u+.5};return 0===u?(r=0,o=0):(o=u/c,t=h(s),i=h(a),n=h(l),s===c?r=n-i:a===c?r=1/3+t-n:l===c&&(r=2/3+i-t),r<0?r+=1:r>1&&(r-=1)),[360*r,100*o,100*c]},i.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=i.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,100*s,100*r]},i.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(1-t,1-i,1-n);return[100*((1-t-r)/(1-r)||0),100*((1-i-r)/(1-r)||0),100*((1-n-r)/(1-r)||0),100*r]},i.rgb.keyword=function(i){const r=t[i];if(r)return r;let o,s=1/0;for(const t of Object.keys(e)){const r=n(i,e[t]);r.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;return[116*r-16,500*(n-r),200*(r-o)]},i.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let r,o,s;if(0===i)return s=255*n,[s,s,s];r=n<.5?n*(1+i):n+i-n*i;const a=2*n-r,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,s=6*o<1?a+6*(r-a)*o:2*o<1?r:3*o<2?a+(r-a)*(2/3-o)*6:a,l[e]=255*s;return l},i.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,r=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,r*=o<=1?o:2-o;return[t,100*(0===n?2*r/(o+r):2*i/(n+i)),100*((n+i)/2)]},i.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const r=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,r){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},i.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,r=Math.max(n,.01);let o,s;s=(2-i)*n;const a=(2-i)*r;return o=i*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},i.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const r=i+n;let o;r>1&&(i/=r,n/=r);const s=Math.floor(6*t),a=1-n;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},i.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},i.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let r,o,s;return r=3.2406*t+-1.5372*i+-.4986*n,o=-.9689*t+1.8758*i+.0415*n,s=.0557*t+-.204*i+1.057*n,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),[255*r,255*o,255*s]},i.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},i.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const r=i**3,o=t**3,s=n**3;return i=r>.008856?r:(i-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,n=s>.008856?s:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},i.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let r;r=360*Math.atan2(n,i)/2/Math.PI,r<0&&(r+=360);return[t,Math.sqrt(i*i+n*n),r]},i.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},i.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let s=null===t?i.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let a=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===s&&(a+=60),a},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];return t===i&&i===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},i.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},i.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},i.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},i.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map(e=>e+e).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},i.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),s=r-o;let a,l;return a=s<1?o/(1-s):0,l=s<=0?0:r===t?(i-n)/s%6:r===i?2+(n-t)/s:4+(t-i)/s,l/=6,l%=1,[360*l,100*s,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let r=0;return n<1&&(r=(i-.5*n)/(1-n)),[e[0],100*n,100*r]},i.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},i.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const r=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return l=(1-i)*n,[255*(i*r[0]+l),255*(i*r[1]+l),255*(i*r[2]+l)]},i.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},i.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},i.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},i.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=function(e){return[0,0,e[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]},z5}function K5(){if(V5)return N5;V5=1;const e=q5();function t(t){const i=function(){const t={},i=Object.keys(e);for(let e=i.length,n=0;n{i[n]={},Object.defineProperty(i[n],"channels",{value:e[n].channels}),Object.defineProperty(i[n],"labels",{value:e[n].labels});const r=t(n);Object.keys(r).forEach(e=>{const t=r[e];i[n][e]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(t)})}),j5=i}();const J5=W5(X5);function Y5({gl:e,type:t,source:i}){const n=e.createShader(t);if(null===n)throw new Error("Cannot create shader");if(e.shaderSource(n,i),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw console.error("Shader compilation error:",e.getShaderInfoLog(n)),e.deleteShader(n),new Error("Cannot compile shader");return n}function e6({gl:e,vertexShaderSource:t,fragmentShaderSource:i,attributesKeys:n,uniformsKeys:r,vertices:o,indices:s}){const a=function({gl:e,vertexShaderSource:t,fragmentShaderSource:i}){const n=Y5({gl:e,type:e.VERTEX_SHADER,source:t}),r=Y5({gl:e,type:e.FRAGMENT_SHADER,source:i}),o=e.createProgram();if(e.attachShader(o,n),e.attachShader(o,r),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw console.error("Error: ",e.getProgramInfoLog(o)),new Error("Cannot link shader program");return o}({gl:e,vertexShaderSource:t,fragmentShaderSource:i}),l=n.reduce((t,i)=>(t[i]=e.getAttribLocation(a,`a_${i}`),t),{}),c=r.reduce((t,i)=>(t[i]=function(e,t,i){const n=e.getUniformLocation(t,i);if(null===n)throw new Error(`Cannot get uniform location for ${i}`);return n}(e,a,`u_${i}`),t),{}),u=e.createBuffer();let h,d;return e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,new Float32Array(o),e.STATIC_DRAW),void 0!==s&&(h=e.createBuffer(),d=s.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(s),e.STATIC_DRAW)),{shaderProgram:a,programInfo:{attributesLocations:l,uniformsLocations:c},positionBuffer:u,indexBuffer:h,indexBufferLength:d}}function t6(e){if(!e)return[1,1,1,0];if("transparent"===e)return[1,1,1,0];try{const t=function(e){return i6=i6??document.createElement("canvas").getContext("2d"),i6?(i6.fillStyle=e,i6.fillStyle):"#000000"}(e),i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(t);if(null!=i&&i.length){const e=!!i[4];return[...J5.hex.rgb(t).map(e=>e/255),e?parseInt(i[4],16)/255:1]}const n=t.match(/(\d\.\d(\d+)?|\d{3}|\d{2}|\d{1})/gi)??["0","0","0"];if(t.includes("rgb")){const e=t.includes("rgba"),i=[...n.map(e=>parseFloat(e)).map((e,t)=>t<3?e/255:e)];return e||i.push(1),i}}catch{}return console.warn([`[parseColorStringToVec4]: Color ${e} is either not a valid color or its type is not supported, defaulting to black`]),[0,0,0,1]}let i6;const n6=.5,r6=.5,o6=.5,s6=[...[-.5,-.5,o6,n6,-.5,o6,n6,r6,o6,-.5,r6,o6],...[-.5,-.5,-.5,-.5,r6,-.5,n6,r6,-.5,n6,-.5,-.5],...[-.5,r6,-.5,-.5,r6,o6,n6,r6,o6,n6,r6,-.5],...[-.5,-.5,-.5,n6,-.5,-.5,n6,-.5,o6,-.5,-.5,o6],...[n6,-.5,-.5,n6,r6,-.5,n6,r6,o6,n6,-.5,o6],...[-.5,-.5,-.5,-.5,-.5,o6,-.5,r6,o6,-.5,r6,-.5]],a6=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],l6="precision mediump float;\n\nvarying vec3 vTextureCoord;\n\n%USE_TEXTURE_MACRO_MARKER%\n\n# ifdef USE_TEXTURE\nuniform samplerCube u_cubeSampler;\nuniform float u_fadeOpacity;\n# endif\n\nuniform vec4 u_bgColor;\n\nvoid main(void) {\n #ifdef USE_TEXTURE\n vec4 texColor = textureCube(u_cubeSampler, vTextureCoord);\n\n gl_FragColor = mix(\n u_bgColor,\n texColor,\n min(texColor.a, u_fadeOpacity)\n );\n\n gl_FragColor.a = max(gl_FragColor.a, u_fadeOpacity);\n\n #else\n gl_FragColor = u_bgColor;\n #endif\n}\n";var c6=(e=>(e.UNIVERSE_DARK="universe-dark",e))(c6||{});const u6={stars:{color:"hsl(233,100%,92%)",preset:"stars"},space:{color:"hsl(210, 100%, 4%)",preset:"space"},milkyway:{color:"hsl(233,100%,92%)",preset:"milkyway"},"milkyway-subtle":{color:"hsl(233,100%,92%)",preset:"milkyway-subtle"},"milkyway-bright":{color:"hsl(233,100%,92%)",preset:"milkyway-bright"},"milkyway-colored":{color:"black",preset:"milkyway-colored"}};var h6=(e=>(e.POSITIVE_X="pX",e.NEGATIVE_X="nX",e.POSITIVE_Y="pY",e.NEGATIVE_Y="nY",e.POSITIVE_Z="pZ",e.NEGATIVE_Z="nZ",e))(h6||{});const d6=new Map,p6=new Map;let f6;function m6(e,t){if(t===h6.POSITIVE_X)return e.TEXTURE_CUBE_MAP_POSITIVE_X;if(t===h6.NEGATIVE_X)return e.TEXTURE_CUBE_MAP_NEGATIVE_X;if(t===h6.POSITIVE_Y)return e.TEXTURE_CUBE_MAP_POSITIVE_Y;if(t===h6.NEGATIVE_Y)return e.TEXTURE_CUBE_MAP_NEGATIVE_Y;if(t===h6.POSITIVE_Z)return e.TEXTURE_CUBE_MAP_POSITIVE_Z;if(t===h6.NEGATIVE_Z)return e.TEXTURE_CUBE_MAP_NEGATIVE_Z;throw new Error(`[CubemapLayer][loadCubemapTexture]: Invalid key ${t}`)}function g6(e,t,i){return e+(t-e)*i}function _6(e){if(!e)return{};const t=Object.keys(e).sort().map(t=>[t,e[t]]);return Object.fromEntries(t)}const A6="https://api.maptiler.com/resources/space",y6=["vertexPosition"],v6=["projectionMatrix","modelViewMatrix","cubeSampler","bgColor","fadeOpacity"],x6="%USE_TEXTURE_MACRO_MARKER%",b6=u6.stars;class w6{constructor(e){HY(this,"id","Cubemap Layer"),HY(this,"type","custom"),HY(this,"renderingMode","3d"),HY(this,"map"),HY(this,"faces"),HY(this,"useCubemapTexture",!0),HY(this,"currentFadeOpacity",0),HY(this,"cubeMapNeedsUpdate",!1),HY(this,"bgColor"),HY(this,"previousBgColor",[0,0,0,0]),HY(this,"targetBgColor",[0,0,0,0]),HY(this,"transitionDelta",0),HY(this,"gl"),HY(this,"cubemap"),HY(this,"texture"),HY(this,"currentFacesDefinitionKey",""),HY(this,"options"),HY(this,"animationActive",!0),HY(this,"imageIsAnimating",!1),HY(this,"imageFadeInDelta",0);const t=function(e,t){if(!T6(e))return{color:"transparent"};if(!0===e)return t;const i={...e};if(e.faces||e.path)return delete i.preset,i;const n=e.preset;if(void 0!==n&&!(n in u6))throw new Error(`[CubemapLayer]: Invalid preset "${n}". Available presets: ${Object.keys(u6).join(", ")}`);return{...i,color:i.color??u6[n].color??"hsl(233,100%,92%)"}}(e,b6);this.options=t,this.currentFacesDefinitionKey=JSON.stringify(t.faces??t.preset??t.path),this.bgColor=[0,0,0,0],this.targetBgColor=t6(t.color),this.faces=E6(t),this.useCubemapTexture=null!==this.faces}updateCubemap({facesNeedUpdate:e}={facesNeedUpdate:!0}){this.useCubemapTexture=null!==this.faces;const t=v6.filter(e=>"cubeSampler"!==e&&"fadeOpacity"!==e||this.useCubemapTexture);this.cubemap=e6({gl:this.gl,vertexShaderSource:"attribute vec3 a_vertexPosition;\nvarying vec3 vTextureCoord;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_modelViewMatrix;\n \nvoid main(void) {\n vTextureCoord = vec3(-a_vertexPosition.x, a_vertexPosition.y, a_vertexPosition.z);\n gl_Position = u_projectionMatrix * u_modelViewMatrix * vec4(a_vertexPosition, 1.0);\n}\n",fragmentShaderSource:this.useCubemapTexture?l6.replace(x6,"#define USE_TEXTURE"):l6.replace(x6,""),attributesKeys:y6,uniformsKeys:t,vertices:s6,indices:a6}),this.cubeMapNeedsUpdate=e,this.useCubemapTexture&&this.updateTexture(this.gl,this.faces),this.animateColorChange()}onAdd(e,t){this.map=e,this.gl=t,this.updateCubemap()}onRemove(e,t){this.cubemap&&(this.texture&&t.deleteTexture(this.texture),t.deleteProgram(this.cubemap.shaderProgram),t.deleteBuffer(this.cubemap.positionBuffer),this.texture=void 0)}updateTexture(e,t){if(!0===this.cubeMapNeedsUpdate&&!this.imageIsAnimating){if(this.cubeMapNeedsUpdate=!1,!this.useCubemapTexture)return;!function({gl:e,faces:t,onReady:i,forceRefresh:n}){if(d6.get(e)&&!n&&f6===JSON.stringify(t))return void i(d6.get(e),p6.get(e));f6=JSON.stringify(t);const r=d6.get(e)??e.createTexture();if(!t)return void console.warn("[CubemapLayer][loadCubemapTexture]: Faces are null");const o=Object.keys(t).length;if(6!==o)return void console.warn(`[CubemapLayer][loadCubemapTexture]: Faces should contain exactly 6 images, but found ${o}`);const s=Object.entries(t).map(([e,t])=>new Promise((i,n)=>{const r=e;if(void 0===t)return void n(new Error(`[CubemapLayer][loadCubemapTexture]: Face ${e} is undefined`));const o=new Image;o.crossOrigin="anonymous";const s=()=>{i({image:o,key:r})};o.src=t,o.complete&&o.naturalWidth>0?s():o.onload=s,o.onerror=()=>{n(new Error(`[CubemapLayer][loadCubemapTexture]: Error loading image ${t}`))}}));Promise.all(s).then(t=>{for(let i=0;ie.image);i(r,n),p6.set(e,n),d6.set(e,r)}).catch(e=>{console.error("[CubemapLayer][loadCubemapTexture]: Error loading cubemap texture",e)})}({gl:e,faces:t,onReady:e=>{this.texture=e,this.animateIn()}})}}prerender(e,t){this.faces&&this.updateTexture(this.gl,this.faces)}animateColorChange(){const e=()=>{this.transitionDelta<1&&(requestAnimationFrame(e),this.bgColor=function(e,t,i){return[g6(e[0],t[0],i),g6(e[1],t[1],i),g6(e[2],t[2],i),g6(e[3],t[3],i)]}(this.previousBgColor,this.targetBgColor,this.transitionDelta),this.transitionDelta+=.075,this.map.triggerRepaint())};requestAnimationFrame(e)}async animateIn(){if(!this.imageIsAnimating)return this.animationActive?new Promise(e=>{this.imageIsAnimating=!0;const t=()=>{this.imageFadeInDelta=Math.min(this.imageFadeInDelta+.05,1),this.currentFadeOpacity=g6(0,1,this.imageFadeInDelta),this.map.triggerRepaint(),this.imageFadeInDelta<1?requestAnimationFrame(t):(this.imageIsAnimating=!1,this.imageFadeInDelta=0,e())};requestAnimationFrame(t)}):(this.currentFadeOpacity=1,this.imageFadeInDelta=1,void this.map.triggerRepaint())}async animateOut(){if(!this.imageIsAnimating&&this.animationActive)return new Promise(e=>{const t=()=>{if(this.imageFadeInDelta=Math.min(this.imageFadeInDelta+.05,1),this.currentFadeOpacity=g6(1,0,this.imageFadeInDelta),this.map.triggerRepaint(),this.imageFadeInDelta>=1)return this.imageIsAnimating=!1,this.imageFadeInDelta=0,void e();requestAnimationFrame(t)};requestAnimationFrame(t)})}setAnimationActive(e){this.animationActive=e}render(e,t){if(!this.map.isGlobeProjection())return;if(void 0===this.map)throw new Error("[CubemapLayer]: Map is undefined");if(void 0===this.cubemap)throw new Error("[CubemapLayer]: Cubemap is undefined");this.texture,e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.DST_ALPHA),e.useProgram(this.cubemap.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.cubemap.positionBuffer),e.vertexAttribPointer(this.cubemap.programInfo.attributesLocations.vertexPosition,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(this.cubemap.programInfo.attributesLocations.vertexPosition);const i=e.canvas,n=i.clientWidth/i.clientHeight,r=this.map.transform,o=r.fov*(Math.PI/180),s=L5();H5(s,o,n,.1,1e4),k5(s,s,r.rollInRadians),F5(s,s,-r.pitchInRadians),k5(s,s,r.bearingInRadians);const a=r.center.lat*Math.PI/180,l=r.center.lng*Math.PI/180;F5(s,s,a),function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r}(s,s,-l),e.uniformMatrix4fv(this.cubemap.programInfo.uniformsLocations.projectionMatrix,!1,s);const c=L5();if(e.uniformMatrix4fv(this.cubemap.programInfo.uniformsLocations.modelViewMatrix,!1,c),e.uniform4fv(this.cubemap.programInfo.uniformsLocations.bgColor,new Float32Array(this.bgColor)),e.uniform1f(this.cubemap.programInfo.uniformsLocations.fadeOpacity,this.currentFadeOpacity),this.useCubemapTexture&&this.texture&&(e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this.texture),e.uniform1i(this.cubemap.programInfo.uniformsLocations.cubeSampler,0)),void 0===this.cubemap.indexBuffer)throw new Error("Index buffer is undefined");if(void 0===this.cubemap.indexBufferLength)throw new Error("Index buffer length is undefined");e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.cubemap.indexBuffer),e.drawElements(e.TRIANGLES,this.cubemap.indexBufferLength,e.UNSIGNED_SHORT,0)}setBgColor(e){this.targetBgColor=e,this.previousBgColor=this.bgColor,this.transitionDelta=0}getConfig(){return this.options}shouldUpdate(e){const t=this.getConfig();if(void 0===e&&t)return!1;const i=_6(e),n=_6(t);return JSON.stringify(i)!==JSON.stringify(n)}async setCubemapFaces(e){if(await this.animateOut(),!e.faces&&!e.preset&&!e.path)return this.faces=null,this.useCubemapTexture=!1,this.currentFacesDefinitionKey="empty",void await this.animateIn();this.faces=E6(e),this.currentFacesDefinitionKey=JSON.stringify(e.faces??e.preset??e.path)}async setCubemap(e){const t="boolean"==typeof e?b6:e;this.options=t;const i=JSON.stringify(t.faces??t.preset??t.path),n=this.currentFacesDefinitionKey!==i;n&&(await this.setCubemapFaces(t),this.cubeMapNeedsUpdate=!0);const r=t6(t.color);if(t.color&&this.targetBgColor.toString()!==r.toString())this.setBgColor(r);else if(!t.color&&t.preset&&t.preset in u6){const e=u6[t.preset];this.setBgColor(t6(e.color))}this.updateCubemap({facesNeedUpdate:n})}show(){this.map.setLayoutProperty(this.id,"visibility","visible")}hide(){this.map.setLayoutProperty(this.id,"visibility","none")}}function T6(e){return!!e&&("boolean"==typeof e||!(!e.path&&!e.preset&&!e.faces&&!e.color||e.preset&&!(e.preset in u6)||e.faces&&(!e.faces.pX||!e.faces.nX||!e.faces.pY||!e.faces.nY||!e.faces.pZ||!e.faces.nZ)))}function E6(e){if(e.faces)return e.faces;if(e.preset)return{pX:`${A6}/${e.preset}/px.webp`,nX:`${A6}/${e.preset}/nx.webp`,pY:`${A6}/${e.preset}/py.webp`,nY:`${A6}/${e.preset}/ny.webp`,pZ:`${A6}/${e.preset}/pz.webp`,nZ:`${A6}/${e.preset}/nz.webp`};if(e.path){const t=e.path.baseUrl,i=e.path.format??"png";return{pX:`${t}/px.${i}`,nX:`${t}/nx.${i}`,pY:`${t}/py.${i}`,nY:`${t}/ny.${i}`,pZ:`${t}/pz.${i}`,nZ:`${t}/nz.${i}`}}return null}const C6=["position"],S6=["matrix","rotationMatrix","stopsNumber","stops","colors","maxDistance","scale"],B6=[-2,-2,0,2,-2,0,-2,2,0,2,2,0],I6={scale:.9,stops:[[0,"rgba(176, 208, 240, 1)"],[.1,"rgba(98, 168, 229, 0.3)"],[.2,"rgba(98, 168, 229, 0.0)"]]};class M6{constructor(e){if(HY(this,"id","Halo Layer"),HY(this,"type","custom"),HY(this,"renderingMode","3d"),HY(this,"gradient"),HY(this,"scale",0),HY(this,"animationDelta",0),HY(this,"map"),HY(this,"plane"),HY(this,"animationActive",!0),"boolean"==typeof e)return void(this.gradient=I6);const t=R6(e);if(t.length>0)throw new Error(`[RadialGradientLayer]: Invalid Halo specification:\n - ${t.join("\n - ")}\n `);this.gradient={...I6,...e}}onAdd(e,t){this.map=e,this.plane=e6({gl:t,vertexShaderSource:"attribute vec3 a_position;\n\nuniform mat4 u_matrix;\nuniform mat4 u_rotationMatrix;\n\nuniform float u_scale;\n\nvarying vec2 v_pos;\nvarying float v_scale;\n\nvoid main() {\n v_scale = u_scale;\n v_pos = a_position.xy * u_scale;\n gl_Position = u_matrix * u_rotationMatrix * vec4(a_position, 1.0);\n}\n",fragmentShaderSource:"precision mediump float;\nvarying vec2 v_pos;\n \nuniform int u_stopsNumber;\nuniform float u_stops[100];\nuniform vec4 u_colors[100];\nuniform float u_maxDistance;\n\nvarying float v_scale;\n\nconst float EPSILON = 0.000001;\n\nvec2 center = vec2(0.0, 0.0);\nvoid main() {\n float rawDistance = distance(center, v_pos);\n float distanceFromGlobeEdge = rawDistance - 1.0;\n\n vec4 color = u_colors[0];\n\n // if we're further than the max distance, we should not render anything.\n // This is to always render a circle, otherwise we end up rendering\n // to the corners of the plane.\n if (distance(center, v_pos) > u_maxDistance * v_scale) {\n discard;\n }\n\n for (int i = 1; i < 100; i++) {\n // if we're past the last stop\n // we should fill to the end with the last stop color\n if (i >= u_stopsNumber) {\n color = u_colors[i - 1];\n break;\n }\n\n float scaledStopPosition = u_stops[i] * pow(v_scale, 1.6);\n float lastStopValue = u_stops[i - 1];\n float thisStopValue = u_stops[i];\n\n // this is to avoid blending errors when the stops are the same\n // eg when you would want a sharp edge between two stops.\n // `numbersAreEqual` will be 1.0 if the numbers are equal, 0.0 if they are not.\n // We then subtract EPSILON from the last stop making the stop value _almost_ equal\n // to the next stop but not enough to cause blending issues.\n // It's more efficient to do this than an if / else statement.\n float numbersAreEqual = 1.0 - step(EPSILON, abs(lastStopValue - thisStopValue));\n lastStopValue = lastStopValue - numbersAreEqual * EPSILON;\n\n float lastScaledStopPosition = lastStopValue * pow(v_scale, 1.6);\n\n if (distanceFromGlobeEdge <= scaledStopPosition) {\n float stopBlendFactor = (distanceFromGlobeEdge - lastScaledStopPosition) / (scaledStopPosition - lastScaledStopPosition);\n color = mix(u_colors[i - 1], u_colors[i], stopBlendFactor);\n break;\n }\n }\n \n // gl_FragColor = color;\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n",attributesKeys:C6,uniformsKeys:S6,vertices:B6}),this.animateIn()}getConfig(){return this.gradient}shouldUpdate(e){const t=this.getConfig();if(void 0===e&&t)return!1;const i=_6(e),n=_6(t);return JSON.stringify(i)!==JSON.stringify(n)}async animateIn(){return this.animationActive?new Promise(e=>{this.animationDelta=0;const t=()=>{if(this.animationDelta<1)return this.scale=g6(0,this.gradient.scale,this.animationDelta),this.animationDelta+=.06,this.map.triggerRepaint(),void requestAnimationFrame(t);e()};requestAnimationFrame(t)}):(this.scale=this.gradient.scale,this.animationDelta=1,void this.map.triggerRepaint())}async animateOut(){if(this.animationActive)return this.animationDelta=0,new Promise(e=>{const t=()=>{if(this.animationDelta<1)return this.scale=g6(this.gradient.scale,0,this.animationDelta),this.animationDelta+=.06,this.map.triggerRepaint(),void requestAnimationFrame(t);e()};t()})}onRemove(e,t){void 0!==this.plane&&(t.deleteProgram(this.plane.shaderProgram),t.deleteBuffer(this.plane.positionBuffer))}prerender(e,t){}render(e,t){if(void 0===this.map)throw new Error("[RadialGradientLayer]: Map is undefined");if(!this.map.isGlobeProjection())return;if(void 0===this.plane)throw new Error("[RadialGradientLayer]: Plane is undefined");e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.useProgram(this.plane.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.plane.positionBuffer);const i=this.plane.programInfo.attributesLocations.position;e.enableVertexAttribArray(i),e.vertexAttribPointer(i,3,e.FLOAT,!1,0,0);const n=L5(),r=this.scale;!function(e,t,i){var n=i[0],r=i[1],o=i[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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]}(n,n,[r,r,r]);const o=L5();!function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*n+v*a+x*h+b*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*n+v*a+x*h+b*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*n+v*a+x*h+b*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A}(o,t.defaultProjectionData.mainMatrix,n);const s=this.plane.programInfo.uniformsLocations.matrix;e.uniformMatrix4fv(s,!1,o);const a=L5(),l=this.map.transform.cameraPosition,c=$5(Q5(),l),u=function(e,t,i){var n=new R5(3);return n[0]=e,n[1]=t,n[2]=i,n}(0,1,0),h=Q5();Z5(h,u,c),$5(h,h);const d=Q5();Z5(d,c,h),$5(d,d),function(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){e[0]=t,e[1]=i,e[2]=n,e[3]=r,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=u,e[10]=h,e[11]=d,e[12]=p,e[13]=f,e[14]=m,e[15]=g}(a,h[0],h[1],h[2],0,d[0],d[1],d[2],0,c[0],c[1],c[2],0,0,0,0,1);const p=this.plane.programInfo.uniformsLocations.rotationMatrix;e.uniformMatrix4fv(p,!1,a);const f=this.gradient.stops.length,m=[],g=[];for(let e=0;e<=f;e++)if(e0)throw new Error(`[RadialGradientLayer]: Invalid Halo specification:\n - ${t.join("\n - ")}\n `);!0===e?(this.gradient.scale=I6.scale,this.gradient.stops=I6.stops):(this.gradient.scale=e.scale??I6.scale,this.gradient.stops=e.stops??I6.stops),await this.animateIn()}setAnimationActive(e){this.animationActive=e}show(){this.map.setLayoutProperty(this.id,"visibility","visible")}hide(){this.map.setLayoutProperty(this.id,"visibility","none")}}const P6=["scale","stops"];function R6(e){var t;const i=[];if("boolean"==typeof e)return[];try{const t=Object.keys(e).filter(e=>!P6.includes(e));t.length>0&&i.push(`Properties ${t.map(e=>`\`${e}\``).join(", ")} are not supported.`)}catch{i.push("Halo specification is not an object.")}return"number"!=typeof e.scale&&i.push("Halo `scale` property is not a number."),(!e.stops||0===e.stops.length)&&i.push("Halo `stops` property is not an array."),null!=(t=e.stops)&&t.some(e=>"number"!=typeof e[0]||"string"!=typeof e[1])&&i.push("Halo `stops` property is not an array of [number, string]"),i}const L6={POINT:"POINT",COUNTRY:"COUNTRY"};let F6=class e extends tJ.Map{constructor(e){(function(e){const t=V0();if(!t)return;let i=null;if("string"==typeof e?i=document.getElementById(e):e instanceof HTMLElement&&(i=e),!i)throw new Error("The Map container must be provided.");const n=document.createElement("div");throw n.innerHTML=t,n.classList.add("webgl-warning-div"),i.appendChild(n),new Error(t)})(e.container),e.apiKey&&(C0.apiKey=e.apiKey);const{style:t,requiresUrlMonitoring:i,isFallback:n}=X4(e.style);n&&console.warn("Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Fallback to default MapTiler style."),C0.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!");const r=location.hash;let o={compact:!1};e.customAttribution?o.customAttribution=e.customAttribution:e.attributionControl&&"object"==typeof e.attributionControl&&(o={...o,...e.attributionControl});const s={...e,style:t,maplibreLogo:!1,transformRequest:z0(e.transformRequest),attributionControl:!0!==e.forceNoAttributionControl&&o};delete s.style,super(s),HY(this,"telemetry"),HY(this,"space"),HY(this,"halo"),HY(this,"options"),HY(this,"isTerrainEnabled",!1),HY(this,"terrainExaggeration",1),HY(this,"primaryLanguage"),HY(this,"terrainGrowing",!1),HY(this,"terrainFlattening",!1),HY(this,"minimap"),HY(this,"forceLanguageUpdate"),HY(this,"languageAlwaysBeenStyle"),HY(this,"isReady",!1),HY(this,"terrainAnimationDuration",1e3),HY(this,"monitoredStyleUrls"),HY(this,"styleInProcess",!1),HY(this,"curentProjection"),HY(this,"originalLabelStyle",new window.Map),HY(this,"isStyleLocalized",!1),HY(this,"languageIsUpdated",!1),this.options=e,this.setStyle(t),i&&this.monitorStyleUrl(t);const a=()=>{let e="The distant style could not be loaded.";this.getStyle()?e+=" Leaving the style as is.":(this.setStyle(aY.STREETS),e+=`Loading default MapTiler Cloud style "${aY.STREETS.getDefaultVariant().getId()}" as a fallback.`),console.warn(e)};if(this.on("style.load",()=>{this.styleInProcess=!1}),this.on("error",e=>{if(console.error(e.error),e.error instanceof tJ.AJAXError){const t=e.error.url,i=new URL(t);i.search="";const n=i.href;return void(this.monitoredStyleUrls&&this.monitoredStyleUrls.has(n)&&(this.monitoredStyleUrls.delete(n),a()))}this.styleInProcess&&a()}),C0.caching&&!M0&&console.warn("The cache API is only available in secure contexts. More info at https://developer.mozilla.org/en-US/docs/Web/API/Cache"),C0.caching&&M0&&D0(),typeof e.language>"u")this.primaryLanguage=C0.primaryLanguage;else{const t=NJ(e.language,x0);this.primaryLanguage=t??C0.primaryLanguage}this.forceLanguageUpdate=!(this.primaryLanguage===x0.STYLE||this.primaryLanguage===x0.STYLE_LOCK),this.languageAlwaysBeenStyle=this.primaryLanguage===x0.STYLE,this.terrainExaggeration=e.terrainExaggeration??this.terrainExaggeration,this.curentProjection=e.projection,this.on("style.load",e=>{"mercator"===this.curentProjection?this.setProjection({type:"mercator"}):"globe"===this.curentProjection&&this.setProjection({type:"globe"})}),this.once("styledata",async()=>{if(!e.geolocate||e.center||e.hash&&r)return;try{if(e.geolocate===L6.COUNTRY)return void await this.fitToIpBounds()}catch(e){console.warn(e.message)}let t;try{await this.centerOnIpPoint(e.zoom),t=this.getCameraHash()}catch(e){console.warn(e.message)}"granted"===(await navigator.permissions.query({name:"geolocation"})).state&&navigator.geolocation.getCurrentPosition(i=>{t===this.getCameraHash()&&(this.terrain?this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:e.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:e.zoom||12,duration:2e3})}))},null,{maximumAge:864e5,timeout:5e3,enableHighAccuracy:!1})}),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage)}),this.on("styledata",()=>{null===this.getTerrain()&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",async()=>{let t={logo:null};try{const e=Object.keys(this.style.sourceCaches).map(e=>this.getSource(e)).filter(e=>e&&"url"in e&&"string"==typeof e.url&&e.url.includes("tiles.json")),i=new URL(e[0].url);i.searchParams.has("key")||i.searchParams.append("key",C0.apiKey),t=await(await fetch(i.href)).json()}catch{}if(e.customControls){const t="[data-maptiler-control-group]",i="[data-maptiler-control]",n=e=>{let t=e.dataset.maptilerControl;return("true"===t||""===t)&&(t=void 0),t},r=e=>e.dataset.maptilerPosition;let o=[...this._container.ownerDocument.querySelectorAll(t)],s=[...this._container.ownerDocument.querySelectorAll(i)].filter(e=>null===e.closest(t));if("string"==typeof e.customControls){const t=e.customControls;o=o.filter(e=>e.matches(t)||null!==e.closest(t)),s=s.filter(e=>e.matches(t)||null!==e.closest(t))}for(const e of o){const t=new I5(e);this.addControl(t,r(e));for(const r of e.querySelectorAll(i))t.configureGroupItem(r,n(r))}for(const e of s)this.addControl(new I5(e,n(e)),r(e));const a=()=>{const{lng:e,lat:t}=this.getCenter();this._container.style.setProperty("--maptiler-center-lng",String(e)),this._container.style.setProperty("--maptiler-center-lat",String(t)),this._container.style.setProperty("--maptiler-zoom",String(this.getZoom())),this._container.style.setProperty("--maptiler-bearing",String(this.getBearing())),this._container.style.setProperty("--maptiler-pitch",String(this.getPitch())),this._container.style.setProperty("--maptiler-roll",String(this.getRoll())),this._container.style.setProperty("--maptiler-is-globe-projection",String(this.isGlobeProjection())),this._container.style.setProperty("--maptiler-has-terrain",String(this.hasTerrain()))};a(),this.on("render",a)}if(!0!==e.forceNoAttributionControl)if("logo"in t&&t.logo){const i=t.logo;this.addControl(new S0({logoURL:i}),e.logoPosition)}else e.maptilerLogo&&this.addControl(new S0,e.logoPosition);if(e.scaleControl){const t=!0===e.scaleControl||void 0===e.scaleControl?"bottom-right":e.scaleControl,i=new u0({unit:C0.unit});this.addControl(i,t),C0.on("unit",e=>{i.setUnit(e)})}if(!1!==e.navigationControl){const t=!0===e.navigationControl||void 0===e.navigationControl?"top-right":e.navigationControl;this.addControl(new n5,t)}if(!1!==e.geolocateControl){const t=!0===e.geolocateControl||void 0===e.geolocateControl?"top-right":e.geolocateControl;this.addControl(new a5({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),t)}if(e.terrainControl){const t=!0===e.terrainControl||void 0===e.terrainControl?"top-right":e.terrainControl;this.addControl(new t5,t)}if(e.projectionControl){const t=!0===e.projectionControl||void 0===e.projectionControl?"top-right":e.projectionControl;this.addControl(new f5,t)}if(e.fullscreenControl){const t=!0===e.fullscreenControl||void 0===e.fullscreenControl?"top-right":e.fullscreenControl;this.addControl(new h0({}),t)}this.isReady=!0,this.fire("ready",{target:this})});let l,c=!1,u=!1;this.once("ready",()=>{c=!0,u&&this.fire("loadWithTerrain",l)}),this.once("style.load",()=>{const{minimap:t}=e;if("object"==typeof t){const{zoom:i,center:n,style:r,language:o,apiKey:s,maptilerLogo:a,canvasContextAttributes:l,refreshExpiredTiles:c,maxBounds:u,scrollZoom:h,minZoom:d,maxZoom:p,boxZoom:f,locale:m,fadeDuration:g,crossSourceCollisions:_,clickTolerance:A,bounds:y,fitBoundsOptions:v,pixelRatio:x,validateStyle:b}=e;this.minimap=new M5(t,{zoom:i,center:n,style:r,language:o,apiKey:s,container:"null",maptilerLogo:a,canvasContextAttributes:l,refreshExpiredTiles:c,maxBounds:u,scrollZoom:h,minZoom:d,maxZoom:p,boxZoom:f,locale:m,fadeDuration:g,crossSourceCollisions:_,clickTolerance:A,bounds:y,fitBoundsOptions:v,pixelRatio:x,validateStyle:b}),this.addControl(this.minimap,t.position??"bottom-left")}else!0===t?(this.minimap=new M5({},e),this.addControl(this.minimap,"bottom-left")):void 0!==t&&!1!==t&&(this.minimap=new M5({},e),this.addControl(this.minimap,t))});const h=e=>{e.terrain&&(u=!0,l={type:"loadWithTerrain",target:this,terrain:e.terrain},this.off("terrain",h),c&&this.fire("loadWithTerrain",l))};this.on("terrain",h),e.terrain&&this.enableTerrain(e.terrainExaggeration??this.terrainExaggeration),this.once("load",()=>{this.getCanvas().addEventListener("webglcontextlost",e=>{!0!==this._removed?(console.warn("[webglcontextlost]","Unexpected loss of WebGL context!"),this.fire("webglContextLost",e)):console.warn("[webglcontextlost]","WebGL context lost after map removal. This is harmless.")}),e.halo&&this.initHalo({options:e,before:this.getLayersOrder()[0]}),e.space&&this.initSpace({options:e,before:this.getLayersOrder()[0]})}),this.telemetry=new P5(this)}getSpace(){return this.space}setSpace(e,t=!0){if(t&&(this.options.space=e),!1!==e)return this.space?(this.space.setCubemap(e),void(this.getLayer(this.space.id)||this.addLayer(this.space,this.getLayersOrder()[0]))):(this.space=new w6(e),void this.once("load",()=>{const e=this.getLayersOrder()[0];this.space&&this.addLayer(this.space,e)}));this.space=void 0}enableSpaceAnimations(){this.setSpaceAnimationActive(!0)}disableSpaceAnimations(){this.setSpaceAnimationActive(!1)}enableHaloAnimations(){this.setHaloAnimationActive(!0)}disableHaloAnimations(){this.setHaloAnimationActive(!1)}setHaloAnimationActive(e){this.halo?this.halo.setAnimationActive(e):this.once("load",()=>{var t;null==(t=this.halo)||t.setAnimationActive(e)})}setSpaceAnimationActive(e){this.space?this.space.setAnimationActive(e):this.once("load",()=>{var t;null==(t=this.space)||t.setAnimationActive(e)})}setSpaceFromSpec({spec:e}){var t;if(!1===this.options.space)return;if("boolean"==typeof e)return void this.setSpace(e,!0);if(!0!==this.options.space&&T6(this.options.space))return void this.setSpace(this.options.space,!0);const i=T6(e);if(JSON.stringify(null==(t=this.space)?void 0:t.getConfig())!==JSON.stringify(e))i?this.setSpace(e,!1):!0!==this.options.space?(()=>{this.space&&this.isGlobeProjection()&&this.space.setCubemap(e)})():this.setSpace(!0);else if(this.space&&!this.getLayer(this.space.id)){const e=this.getLayersOrder()[0];this.addLayer(this.space,e)}}setHaloFromSpec({spec:e}){var t,i;if(!1!==this.options.halo){if("boolean"==typeof e)return console.log("spec is boolean",e),void this.setHalo(e);if(JSON.stringify(null==(t=this.halo)?void 0:t.getConfig())!==JSON.stringify(e)){if(!e&&!this.options.halo)return console.log("spec is false, and options.halo is false"),void this.setHalo({stops:[[0,"transparent"],[1,"transparent"]],scale:1});(()=>{var t;if(console.log("updateHalo",e),this.halo){if(console.log("halo exists",this.getLayer(this.halo.id)),!this.getLayer(this.halo.id)){console.log("halo not in map, adding it");const e=this.getLayersOrder().indexOf((null==(t=this.space)?void 0:t.id)??"")+1,i=this.getLayersOrder()[e];this.addLayer(this.halo,i)}e&&(console.log("SET HALO FROM SPEC",e),this.halo.setGradient(e))}})()}else if(console.log("HALO IS THE SAME",e),this.halo&&!this.getLayer(this.halo.id)){const e=this.getLayersOrder().indexOf((null==(i=this.space)?void 0:i.id)??"")+1,t=this.getLayersOrder()[e];this.addLayer(this.halo,t)}}else console.log("options.halo is false")}initSpace({options:e=this.options,before:t=this.getLayersOrder()[0],spec:i}){if(this.space)return void(this.getLayer(this.space.id)||this.addLayer(this.space,t));if(!1===e.space)return;const n=i;if(e.space)return this.space=new w6(e.space),void this.addLayer(this.space,t);n&&(this.space=new w6(n),this.addLayer(this.space,t))}initHalo({options:e=this.options,before:t=this.getLayersOrder()[0],spec:i}){if(this.halo&&this.getLayer(this.halo.id)||!1===e.halo)return;const n=i;if(e.halo)return this.halo=new M6(e.halo),void this.addLayer(this.halo,t);n&&(this.halo=new M6(n),this.addLayer(this.halo,t))}getHalo(){return this.halo}setHalo(e){if(this.options.halo=e,this.isGlobeProjection()){if(this.halo)return void this.halo.setGradient(e);this.halo=new M6(e),this.once("load",()=>{var e;const t=this.getLayersOrder(),i=t[0],n=t.indexOf((null==(e=this.space)?void 0:e.id)??"")+2,r=t[n];this.halo&&this.addLayer(this.halo,this.space?r:i)})}}recreate(){const t={center:this.getCenter(),zoom:this.getZoom(),bearing:this.getBearing(),pitch:this.getPitch()};this.remove(),Object.assign(this,new e({...this.options})),this.once("load",()=>{this.jumpTo(t)})}setTerrainAnimationDuration(e){this.terrainAnimationDuration=Math.max(e,0)}async onLoadAsync(){return new Promise(e=>{this.loaded()?e(this):this.once("load",()=>{e(this)})})}async onReadyAsync(){return new Promise(e=>{this.isReady?e(this):this.once("ready",()=>{e(this)})})}async onLoadWithTerrainAsync(){return new Promise(e=>{this.isReady&&this.terrain?e(this):this.once("loadWithTerrain",()=>{e(this)})})}monitorStyleUrl(e){typeof this.monitoredStyleUrls>"u"&&(this.monitoredStyleUrls=new Set);const t=new URL(e);t.search="",this.monitoredStyleUrls.add(t.href)}setStyle(e,t={}){var i,n,r,o,s;const a={transformStyle:(e,t)=>{var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w;const T=!(null!=(n=null==(i=null==t?void 0:t.metadata)?void 0:i.maptiler)&&n.space||null==(o=null==(r=null==e?void 0:e.metadata)?void 0:r.maptiler)||!o.space),E=!(null!=(a=null==(s=null==t?void 0:t.metadata)?void 0:s.maptiler)&&a.halo||null==(c=null==(l=null==e?void 0:e.metadata)?void 0:l.maptiler)||!c.halo);T&&(console.trace("space has been removed from style, removing it"),null==(u=this.space)||u.onRemove(this,this.getCanvas().getContext("webgl2")),this.space=void 0),E&&(console.trace("halo has been removed from style, removing it"),null==(h=this.halo)||h.onRemove(this,this.getCanvas().getContext("webgl2")),this.halo=void 0);const C=!this.space||this.space.shouldUpdate(null==(p=null==(d=null==t?void 0:t.metadata)?void 0:d.maptiler)?void 0:p.space),S=!this.halo||this.halo.shouldUpdate(null==(m=null==(f=null==t?void 0:t.metadata)?void 0:f.maptiler)?void 0:m.halo),B=(null==(g=null==e?void 0:e.terrain)?void 0:g.source)!==(null==(_=null==t?void 0:t.terrain)?void 0:_.source)||(null==(A=null==e?void 0:e.terrain)?void 0:A.exaggeration)!==(null==(y=null==t?void 0:t.terrain)?void 0:y.exaggeration),I=S||B;if(C||B)try{const e=(null==(x=null==(v=null==t?void 0:t.metadata)?void 0:v.maptiler)?void 0:x.space)??!1;this.once("style.load",()=>{var t;this.getLayer((null==(t=this.space)?void 0:t.id)??"")?this.setSpaceFromSpec({spec:e}):this.initSpace({spec:e})})}catch(e){console.error(e)}if(I)try{const e=(null==(w=null==(b=null==t?void 0:t.metadata)?void 0:b.maptiler)?void 0:w.halo)??!1;this.once("style.load",()=>{var t;this.getLayer((null==(t=this.halo)?void 0:t.id)??"")?this.setHaloFromSpec({spec:e}):this.initHalo({spec:e})})}catch(e){console.error(e)}return{...t}},diff:!0,...t};this.originalLabelStyle.clear(),null==(i=this.minimap)||i.setStyle(e,{}),this.forceLanguageUpdate=!0,this.once("idle",()=>{this.forceLanguageUpdate=!1});const l=X4(e);if(l.requiresUrlMonitoring&&this.monitorStyleUrl(l.style),l.isFallback){if(this.getStyle())return console.warn("[Map.setStyle]: Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Keeping the curent style instead."),this;console.warn("[Map.setStyle]: Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Fallback to default MapTiler style.")}try{super.setStyle(l.style,a),this.styleInProcess=!0}catch(e){this.styleInProcess=!1,console.error("[Map.setStyle]: Error while setting style:",e)}try{if(l.isJSON){const e=null==(r=null==(n=l.style.metadata)?void 0:n.maptiler)?void 0:r.halo,t=null==(s=null==(o=l.style.metadata)?void 0:o.maptiler)?void 0:s.space;e&&this.setHalo(e),t&&this.setSpace(t)}}catch(e){console.error("[Map.setStyle]: Error while setting halo or space from style:",e)}return this}addLayer(e,t){var i;return null==(i=this.minimap)||i.addLayer(e,t),super.addLayer(e,t)}moveLayer(e,t){var i;return null==(i=this.minimap)||i.moveLayer(e,t),super.moveLayer(e,t)}removeLayer(e){var t;return null==(t=this.minimap)||t.removeLayer(e),super.removeLayer(e)}setLayerZoomRange(e,t,i){var n;return null==(n=this.minimap)||n.setLayerZoomRange(e,t,i),super.setLayerZoomRange(e,t,i)}setFilter(e,t,i){var n;return null==(n=this.minimap)||n.setFilter(e,t,i),super.setFilter(e,t,i)}setPaintProperty(e,t,i,n){var r;return null==(r=this.minimap)||r.setPaintProperty(e,t,i,n),super.setPaintProperty(e,t,i,n)}setLayoutProperty(e,t,i,n){var r;return null==(r=this.minimap)||r.setLayoutProperty(e,t,i,n),super.setLayoutProperty(e,t,i,n)}setGlyphs(e,t){var i;return null==(i=this.minimap)||i.setGlyphs(e,t),super.setGlyphs(e,t)}getStyleLanguage(){return this.style&&this.style.stylesheet&&this.style.stylesheet.metadata&&"object"==typeof this.style.stylesheet.metadata&&"maptiler:language"in this.style.stylesheet.metadata&&"string"==typeof this.style.stylesheet.metadata["maptiler:language"]?OJ(this.style.stylesheet.metadata["maptiler:language"]):null}setLanguage(e){var t;null==(t=this.minimap)||t.map.setLanguage(e),this.onStyleReady(()=>{this.setPrimaryLanguage(e)})}setPrimaryLanguage(e){const t=this.getStyleLanguage(),i=NJ(e,x0);if(!i)return void console.warn(`The language "${i}" is not supported.`);if((i.flag!==x0.STYLE.flag||!t||t.flag!==x0.AUTO.flag&&t.flag!==x0.VISITOR.flag)&&(i.flag!==x0.STYLE.flag&&(this.languageAlwaysBeenStyle=!1),this.languageAlwaysBeenStyle||this.primaryLanguage===i&&!this.forceLanguageUpdate))return;if(this.primaryLanguage.flag===x0.STYLE_LOCK.flag)return void console.warn("The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag.");this.primaryLanguage=i;let n=i;if(i.flag===x0.STYLE.flag){if(!t)return void console.warn("The style has no default languages or has an invalid one.");n=t}let r=x0.LOCAL.flag,o=["get",r];n.flag===x0.VISITOR.flag?(r=b0().flag,o=["case",["all",["has",r],["has",x0.LOCAL.flag]],["case",["==",["get",r],["get",x0.LOCAL.flag]],["get",x0.LOCAL.flag],["format",["get",r],{"font-scale":.8},"\n",["get",x0.LOCAL.flag],{"font-scale":1.1}]],["get",x0.LOCAL.flag]]):n.flag===x0.VISITOR_ENGLISH.flag?(r=x0.ENGLISH.flag,o=["case",["all",["has",r],["has",x0.LOCAL.flag]],["case",["==",["get",r],["get",x0.LOCAL.flag]],["get",x0.LOCAL.flag],["format",["get",r],{"font-scale":.8},"\n",["get",x0.LOCAL.flag],{"font-scale":1.1}]],["get",x0.LOCAL.flag]]):n.flag===x0.AUTO.flag?(r=b0().flag,o=["coalesce",["get",r],["get",x0.LOCAL.flag]]):n===x0.LOCAL?(r=x0.LOCAL.flag,o=["get",r]):(r=n.flag,o=["coalesce",["get",r],["get",x0.LOCAL.flag]]);const{layers:s}=this.getStyle(),a=0===this.originalLabelStyle.size;if(a){const e=function(e,t){const i=[];for(const n of e){if("symbol"!==n.type)continue;const e=n,{id:r,layout:o}=e;if(!o||!("text-field"in o))continue;const s=t.getLayoutProperty(r,"text-field");if(s)if("string"==typeof s){const e=$0(s);i.push(e)}else{const e=W0(s);i.push(e)}}const n=i.flat(),r={unlocalized:0,localized:{}};for(const e of n)null===e?r.unlocalized+=1:(e in r.localized||(r.localized[e]=0),r.localized[e]+=1);return r}(s,this);this.isStyleLocalized=Object.keys(e.localized).length>0}for(const e of s){if("symbol"!==e.type)continue;const t=e,i=this.getSource(t.source);if(!i||!("url"in i)||"string"!=typeof i.url||new URL(i.url).host!==w0.maptilerApiHost)continue;const{id:n,layout:r}=t;if(!r||!("text-field"in r))continue;let s;if(a?(s=this.getLayoutProperty(n,"text-field"),this.originalLabelStyle.set(n,s)):s=this.originalLabelStyle.get(n),"string"==typeof s){const{contains:e,exactMatch:t}=H0(s,this.isStyleLocalized);if(!e)continue;if(t)this.setLayoutProperty(n,"text-field",o);else{const e=Q0(s,o,this.isStyleLocalized);this.setLayoutProperty(n,"text-field",e)}}else{const e=G0(s,o,this.isStyleLocalized);this.setLayoutProperty(n,"text-field",e)}}this.languageIsUpdated=!0}getPrimaryLanguage(){return this.primaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(e){if(!this.terrain)return;const t=performance.now(),i=this.terrain.exaggeration,n=e-i,r=()=>{if(!this.terrain||this.terrainFlattening)return;const o=(performance.now()-t)/this.terrainAnimationDuration;if(o<.99){const e=i+(1-(1-o)**4)*n;this.terrain.exaggeration=e,requestAnimationFrame(r)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=e,this.fire("terrainAnimationStop",{terrain:this.terrain});this._elevationFreeze=!1,this.triggerRepaint()};!this.terrainGrowing&&!this.terrainFlattening&&this.fire("terrainAnimationStart",{terrain:this.terrain}),this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(r)}enableTerrain(e=this.terrainExaggeration){if(e<0)return void console.warn("Terrain exaggeration cannot be negative.");const t=i=>{!this.terrain||"data"!==i.type||"source"!==i.dataType||!("source"in i)||"maptiler-terrain"!==i.sourceId||"raster-dem"!==i.source.type||i.isSourceLoaded&&(this.off("data",t),this.growTerrain(e))},i=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=e,this.on("data",t),this.addSource(w0.terrainSourceId,{type:"raster-dem",url:w0.terrainSourceURL}),this.setTerrain({source:w0.terrainSourceId,exaggeration:0})};if(this.getTerrain())return this.isTerrainEnabled=!0,void this.growTerrain(e);if(this.loaded()||this.isTerrainEnabled)i();else{const e=()=>{this.getTerrain()&&this.getSource(w0.terrainSourceId)||i()};this.once("load",()=>{e()}),this.once("moveend",()=>{e()})}}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const e=performance.now(),t=this.terrain.exaggeration,i=()=>{if(!this.terrain||this.terrainGrowing)return;const n=(performance.now()-e)/this.terrainAnimationDuration;if(this._elevationFreeze=!1,n<.99){const e=t*(1-n)**4;this.terrain.exaggeration=e,requestAnimationFrame(i)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(),this.getSource(w0.terrainSourceId)&&this.removeSource(w0.terrainSourceId),this.fire("terrainAnimationStop",{terrain:null});this.triggerRepaint()};!this.terrainGrowing&&!this.terrainFlattening&&this.fire("terrainAnimationStart",{terrain:this.terrain}),this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(i)}setTerrainExaggeration(e,t=!0){!t&&this.terrain?(this.terrainExaggeration=e,this.terrain.exaggeration=e,this.triggerRepaint()):this.enableTerrain(e)}onStyleReady(e){this.isStyleLoaded()?e():this.once("styledata",()=>{e()})}async fitToIpBounds(){const e=await KJ.info();this.fitBounds(e.country_bounds,{duration:0,padding:100})}async centerOnIpPoint(e){const t=await KJ.info();this.jumpTo({center:[t.longitude??0,t.latitude??0],zoom:e||11})}getCameraHash(){const e=new Float32Array(5),t=this.getCenter();return e[0]=t.lng,e[1]=t.lat,e[2]=this.getZoom(),e[3]=this.getPitch(),e[4]=this.getBearing(),fJ(new Uint8Array(e.buffer))}getSdkConfig(){return C0}getMaptilerSessionId(){return T0}setTransformRequest(e){return super.setTransformRequest(z0(e)),this}getProjection(){const e=this.style.getProjection();return void 0===!e&&this.style.projection?{type:this.style.projection.name}:e}isGlobeProjection(){const e=this.getProjection();return!!e&&"globe"===e.type}enableGlobeProjection(){!0!==this.isGlobeProjection()&&(this.setProjection({type:"globe"}),this.curentProjection="globe")}enableMercatorProjection(){!1!==this.isGlobeProjection()&&(this.setProjection({type:"mercator"}),this.curentProjection="mercator")}setProjection(e){return this.fire("projection.change",{target:this,projection:e}),super.setProjection(e)}isLanguageUpdated(){return this.languageIsUpdated}};class k6{constructor(e,t,i,n={}){HY(this,"type"),HY(this,"target"),HY(this,"originalEvent"),HY(this,"imageX"),HY(this,"imageY"),HY(this,"isOutOfBounds"),this.type=e,this.target=t,this.originalEvent=i??null,Object.assign(this,n)}}const D6=["idle","render","load","remove","idle"],O6=["error"],z6=["resize"],U6=["webglcontextlost","webglcontextrestored"],N6=["moveend","movestart","move","zoomend","zoomstart","zoom","rotatestart","rotateend","rotate","dragstart","dragend","drag","boxzoomcancel","boxzoomend","boxzoomstart"],V6=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseover","contextmenu","touchstart","touchend","touchmove","touchcancel"],j6=["cooperativegestureprevented"],G6=["data","dataloading","sourcedata","sourcedataloading","dataabort","sourcedataabort"],H6=[...D6,...O6,...z6,...U6,...N6,...V6,...G6,...j6],Q6=["lngLat","_defaultPrevented"];class $6 extends Error{constructor(e,t,i){const n=`[${i}]: Failed to fetch ${t} at ${e.url}: ${e.status.toString()}: ${e.statusText}`;super(n),HY(this,"status"),HY(this,"statusText"),this.name="FetchError",this.message=n,this.status=e.status,this.statusText=e.statusText}}function Z6(e,t,i){return Math.min(i,Math.max(t,e))}function W6(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function q6(e){return(180+e)/360}function K6(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function X6(e){e.transform.getConstrained=function(e,t){t=Z6(+t,this.minZoom,this.maxZoom);const i={center:new O9(e.lng,e.lat),zoom:t};let n=this._helper._lngRange;null===n&&(n=[-179.9999999999,179.9999999999]);const r=this.tileSize*function(e){return Math.pow(2,e)}(i.zoom);let o=0,s=r,a=0,l=r,c=0,u=0;const{x:h,y:d}=this.size,p=.5;if(this._helper._latRange){const e=this._helper._latRange;o=W6(e[1])*r,s=W6(e[0])*r,s-os&&(_=s-e)}if(n){const e=w*h/2;f-el&&(g=l-e)}if(void 0!==g||void 0!==_){const e=new Q9(g??f,_??m);i.center=function(e,t){return new U9(t.x/e,t.y/e).toLngLat()}(r,e).wrap()}return i}}const J6={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 Y6{constructor({imageViewer:e}){if(HY(this,"viewer"),HY(this,"container"),HY(this,"handleClick",()=>{this.viewer.fitImageToViewport({ease:!0})}),!e)throw new Error("ImageViewerFitImageToBoundsControl: an instance of 'ImageViewer' is required");this.viewer=e}onAdd(e){const t=document.createElement("button");this.container=document.createElement("div"),this.container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),t.classList.add("maplibregl-ctrl-fit-image-to-bounds");const i=document.createElement("span");return i.classList.add("maplibregl-ctrl-icon"),t.title="Zoom image to viewport bounds",t.appendChild(i),t.addEventListener("click",this.handleClick),this.container.appendChild(t),this.container}onRemove(){this.container.remove()}}const e8=Symbol("MapTiler:ImageViewer:Internal:lngLatToPxInternal"),t8=Symbol("MapTiler:ImageViewer:Internal:pxToLngLatInternal"),{Evented:i8}=tJ,n8={style:{version:8,sources:{},layers:[]},minPitch:0,maxPitch:0,pitch:0,bearing:0,projection:"mercator",geolocateControl:!1,navigationControl:!1,projectionControl:!1,hash:!1,renderWorldCopies:!1,terrain:!1,space:!1,halo:!1},r8={debug:!1,fitToBoundsControl:!0,navigationControl:!0};var o8,s8,a8;class l8 extends(a8=i8,s8=e8,o8=t8,a8){constructor(e){if(super(),HY(this,"imageUUID"),HY(this,"debug"),HY(this,"imageMetadata"),HY(this,"sdk"),HY(this,"options"),HY(this,"imageSize"),HY(this,"paddedSizeMax"),HY(this,"fitToBoundsControlInstance"),HY(this,"shouldFitImageToViewport",!0),HY(this,s8,this.lngLatToPx.bind(this)),HY(this,o8,this.pxToLngLat.bind(this)),!e.imageUUID)throw new Error("[ImageViewer]: `imageUUID` is required");if("string"!=typeof e.container&&!(e.container instanceof HTMLElement))throw new Error("[ImageViewer]: `container` is required and must be a string or HTMLElement");this.options={...r8,...e};const t={...this.options,...n8};delete t.center,this.sdk=new F6(t),this.sdk.telemetry.registerViewerType("ImageViewer");const{imageUUID:i,debug:n}=e;this.imageUUID=i,this.debug=n??!1,this.debug&&(this.sdk.showTileBoundaries=this.debug,this.sdk.showPadding=this.debug,this.sdk.showCollisionBoxes=this.debug,this.sdk.repaint=this.debug),this.init()}get version(){return this.sdk.version}async onReadyAsync(){try{await this.sdk.onReadyAsync(),await Promise.race([new Promise((e,t)=>{this.once("imageviewerready",t=>{e(t)}),this.once("imagevieweriniterror",e=>{t(e.error)})}),new Promise((e,t)=>{setTimeout(()=>{t(new Error("Timeout waiting for image viewer to be ready"))},5e3)})])}catch(e){throw e}}async init(){var e,t,i;try{await this.fetchImageMetadata(),this.addImageSource(),this.options.navigationControl&&this.sdk.addControl(new s0({visualizePitch:!1,visualizeRoll:!1})),this.fitToBoundsControlInstance=new Y6({imageViewer:this}),this.options.fitToBoundsControl&&this.sdk.addControl(this.fitToBoundsControlInstance),function({map:e,viewer:t,lngLatToPx:i}){H6.forEach(n=>{try{e.on(n,e=>{const r=n;if(V6.includes(r)){const r=e,o=r.lngLat&&i(r.lngLat),s=t.getImageMetadata(),a={isOutOfBounds:!s||o[0]<0||o[0]>s.width||o[1]<0||o[1]>s.height,imageX:o[0],imageY:o[1],...Object.fromEntries(Object.entries(e).filter(([e])=>!Q6.includes(e)))};return void t.fire(new k6(n,t,r.originalEvent,a))}const o=n;if(N6.includes(o)){const i=e;return void t.fire(new k6(n,t,i.originalEvent,i))}const s=n;if(O6.includes(s)){const i=e;return void t.fire(new k6(n,t,null,i))}const a=n;if(z6.includes(a)){const i=e;return void t.fire(new k6(n,t,null,i))}const l=n;if(U6.includes(l)){const i=e;return void t.fire(new k6(n,t,i.originalEvent,i))}const c=n;if(G6.includes(c)){const i=e;return void t.fire(new k6(n,t,null,i))}const u=n;if(j6.includes(u)){const i=e;return void t.fire(new k6(n,t,null,i))}const h=n;D6.includes(h)&&t.fire(new k6(n,t))})}catch(e){console.error(`Error forwarding event to ImageViewer, event of type "${n}" is not supported`,e)}})}({map:this.sdk,viewer:this,lngLatToPx:e=>this.lngLatToPx(e)}),X6(this.sdk);const{center:n,zoom:r,bearing:o}=this.options,s=n??[((null==(e=this.imageMetadata)?void 0:e.width)??0)/2,((null==(t=this.imageMetadata)?void 0:t.height)??0)/2];this.setCenter(s),this.setBearing(o??0),this.options.zoom?this.setZoom(r??(null==(i=this.imageMetadata)?void 0:i.maxzoom)??5):this.fitImageToViewport(),this.sdk.on("wheel",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("touchstart",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("drag",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("resize",()=>{var e,t;const i=this.getCenter(),n=(null==(e=this.imageMetadata)?void 0:e.width)??0,r=(null==(t=this.imageMetadata)?void 0:t.height)??0;this.shouldFitImageToViewport&&this.fitImageToViewport(),(i[0]!==n/2||i[1]!==r/2)&&this.setCenter(i)}),this.fire("imageviewerready",new k6("imageviewerready",this))}catch(e){this.fire("imagevieweriniterror",{error:e})}}fitImageToViewport({ease:e=!1}={}){if(!this.imageMetadata)throw new Error("[ImageViewer]: Image metadata not found");const t=this.pxToLngLat([0,0]),i=this.pxToLngLat([this.imageMetadata.width??0,this.imageMetadata.height??0]),n=this.sdk.cameraForBounds([t,i],{padding:50});n&&(e?this.sdk.easeTo({...n,pitch:0},null):this.sdk.jumpTo({...n,pitch:0},null)),this.shouldFitImageToViewport=!0}async fetchImageMetadata(){const e=function(e){return`https://api.maptiler.com/images/${e}/image.json?key=${C0.apiKey}`}(this.imageUUID),t=await fetch(e);if(!t.ok)throw new $6(t,"image metadata","ImageViewer");const i=await t.json();this.imageMetadata=i,Object.freeze(this.imageMetadata)}addImageSource(){if(!this.imageMetadata)throw this.fire("error",new k6("error",this,null,{error:new Error("[ImageViewer]: Image metadata not found")})),new Error("[ImageViewer]: Image metadata not found");const e=function(e){return`https://api.maptiler.com/images/${e}/{z}/{x}/{y}?key=${C0.apiKey}`}(this.imageUUID),t=e=>Math.pow(2,Math.ceil(Math.log(e)/Math.LN2));this.imageSize=[this.imageMetadata.width,this.imageMetadata.height],this.paddedSizeMax=Math.max(t(this.imageSize[0]),t(this.imageSize[1]));const i=this.pxToLngLat([0,0]),n=this.pxToLngLat(this.imageSize),r=[i.lng,n.lat,n.lng,i.lat];this.sdk.addSource("image",{...this.imageMetadata,type:"raster",bounds:r,tiles:[e]}),this.sdk.addLayer({id:"image",type:"raster",source:"image"})}triggerRepaint(){this.sdk.triggerRepaint()}get scrollZoom(){return this.sdk.scrollZoom}set scrollZoom(e){this.sdk.scrollZoom=e}get boxZoom(){return this.sdk.boxZoom}set boxZoom(e){this.sdk.boxZoom=e}get dragPan(){return this.sdk.dragPan}set dragPan(e){this.sdk.dragPan=e}get keyboard(){return this.sdk.keyboard}set keyboard(e){this.sdk.keyboard=e}get doubleClickZoom(){return this.sdk.doubleClickZoom}set doubleClickZoom(e){this.sdk.doubleClickZoom=e}get touchZoomRotate(){return this.sdk.touchZoomRotate}set touchZoomRotate(e){this.sdk.touchZoomRotate=e}get cooperativeGestures(){return this.sdk.cooperativeGestures}set cooperativeGestures(e){this.sdk.cooperativeGestures=e}lngLatToPx(e){if(!this.paddedSizeMax){const e="[ImageViewer]: Unable to convert LngLat to px, padded size max not set";throw this.fire("error",new k6("error",this,null,{error:new Error(e)})),new Error(e)}const t=U9.fromLngLat(e);return[t.x*this.paddedSizeMax,t.y*this.paddedSizeMax]}pxToLngLat(e){if(!this.paddedSizeMax){const e="[ImageViewer]: Unable to convert px to LngLat, padded size max not set";throw this.fire("error",new k6("error",this,null,{error:new Error(e)})),new Error(e)}return new U9(e[0]/this.paddedSizeMax,e[1]/this.paddedSizeMax).toLngLat()}getSDKInternal(){return this.sdk}getCanvas(){return this.sdk.getCanvas()}flyTo(e,t){const i=this.pxToLngLat(e.center);return this.sdk.flyTo({...e,pitch:0,center:i},t),this}jumpTo(e,t){const i=this.pxToLngLat(e.center);return this.sdk.jumpTo({...e,pitch:0,center:i},t),this}setZoom(e){return this.sdk.setZoom(e),this}getZoom(){return this.sdk.getZoom()}getCenter(){const e=this.sdk.getCenter();return this.lngLatToPx(e)}setCenter(e){return this.sdk.setCenter(this.pxToLngLat(e)),this}setBearing(e){return this.sdk.setBearing(e),this}getBearing(){return this.sdk.getBearing()}panBy(e,t,i){return this.sdk.panBy(e,{...t,pitch:0},i),this}panTo(e,t,i){return this.sdk.panTo(this.pxToLngLat(e),{...t,pitch:0},i),this}getImageMetadata(){return this.imageMetadata}getImageBounds(){const e=this.sdk.getBounds().toArray().map(e=>this.lngLatToPx(O9.convert(e)));return[[e[0][0],e[1][1]],[e[1][0],e[0][1]]]}fitImageBounds([e,t]){const i=this.pxToLngLat(e),n=this.pxToLngLat(t),r=z9.convert([i,n]);return this.sdk.fitBounds(r),this}remove(){this.fire("beforeremove",new k6("beforeremove",this)),this.sdk.remove(),this._listeners&&Object.entries(this._listeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this._oneTimeListeners&&Object.entries(this._oneTimeListeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})})}pointIsWithinImageBounds(e){const t=this.getImageMetadata();if(!t)return!1;const i=[[0,0],[t.width,t.height]];return e[0]>=i[0][0]&&e[0]<=i[1][0]&&e[1]>=i[0][1]&&e[1]<=i[1][1]}}const{Evented:c8}=tJ;const u8=["dragstart","drag","dragend"],h8=["lngLat","_defaultPrevented","target"];class d8{constructor(e,t,i){HY(this,"type"),HY(this,"target"),this.type=e,this.target=t,Object.assign(this,i)}}function p8(e){if(typeof DOMParser<"u"){const t=(new DOMParser).parseFromString(e,"application/xml");if(t.querySelector("parsererror"))throw new Error("The provided string is not valid XML");return t}throw new Error("No XML parser found")}function f8(e,t){if(!e.hasChildNodes())return!1;for(const i of Array.from(e.childNodes)){const e=i.nodeName;if("string"==typeof e&&e.trim().toLowerCase()===t.toLowerCase())return!0}return!1}function m8(e){if(typeof XMLSerializer<"u")return(new XMLSerializer).serializeToString(e);throw new Error("No XML serializer found")}function g8(e){const t="string"==typeof e?p8(e):e;if(!f8(t,"gpx"))throw new Error("The XML document is not valid GPX");const i=M8(t,"trk"),n=M8(t,"rte"),r=M8(t,"wpt"),o={type:"FeatureCollection",features:[]};for(const e of Array.from(i)){const t=T8(e);t&&o.features.push(t)}for(const e of Array.from(n)){const t=E8(e);t&&o.features.push(t)}for(const e of Array.from(r))o.features.push(C8(e));return o}function _8(e,t){let i=e;if("string"==typeof i&&(i=p8(i)),!f8(i,"kml"))throw new Error("The XML document is not valid KML");const n={type:"FeatureCollection",features:[]},r={},o={},s={},a=M8(i,"Placemark"),l=M8(i,"Style"),c=M8(i,"StyleMap");for(const e of Array.from(l)){const i=I8(void 0!==t?t(e):m8(e)).toString(16);r[`#${P8(e,"id")}`]=i,o[i]=e}for(const e of Array.from(c)){r[`#${P8(e,"id")}`]=I8(void 0!==t?t(e):m8(e)).toString(16);const i=M8(e,"Pair"),n={};for(const e of Array.from(i))n[k8(L8(e,"key"))??""]=k8(L8(e,"styleUrl"));s[`#${P8(e,"id")}`]=n}for(const e of Array.from(a))n.features=n.features.concat(b8(e,r,o,s));return n}function A8(e){if(null===e)return["#000000",1];let t="",i=1,n=e;return n.startsWith("#")&&(n=n.substring(1)),(6===n.length||3===n.length)&&(t=n),8===n.length&&(i=Number.parseInt(n.substring(0,2),16)/255,t=`#${n.substring(6,8)}${n.substring(4,6)}${n.substring(2,4)}`),[t??"#000000",i??1]}function y8(e){return F8(e.split(" "))}function v8(e){let t=M8(e,"coord");const i=[],n=[];0===t.length&&(t=M8(e,"gx:coord"));for(const e of Array.from(t))i.push(y8(k8(e)??""));const r=M8(e,"when");for(const e of Array.from(r))n.push(k8(e));return{coords:i,times:n}}function x8(e){const t=["Polygon","LineString","Point","Track","gx:Track"];let i,n,r,o,s;const a=[],l=[];if(null!==L8(e,"MultiGeometry"))return x8(L8(e,"MultiGeometry"));if(null!==L8(e,"MultiTrack"))return x8(L8(e,"MultiTrack"));if(null!==L8(e,"gx:MultiTrack"))return x8(L8(e,"gx:MultiTrack"));for(r=0;rNumber.isNaN(e)?null:e)}function k8(e){return e&&function(e){e.normalize&&e.normalize()}(e),e&&e.textContent}function D8(e,t){const i={};let n,r;for(r=0;r=e[e.length-1].zoom)return e[e.length-1].value;for(let i=0;i=e[i].zoom&&t[e.zoom,e.value])]}function Z8(e){return["interpolate",["linear"],["zoom"],...e.flatMap(e=>[e.zoom,e.value])]}function W8(e,t){if("number"==typeof t&&"number"==typeof e)return 2*t+e;if("number"==typeof t&&Array.isArray(e))return["interpolate",["linear"],["zoom"],...e.flatMap(e=>[e.zoom,2*t+e.value])];if("number"==typeof e&&Array.isArray(t))return["interpolate",["linear"],["zoom"],...t.flatMap(t=>[t.zoom,2*t.value+e])];if(Array.isArray(e)&&Array.isArray(t)){const i=Array.from(new Set([...e.map(e=>e.zoom),...t.map(e=>e.zoom)])).sort((e,t)=>e[i,2*Q8(t,i)+Q8(e,i)])]}return 0}function q8(e,t){return["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]}function K8(e){const t=e.trimStart(),i=`${t}${" ".repeat(e.length-t.length)}`,n=Array.from(i);if(!n.every(e=>" "===e||"_"===e))throw new Error("A dash pattern must be composed only of whitespace and underscore characters.");if(!n.some(e=>"_"===e)||!n.some(e=>" "===e))throw new Error("A dash pattern must contain at least one underscore and one whitespace character");const r=[1];for(let e=1;e[e.value,e.color])]}function J8(e,t,i=!0){return i?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.025*e.pointRadius])],2,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.05*e.pointRadius])],4,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.1*e.pointRadius])],8,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.25*e.pointRadius])],16,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,e.pointRadius])]]:["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,e.pointRadius])]}function Y8(e,t,i=!0){return i?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.025*e.value])],2,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.05*e.value])],4,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.1*e.value])],8,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.25*e.value])],16,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]]:["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]}function e9(e,t){return e.every(t=>t.color[3]===e[0].color[3])?e[0].color[3]?e[0].color[3]/255:1:["interpolate",["linear"],["get",t],...e.getRawColorStops().flatMap(e=>{const t=e.value,i=e.color;return[t,4===i.length?i[3]/255:1]})]}function t9(e,t=10){return["interpolate",["linear"],["heatmap-density"],...Array.from({length:t+1},(i,n)=>{const r=n/t;return[r,e.getColorHex(r)]}).flat()]}function i9(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}class n9 extends Array{constructor(e={}){super(),HY(this,"min",0),HY(this,"max",1),"min"in e&&(this.min=e.min),"max"in e&&(this.max=e.max),"stops"in e&&this.setStops(e.stops,{clone:!1})}static fromArrayDefinition(e){return new n9({stops:e.map(e=>({value:e[0],color:e[1]}))})}setStops(e,t={clone:!0}){const i=t.clone?this.clone():this;i.length=0;let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let t=0;te.value=this.at(-1).value)return this.at(-1).color;for(let i=0;ithis[i+1].value)continue;const n=this[i].color;if(!t.smooth)return n.slice();const r=this[i].value,o=this[i+1].value,s=this[i+1].color,a=(o-e)/(o-r);return n.map((e,t)=>Math.round(e*a+s[t]*(1-a)))}return[0,0,0]}getColorHex(e,t={smooth:!0,withAlpha:!1}){return function(e){return`#${i9(e[0])}${i9(e[1])}${i9(e[2])}${4===e.length?i9(e[3]):""}`}(this.getColor(e,t))}getColorRelative(e,t={smooth:!0}){const i=this.getBounds();return this.getColor(i.min+e*(i.max-i.min),t)}getCanvasStrip(e={horizontal:!0,size:512,smooth:!0}){const t=document.createElement("canvas");t.width=e.horizontal?e.size:1,t.height=e.horizontal?1:e.size;const i=t.getContext("2d");if(!i)throw new Error("Canvs context is missing");const n=i.getImageData(0,0,t.width,t.height),r=n.data,o=e.size,s=this[0].value,a=(this.at(-1).value-s)/o;for(let t=0;t3?i[3]:255}return i.putImageData(n,0,0),t}resample(e,t=15){const i=this.getBounds(),n=this.scale(0,1),r=1/(t-1);let o;if("ease-in-square"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=i**2;return{value:i,color:n.getColor(o)}});else if("ease-out-square"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-(1-i)**2;return{value:i,color:n.getColor(o)}});else if("ease-out-sqrt"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=i**.5;return{value:i,color:n.getColor(o)}});else if("ease-in-sqrt"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-(1-i)**.5;return{value:i,color:n.getColor(o)}});else if("ease-out-exp"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-2**(-10*i);return{value:i,color:n.getColor(o)}});else{if("ease-in-exp"!==e)throw new Error("Invalid ressampling method.");o=Array.from({length:t},(e,t)=>{const i=t*r,o=2**(10*i-10);return{value:i,color:n.getColor(o)}})}return new n9({stops:o}).scale(i.min,i.max)}transparentStart(){const e=this.getRawColorStops();e.unshift({value:e[0].value,color:e[0].color.slice()}),e[1].value+=.001;for(const t of e)3===t.color.length&&t.color.push(255);return e[0].color[3]=0,new n9({stops:e})}hasTransparentStart(){return 4===this[0].color.length&&0===this[0].color[3]}}const r9={NULL:new n9({stops:[{value:0,color:[0,0,0,0]},{value:1,color:[0,0,0,0]}]}),GRAY:new n9({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),JET:new n9({stops:[{value:0,color:[0,0,131]},{value:.125,color:[0,60,170]},{value:.375,color:[5,255,255]},{value:.625,color:[255,255,0]},{value:.875,color:[250,0,0]},{value:1,color:[128,0,0]}]}),HSV:new n9({stops:[{value:0,color:[255,0,0]},{value:.169,color:[253,255,2]},{value:.173,color:[247,255,2]},{value:.337,color:[0,252,4]},{value:.341,color:[0,252,10]},{value:.506,color:[1,249,255]},{value:.671,color:[2,0,253]},{value:.675,color:[8,0,253]},{value:.839,color:[255,0,251]},{value:.843,color:[255,0,245]},{value:1,color:[255,0,6]}]}),HOT:new n9({stops:[{value:0,color:[0,0,0]},{value:.3,color:[230,0,0]},{value:.6,color:[255,210,0]},{value:1,color:[255,255,255]}]}),SPRING:new n9({stops:[{value:0,color:[255,0,255]},{value:1,color:[255,255,0]}]}),SUMMER:new n9({stops:[{value:0,color:[0,128,102]},{value:1,color:[255,255,102]}]}),AUTOMN:new n9({stops:[{value:0,color:[255,0,0]},{value:1,color:[255,255,0]}]}),WINTER:new n9({stops:[{value:0,color:[0,0,255]},{value:1,color:[0,255,128]}]}),BONE:new n9({stops:[{value:0,color:[0,0,0]},{value:.376,color:[84,84,116]},{value:.753,color:[169,200,200]},{value:1,color:[255,255,255]}]}),COPPER:new n9({stops:[{value:0,color:[0,0,0]},{value:.804,color:[255,160,102]},{value:1,color:[255,199,127]}]}),GREYS:new n9({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),YIGNBU:new n9({stops:[{value:0,color:[8,29,88]},{value:.125,color:[37,52,148]},{value:.25,color:[34,94,168]},{value:.375,color:[29,145,192]},{value:.5,color:[65,182,196]},{value:.625,color:[127,205,187]},{value:.75,color:[199,233,180]},{value:.875,color:[237,248,217]},{value:1,color:[255,255,217]}]}),GREENS:new n9({stops:[{value:0,color:[0,68,27]},{value:.125,color:[0,109,44]},{value:.25,color:[35,139,69]},{value:.375,color:[65,171,93]},{value:.5,color:[116,196,118]},{value:.625,color:[161,217,155]},{value:.75,color:[199,233,192]},{value:.875,color:[229,245,224]},{value:1,color:[247,252,245]}]}),YIORRD:new n9({stops:[{value:0,color:[128,0,38]},{value:.125,color:[189,0,38]},{value:.25,color:[227,26,28]},{value:.375,color:[252,78,42]},{value:.5,color:[253,141,60]},{value:.625,color:[254,178,76]},{value:.75,color:[254,217,118]},{value:.875,color:[255,237,160]},{value:1,color:[255,255,204]}]}),BLUERED:new n9({stops:[{value:0,color:[0,0,255]},{value:1,color:[255,0,0]}]}),RDBU:new n9({stops:[{value:0,color:[5,10,172]},{value:.35,color:[106,137,247]},{value:.5,color:[190,190,190]},{value:.6,color:[220,170,132]},{value:.7,color:[230,145,90]},{value:1,color:[178,10,28]}]}),PICNIC:new n9({stops:[{value:0,color:[0,0,255]},{value:.1,color:[51,153,255]},{value:.2,color:[102,204,255]},{value:.3,color:[153,204,255]},{value:.4,color:[204,204,255]},{value:.5,color:[255,255,255]},{value:.6,color:[255,204,255]},{value:.7,color:[255,153,255]},{value:.8,color:[255,102,204]},{value:.9,color:[255,102,102]},{value:1,color:[255,0,0]}]}),RAINBOW:new n9({stops:[{value:0,color:[150,0,90]},{value:.125,color:[0,0,200]},{value:.25,color:[0,25,255]},{value:.375,color:[0,152,255]},{value:.5,color:[44,255,150]},{value:.625,color:[151,255,0]},{value:.75,color:[255,234,0]},{value:.875,color:[255,111,0]},{value:1,color:[255,0,0]}]}),PORTLAND:new n9({stops:[{value:0,color:[12,51,131]},{value:.25,color:[10,136,186]},{value:.5,color:[242,211,56]},{value:.75,color:[242,143,56]},{value:1,color:[217,30,30]}]}),BLACKBODY:new n9({stops:[{value:0,color:[0,0,0]},{value:.2,color:[230,0,0]},{value:.4,color:[230,210,0]},{value:.7,color:[255,255,255]},{value:1,color:[160,200,255]}]}),EARTH:new n9({stops:[{value:0,color:[0,0,130]},{value:.1,color:[0,180,180]},{value:.2,color:[40,210,40]},{value:.4,color:[230,230,50]},{value:.6,color:[120,70,20]},{value:1,color:[255,255,255]}]}),ELECTRIC:new n9({stops:[{value:0,color:[0,0,0]},{value:.15,color:[30,0,100]},{value:.4,color:[120,0,100]},{value:.6,color:[160,90,0]},{value:.8,color:[230,200,0]},{value:1,color:[255,250,220]}]}),VIRIDIS:new n9({stops:[{value:0,color:[68,1,84]},{value:.13,color:[71,44,122]},{value:.25,color:[59,81,139]},{value:.38,color:[44,113,142]},{value:.5,color:[33,144,141]},{value:.63,color:[39,173,129]},{value:.75,color:[92,200,99]},{value:.88,color:[170,220,50]},{value:1,color:[253,231,37]}]}),INFERNO:new n9({stops:[{value:0,color:[0,0,4]},{value:.13,color:[31,12,72]},{value:.25,color:[85,15,109]},{value:.38,color:[136,34,106]},{value:.5,color:[186,54,85]},{value:.63,color:[227,89,51]},{value:.75,color:[249,140,10]},{value:.88,color:[249,201,50]},{value:1,color:[252,255,164]}]}),MAGMA:new n9({stops:[{value:0,color:[0,0,4]},{value:.13,color:[28,16,68]},{value:.25,color:[79,18,123]},{value:.38,color:[129,37,129]},{value:.5,color:[181,54,122]},{value:.63,color:[229,80,100]},{value:.75,color:[251,135,97]},{value:.88,color:[254,194,135]},{value:1,color:[252,253,191]}]}),PLASMA:new n9({stops:[{value:0,color:[13,8,135]},{value:.13,color:[75,3,161]},{value:.25,color:[125,3,168]},{value:.38,color:[168,34,150]},{value:.5,color:[203,70,121]},{value:.63,color:[229,107,93]},{value:.75,color:[248,148,65]},{value:.88,color:[253,195,40]},{value:1,color:[240,249,33]}]}),WARM:new n9({stops:[{value:0,color:[125,0,179]},{value:.13,color:[172,0,187]},{value:.25,color:[219,0,170]},{value:.38,color:[255,0,130]},{value:.5,color:[255,63,74]},{value:.63,color:[255,123,0]},{value:.75,color:[234,176,0]},{value:.88,color:[190,228,0]},{value:1,color:[147,255,0]}]}),COOL:new n9({stops:[{value:0,color:[125,0,179]},{value:.13,color:[116,0,218]},{value:.25,color:[98,74,237]},{value:.38,color:[68,146,231]},{value:.5,color:[0,204,197]},{value:.63,color:[0,247,146]},{value:.75,color:[0,255,88]},{value:.88,color:[40,255,8]},{value:1,color:[147,255,0]}]}),RAINBOW_SOFT:new n9({stops:[{value:0,color:[125,0,179]},{value:.1,color:[199,0,180]},{value:.2,color:[255,0,121]},{value:.3,color:[255,108,0]},{value:.4,color:[222,194,0]},{value:.5,color:[150,255,0]},{value:.6,color:[0,255,55]},{value:.7,color:[0,246,150]},{value:.8,color:[50,167,222]},{value:.9,color:[103,51,235]},{value:1,color:[124,0,186]}]}),BATHYMETRY:new n9({stops:[{value:0,color:[40,26,44]},{value:.13,color:[59,49,90]},{value:.25,color:[64,76,139]},{value:.38,color:[63,110,151]},{value:.5,color:[72,142,158]},{value:.63,color:[85,174,163]},{value:.75,color:[120,206,163]},{value:.88,color:[187,230,172]},{value:1,color:[253,254,204]}]}),CDOM:new n9({stops:[{value:0,color:[47,15,62]},{value:.13,color:[87,23,86]},{value:.25,color:[130,28,99]},{value:.38,color:[171,41,96]},{value:.5,color:[206,67,86]},{value:.63,color:[230,106,84]},{value:.75,color:[242,149,103]},{value:.88,color:[249,193,135]},{value:1,color:[254,237,176]}]}),CHLOROPHYLL:new n9({stops:[{value:0,color:[18,36,20]},{value:.13,color:[25,63,41]},{value:.25,color:[24,91,59]},{value:.38,color:[13,119,72]},{value:.5,color:[18,148,80]},{value:.63,color:[80,173,89]},{value:.75,color:[132,196,122]},{value:.88,color:[175,221,162]},{value:1,color:[215,249,208]}]}),DENSITY:new n9({stops:[{value:0,color:[54,14,36]},{value:.13,color:[89,23,80]},{value:.25,color:[110,45,132]},{value:.38,color:[120,77,178]},{value:.5,color:[120,113,213]},{value:.63,color:[115,151,228]},{value:.75,color:[134,185,227]},{value:.88,color:[177,214,227]},{value:1,color:[230,241,241]}]}),FREESURFACE_BLUE:new n9({stops:[{value:0,color:[30,4,110]},{value:.13,color:[47,14,176]},{value:.25,color:[41,45,236]},{value:.38,color:[25,99,212]},{value:.5,color:[68,131,200]},{value:.63,color:[114,156,197]},{value:.75,color:[157,181,203]},{value:.88,color:[200,208,216]},{value:1,color:[241,237,236]}]}),FREESURFACE_RED:new n9({stops:[{value:0,color:[60,9,18]},{value:.13,color:[100,17,27]},{value:.25,color:[142,20,29]},{value:.38,color:[177,43,27]},{value:.5,color:[192,87,63]},{value:.63,color:[205,125,105]},{value:.75,color:[216,162,148]},{value:.88,color:[227,199,193]},{value:1,color:[241,237,236]}]}),OXYGEN:new n9({stops:[{value:0,color:[64,5,5]},{value:.13,color:[106,6,15]},{value:.25,color:[144,26,7]},{value:.38,color:[168,64,3]},{value:.5,color:[188,100,4]},{value:.63,color:[206,136,11]},{value:.75,color:[220,174,25]},{value:.88,color:[231,215,44]},{value:1,color:[248,254,105]}]}),PAR:new n9({stops:[{value:0,color:[51,20,24]},{value:.13,color:[90,32,35]},{value:.25,color:[129,44,34]},{value:.38,color:[159,68,25]},{value:.5,color:[182,99,19]},{value:.63,color:[199,134,22]},{value:.75,color:[212,171,35]},{value:.88,color:[221,210,54]},{value:1,color:[225,253,75]}]}),PHASE:new n9({stops:[{value:0,color:[145,105,18]},{value:.13,color:[184,71,38]},{value:.25,color:[186,58,115]},{value:.38,color:[160,71,185]},{value:.5,color:[110,97,218]},{value:.63,color:[50,123,164]},{value:.75,color:[31,131,110]},{value:.88,color:[77,129,34]},{value:1,color:[145,105,18]}]}),SALINITY:new n9({stops:[{value:0,color:[42,24,108]},{value:.13,color:[33,50,162]},{value:.25,color:[15,90,145]},{value:.38,color:[40,118,137]},{value:.5,color:[59,146,135]},{value:.63,color:[79,175,126]},{value:.75,color:[120,203,104]},{value:.88,color:[193,221,100]},{value:1,color:[253,239,154]}]}),TEMPERATURE:new n9({stops:[{value:0,color:[4,35,51]},{value:.13,color:[23,51,122]},{value:.25,color:[85,59,157]},{value:.38,color:[129,79,143]},{value:.5,color:[175,95,130]},{value:.63,color:[222,112,101]},{value:.75,color:[249,146,66]},{value:.88,color:[249,196,65]},{value:1,color:[232,250,91]}]}),TURBIDITY:new n9({stops:[{value:0,color:[34,31,27]},{value:.13,color:[65,50,41]},{value:.25,color:[98,69,52]},{value:.38,color:[131,89,57]},{value:.5,color:[161,112,59]},{value:.63,color:[185,140,66]},{value:.75,color:[202,174,88]},{value:.88,color:[216,209,126]},{value:1,color:[233,246,171]}]}),VELOCITY_BLUE:new n9({stops:[{value:0,color:[17,32,64]},{value:.13,color:[35,52,116]},{value:.25,color:[29,81,156]},{value:.38,color:[31,113,162]},{value:.5,color:[50,144,169]},{value:.63,color:[87,173,176]},{value:.75,color:[149,196,189]},{value:.88,color:[203,221,211]},{value:1,color:[254,251,230]}]}),VELOCITY_GREEN:new n9({stops:[{value:0,color:[23,35,19]},{value:.13,color:[24,64,38]},{value:.25,color:[11,95,45]},{value:.38,color:[39,123,35]},{value:.5,color:[95,146,12]},{value:.63,color:[152,165,18]},{value:.75,color:[201,186,69]},{value:.88,color:[233,216,137]},{value:1,color:[255,253,205]}]}),CUBEHELIX:new n9({stops:[{value:0,color:[0,0,0]},{value:.07,color:[22,5,59]},{value:.13,color:[60,4,105]},{value:.2,color:[109,1,135]},{value:.27,color:[161,0,147]},{value:.33,color:[210,2,142]},{value:.4,color:[251,11,123]},{value:.47,color:[255,29,97]},{value:.53,color:[255,54,69]},{value:.6,color:[255,85,46]},{value:.67,color:[255,120,34]},{value:.73,color:[255,157,37]},{value:.8,color:[241,191,57]},{value:.87,color:[224,220,93]},{value:.93,color:[218,241,142]},{value:1,color:[227,253,198]}]}),CIVIDIS:new n9({stops:[{value:0,color:[0,32,77,255]},{value:.125,color:[5,54,110,255]},{value:.25,color:[65,77,108,255]},{value:.375,color:[97,100,111,255]},{value:.5,color:[125,124,121,255]},{value:.625,color:[156,149,120,255]},{value:.75,color:[190,175,111,255]},{value:.875,color:[225,204,94,255]},{value:1,color:[255,235,70,255]}]}),TURBO:new n9({stops:[{value:0,color:[48,18,59,255]},{value:.125,color:[70,107,227,255]},{value:.25,color:[40,187,236,255]},{value:.375,color:[49,242,153,255]},{value:.5,color:[162,252,60,255]},{value:.625,color:[237,208,58,255]},{value:.75,color:[251,128,34,255]},{value:.875,color:[210,49,5,255]},{value:1,color:[122,4,3,255]}]}),ROCKET:new n9({stops:[{value:0,color:[250,235,221,0]},{value:.133,color:[250,235,221,255]},{value:.266,color:[246,170,130,255]},{value:.4,color:[240,96,67,255]},{value:.533,color:[203,27,79,255]},{value:.666,color:[132,30,90,255]},{value:.8,color:[63,27,68,255]},{value:1,color:[3,5,26,255]}]}),MAKO:new n9({stops:[{value:0,color:[11,4,5,255]},{value:.125,color:[43,28,53,255]},{value:.25,color:[62,53,107,255]},{value:.375,color:[59,86,152,255]},{value:.5,color:[53,123,162,255]},{value:.625,color:[53,158,170,255]},{value:.75,color:[73,193,173,255]},{value:.875,color:[150,221,181,255]},{value:1,color:[222,245,229,255]}]})};const o9=Object.freeze(Object.defineProperty({__proto__:null,addHeatmap:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??G8(),n=t.layerId??H8(),r=t.minzoom??0,o=t.maxzoom??23,s=t.zoomCompensation??!0,a=t.opacity??[{zoom:r,value:0},{zoom:r+.25,value:1},{zoom:o-.25,value:1},{zoom:o,value:0}];let l=Array.isArray(t.colorRamp)?t.colorRamp:r9.TURBO.transparentStart();const c=l.getBounds();(0!==c.min||1!==c.max)&&(l=l.scale(0,1)),l.hasTransparentStart()||(l=l.transparentStart());const u=t.intensity??[{zoom:0,value:.01},{zoom:4,value:.2},{zoom:16,value:1}],h=t.property??null,d=t.weight??1;let p=1;h?"number"==typeof d?(p=d,"number"==typeof t.weight&&console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`")):Array.isArray(d)?p=q8(d,h):console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`"):"number"==typeof d?p=d:Array.isArray(d)&&console.warn("The options `.propertyValueWeights` can only be used when `.property` is provided.");const f=[{zoom:0,value:1.25},{zoom:2,value:2.5},{zoom:4,value:5},{zoom:8,value:12.5},{zoom:16,value:50}],m=t.radius??(s?f:10);let g=1;"number"==typeof m?g=m:Array.isArray(m)&&"zoom"in m[0]?g=Z8(m):h&&Array.isArray(m)&&"propertyValue"in m[0]?g=Y8(m,h,s):!h&&Array.isArray(m)&&"propertyValue"in m[0]?(g=Z8(f),console.warn("The option `.radius` can only be property-driven if the option `.property` is provided.")):g=Z8(f);const _={heatmapLayerId:n,heatmapSourceId:i};if(t.data&&!e.getSource(i)){let n=t.data;"string"==typeof n&&N0(n)&&(n=`https://api.maptiler.com/data/${n}/features.json?key=${C0.apiKey}`),e.addSource(i,{type:"geojson",data:n})}return e.addLayer({id:n,type:"heatmap",source:i,minzoom:r,maxzoom:o,paint:{"heatmap-weight":p,"heatmap-intensity":"number"==typeof u?u:Z8(u),"heatmap-color":t9(l),"heatmap-radius":g,"heatmap-opacity":"number"==typeof a?a:Z8(a)}},t.beforeId),_},addPoint:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.minPointRadius??10,n=t.maxPointRadius??50,r=t.cluster??!1,o=20,s=Array.isArray(t.pointColor)?t.pointColor:r9.TURBO.scale(10,t.cluster?1e4:1e3).resample("ease-out-square"),a=s.getBounds(),l=t.sourceId??G8(),c=t.layerId??H8(),u=t.showLabel??r,h=t.alignOnViewport??!0,d=t.outline??!1,p=t.outlineOpacity??1,f=t.outlineWidth??1,m=t.outlineColor??"#FFFFFF";let g;const _=t.zoomCompensation??!0,A=t.minzoom??0,y=t.maxzoom??23;g="number"==typeof t.pointOpacity?t.pointOpacity:Array.isArray(t.pointOpacity)?Z8(t.pointOpacity):t.cluster?e9(s,"point_count"):t.property?e9(s,t.property):Z8([{zoom:A,value:0},{zoom:A+.25,value:1},{zoom:y-.25,value:1},{zoom:y,value:0}]);const v={pointLayerId:c,clusterLayerId:"",labelLayerId:"",pointSourceId:l};if(t.data&&!e.getSource(l)){let i=t.data;"string"==typeof i&&N0(i)&&(i=`https://api.maptiler.com/data/${i}/features.json?key=${C0.apiKey}`),e.addSource(l,{type:"geojson",data:i,cluster:r})}if(r){v.clusterLayerId=`${c}_cluster`;const r=Array.from({length:o},(e,t)=>{const r=a.min+t*(a.max-a.min)/19;return{value:r,pointRadius:i+(n-i)*(t/19)**.5,color:s.getColorHex(r)}});e.addLayer({id:v.clusterLayerId,type:"circle",source:l,filter:["has","point_count"],paint:{"circle-color":"string"==typeof t.pointColor?t.pointColor:X8(r,"point_count"),"circle-radius":"number"==typeof t.pointRadius?t.pointRadius:Array.isArray(t.pointRadius)?Z8(t.pointRadius):J8(r,"point_count",!1),"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-opacity":g,...d&&{"circle-stroke-opacity":"number"==typeof p?p:Z8(p),"circle-stroke-width":"number"==typeof f?f:Z8(f),"circle-stroke-color":"string"==typeof m?m:$8(m)}},minzoom:A,maxzoom:y},t.beforeId),e.addLayer({id:v.pointLayerId,type:"circle",source:l,filter:["!",["has","point_count"]],paint:{"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-color":"string"==typeof t.pointColor?t.pointColor:s.getColorHex(s.getBounds().min),"circle-radius":"number"==typeof t.pointRadius?t.pointRadius:Array.isArray(t.pointRadius)?Z8(t.pointRadius):.75*r[0].pointRadius,"circle-opacity":g,...d&&{"circle-stroke-opacity":"number"==typeof p?p:Z8(p),"circle-stroke-width":"number"==typeof f?f:Z8(f),"circle-stroke-color":"string"==typeof m?m:$8(m)}},minzoom:A,maxzoom:y},t.beforeId)}else{let r="string"==typeof t.pointColor?t.pointColor:Array.isArray(t.pointColor)?t.pointColor.getColorHex(t.pointColor.getBounds().min):j8(),c="number"==typeof t.pointRadius?_?Z8([{zoom:0,value:.025*t.pointRadius},{zoom:2,value:.05*t.pointRadius},{zoom:4,value:.1*t.pointRadius},{zoom:8,value:.25*t.pointRadius},{zoom:16,value:1*t.pointRadius}]):t.pointRadius:Array.isArray(t.pointRadius)?Z8(t.pointRadius):_?Z8([{zoom:0,value:.05*i},{zoom:2,value:.1*i},{zoom:4,value:.2*i},{zoom:8,value:.5*i},{zoom:16,value:1*i}]):i;if(t.property&&Array.isArray(t.pointColor)){const e=Array.from({length:o},(e,r)=>{const o=a.min+r*(a.max-a.min)/19;return{value:o,pointRadius:"number"==typeof t.pointRadius?t.pointRadius:i+(n-i)*(r/19)**.5,color:"string"==typeof t.pointColor?t.pointColor:s.getColorHex(o)}});r=X8(e,t.property),c=J8(e,t.property,_)}e.addLayer({id:v.pointLayerId,type:"circle",source:l,layout:{"circle-sort-key":t.property?["/",1,["get",t.property]]:0},paint:{"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-color":r,"circle-opacity":g,"circle-radius":c,...d&&{"circle-stroke-opacity":"number"==typeof p?p:Z8(p),"circle-stroke-width":"number"==typeof f?f:Z8(f),"circle-stroke-color":"string"==typeof m?m:$8(m)}},minzoom:A,maxzoom:y},t.beforeId)}if(!1!==u&&(t.cluster||t.property)){v.labelLayerId=`${c}_label`;const i=t.labelColor??"#fff",n=t.labelSize??12;e.addLayer({id:v.labelLayerId,type:"symbol",source:l,filter:["has",t.cluster?"point_count":t.property],layout:{"text-field":t.cluster?"{point_count_abbreviated}":`{${t.property}}`,"text-font":["Noto Sans Regular"],"text-size":n,"text-pitch-alignment":h?"viewport":"map","symbol-sort-key":["/",1,["get",t.cluster?"point_count":t.property]]},paint:{"text-color":i,"text-opacity":g},minzoom:A,maxzoom:y},t.beforeId)}return v},addPolygon:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??G8(),n=t.layerId??H8(),r={polygonLayerId:n,polygonOutlineLayerId:t.outline?`${n}_outline`:"",polygonSourceId:i};if(t.data&&!e.getSource(i)){let n=t.data;"string"==typeof n&&N0(n)&&(n=`https://api.maptiler.com/data/${n}/features.json?key=${C0.apiKey}`),e.addSource(i,{type:"geojson",data:n})}let o=t.outlineDashArray??null;const s=t.outlineWidth??1,a=t.outlineColor??"#FFFFFF",l=t.outlineOpacity??1,c=t.outlineBlur??0,u=t.fillColor??j8(),h=t.fillOpacity??1,d=t.outlinePosition??"center",p=t.pattern??null;"string"==typeof o&&(o=K8(o));const f=(p=null)=>{if(e.addLayer({id:n,type:"fill",source:i,minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"fill-color":"string"==typeof u?u:$8(u),"fill-opacity":"number"==typeof h?h:Z8(h),...p&&{"fill-pattern":p}}},t.beforeId),!0===t.outline){let n;n="inside"===d?"number"==typeof s?.5*s:Z8(s.map(({zoom:e,value:t})=>({zoom:e,value:.5*t}))):"outside"===d?"number"==typeof s?-.5*s:Z8(s.map(e=>({zoom:e.zoom,value:-.5*e.value}))):0,e.addLayer({id:r.polygonOutlineLayerId,type:"line",source:i,layout:{"line-join":t.outlineJoin??"round","line-cap":t.outlineCap??"butt"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof l?l:Z8(l),"line-color":"string"==typeof a?a:$8(a),"line-width":"number"==typeof s?s:Z8(s),"line-blur":"number"==typeof c?c:Z8(c),"line-offset":n,...o&&{"line-dasharray":o}}},t.beforeId)}};return p?e.hasImage(p)?f(p):e.loadImage(p).then(t=>{e.addImage(p,t.data),f(p)}).catch(e=>{console.error("Could not load the pattern image.",e.message),f()}):f(),r},addPolyline:async function(e,t,i={}){var n,r;if(!t.sourceId&&!t.data)throw new Error("Creating a polyline layer requires an existing .sourceId or a valid .data property");let o=t.data;if("string"==typeof o){if(N0(o))o=`https://api.maptiler.com/data/${t.data}/features.json?key=${C0.apiKey}`;else if("gpx"===(null==(n=o.split(".").pop())?void 0:n.toLowerCase().trim())){o=g8(await(await fetch(o,i)).text())}else if("kml"===(null==(r=o.split(".").pop())?void 0:r.toLowerCase().trim())){o=_8(await(await fetch(o,i)).text())}else{const e=function(e){try{return JSON.parse(e)}catch{}return null}(o)??N8(o);e&&(o=e)}if(!o)throw new Error("Polyline data was provided as string but is incompatible with valid formats.")}return function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??G8(),n=t.layerId??H8(),r={polylineLayerId:n,polylineOutlineLayerId:"",polylineSourceId:i};t.data&&!e.getSource(i)&&e.addSource(i,{type:"geojson",data:t.data});const o=t.lineWidth??3,s=t.lineColor??j8(),a=t.lineOpacity??1,l=t.lineBlur??0,c=t.lineGapWidth??0;let u=t.lineDashArray??null;const h=t.outlineWidth??1,d=t.outlineColor??"#FFFFFF",p=t.outlineOpacity??1,f=t.outlineBlur??0;if("string"==typeof u&&(u=K8(u)),!0===t.outline){const s=`${n}_outline`;r.polylineOutlineLayerId=s,e.addLayer({id:s,type:"line",source:i,layout:{"line-join":t.lineJoin??"round","line-cap":t.lineCap??"round"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof p?p:Z8(p),"line-color":"string"==typeof d?d:$8(d),"line-width":W8(o,h),"line-blur":"number"==typeof f?f:Z8(f)}},t.beforeId)}return e.addLayer({id:n,type:"line",source:i,layout:{"line-join":t.lineJoin??"round","line-cap":t.lineCap??"round"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof a?a:Z8(a),"line-color":"string"==typeof s?s:$8(s),"line-width":"number"==typeof o?o:Z8(o),"line-blur":"number"==typeof l?l:Z8(l),"line-gap-width":"number"==typeof c?c:Z8(c),...u&&{"line-dasharray":u}}},t.beforeId),r}(e,{...t,data:o})},colorDrivenByProperty:X8,colorPalettes:V8,computeRampedOutlineWidth:W8,dashArrayMaker:K8,generateRandomLayerName:H8,generateRandomSourceName:G8,getRandomColor:j8,heatmapIntensityFromColorRamp:t9,lerpZoomNumberValues:Q8,opacityDrivenByProperty:e9,paintColorOptionsToPaintSpec:$8,radiusDrivenByProperty:J8,radiusDrivenByPropertyHeatmap:Y8,rampedOptionsToLayerPaintSpec:Z8,rampedPropertyValueWeight:q8,takeScreenshot:async function(e,t={}){const i=t.download??!1,n=await function(e){return new Promise((t,i)=>{e.redraw(),e.once("idle",()=>{e.getCanvas().toBlob(e=>{e?t(e):i(Error("Screenshot could not be created."))},"image/png")})})}(e);if(i){const e=t.filename??"maptiler_screenshot.png",i=document.createElement("a");i.style.display="none",document.body.appendChild(i),i.href=URL.createObjectURL(n),i.download=e,i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(i.href)},0)}return n}},Symbol.toStringTag,{value:"Module"}));function s9(){return"3.9.0"}const a9=tJ.Map,l9=tJ.Marker,c9=tJ.Popup,u9=tJ.Style,h9=tJ.CanvasSource,d9=tJ.GeoJSONSource,p9=tJ.ImageSource,f9=tJ.RasterTileSource,m9=tJ.RasterDEMTileSource,g9=tJ.VectorTileSource,_9=tJ.VideoSource,A9=tJ.NavigationControl,y9=tJ.GeolocateControl,v9=tJ.AttributionControl,x9=tJ.LogoControl,b9=tJ.ScaleControl,w9=tJ.FullscreenControl,T9=tJ.TerrainControl,E9=tJ.BoxZoomHandler,C9=tJ.ScrollZoomHandler,S9=tJ.CooperativeGesturesHandler,B9=tJ.KeyboardHandler,I9=tJ.TwoFingersTouchPitchHandler,M9=tJ.MapWheelEvent,P9=tJ.MapTouchEvent,R9=tJ.MapMouseEvent,L9=tJ.config,F9=tJ.getVersion,{setRTLTextPlugin:k9,getRTLTextPluginStatus:D9,LngLat:O9,LngLatBounds:z9,MercatorCoordinate:U9,Evented:N9,AJAXError:V9,prewarm:j9,clearPrewarmedResources:G9,Hash:H9,Point:Q9,EdgeInsets:$9,DragRotateHandler:Z9,DragPanHandler:W9,TwoFingersTouchZoomRotateHandler:q9,DoubleClickZoomHandler:K9,TwoFingersTouchZoomHandler:X9,TwoFingersTouchRotateHandler:J9,getWorkerCount:Y9,setWorkerCount:e7,getMaxParallelImageRequests:t7,setMaxParallelImageRequests:i7,getWorkerUrl:n7,setWorkerUrl:r7,addSourceType:o7,importScriptInWorkers:s7,addProtocol:a7,removeProtocol:l7}=tJ;var c7=Object.freeze({__proto__:null,AJAXError:V9,AttributionControl:l0,AttributionControlMLGL:v9,BoxZoomHandler:p0,BoxZoomHandlerMLGL:E9,CanvasSource:YY,CanvasSourceMLGL:h9,ColorRamp:n9,ColorRampCollection:r9,CooperativeGesturesHandler:m0,CooperativeGesturesHandlerMLGL:S9,CubemapFaceNames:h6,CubemapImagesPresets:c6,CubemapLayer:w6,DOMcreate:Y4,DOMremove:e5,DoubleClickZoomHandler:K9,DragPanHandler:W9,DragRotateHandler:Z9,EdgeInsets:$9,Evented:N9,FullscreenControl:h0,FullscreenControlMLGL:w9,GeoJSONSource:e0,GeoJSONSourceMLGL:d9,GeolocateControl:a0,GeolocateControlMLGL:y9,GeolocationType:L6,Hash:H9,ImageSource:t0,ImageSourceMLGL:p9,ImageViewer:l8,ImageViewerEvent:k6,ImageViewerMarker:class extends c8{constructor({...e}){super(),HY(this,"viewer"),HY(this,"marker"),HY(this,"position",[0,0]),this.marker=new KY(e)}addTo(e){if(!(e instanceof l8))throw new Error("[ImageViewerMarker]: an ImageViewerMarker must be added to an instance of ImageViewer");this.viewer=e,function(e,t,i){u8.forEach(n=>{e.on(n,e=>{var r,o;if(null==(r=e.target)?void 0:r.getLngLat()){const n=i(null==(o=e.target)?void 0:o.getLngLat());t.setPosition(n)}t.fire(n,new d8(n,t,{...Object.fromEntries(Object.entries(e).filter(([e])=>!h8.includes(e)))}))})})}(this.marker,this,this.viewer[e8]);const t=this.viewer.getSDKInternal();return this.setPosition(this.position),function(e){e._update=function(e){if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!e||"moveend"===e.type)&&(this._pos=this._pos.round());const r=`${J6[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`;this._element.style.transform=r}.bind(e)}(this.marker),this.marker.addTo(t),this}addClassName(e){return this.marker.addClassName(e),this}getElement(){return this.marker.getElement()}getPosition(){return this.position}getOffset(){return this.marker.getOffset()}getPitchAlignment(){return this.marker.getPitchAlignment()}getPopup(){return this.marker.getPopup()}getRotation(){return this.marker.getRotation()}getRotationAlignment(){return this.marker.getRotationAlignment()}isDraggable(){return this.marker.isDraggable()}fire(e,t){return super.fire(e,t),this}off(e,t){return super.off(e,t),this}on(e,t){return super.on(e,t)}isWithinImageBounds(){return this.viewer.pointIsWithinImageBounds(this.position)}remove(){return this.marker.remove(),this.marker._listeners&&Object.entries(this.marker._listeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this.marker._oneTimeListeners&&Object.entries(this.marker._oneTimeListeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this}removeClassName(e){return this.marker.removeClassName(e),this}setDraggable(e){return this.marker.setDraggable(e),this}setPosition(e){if(this.position[0]=e[0],this.position[1]=e[1],!this.viewer)return this;const t=this.viewer[t8](e);return this.marker.setLngLat(t),this}setOffset(e){return this.marker.setOffset(e),this}setOpacity(e,t){return this.marker.setOpacity(e,t),this}setPitchAlignment(e){return this.marker.setPitchAlignment(e),this}setPopup(e){return this.marker.setPopup(e),this}setRotation(e){return this.marker.setRotation(e),this}setRotationAlignment(e){return this.marker.setRotationAlignment(e),this}setSubpixelPositioning(e){return this.marker.setSubpixelPositioning(e),this}toggleClassName(e){return this.marker.toggleClassName(e),this}togglePopup(){return this.marker.togglePopup(),this}},ImageViewerMarkerEvent:d8,KeyboardHandler:g0,KeyboardHandlerMLGL:B9,Language:x0,LngLat:O9,LngLatBounds:z9,LogoControl:c0,LogoControlMLGL:x9,Map:F6,MapMLGL:a9,MapMouseEvent:v0,MapMouseEventMLGL:R9,MapStyle:aY,MapStyleVariant:iY,MapTouchEvent:y0,MapTouchEventMLGL:P9,MapWheelEvent:A0,MapWheelEventMLGL:M9,MaptilerCustomControl:p5,MaptilerExternalControl:I5,MaptilerGeolocateControl:a5,MaptilerLogoControl:S0,MaptilerNavigationControl:n5,MaptilerProjectionControl:f5,MaptilerTerrainControl:t5,Marker:KY,MarkerMLGL:l9,MercatorCoordinate:U9,NavigationControMLGL:A9,NavigationControl:s0,Point:Q9,Popup:XY,PopupMLGL:c9,RadialGradientLayer:M6,RasterDEMTileSource:n0,RasterDEMTileSourceMLGL:m9,RasterTileSource:i0,RasterTileSourceMLGL:f9,ReferenceMapStyle:nY,ScaleControl:u0,ScaleControlMLGL:b9,ScrollZoomHandler:f0,ScrollZoomHandlerMLGL:C9,SdkConfig:E0,ServiceError:GJ,Style:JY,StyleMLGL:u9,TerrainControMLGL:T9,TerrainControl:d0,TwoFingersTouchPitchHandler:_0,TwoFingersTouchPitchHandlerMLGL:I9,TwoFingersTouchRotateHandler:J9,TwoFingersTouchZoomHandler:X9,TwoFingersTouchZoomRotateHandler:q9,VectorTileSource:r0,VectorTileSourceMLGL:g9,VideoSource:o0,VideoSourceMLGL:_9,addProtocol:a7,addSourceType:o7,areSameLanguages:function(e,t,i=FJ){const n=NJ(e,i),r=NJ(t,i);return n&&r&&n.flag===r.flag},bufferToPixelDataBrowser:PY,canParsePixelData:LY,circumferenceAtLatitude:TY,clearPrewarmedResources:G9,config:C0,configMLGL:L9,coordinates:JJ,cubemapPresets:u6,data:eY,displayWebGLContextLostWarning:function(e){const t=e.getContainer(),i=document.createElement("div");i.innerHTML="The WebGL context was lost.",i.classList.add("webgl-warning-div"),t.appendChild(i)},elevation:OY,expandMapStyle:tY,geocoding:WJ,geolocation:KJ,getAutoLanguage:zJ,getBrowserLanguage:b0,getBufferToPixelDataParser:RY,getLanguageInfoFromCode:DJ,getLanguageInfoFromFlag:OJ,getLanguageInfoFromKey:kJ,getMapLibreVersion:F9,getMaxParallelImageRequests:t7,getRTLTextPluginStatus:D9,getTileCache:MY,getVersion:s9,getWebGLSupportError:V0,getWorkerCount:Y9,getWorkerUrl:n7,gpx:g8,gpxOrKml:N8,hasChildNodeWithName:f8,helpers:o9,importScriptInWorkers:s7,isLanguageInfo:UJ,kml:_8,mapStylePresetList:rY,math:BY,misc:hY,prewarm:j9,removeProtocol:l7,setMaxParallelImageRequests:i7,setRTLTextPlugin:k9,setWorkerCount:e7,setWorkerUrl:r7,staticMaps:fY,str2xml:p8,styleToStyle:sY,toLanguageInfo:NJ,toggleProjection:m5,toggleTerrain:i5,xml2str:m8}),u7=Object.freeze({__proto__:null,default:undefined});export{XX as startApp}; +var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])},e(t,i)};function t(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,i=1,n=arguments.length;i0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=55296&&r<=56319&&i>10),s%1024+56320)),(r+1===i||n.length>16384)&&(o+=String.fromCharCode.apply(String,n),n.length=0)}return o},h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="undefined"==typeof Uint8Array?[]:new Uint8Array(256),p=0;p>4,u[l++]=(15&n)<<4|r>>2,u[l++]=(3&r)<<6|63&o;return c},A=function(e){for(var t=e.length,i=[],n=0;n>v,T=(1<>v)+32,C=65536>>x,S=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>v])<>v)])<>x),t=this.index[t],t+=e>>v&S,t=((t=this.index[t])<k?(r.push(!0),s-=k):r.push(!1),-1!==["normal","auto","loose"].indexOf(t)&&-1!==[8208,8211,12316,12448].indexOf(e))return n.push(o),i.push(K);if(s===U||s===Q){if(0===o)return n.push(o),i.push(ue);var a=i[o-1];return-1===Le.indexOf(a)?(n.push(n[o-1]),i.push(a)):(n.push(o),i.push(ue))}return n.push(o),s===he?i.push("strict"===t?te:_e):s===be||s===ce?i.push(ue):s===we?e>=131072&&e<=196605||e>=196608&&e<=262141?i.push(_e):i.push(ue):void i.push(s)}),[n,i,r]},Oe=function(e,t,i,n){var r=n[i];if(Array.isArray(e)?-1!==e.indexOf(r):e===r)for(var o=i;o<=n.length;){if((l=n[++o])===t)return!0;if(l!==H)break}if(r===H)for(o=i;o>0;){var s=n[--o];if(Array.isArray(e)?-1!==e.indexOf(s):e===s)for(var a=i;a<=n.length;){var l;if((l=n[++a])===t)return!0;if(l!==H)break}if(s!==H)break}return!1},ze=function(e,t){for(var i=e;i>=0;){var n=t[i];if(n!==H)return n;i--}return 0},Ue=function(e,t,i,n,r){if(0===i[n])return Ce;var o=n-1;if(Array.isArray(r)&&!0===r[o])return Ce;var s=o-1,a=o+1,l=t[o],c=s>=0?t[s]:0,u=t[a];if(l===O&&u===z)return Ce;if(-1!==Me.indexOf(l))return Ee;if(-1!==Me.indexOf(u))return Ce;if(-1!==Pe.indexOf(u))return Ce;if(ze(o,t)===j)return Se;if(Be.get(e[o])===Q)return Ce;if((l===de||l===pe)&&Be.get(e[a])===Q)return Ce;if(l===V||u===V)return Ce;if(l===G)return Ce;if(-1===[H,Z,q].indexOf(l)&&u===G)return Ce;if(-1!==[X,J,Y,re,le].indexOf(u))return Ce;if(ze(o,t)===ie)return Ce;if(Oe(ne,ie,o,t))return Ce;if(Oe([X,J],te,o,t))return Ce;if(Oe($,$,o,t))return Ce;if(l===H)return Se;if(l===ne||u===ne)return Ce;if(u===K||l===K)return Se;if(-1!==[Z,q,te].indexOf(u)||l===W)return Ce;if(c===ge&&-1!==ke.indexOf(l))return Ce;if(l===le&&u===ge)return Ce;if(u===ee)return Ce;if(-1!==Ie.indexOf(u)&&l===oe||-1!==Ie.indexOf(l)&&u===oe)return Ce;if(l===ae&&-1!==[_e,de,pe].indexOf(u)||-1!==[_e,de,pe].indexOf(l)&&u===se)return Ce;if(-1!==Ie.indexOf(l)&&-1!==Re.indexOf(u)||-1!==Re.indexOf(l)&&-1!==Ie.indexOf(u))return Ce;if(-1!==[ae,se].indexOf(l)&&(u===oe||-1!==[ie,q].indexOf(u)&&t[a+1]===oe)||-1!==[ie,q].indexOf(l)&&u===oe||l===oe&&-1!==[oe,le,re].indexOf(u))return Ce;if(-1!==[oe,le,re,X,J].indexOf(u))for(var h=o;h>=0;){if((d=t[h])===oe)return Ce;if(-1===[le,re].indexOf(d))break;h--}if(-1!==[ae,se].indexOf(u))for(h=-1!==[X,J].indexOf(l)?s:o;h>=0;){var d;if((d=t[h])===oe)return Ce;if(-1===[le,re].indexOf(d))break;h--}if(Ae===l&&-1!==[Ae,ye,fe,me].indexOf(u)||-1!==[ye,fe].indexOf(l)&&-1!==[ye,ve].indexOf(u)||-1!==[ve,me].indexOf(l)&&u===ve)return Ce;if(-1!==Fe.indexOf(l)&&-1!==[ee,se].indexOf(u)||-1!==Fe.indexOf(u)&&l===ae)return Ce;if(-1!==Ie.indexOf(l)&&-1!==Ie.indexOf(u))return Ce;if(l===re&&-1!==Ie.indexOf(u))return Ce;if(-1!==Ie.concat(oe).indexOf(l)&&u===ie&&-1===Te.indexOf(e[a])||-1!==Ie.concat(oe).indexOf(u)&&l===J)return Ce;if(l===xe&&u===xe){for(var p=i[o],f=1;p>0&&t[--p]===xe;)f++;if(f%2!=0)return Ce}return l===de&&u===pe?Ce:Se},Ne=function(e,t){t||(t={lineBreak:"normal",wordBreak:"normal"});var i=De(e,t.lineBreak),n=i[0],r=i[1],o=i[2];"break-all"!==t.wordBreak&&"break-word"!==t.wordBreak||(r=r.map(function(e){return-1!==[oe,ue,be].indexOf(e)?_e:e}));var s="keep-all"===t.wordBreak?o.map(function(t,i){return t&&e[i]>=19968&&e[i]<=40959}):void 0;return[n,r,s]},Ve=function(){function e(e,t,i,n){this.codePoints=e,this.required=t===Ee,this.start=i,this.end=n}return e.prototype.slice=function(){return u.apply(void 0,this.codePoints.slice(this.start,this.end))},e}(),je=function(e,t){var i=c(e),n=Ne(i,t),r=n[0],o=n[1],s=n[2],a=i.length,l=0,u=0;return{next:function(){if(u>=a)return{done:!0,value:null};for(var e=Ce;u=kt&&e<=57},Zt=function(e){return e>=55296&&e<=57343},Wt=function(e){return $t(e)||e>=Vt&&e<=Gt||e>=Dt&&e<=zt},qt=function(e){return e>=Dt&&e<=Nt},Kt=function(e){return e>=Vt&&e<=Qt},Xt=function(e){return qt(e)||Kt(e)},Jt=function(e){return e>=vt},Yt=function(e){return e===Ze||e===Ke||e===Xe},ei=function(e){return Xt(e)||Jt(e)||e===st},ti=function(e){return ei(e)||$t(e)||e===at},ii=function(e){return e>=Bt&&e<=It||e===Mt||e>=Pt&&e<=Rt||e===Lt},ni=function(e,t){return e===qe&&t!==Ze},ri=function(e,t,i){return e===at?ei(t)||ni(t,i):!!ei(e)||!(e!==qe||!ni(e,t))},oi=function(e,t,i){return e===wt||e===at?!!$t(t)||t===St&&$t(i):$t(e===St?t:e)},si=function(e){var t=0,i=1;e[t]!==wt&&e[t]!==at||(e[t]===at&&(i=-1),t++);for(var n=[];$t(e[t]);)n.push(e[t++]);var r=n.length?parseInt(u.apply(void 0,n),10):0;e[t]===St&&t++;for(var o=[];$t(e[t]);)o.push(e[t++]);var s=o.length,a=s?parseInt(u.apply(void 0,o),10):0;e[t]!==jt&&e[t]!==Ot||t++;var l=1;e[t]!==wt&&e[t]!==at||(e[t]===at&&(l=-1),t++);for(var c=[];$t(e[t]);)c.push(e[t++]);var h=c.length?parseInt(u.apply(void 0,c),10):0;return i*(r+a*Math.pow(10,-s))*Math.pow(10,l*h)},ai={type:2},li={type:3},ci={type:4},ui={type:13},hi={type:8},di={type:21},pi={type:9},fi={type:10},mi={type:11},gi={type:12},_i={type:14},Ai={type:23},yi={type:1},vi={type:25},xi={type:24},bi={type:26},wi={type:27},Ti={type:28},Ei={type:29},Ci={type:31},Si={type:32},Bi=function(){function e(){this._value=[]}return e.prototype.write=function(e){this._value=this._value.concat(c(e))},e.prototype.read=function(){for(var e=[],t=this.consumeToken();t!==Si;)e.push(t),t=this.consumeToken();return e},e.prototype.consumeToken=function(){var e=this.consumeCodePoint();switch(e){case Je:return this.consumeStringToken(Je);case et:var t=this.peekCodePoint(0),i=this.peekCodePoint(1),n=this.peekCodePoint(2);if(ti(t)||ni(i,n)){var r=ri(t,i,n)?He:Ge;return{type:5,value:this.consumeName(),flags:r}}break;case tt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),ui;break;case nt:return this.consumeStringToken(nt);case rt:return ai;case ot:return li;case bt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),_i;break;case wt:if(oi(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case Tt:return ci;case at:var o=e,s=this.peekCodePoint(0),a=this.peekCodePoint(1);if(oi(o,s,a))return this.reconsumeCodePoint(e),this.consumeNumericToken();if(ri(o,s,a))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();if(s===at&&a===ut)return this.consumeCodePoint(),this.consumeCodePoint(),xi;break;case St:if(oi(e,this.peekCodePoint(0),this.peekCodePoint(1)))return this.reconsumeCodePoint(e),this.consumeNumericToken();break;case We:if(this.peekCodePoint(0)===bt)for(this.consumeCodePoint();;){var l=this.consumeCodePoint();if(l===bt&&(l=this.consumeCodePoint())===We)return this.consumeToken();if(l===Ft)return this.consumeToken()}break;case Et:return bi;case Ct:return wi;case ct:if(this.peekCodePoint(0)===lt&&this.peekCodePoint(1)===at&&this.peekCodePoint(2)===at)return this.consumeCodePoint(),this.consumeCodePoint(),vi;break;case ht:var c=this.peekCodePoint(0),h=this.peekCodePoint(1),d=this.peekCodePoint(2);if(ri(c,h,d))return{type:7,value:this.consumeName()};break;case dt:return Ti;case qe:if(ni(e,this.peekCodePoint(0)))return this.reconsumeCodePoint(e),this.consumeIdentLikeToken();break;case pt:return Ei;case ft:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),hi;break;case mt:return mi;case _t:return gi;case Ut:case Ht:var p=this.peekCodePoint(0),f=this.peekCodePoint(1);return p!==wt||!Wt(f)&&f!==gt||(this.consumeCodePoint(),this.consumeUnicodeRangeToken()),this.reconsumeCodePoint(e),this.consumeIdentLikeToken();case At:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),pi;if(this.peekCodePoint(0)===At)return this.consumeCodePoint(),di;break;case yt:if(this.peekCodePoint(0)===Ye)return this.consumeCodePoint(),fi;break;case Ft:return Si}return Yt(e)?(this.consumeWhiteSpace(),Ci):$t(e)?(this.reconsumeCodePoint(e),this.consumeNumericToken()):ei(e)?(this.reconsumeCodePoint(e),this.consumeIdentLikeToken()):{type:6,value:u(e)}},e.prototype.consumeCodePoint=function(){var e=this._value.shift();return void 0===e?-1:e},e.prototype.reconsumeCodePoint=function(e){this._value.unshift(e)},e.prototype.peekCodePoint=function(e){return e>=this._value.length?-1:this._value[e]},e.prototype.consumeUnicodeRangeToken=function(){for(var e=[],t=this.consumeCodePoint();Wt(t)&&e.length<6;)e.push(t),t=this.consumeCodePoint();for(var i=!1;t===gt&&e.length<6;)e.push(t),t=this.consumeCodePoint(),i=!0;if(i)return{type:30,start:parseInt(u.apply(void 0,e.map(function(e){return e===gt?kt:e})),16),end:parseInt(u.apply(void 0,e.map(function(e){return e===gt?Gt:e})),16)};var n=parseInt(u.apply(void 0,e),16);if(this.peekCodePoint(0)===at&&Wt(this.peekCodePoint(1))){this.consumeCodePoint(),t=this.consumeCodePoint();for(var r=[];Wt(t)&&r.length<6;)r.push(t),t=this.consumeCodePoint();return{type:30,start:n,end:parseInt(u.apply(void 0,r),16)}}return{type:30,start:n,end:n}},e.prototype.consumeIdentLikeToken=function(){var e=this.consumeName();return"url"===e.toLowerCase()&&this.peekCodePoint(0)===rt?(this.consumeCodePoint(),this.consumeUrlToken()):this.peekCodePoint(0)===rt?(this.consumeCodePoint(),{type:19,value:e}):{type:20,value:e}},e.prototype.consumeUrlToken=function(){var e=[];if(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft)return{type:22,value:""};var t=this.peekCodePoint(0);if(t===nt||t===Je){var i=this.consumeStringToken(this.consumeCodePoint());return 0===i.type&&(this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft||this.peekCodePoint(0)===ot)?(this.consumeCodePoint(),{type:22,value:i.value}):(this.consumeBadUrlRemnants(),Ai)}for(;;){var n=this.consumeCodePoint();if(n===Ft||n===ot)return{type:22,value:u.apply(void 0,e)};if(Yt(n))return this.consumeWhiteSpace(),this.peekCodePoint(0)===Ft||this.peekCodePoint(0)===ot?(this.consumeCodePoint(),{type:22,value:u.apply(void 0,e)}):(this.consumeBadUrlRemnants(),Ai);if(n===Je||n===nt||n===rt||ii(n))return this.consumeBadUrlRemnants(),Ai;if(n===qe){if(!ni(n,this.peekCodePoint(0)))return this.consumeBadUrlRemnants(),Ai;e.push(this.consumeEscapedCodePoint())}else e.push(n)}},e.prototype.consumeWhiteSpace=function(){for(;Yt(this.peekCodePoint(0));)this.consumeCodePoint()},e.prototype.consumeBadUrlRemnants=function(){for(;;){var e=this.consumeCodePoint();if(e===ot||e===Ft)return;ni(e,this.peekCodePoint(0))&&this.consumeEscapedCodePoint()}},e.prototype.consumeStringSlice=function(e){for(var t=5e4,i="";e>0;){var n=Math.min(t,e);i+=u.apply(void 0,this._value.splice(0,n)),e-=n}return this._value.shift(),i},e.prototype.consumeStringToken=function(e){for(var t="",i=0;;){var n=this._value[i];if(n===Ft||void 0===n||n===e)return{type:0,value:t+=this.consumeStringSlice(i)};if(n===Ze)return this._value.splice(0,i),yi;if(n===qe){var r=this._value[i+1];r!==Ft&&void 0!==r&&(r===Ze?(t+=this.consumeStringSlice(i),i=-1,this._value.shift()):ni(n,r)&&(t+=this.consumeStringSlice(i),t+=u(this.consumeEscapedCodePoint()),i=-1))}i++}},e.prototype.consumeNumber=function(){var e=[],t=Qe,i=this.peekCodePoint(0);for(i!==wt&&i!==at||e.push(this.consumeCodePoint());$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0);var n=this.peekCodePoint(1);if(i===St&&$t(n))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=$e;$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());i=this.peekCodePoint(0),n=this.peekCodePoint(1);var r=this.peekCodePoint(2);if((i===jt||i===Ot)&&((n===wt||n===at)&&$t(r)||$t(n)))for(e.push(this.consumeCodePoint(),this.consumeCodePoint()),t=$e;$t(this.peekCodePoint(0));)e.push(this.consumeCodePoint());return[si(e),t]},e.prototype.consumeNumericToken=function(){var e=this.consumeNumber(),t=e[0],i=e[1],n=this.peekCodePoint(0),r=this.peekCodePoint(1),o=this.peekCodePoint(2);return ri(n,r,o)?{type:15,number:t,flags:i,unit:this.consumeName()}:n===it?(this.consumeCodePoint(),{type:16,number:t,flags:i}):{type:17,number:t,flags:i}},e.prototype.consumeEscapedCodePoint=function(){var e=this.consumeCodePoint();if(Wt(e)){for(var t=u(e);Wt(this.peekCodePoint(0))&&t.length<6;)t+=u(this.consumeCodePoint());Yt(this.peekCodePoint(0))&&this.consumeCodePoint();var i=parseInt(t,16);return 0===i||Zt(i)||i>1114111?xt:i}return e===Ft?xt:e},e.prototype.consumeName=function(){for(var e="";;){var t=this.consumeCodePoint();if(ti(t))e+=u(t);else{if(!ni(t,this.peekCodePoint(0)))return this.reconsumeCodePoint(t),e;e+=u(this.consumeEscapedCodePoint())}}},e}(),Ii=function(){function e(e){this._tokens=e}return e.create=function(t){var i=new Bi;return i.write(t),new e(i.read())},e.parseValue=function(t){return e.create(t).parseComponentValue()},e.parseValues=function(t){return e.create(t).parseComponentValues()},e.prototype.parseComponentValue=function(){for(var e=this.consumeToken();31===e.type;)e=this.consumeToken();if(32===e.type)throw new SyntaxError("Error parsing CSS component value, unexpected EOF");this.reconsumeToken(e);var t=this.consumeComponentValue();do{e=this.consumeToken()}while(31===e.type);if(32===e.type)return t;throw new SyntaxError("Error parsing CSS component value, multiple values found when expecting only one")},e.prototype.parseComponentValues=function(){for(var e=[];;){var t=this.consumeComponentValue();if(32===t.type)return e;e.push(t),e.push()}},e.prototype.consumeComponentValue=function(){var e=this.consumeToken();switch(e.type){case 11:case 28:case 2:return this.consumeSimpleBlock(e.type);case 19:return this.consumeFunction(e)}return e},e.prototype.consumeSimpleBlock=function(e){for(var t={type:e,values:[]},i=this.consumeToken();;){if(32===i.type||zi(i,e))return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue()),i=this.consumeToken()}},e.prototype.consumeFunction=function(e){for(var t={name:e.value,values:[],type:18};;){var i=this.consumeToken();if(32===i.type||3===i.type)return t;this.reconsumeToken(i),t.values.push(this.consumeComponentValue())}},e.prototype.consumeToken=function(){var e=this._tokens.shift();return void 0===e?Si:e},e.prototype.reconsumeToken=function(e){this._tokens.unshift(e)},e}(),Mi=function(e){return 15===e.type},Pi=function(e){return 17===e.type},Ri=function(e){return 20===e.type},Li=function(e){return 0===e.type},Fi=function(e,t){return Ri(e)&&e.value===t},ki=function(e){return 31!==e.type},Di=function(e){return 31!==e.type&&4!==e.type},Oi=function(e){var t=[],i=[];return e.forEach(function(e){if(4===e.type){if(0===i.length)throw new Error("Error parsing function args, zero tokens for arg");return t.push(i),void(i=[])}31!==e.type&&i.push(e)}),i.length&&t.push(i),t},zi=function(e,t){return 11===t&&12===e.type||28===t&&29===e.type||2===t&&3===e.type},Ui=function(e){return 17===e.type||15===e.type},Ni=function(e){return 16===e.type||Ui(e)},Vi=function(e){return e.length>1?[e[0],e[1]]:[e[0]]},ji={type:17,number:0,flags:Qe},Gi={type:16,number:50,flags:Qe},Hi={type:16,number:100,flags:Qe},Qi=function(e,t,i){var n=e[0],r=e[1];return[$i(n,t),$i(void 0!==r?r:n,i)]},$i=function(e,t){if(16===e.type)return e.number/100*t;if(Mi(e))switch(e.unit){case"rem":case"em":return 16*e.number;default:return e.number}return e.number},Zi="deg",Wi="grad",qi="rad",Ki="turn",Xi={name:"angle",parse:function(e,t){if(15===t.type)switch(t.unit){case Zi:return Math.PI*t.number/180;case Wi:return Math.PI/200*t.number;case qi:return t.number;case Ki:return 2*Math.PI*t.number}throw new Error("Unsupported angle type")}},Ji=function(e){return 15===e.type&&(e.unit===Zi||e.unit===Wi||e.unit===qi||e.unit===Ki)},Yi=function(e){switch(e.filter(Ri).map(function(e){return e.value}).join(" ")){case"to bottom right":case"to right bottom":case"left top":case"top left":return[ji,ji];case"to top":case"bottom":return en(0);case"to bottom left":case"to left bottom":case"right top":case"top right":return[ji,Hi];case"to right":case"left":return en(90);case"to top left":case"to left top":case"right bottom":case"bottom right":return[Hi,Hi];case"to bottom":case"top":return en(180);case"to top right":case"to right top":case"left bottom":case"bottom left":return[Hi,ji];case"to left":case"right":return en(270)}return 0},en=function(e){return Math.PI*e/180},tn={name:"color",parse:function(e,t){if(18===t.type){var i=un[t.name];if(void 0===i)throw new Error('Attempting to parse an unsupported color function "'+t.name+'"');return i(e,t.values)}if(5===t.type){if(3===t.value.length){var n=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);return on(parseInt(n+n,16),parseInt(r+r,16),parseInt(o+o,16),1)}if(4===t.value.length){n=t.value.substring(0,1),r=t.value.substring(1,2),o=t.value.substring(2,3);var s=t.value.substring(3,4);return on(parseInt(n+n,16),parseInt(r+r,16),parseInt(o+o,16),parseInt(s+s,16)/255)}if(6===t.value.length)return n=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),on(parseInt(n,16),parseInt(r,16),parseInt(o,16),1);if(8===t.value.length)return n=t.value.substring(0,2),r=t.value.substring(2,4),o=t.value.substring(4,6),s=t.value.substring(6,8),on(parseInt(n,16),parseInt(r,16),parseInt(o,16),parseInt(s,16)/255)}if(20===t.type){var a=dn[t.value.toUpperCase()];if(void 0!==a)return a}return dn.TRANSPARENT}},nn=function(e){return!(255&e)},rn=function(e){var t=255&e,i=255&e>>8,n=255&e>>16,r=255&e>>24;return t<255?"rgba("+r+","+n+","+i+","+t/255+")":"rgb("+r+","+n+","+i+")"},on=function(e,t,i,n){return(e<<24|t<<16|i<<8|Math.round(255*n))>>>0},sn=function(e,t){if(17===e.type)return e.number;if(16===e.type){var i=3===t?1:255;return 3===t?e.number/100*i:Math.round(e.number/100*i)}return 0},an=function(e,t){var i=t.filter(Di);if(3===i.length){var n=i.map(sn),r=n[0],o=n[1],s=n[2];return on(r,o,s,1)}if(4===i.length){var a=i.map(sn),l=(r=a[0],o=a[1],s=a[2],a[3]);return on(r,o,s,l)}return 0};function ln(e,t,i){return i<0&&(i+=1),i>=1&&(i-=1),i<1/6?(t-e)*i*6+e:i<.5?t:i<2/3?6*(t-e)*(2/3-i)+e:e}var cn=function(e,t){var i=t.filter(Di),n=i[0],r=i[1],o=i[2],s=i[3],a=(17===n.type?en(n.number):Xi.parse(e,n))/(2*Math.PI),l=Ni(r)?r.number/100:0,c=Ni(o)?o.number/100:0,u=void 0!==s&&Ni(s)?$i(s,1):1;if(0===l)return on(255*c,255*c,255*c,1);var h=c<=.5?c*(l+1):c+l-c*l,d=2*c-h,p=ln(d,h,a+1/3),f=ln(d,h,a),m=ln(d,h,a-1/3);return on(255*p,255*f,255*m,u)},un={hsl:cn,hsla:cn,rgb:an,rgba:an},hn=function(e,t){return tn.parse(e,Ii.create(t).parseComponentValue())},dn={ALICEBLUE:4042850303,ANTIQUEWHITE:4209760255,AQUA:16777215,AQUAMARINE:2147472639,AZURE:4043309055,BEIGE:4126530815,BISQUE:4293182719,BLACK:255,BLANCHEDALMOND:4293643775,BLUE:65535,BLUEVIOLET:2318131967,BROWN:2771004159,BURLYWOOD:3736635391,CADETBLUE:1604231423,CHARTREUSE:2147418367,CHOCOLATE:3530104575,CORAL:4286533887,CORNFLOWERBLUE:1687547391,CORNSILK:4294499583,CRIMSON:3692313855,CYAN:16777215,DARKBLUE:35839,DARKCYAN:9145343,DARKGOLDENROD:3095837695,DARKGRAY:2846468607,DARKGREEN:6553855,DARKGREY:2846468607,DARKKHAKI:3182914559,DARKMAGENTA:2332068863,DARKOLIVEGREEN:1433087999,DARKORANGE:4287365375,DARKORCHID:2570243327,DARKRED:2332033279,DARKSALMON:3918953215,DARKSEAGREEN:2411499519,DARKSLATEBLUE:1211993087,DARKSLATEGRAY:793726975,DARKSLATEGREY:793726975,DARKTURQUOISE:13554175,DARKVIOLET:2483082239,DEEPPINK:4279538687,DEEPSKYBLUE:12582911,DIMGRAY:1768516095,DIMGREY:1768516095,DODGERBLUE:512819199,FIREBRICK:2988581631,FLORALWHITE:4294635775,FORESTGREEN:579543807,FUCHSIA:4278255615,GAINSBORO:3705462015,GHOSTWHITE:4177068031,GOLD:4292280575,GOLDENROD:3668254975,GRAY:2155905279,GREEN:8388863,GREENYELLOW:2919182335,GREY:2155905279,HONEYDEW:4043305215,HOTPINK:4285117695,INDIANRED:3445382399,INDIGO:1258324735,IVORY:4294963455,KHAKI:4041641215,LAVENDER:3873897215,LAVENDERBLUSH:4293981695,LAWNGREEN:2096890111,LEMONCHIFFON:4294626815,LIGHTBLUE:2916673279,LIGHTCORAL:4034953471,LIGHTCYAN:3774873599,LIGHTGOLDENRODYELLOW:4210742015,LIGHTGRAY:3553874943,LIGHTGREEN:2431553791,LIGHTGREY:3553874943,LIGHTPINK:4290167295,LIGHTSALMON:4288707327,LIGHTSEAGREEN:548580095,LIGHTSKYBLUE:2278488831,LIGHTSLATEGRAY:2005441023,LIGHTSLATEGREY:2005441023,LIGHTSTEELBLUE:2965692159,LIGHTYELLOW:4294959359,LIME:16711935,LIMEGREEN:852308735,LINEN:4210091775,MAGENTA:4278255615,MAROON:2147483903,MEDIUMAQUAMARINE:1724754687,MEDIUMBLUE:52735,MEDIUMORCHID:3126187007,MEDIUMPURPLE:2473647103,MEDIUMSEAGREEN:1018393087,MEDIUMSLATEBLUE:2070474495,MEDIUMSPRINGGREEN:16423679,MEDIUMTURQUOISE:1221709055,MEDIUMVIOLETRED:3340076543,MIDNIGHTBLUE:421097727,MINTCREAM:4127193855,MISTYROSE:4293190143,MOCCASIN:4293178879,NAVAJOWHITE:4292783615,NAVY:33023,OLDLACE:4260751103,OLIVE:2155872511,OLIVEDRAB:1804477439,ORANGE:4289003775,ORANGERED:4282712319,ORCHID:3664828159,PALEGOLDENROD:4008225535,PALEGREEN:2566625535,PALETURQUOISE:2951671551,PALEVIOLETRED:3681588223,PAPAYAWHIP:4293907967,PEACHPUFF:4292524543,PERU:3448061951,PINK:4290825215,PLUM:3718307327,POWDERBLUE:2967529215,PURPLE:2147516671,REBECCAPURPLE:1714657791,RED:4278190335,ROSYBROWN:3163525119,ROYALBLUE:1097458175,SADDLEBROWN:2336560127,SALMON:4202722047,SANDYBROWN:4104413439,SEAGREEN:780883967,SEASHELL:4294307583,SIENNA:2689740287,SILVER:3233857791,SKYBLUE:2278484991,SLATEBLUE:1784335871,SLATEGRAY:1887473919,SLATEGREY:1887473919,SNOW:4294638335,SPRINGGREEN:16744447,STEELBLUE:1182971135,TAN:3535047935,TEAL:8421631,THISTLE:3636451583,TOMATO:4284696575,TRANSPARENT:0,TURQUOISE:1088475391,VIOLET:4001558271,WHEAT:4125012991,WHITE:4294967295,WHITESMOKE:4126537215,YELLOW:4294902015,YELLOWGREEN:2597139199},pn={name:"background-clip",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Ri(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},fn={name:"background-color",initialValue:"transparent",prefix:!1,type:3,format:"color"},mn=function(e,t){var i=tn.parse(e,t[0]),n=t[1];return n&&Ni(n)?{color:i,stop:n}:{color:i,stop:null}},gn=function(e,t){var i=e[0],n=e[e.length-1];null===i.stop&&(i.stop=ji),null===n.stop&&(n.stop=Hi);for(var r=[],o=0,s=0;so?r.push(l):r.push(o),o=l}else r.push(null)}var c=null;for(s=0;se.optimumDistance)?{optimumCorner:t,optimumDistance:a}:e},{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},xn=function(e,t,i,n,r){var o=0,s=0;switch(e.size){case 0:0===e.shape?o=s=Math.min(Math.abs(t),Math.abs(t-n),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.min(Math.abs(t),Math.abs(t-n)),s=Math.min(Math.abs(i),Math.abs(i-r)));break;case 2:if(0===e.shape)o=s=Math.min(yn(t,i),yn(t,i-r),yn(t-n,i),yn(t-n,i-r));else if(1===e.shape){var a=Math.min(Math.abs(i),Math.abs(i-r))/Math.min(Math.abs(t),Math.abs(t-n)),l=vn(n,r,t,i,!0),c=l[0],u=l[1];s=a*(o=yn(c-t,(u-i)/a))}break;case 1:0===e.shape?o=s=Math.max(Math.abs(t),Math.abs(t-n),Math.abs(i),Math.abs(i-r)):1===e.shape&&(o=Math.max(Math.abs(t),Math.abs(t-n)),s=Math.max(Math.abs(i),Math.abs(i-r)));break;case 3:if(0===e.shape)o=s=Math.max(yn(t,i),yn(t,i-r),yn(t-n,i),yn(t-n,i-r));else if(1===e.shape){a=Math.max(Math.abs(i),Math.abs(i-r))/Math.max(Math.abs(t),Math.abs(t-n));var h=vn(n,r,t,i,!1);c=h[0],u=h[1],s=a*(o=yn(c-t,(u-i)/a))}}return Array.isArray(e.size)&&(o=$i(e.size[0],n),s=2===e.size.length?$i(e.size[1],r):o),[o,s]},bn=function(e,t){var i=en(180),n=[];return Oi(t).forEach(function(t,r){if(0===r){var o=t[0];if(20===o.type&&"to"===o.value)return void(i=Yi(t));if(Ji(o))return void(i=Xi.parse(e,o))}var s=mn(e,t);n.push(s)}),{angle:i,stops:n,type:1}},wn=function(e,t){var i=en(180),n=[];return Oi(t).forEach(function(t,r){if(0===r){var o=t[0];if(20===o.type&&-1!==["top","left","right","bottom"].indexOf(o.value))return void(i=Yi(t));if(Ji(o))return void(i=(Xi.parse(e,o)+en(270))%en(360))}var s=mn(e,t);n.push(s)}),{angle:i,stops:n,type:1}},Tn=function(e,t){var i=en(180),n=[],r=1,o=0,s=3,a=[];return Oi(t).forEach(function(t,i){var o=t[0];if(0===i){if(Ri(o)&&"linear"===o.value)return void(r=1);if(Ri(o)&&"radial"===o.value)return void(r=2)}if(18===o.type)if("from"===o.name){var s=tn.parse(e,o.values[0]);n.push({stop:ji,color:s})}else if("to"===o.name)s=tn.parse(e,o.values[0]),n.push({stop:Hi,color:s});else if("color-stop"===o.name){var a=o.values.filter(Di);if(2===a.length){s=tn.parse(e,a[1]);var l=a[0];Pi(l)&&n.push({stop:{type:16,number:100*l.number,flags:l.flags},color:s})}}}),1===r?{angle:(i+en(180))%en(360),stops:n,type:r}:{size:s,shape:o,stops:n,position:a,type:r}},En="closest-side",Cn="farthest-side",Sn="closest-corner",Bn="farthest-corner",In="circle",Mn="ellipse",Pn="cover",Rn="contain",Ln=function(e,t){var i=0,n=3,r=[],o=[];return Oi(t).forEach(function(t,s){var a=!0;if(0===s){var l=!1;a=t.reduce(function(e,t){if(l)if(Ri(t))switch(t.value){case"center":return o.push(Gi),e;case"top":case"left":return o.push(ji),e;case"right":case"bottom":return o.push(Hi),e}else(Ni(t)||Ui(t))&&o.push(t);else if(Ri(t))switch(t.value){case In:return i=0,!1;case Mn:return i=1,!1;case"at":return l=!0,!1;case En:return n=0,!1;case Pn:case Cn:return n=1,!1;case Rn:case Sn:return n=2,!1;case Bn:return n=3,!1}else if(Ui(t)||Ni(t))return Array.isArray(n)||(n=[]),n.push(t),!1;return e},a)}if(a){var c=mn(e,t);r.push(c)}}),{size:n,shape:i,stops:r,position:o,type:2}},Fn=function(e,t){var i=0,n=3,r=[],o=[];return Oi(t).forEach(function(t,s){var a=!0;if(0===s?a=t.reduce(function(e,t){if(Ri(t))switch(t.value){case"center":return o.push(Gi),!1;case"top":case"left":return o.push(ji),!1;case"right":case"bottom":return o.push(Hi),!1}else if(Ni(t)||Ui(t))return o.push(t),!1;return e},a):1===s&&(a=t.reduce(function(e,t){if(Ri(t))switch(t.value){case In:return i=0,!1;case Mn:return i=1,!1;case Rn:case En:return n=0,!1;case Cn:return n=1,!1;case Sn:return n=2,!1;case Pn:case Bn:return n=3,!1}else if(Ui(t)||Ni(t))return Array.isArray(n)||(n=[]),n.push(t),!1;return e},a)),a){var l=mn(e,t);r.push(l)}}),{size:n,shape:i,stops:r,position:o,type:2}},kn=function(e){return 1===e.type},Dn=function(e){return 2===e.type},On={name:"image",parse:function(e,t){if(22===t.type){var i={url:t.value,type:0};return e.cache.addImage(t.value),i}if(18===t.type){var n=Nn[t.name];if(void 0===n)throw new Error('Attempting to parse an unsupported image function "'+t.name+'"');return n(e,t.values)}throw new Error("Unsupported image type "+t.type)}};function zn(e){return!(20===e.type&&"none"===e.value||18===e.type&&!Nn[e.name])}var Un,Nn={"linear-gradient":bn,"-moz-linear-gradient":wn,"-ms-linear-gradient":wn,"-o-linear-gradient":wn,"-webkit-linear-gradient":wn,"radial-gradient":Ln,"-moz-radial-gradient":Fn,"-ms-radial-gradient":Fn,"-o-radial-gradient":Fn,"-webkit-radial-gradient":Fn,"-webkit-gradient":Tn},Vn={name:"background-image",initialValue:"none",type:1,prefix:!1,parse:function(e,t){if(0===t.length)return[];var i=t[0];return 20===i.type&&"none"===i.value?[]:t.filter(function(e){return Di(e)&&zn(e)}).map(function(t){return On.parse(e,t)})}},jn={name:"background-origin",initialValue:"border-box",prefix:!1,type:1,parse:function(e,t){return t.map(function(e){if(Ri(e))switch(e.value){case"padding-box":return 1;case"content-box":return 2}return 0})}},Gn={name:"background-position",initialValue:"0% 0%",type:1,prefix:!1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Ni)}).map(Vi)}},Hn={name:"background-repeat",initialValue:"repeat",prefix:!1,type:1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Ri).map(function(e){return e.value}).join(" ")}).map(Qn)}},Qn=function(e){switch(e){case"no-repeat":return 1;case"repeat-x":case"repeat no-repeat":return 2;case"repeat-y":case"no-repeat repeat":return 3;default:return 0}};!function(e){e.AUTO="auto",e.CONTAIN="contain",e.COVER="cover"}(Un||(Un={}));var $n,Zn={name:"background-size",initialValue:"0",prefix:!1,type:1,parse:function(e,t){return Oi(t).map(function(e){return e.filter(Wn)})}},Wn=function(e){return Ri(e)||Ni(e)},qn=function(e){return{name:"border-"+e+"-color",initialValue:"transparent",prefix:!1,type:3,format:"color"}},Kn=qn("top"),Xn=qn("right"),Jn=qn("bottom"),Yn=qn("left"),er=function(e){return{name:"border-radius-"+e,initialValue:"0 0",prefix:!1,type:1,parse:function(e,t){return Vi(t.filter(Ni))}}},tr=er("top-left"),ir=er("top-right"),nr=er("bottom-right"),rr=er("bottom-left"),or=function(e){return{name:"border-"+e+"-style",initialValue:"solid",prefix:!1,type:2,parse:function(e,t){switch(t){case"none":return 0;case"dashed":return 2;case"dotted":return 3;case"double":return 4}return 1}}},sr=or("top"),ar=or("right"),lr=or("bottom"),cr=or("left"),ur=function(e){return{name:"border-"+e+"-width",initialValue:"0",type:0,prefix:!1,parse:function(e,t){return Mi(t)?t.number:0}}},hr=ur("top"),dr=ur("right"),pr=ur("bottom"),fr=ur("left"),mr={name:"color",initialValue:"transparent",prefix:!1,type:3,format:"color"},gr={name:"direction",initialValue:"ltr",prefix:!1,type:2,parse:function(e,t){return"rtl"===t?1:0}},_r={name:"display",initialValue:"inline-block",prefix:!1,type:1,parse:function(e,t){return t.filter(Ri).reduce(function(e,t){return e|Ar(t.value)},0)}},Ar=function(e){switch(e){case"block":case"-webkit-box":return 2;case"inline":return 4;case"run-in":return 8;case"flow":return 16;case"flow-root":return 32;case"table":return 64;case"flex":case"-webkit-flex":return 128;case"grid":case"-ms-grid":return 256;case"ruby":return 512;case"subgrid":return 1024;case"list-item":return 2048;case"table-row-group":return 4096;case"table-header-group":return 8192;case"table-footer-group":return 16384;case"table-row":return 32768;case"table-cell":return 65536;case"table-column-group":return 131072;case"table-column":return 262144;case"table-caption":return 524288;case"ruby-base":return 1048576;case"ruby-text":return 2097152;case"ruby-base-container":return 4194304;case"ruby-text-container":return 8388608;case"contents":return 16777216;case"inline-block":return 33554432;case"inline-list-item":return 67108864;case"inline-table":return 134217728;case"inline-flex":return 268435456;case"inline-grid":return 536870912}return 0},yr={name:"float",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"left":return 1;case"right":return 2;case"inline-start":return 3;case"inline-end":return 4}return 0}},vr={name:"letter-spacing",initialValue:"0",prefix:!1,type:0,parse:function(e,t){return 20===t.type&&"normal"===t.value?0:17===t.type||15===t.type?t.number:0}};!function(e){e.NORMAL="normal",e.STRICT="strict"}($n||($n={}));var xr,br={name:"line-break",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"strict"===t?$n.STRICT:$n.NORMAL}},wr={name:"line-height",initialValue:"normal",prefix:!1,type:4},Tr=function(e,t){return Ri(e)&&"normal"===e.value?1.2*t:17===e.type?t*e.number:Ni(e)?$i(e,t):t},Er={name:"list-style-image",initialValue:"none",type:0,prefix:!1,parse:function(e,t){return 20===t.type&&"none"===t.value?null:On.parse(e,t)}},Cr={name:"list-style-position",initialValue:"outside",prefix:!1,type:2,parse:function(e,t){return"inside"===t?0:1}},Sr={name:"list-style-type",initialValue:"none",prefix:!1,type:2,parse:function(e,t){switch(t){case"disc":return 0;case"circle":return 1;case"square":return 2;case"decimal":return 3;case"cjk-decimal":return 4;case"decimal-leading-zero":return 5;case"lower-roman":return 6;case"upper-roman":return 7;case"lower-greek":return 8;case"lower-alpha":return 9;case"upper-alpha":return 10;case"arabic-indic":return 11;case"armenian":return 12;case"bengali":return 13;case"cambodian":return 14;case"cjk-earthly-branch":return 15;case"cjk-heavenly-stem":return 16;case"cjk-ideographic":return 17;case"devanagari":return 18;case"ethiopic-numeric":return 19;case"georgian":return 20;case"gujarati":return 21;case"gurmukhi":case"hebrew":return 22;case"hiragana":return 23;case"hiragana-iroha":return 24;case"japanese-formal":return 25;case"japanese-informal":return 26;case"kannada":return 27;case"katakana":return 28;case"katakana-iroha":return 29;case"khmer":return 30;case"korean-hangul-formal":return 31;case"korean-hanja-formal":return 32;case"korean-hanja-informal":return 33;case"lao":return 34;case"lower-armenian":return 35;case"malayalam":return 36;case"mongolian":return 37;case"myanmar":return 38;case"oriya":return 39;case"persian":return 40;case"simp-chinese-formal":return 41;case"simp-chinese-informal":return 42;case"tamil":return 43;case"telugu":return 44;case"thai":return 45;case"tibetan":return 46;case"trad-chinese-formal":return 47;case"trad-chinese-informal":return 48;case"upper-armenian":return 49;case"disclosure-open":return 50;case"disclosure-closed":return 51;default:return-1}}},Br=function(e){return{name:"margin-"+e,initialValue:"0",prefix:!1,type:4}},Ir=Br("top"),Mr=Br("right"),Pr=Br("bottom"),Rr=Br("left"),Lr={name:"overflow",initialValue:"visible",prefix:!1,type:1,parse:function(e,t){return t.filter(Ri).map(function(e){switch(e.value){case"hidden":return 1;case"scroll":return 2;case"clip":return 3;case"auto":return 4;default:return 0}})}},Fr={name:"overflow-wrap",initialValue:"normal",prefix:!1,type:2,parse:function(e,t){return"break-word"===t?"break-word":"normal"}},kr=function(e){return{name:"padding-"+e,initialValue:"0",prefix:!1,type:3,format:"length-percentage"}},Dr=kr("top"),Or=kr("right"),zr=kr("bottom"),Ur=kr("left"),Nr={name:"text-align",initialValue:"left",prefix:!1,type:2,parse:function(e,t){switch(t){case"right":return 2;case"center":case"justify":return 1;default:return 0}}},Vr={name:"position",initialValue:"static",prefix:!1,type:2,parse:function(e,t){switch(t){case"relative":return 1;case"absolute":return 2;case"fixed":return 3;case"sticky":return 4}return 0}},jr={name:"text-shadow",initialValue:"none",type:1,prefix:!1,parse:function(e,t){return 1===t.length&&Fi(t[0],"none")?[]:Oi(t).map(function(t){for(var i={color:dn.TRANSPARENT,offsetX:ji,offsetY:ji,blur:ji},n=0,r=0;r1?1:0],this.overflowWrap=bo(e,Fr,t.overflowWrap),this.paddingTop=bo(e,Dr,t.paddingTop),this.paddingRight=bo(e,Or,t.paddingRight),this.paddingBottom=bo(e,zr,t.paddingBottom),this.paddingLeft=bo(e,Ur,t.paddingLeft),this.paintOrder=bo(e,go,t.paintOrder),this.position=bo(e,Vr,t.position),this.textAlign=bo(e,Nr,t.textAlign),this.textDecorationColor=bo(e,eo,null!==(i=t.textDecorationColor)&&void 0!==i?i:t.color),this.textDecorationLine=bo(e,to,null!==(n=t.textDecorationLine)&&void 0!==n?n:t.textDecoration),this.textShadow=bo(e,jr,t.textShadow),this.textTransform=bo(e,Gr,t.textTransform),this.transform=bo(e,Hr,t.transform),this.transformOrigin=bo(e,Wr,t.transformOrigin),this.visibility=bo(e,qr,t.visibility),this.webkitTextStrokeColor=bo(e,_o,t.webkitTextStrokeColor),this.webkitTextStrokeWidth=bo(e,Ao,t.webkitTextStrokeWidth),this.wordBreak=bo(e,Kr,t.wordBreak),this.zIndex=bo(e,Xr,t.zIndex)}return e.prototype.isVisible=function(){return this.display>0&&this.opacity>0&&0===this.visibility},e.prototype.isTransparent=function(){return nn(this.backgroundColor)},e.prototype.isTransformed=function(){return null!==this.transform},e.prototype.isPositioned=function(){return 0!==this.position},e.prototype.isPositionedWithZIndex=function(){return this.isPositioned()&&!this.zIndex.auto},e.prototype.isFloating=function(){return 0!==this.float},e.prototype.isInlineLevel=function(){return ao(this.display,4)||ao(this.display,33554432)||ao(this.display,268435456)||ao(this.display,536870912)||ao(this.display,67108864)||ao(this.display,134217728)},e}(),vo=function(){function e(e,t){this.content=bo(e,lo,t.content),this.quotes=bo(e,po,t.quotes)}return e}(),xo=function(){function e(e,t){this.counterIncrement=bo(e,co,t.counterIncrement),this.counterReset=bo(e,uo,t.counterReset)}return e}(),bo=function(e,t,i){var n=new Bi,r=null!=i?i.toString():t.initialValue;n.write(r);var o=new Ii(n.read());switch(t.type){case 2:var s=o.parseComponentValue();return t.parse(e,Ri(s)?s.value:t.initialValue);case 0:return t.parse(e,o.parseComponentValue());case 1:return t.parse(e,o.parseComponentValues());case 4:return o.parseComponentValue();case 3:switch(t.format){case"angle":return Xi.parse(e,o.parseComponentValue());case"color":return tn.parse(e,o.parseComponentValue());case"image":return On.parse(e,o.parseComponentValue());case"length":var a=o.parseComponentValue();return Ui(a)?a:ji;case"length-percentage":var l=o.parseComponentValue();return Ni(l)?l:ji;case"time":return Jr.parse(e,o.parseComponentValue())}}},wo="data-html2canvas-debug",To=function(e){switch(e.getAttribute(wo)){case"all":return 1;case"clone":return 2;case"parse":return 3;case"render":return 4;default:return 0}},Eo=function(e,t){var i=To(e);return 1===i||t===i},Co=function(){function e(e,t){this.context=e,this.textNodes=[],this.elements=[],this.flags=0,Eo(t,3),this.styles=new yo(e,window.getComputedStyle(t,null)),pa(t)&&(this.styles.animationDuration.some(function(e){return e>0})&&(t.style.animationDuration="0s"),null!==this.styles.transform&&(t.style.transform="none")),this.bounds=a(this.context,t),Eo(t,4)&&(this.flags|=16)}return e}(),So="AAAAAAAAAAAAEA4AGBkAAFAaAAACAAAAAAAIABAAGAAwADgACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAIABAAQABIAEQATAAIABAACAAQAAgAEAAIABAAVABcAAgAEAAIABAACAAQAGAAaABwAHgAgACIAI4AlgAIABAAmwCjAKgAsAC2AL4AvQDFAMoA0gBPAVYBWgEIAAgACACMANoAYgFkAWwBdAF8AX0BhQGNAZUBlgGeAaMBlQGWAasBswF8AbsBwwF0AcsBYwHTAQgA2wG/AOMBdAF8AekB8QF0AfkB+wHiAHQBfAEIAAMC5gQIAAsCEgIIAAgAFgIeAggAIgIpAggAMQI5AkACygEIAAgASAJQAlgCYAIIAAgACAAKBQoFCgUTBRMFGQUrBSsFCAAIAAgACAAIAAgACAAIAAgACABdAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABoAmgCrwGvAQgAbgJ2AggAHgEIAAgACADnAXsCCAAIAAgAgwIIAAgACAAIAAgACACKAggAkQKZAggAPADJAAgAoQKkAqwCsgK6AsICCADJAggA0AIIAAgACAAIANYC3gIIAAgACAAIAAgACABAAOYCCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAkASoB+QIEAAgACAA8AEMCCABCBQgACABJBVAFCAAIAAgACAAIAAgACAAIAAgACABTBVoFCAAIAFoFCABfBWUFCAAIAAgACAAIAAgAbQUIAAgACAAIAAgACABzBXsFfQWFBYoFigWKBZEFigWKBYoFmAWfBaYFrgWxBbkFCAAIAAgACAAIAAgACAAIAAgACAAIAMEFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAMgFCADQBQgACAAIAAgACAAIAAgACAAIAAgACAAIAO4CCAAIAAgAiQAIAAgACABAAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAD0AggACAD8AggACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIANYFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAMDvwAIAAgAJAIIAAgACAAIAAgACAAIAAgACwMTAwgACAB9BOsEGwMjAwgAKwMyAwsFYgE3A/MEPwMIAEUDTQNRAwgAWQOsAGEDCAAIAAgACAAIAAgACABpAzQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFOgU0BTUFNgU3BTgFOQU6BTQFNQU2BTcFOAU5BToFNAU1BTYFNwU4BTkFIQUoBSwFCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABtAwgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABMAEwACAAIAAgACAAIABgACAAIAAgACAC/AAgACAAyAQgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACAAIAAwAAgACAAIAAgACAAIAAgACAAIAAAARABIAAgACAAIABQASAAIAAgAIABwAEAAjgCIABsAqAC2AL0AigDQAtwC+IJIQqVAZUBWQqVAZUBlQGVAZUBlQGrC5UBlQGVAZUBlQGVAZUBlQGVAXsKlQGVAbAK6wsrDGUMpQzlDJUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAZUBlQGVAfAKAAuZA64AtwCJALoC6ADwAAgAuACgA/oEpgO6AqsD+AAIAAgAswMIAAgACAAIAIkAuwP5AfsBwwPLAwgACAAIAAgACADRA9kDCAAIAOED6QMIAAgACAAIAAgACADuA/YDCAAIAP4DyQAIAAgABgQIAAgAXQAOBAgACAAIAAgACAAIABMECAAIAAgACAAIAAgACAD8AAQBCAAIAAgAGgQiBCoECAExBAgAEAEIAAgACAAIAAgACAAIAAgACAAIAAgACAA4BAgACABABEYECAAIAAgATAQYAQgAVAQIAAgACAAIAAgACAAIAAgACAAIAFoECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAOQEIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAB+BAcACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAEABhgSMBAgACAAIAAgAlAQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAwAEAAQABAADAAMAAwADAAQABAAEAAQABAAEAAQABHATAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAdQMIAAgACAAIAAgACAAIAMkACAAIAAgAfQMIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACACFA4kDCAAIAAgACAAIAOcBCAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAIcDCAAIAAgACAAIAAgACAAIAAgACAAIAJEDCAAIAAgACADFAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABgBAgAZgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAbAQCBXIECAAIAHkECAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACABAAJwEQACjBKoEsgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAC6BMIECAAIAAgACAAIAAgACABmBAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAxwQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAGYECAAIAAgAzgQIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBd0FXwUIAOIF6gXxBYoF3gT5BQAGCAaKBYoFigWKBYoFigWKBYoFigWKBYoFigXWBIoFigWKBYoFigWKBYoFigWKBYsFEAaKBYoFigWKBYoFigWKBRQGCACKBYoFigWKBQgACAAIANEECAAIABgGigUgBggAJgYIAC4GMwaKBYoF0wQ3Bj4GigWKBYoFigWKBYoFigWKBYoFigWKBYoFigUIAAgACAAIAAgACAAIAAgAigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWKBYoFigWLBf///////wQABAAEAAQABAAEAAQABAAEAAQAAwAEAAQAAgAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAQADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUAAAAFAAUAAAAFAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUAAQAAAAUABQAFAAUABQAFAAAAAAAFAAUAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAFAAUAAQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAAABwAHAAcAAAAHAAcABwAFAAEAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAcABwAFAAUAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAQABAAAAAAAAAAAAAAAFAAUABQAFAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAHAAcAAAAHAAcAAAAAAAUABQAHAAUAAQAHAAEABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwABAAUABQAFAAUAAAAAAAAAAAAAAAEAAQABAAEAAQABAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABQANAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAQABAAEAAQABAAEAAQABAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAABQAHAAUABQAFAAAAAAAAAAcABQAFAAUABQAFAAQABAAEAAQABAAEAAQABAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUAAAAFAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAUAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAcABwAFAAcABwAAAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUABwAHAAUABQAFAAUAAAAAAAcABwAAAAAABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAABQAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAAAAAAAAAAABQAFAAAAAAAFAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAFAAUABQAFAAUAAAAFAAUABwAAAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABwAFAAUABQAFAAAAAAAHAAcAAAAAAAcABwAFAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAAAAAAAAAHAAcABwAAAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAABQAHAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAUABQAFAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAHAAcABQAHAAcAAAAFAAcABwAAAAcABwAFAAUAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAFAAcABwAFAAUABQAAAAUAAAAHAAcABwAHAAcABwAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAHAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAABwAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAUAAAAFAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABwAFAAUABQAFAAUAAAAFAAUAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABwAFAAUABQAFAAUABQAAAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABQAFAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABQAFAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAHAAUABQAFAAUABQAFAAUABwAHAAcABwAHAAcABwAHAAUABwAHAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABwAHAAcABwAFAAUABwAHAAcAAAAAAAAAAAAHAAcABQAHAAcABwAHAAcABwAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAcABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAUABQAFAAUABQAFAAUAAAAFAAAABQAAAAAABQAFAAUABQAFAAUABQAFAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAFAAUAAAAAAAUABQAFAAUABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABwAFAAcABwAHAAcABwAFAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAUABQAFAAUABwAHAAUABQAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABQAFAAcABwAHAAUABwAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAcABQAFAAUABQAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAAAAAABwAFAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAAAAAAAAAFAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAUABQAHAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAUABQAFAAUABQAHAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAcABwAFAAUABQAFAAcABwAFAAUABwAHAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAFAAcABwAFAAUABwAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAFAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAFAAUABQAAAAAABQAFAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAcABwAAAAAAAAAAAAAABwAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAcABwAFAAcABwAAAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAFAAUABQAAAAUABQAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABwAFAAUABQAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAUABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAHAAcABQAHAAUABQAAAAAAAAAAAAAAAAAFAAAABwAHAAcABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAHAAcABwAAAAAABwAHAAAAAAAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABwAHAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAFAAUABwAFAAcABwAFAAcABQAFAAcABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAHAAcABQAFAAUABQAAAAAABwAHAAcABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAHAAUABQAFAAUABQAFAAUABQAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABwAFAAcABwAFAAUABQAFAAUABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAcABwAFAAUABQAFAAcABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAUABQAFAAUABQAHAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAFAAUABQAFAAAAAAAFAAUABwAHAAcABwAFAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABwAHAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAcABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUAAAAHAAUABQAFAAUABQAFAAUABwAFAAUABwAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUAAAAAAAAABQAAAAUABQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAcABwAHAAcAAAAFAAUAAAAHAAcABQAHAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAAAAUABQAFAAAAAAAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAFAAUABQAAAAAABQAFAAUABQAFAAUABQAAAAUABQAAAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUABQAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAFAAUABQAFAAUABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAFAAUABQAFAAUADgAOAA4ADgAOAA4ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAA8ADwAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAcABwAHAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAMAAwADAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAAAAAAAAAAAAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAKAAoACgAAAAAAAAAAAAsADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwACwAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAMAAwADAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAADgAOAA4AAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAAAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4AAAAOAAAAAAAAAAAAAAAAAA4AAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAAAAAAAAAAAA4AAAAOAAAAAAAAAAAADgAOAA4AAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAA4ADgAOAA4ADgAOAA4ADgAOAAAADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4ADgAOAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAOAA4ADgAOAA4AAAAAAAAAAAAAAAAAAAAAAA4ADgAOAA4ADgAOAA4ADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAOAA4ADgAOAA4ADgAAAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4ADgAOAA4AAAAAAAAAAAA=",Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Io="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Mo=0;Mo>4,u[l++]=(15&n)<<4|r>>2,u[l++]=(3&r)<<6|63&o;return c},Ro=function(e){for(var t=e.length,i=[],n=0;n>Fo,zo=(1<>Fo)+32,No=65536>>ko,Vo=(1<=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>Fo])<>Fo)])<>ko),t=this.index[t],t+=e>>Fo&Vo,t=((t=this.index[t])<=55296&&r<=56319&&i>10),s%1024+56320)),(r+1===i||n.length>16384)&&(o+=String.fromCharCode.apply(String,n),n.length=0)}return o},ds=Ho(So),ps="×",fs="÷",ms=function(e){return ds.get(e)},gs=function(e,t,i){var n=i-2,r=t[n],o=t[i-1],s=t[i];if(o===Xo&&s===Jo)return ps;if(o===Xo||o===Jo||o===Yo)return fs;if(s===Xo||s===Jo||s===Yo)return fs;if(o===is&&-1!==[is,ns,os,ss].indexOf(s))return ps;if(!(o!==os&&o!==ns||s!==ns&&s!==rs))return ps;if((o===ss||o===rs)&&s===rs)return ps;if(s===as||s===es)return ps;if(s===ts)return ps;if(o===Ko)return ps;if(o===as&&s===ls){for(;r===es;)r=t[--n];if(r===ls)return ps}if(o===cs&&s===cs){for(var a=0;r===cs;)a++,r=t[--n];if(a%2==0)return ps}return fs},_s=function(e){var t=us(e),i=t.length,n=0,r=0,o=t.map(ms);return{next:function(){if(n>=i)return{done:!0,value:null};for(var e=ps;ns.x||r.y>s.y;return s=r,0===t||a});return e.body.removeChild(t),a},xs=function(){return void 0!==(new Image).crossOrigin},bs=function(){return"string"==typeof(new XMLHttpRequest).responseType},ws=function(e){var t=new Image,i=e.createElement("canvas"),n=i.getContext("2d");if(!n)return!1;t.src="data:image/svg+xml,";try{n.drawImage(t,0,0),i.toDataURL()}catch(e){return!1}return!0},Ts=function(e){return 0===e[0]&&255===e[1]&&0===e[2]&&255===e[3]},Es=function(e){var t=e.createElement("canvas"),i=100;t.width=i,t.height=i;var n=t.getContext("2d");if(!n)return Promise.reject(!1);n.fillStyle="rgb(0, 255, 0)",n.fillRect(0,0,i,i);var r=new Image,o=t.toDataURL();r.src=o;var s=Cs(i,i,0,0,r);return n.fillStyle="red",n.fillRect(0,0,i,i),Ss(s).then(function(t){n.drawImage(t,0,0);var r=n.getImageData(0,0,i,i).data;n.fillStyle="red",n.fillRect(0,0,i,i);var s=e.createElement("div");return s.style.backgroundImage="url("+o+")",s.style.height=i+"px",Ts(r)?Ss(Cs(i,i,0,0,s)):Promise.reject(!1)}).then(function(e){return n.drawImage(e,0,0),Ts(n.getImageData(0,0,i,i).data)}).catch(function(){return!1})},Cs=function(e,t,i,n,r){var o="http://www.w3.org/2000/svg",s=document.createElementNS(o,"svg"),a=document.createElementNS(o,"foreignObject");return s.setAttributeNS(null,"width",e.toString()),s.setAttributeNS(null,"height",t.toString()),a.setAttributeNS(null,"width","100%"),a.setAttributeNS(null,"height","100%"),a.setAttributeNS(null,"x",i.toString()),a.setAttributeNS(null,"y",n.toString()),a.setAttributeNS(null,"externalResourcesRequired","true"),s.appendChild(a),a.appendChild(r),s},Ss=function(e){return new Promise(function(t,i){var n=new Image;n.onload=function(){return t(n)},n.onerror=i,n.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(e))})},Bs={get SUPPORT_RANGE_BOUNDS(){var e=ys(document);return Object.defineProperty(Bs,"SUPPORT_RANGE_BOUNDS",{value:e}),e},get SUPPORT_WORD_BREAKING(){var e=Bs.SUPPORT_RANGE_BOUNDS&&vs(document);return Object.defineProperty(Bs,"SUPPORT_WORD_BREAKING",{value:e}),e},get SUPPORT_SVG_DRAWING(){var e=ws(document);return Object.defineProperty(Bs,"SUPPORT_SVG_DRAWING",{value:e}),e},get SUPPORT_FOREIGNOBJECT_DRAWING(){var e="function"==typeof Array.from&&"function"==typeof window.fetch?Es(document):Promise.resolve(!1);return Object.defineProperty(Bs,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:e}),e},get SUPPORT_CORS_IMAGES(){var e=xs();return Object.defineProperty(Bs,"SUPPORT_CORS_IMAGES",{value:e}),e},get SUPPORT_RESPONSE_TYPE(){var e=bs();return Object.defineProperty(Bs,"SUPPORT_RESPONSE_TYPE",{value:e}),e},get SUPPORT_CORS_XHR(){var e="withCredentials"in new XMLHttpRequest;return Object.defineProperty(Bs,"SUPPORT_CORS_XHR",{value:e}),e},get SUPPORT_NATIVE_TEXT_SEGMENTATION(){var e=!("undefined"==typeof Intl||!Intl.Segmenter);return Object.defineProperty(Bs,"SUPPORT_NATIVE_TEXT_SEGMENTATION",{value:e}),e}},Is=function(){function e(e,t){this.text=e,this.bounds=t}return e}(),Ms=function(e,t,i,n){var r=ks(t,i),o=[],a=0;return r.forEach(function(t){if(i.textDecorationLine.length||t.trim().length>0)if(Bs.SUPPORT_RANGE_BOUNDS){var r=Rs(n,a,t.length).getClientRects();if(r.length>1){var l=Ls(t),c=0;l.forEach(function(t){o.push(new Is(t,s.fromDOMRectList(e,Rs(n,c+a,t.length).getClientRects()))),c+=t.length})}else o.push(new Is(t,s.fromDOMRectList(e,r)))}else{var u=n.splitText(t.length);o.push(new Is(t,Ps(e,n))),n=u}else Bs.SUPPORT_RANGE_BOUNDS||(n=n.splitText(t.length));a+=t.length}),o},Ps=function(e,t){var i=t.ownerDocument;if(i){var n=i.createElement("html2canvaswrapper");n.appendChild(t.cloneNode(!0));var r=t.parentNode;if(r){r.replaceChild(n,t);var o=a(e,n);return n.firstChild&&r.replaceChild(n.firstChild,n),o}}return s.EMPTY},Rs=function(e,t,i){var n=e.ownerDocument;if(!n)throw new Error("Node has no owner document");var r=n.createRange();return r.setStart(e,t),r.setEnd(e,t+i),r},Ls=function(e){if(Bs.SUPPORT_NATIVE_TEXT_SEGMENTATION){var t=new Intl.Segmenter(void 0,{granularity:"grapheme"});return Array.from(t.segment(e)).map(function(e){return e.segment})}return As(e)},Fs=function(e,t){if(Bs.SUPPORT_NATIVE_TEXT_SEGMENTATION){var i=new Intl.Segmenter(void 0,{granularity:"word"});return Array.from(i.segment(e)).map(function(e){return e.segment})}return Os(e,t)},ks=function(e,t){return 0!==t.letterSpacing?Ls(e):Fs(e,t)},Ds=[32,160,4961,65792,65793,4153,4241],Os=function(e,t){for(var i,n=je(e,{lineBreak:t.lineBreak,wordBreak:"break-word"===t.overflowWrap?"break-word":t.wordBreak}),r=[],o=function(){if(i.value){var e=i.value.slice(),t=c(e),n="";t.forEach(function(e){-1===Ds.indexOf(e)?n+=u(e):(n.length&&r.push(n),r.push(u(e)),n="")}),n.length&&r.push(n)}};!(i=n.next()).done;)o();return r},zs=function(){function e(e,t,i){this.text=Us(t.data,i.textTransform),this.textBounds=Ms(e,this.text,i,t)}return e}(),Us=function(e,t){switch(t){case 1:return e.toLowerCase();case 3:return e.replace(Ns,Vs);case 2:return e.toUpperCase();default:return e}},Ns=/(^|\s|:|-|\(|\))([a-z])/g,Vs=function(e,t,i){return e.length>0?t+i.toUpperCase():e},js=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.src=i.currentSrc||i.src,n.intrinsicWidth=i.naturalWidth,n.intrinsicHeight=i.naturalHeight,n.context.cache.addImage(n.src),n}return t(i,e),i}(Co),Gs=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.canvas=i,n.intrinsicWidth=i.width,n.intrinsicHeight=i.height,n}return t(i,e),i}(Co),Hs=function(e){function i(t,i){var n=e.call(this,t,i)||this,r=new XMLSerializer,o=a(t,i);return i.setAttribute("width",o.width+"px"),i.setAttribute("height",o.height+"px"),n.svg="data:image/svg+xml,"+encodeURIComponent(r.serializeToString(i)),n.intrinsicWidth=i.width.baseVal.value,n.intrinsicHeight=i.height.baseVal.value,n.context.cache.addImage(n.svg),n}return t(i,e),i}(Co),Qs=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.value=i.value,n}return t(i,e),i}(Co),$s=function(e){function i(t,i){var n=e.call(this,t,i)||this;return n.start=i.start,n.reversed="boolean"==typeof i.reversed&&!0===i.reversed,n}return t(i,e),i}(Co),Zs=[{type:15,flags:0,unit:"px",number:3}],Ws=[{type:16,flags:0,number:50}],qs=function(e){return e.width>e.height?new s(e.left+(e.width-e.height)/2,e.top,e.height,e.height):e.width0)i.textNodes.push(new zs(e,r,i.styles));else if(da(r))if(Ia(r)&&r.assignedNodes)r.assignedNodes().forEach(function(t){return sa(e,t,i,n)});else{var s=aa(e,r);s.styles.isVisible()&&(ca(r,s,n)?s.flags|=4:ua(s.styles)&&(s.flags|=2),-1!==oa.indexOf(r.tagName)&&(s.flags|=8),i.elements.push(s),r.slot,r.shadowRoot?sa(e,r.shadowRoot,s,n):Sa(r)||ya(r)||Ba(r)||sa(e,r,s,n))}},aa=function(e,t){return wa(t)?new js(e,t):xa(t)?new Gs(e,t):ya(t)?new Hs(e,t):ma(t)?new Qs(e,t):ga(t)?new $s(e,t):_a(t)?new ta(e,t):Ba(t)?new ia(e,t):Sa(t)?new na(e,t):Ta(t)?new ra(e,t):new Co(e,t)},la=function(e,t){var i=aa(e,t);return i.flags|=4,sa(e,t,i,i),i},ca=function(e,t,i){return t.styles.isPositionedWithZIndex()||t.styles.opacity<1||t.styles.isTransformed()||va(e)&&i.styles.isTransparent()},ua=function(e){return e.isPositioned()||e.isFloating()},ha=function(e){return e.nodeType===Node.TEXT_NODE},da=function(e){return e.nodeType===Node.ELEMENT_NODE},pa=function(e){return da(e)&&void 0!==e.style&&!fa(e)},fa=function(e){return"object"==typeof e.className},ma=function(e){return"LI"===e.tagName},ga=function(e){return"OL"===e.tagName},_a=function(e){return"INPUT"===e.tagName},Aa=function(e){return"HTML"===e.tagName},ya=function(e){return"svg"===e.tagName},va=function(e){return"BODY"===e.tagName},xa=function(e){return"CANVAS"===e.tagName},ba=function(e){return"VIDEO"===e.tagName},wa=function(e){return"IMG"===e.tagName},Ta=function(e){return"IFRAME"===e.tagName},Ea=function(e){return"STYLE"===e.tagName},Ca=function(e){return"SCRIPT"===e.tagName},Sa=function(e){return"TEXTAREA"===e.tagName},Ba=function(e){return"SELECT"===e.tagName},Ia=function(e){return"SLOT"===e.tagName},Ma=function(e){return e.tagName.indexOf("-")>0},Pa=function(){function e(){this.counters={}}return e.prototype.getCounterValue=function(e){var t=this.counters[e];return t&&t.length?t[t.length-1]:1},e.prototype.getCounterValues=function(e){var t=this.counters[e];return t||[]},e.prototype.pop=function(e){var t=this;e.forEach(function(e){return t.counters[e].pop()})},e.prototype.parse=function(e){var t=this,i=e.counterIncrement,n=e.counterReset,r=!0;null!==i&&i.forEach(function(e){var i=t.counters[e.counter];i&&0!==e.increment&&(r=!1,i.length||i.push(1),i[Math.max(0,i.length-1)]+=e.increment)});var o=[];return r&&n.forEach(function(e){var i=t.counters[e.counter];o.push(e.counter),i||(i=t.counters[e.counter]=[]),i.push(e.reset)}),o},e}(),Ra={integers:[1e3,900,500,400,100,90,50,40,10,9,5,4,1],values:["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]},La={integers:[9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["Ք","Փ","Ւ","Ց","Ր","Տ","Վ","Ս","Ռ","Ջ","Պ","Չ","Ո","Շ","Ն","Յ","Մ","Ճ","Ղ","Ձ","Հ","Կ","Ծ","Խ","Լ","Ի","Ժ","Թ","Ը","Է","Զ","Ե","Դ","Գ","Բ","Ա"]},Fa={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,400,300,200,100,90,80,70,60,50,40,30,20,19,18,17,16,15,10,9,8,7,6,5,4,3,2,1],values:["י׳","ט׳","ח׳","ז׳","ו׳","ה׳","ד׳","ג׳","ב׳","א׳","ת","ש","ר","ק","צ","פ","ע","ס","נ","מ","ל","כ","יט","יח","יז","טז","טו","י","ט","ח","ז","ו","ה","ד","ג","ב","א"]},ka={integers:[1e4,9e3,8e3,7e3,6e3,5e3,4e3,3e3,2e3,1e3,900,800,700,600,500,400,300,200,100,90,80,70,60,50,40,30,20,10,9,8,7,6,5,4,3,2,1],values:["ჵ","ჰ","ჯ","ჴ","ხ","ჭ","წ","ძ","ც","ჩ","შ","ყ","ღ","ქ","ფ","ჳ","ტ","ს","რ","ჟ","პ","ო","ჲ","ნ","მ","ლ","კ","ი","თ","ჱ","ზ","ვ","ე","დ","გ","ბ","ა"]},Da=function(e,t,i,n,r,o){return ei?qa(e,r,o.length>0):n.integers.reduce(function(t,i,r){for(;e>=i;)e-=i,t+=n.values[r];return t},"")+o},Oa=function(e,t,i,n){var r="";do{i||e--,r=n(e)+r,e/=t}while(e*t>=t);return r},za=function(e,t,i,n,r){var o=i-t+1;return(e<0?"-":"")+(Oa(Math.abs(e),o,n,function(e){return u(Math.floor(e%o)+t)})+r)},Ua=function(e,t,i){void 0===i&&(i=". ");var n=t.length;return Oa(Math.abs(e),n,!1,function(e){return t[Math.floor(e%n)]})+i},Na=1,Va=2,ja=4,Ga=8,Ha=function(e,t,i,n,r,o){if(e<-9999||e>9999)return qa(e,4,r.length>0);var s=Math.abs(e),a=r;if(0===s)return t[0]+a;for(var l=0;s>0&&l<=4;l++){var c=s%10;0===c&&ao(o,Na)&&""!==a?a=t[c]+a:c>1||1===c&&0===l||1===c&&1===l&&ao(o,Va)||1===c&&1===l&&ao(o,ja)&&e>100||1===c&&l>1&&ao(o,Ga)?a=t[c]+(l>0?i[l-1]:"")+a:1===c&&l>0&&(a=i[l-1]+a),s=Math.floor(s/10)}return(e<0?n:"")+a},Qa="十百千萬",$a="拾佰仟萬",Za="マイナス",Wa="마이너스",qa=function(e,t,i){var n=i?". ":"",r=i?"、":"",o=i?", ":"",s=i?" ":"";switch(t){case 0:return"•"+s;case 1:return"◦"+s;case 2:return"◾"+s;case 5:var a=za(e,48,57,!0,n);return a.length<4?"0"+a:a;case 4:return Ua(e,"〇一二三四五六七八九",r);case 6:return Da(e,1,3999,Ra,3,n).toLowerCase();case 7:return Da(e,1,3999,Ra,3,n);case 8:return za(e,945,969,!1,n);case 9:return za(e,97,122,!1,n);case 10:return za(e,65,90,!1,n);case 11:return za(e,1632,1641,!0,n);case 12:case 49:return Da(e,1,9999,La,3,n);case 35:return Da(e,1,9999,La,3,n).toLowerCase();case 13:return za(e,2534,2543,!0,n);case 14:case 30:return za(e,6112,6121,!0,n);case 15:return Ua(e,"子丑寅卯辰巳午未申酉戌亥",r);case 16:return Ua(e,"甲乙丙丁戊己庚辛壬癸",r);case 17:case 48:return Ha(e,"零一二三四五六七八九",Qa,"負",r,Va|ja|Ga);case 47:return Ha(e,"零壹貳參肆伍陸柒捌玖",$a,"負",r,Na|Va|ja|Ga);case 42:return Ha(e,"零一二三四五六七八九",Qa,"负",r,Va|ja|Ga);case 41:return Ha(e,"零壹贰叁肆伍陆柒捌玖",$a,"负",r,Na|Va|ja|Ga);case 26:return Ha(e,"〇一二三四五六七八九","十百千万",Za,r,0);case 25:return Ha(e,"零壱弐参四伍六七八九","拾百千万",Za,r,Na|Va|ja);case 31:return Ha(e,"영일이삼사오육칠팔구","십백천만",Wa,o,Na|Va|ja);case 33:return Ha(e,"零一二三四五六七八九","十百千萬",Wa,o,0);case 32:return Ha(e,"零壹貳參四五六七八九","拾百千",Wa,o,Na|Va|ja);case 18:return za(e,2406,2415,!0,n);case 20:return Da(e,1,19999,ka,3,n);case 21:return za(e,2790,2799,!0,n);case 22:return za(e,2662,2671,!0,n);case 22:return Da(e,1,10999,Fa,3,n);case 23:return Ua(e,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case 24:return Ua(e,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case 27:return za(e,3302,3311,!0,n);case 28:return Ua(e,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",r);case 29:return Ua(e,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",r);case 34:return za(e,3792,3801,!0,n);case 37:return za(e,6160,6169,!0,n);case 38:return za(e,4160,4169,!0,n);case 39:return za(e,2918,2927,!0,n);case 40:return za(e,1776,1785,!0,n);case 43:return za(e,3046,3055,!0,n);case 44:return za(e,3174,3183,!0,n);case 45:return za(e,3664,3673,!0,n);case 46:return za(e,3872,3881,!0,n);default:return za(e,48,57,!0,n)}},Ka="data-html2canvas-ignore",Xa=function(){function e(e,t,i){if(this.context=e,this.options=i,this.scrolledElements=[],this.referenceElement=t,this.counters=new Pa,this.quoteDepth=0,!t.ownerDocument)throw new Error("Cloned element does not have an owner document");this.documentElement=this.cloneNode(t.ownerDocument.documentElement,!1)}return e.prototype.toIFrame=function(e,t){var i=this,o=Ya(e,t);if(!o.contentWindow)return Promise.reject("Unable to find iframe window");var s=e.defaultView.pageXOffset,a=e.defaultView.pageYOffset,l=o.contentWindow,c=l.document,u=il(o).then(function(){return n(i,void 0,void 0,function(){var e,i;return r(this,function(n){switch(n.label){case 0:return this.scrolledElements.forEach(al),l&&(l.scrollTo(t.left,t.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||l.scrollY===t.top&&l.scrollX===t.left||(this.context.logger.warn("Unable to restore scroll position for cloned document"),this.context.windowBounds=this.context.windowBounds.add(l.scrollX-t.left,l.scrollY-t.top,0,0))),e=this.options.onclone,void 0===(i=this.clonedReferenceElement)?[2,Promise.reject("Error finding the "+this.referenceElement.nodeName+" in the cloned document")]:c.fonts&&c.fonts.ready?[4,c.fonts.ready]:[3,2];case 1:n.sent(),n.label=2;case 2:return/(AppleWebKit)/g.test(navigator.userAgent)?[4,tl(c)]:[3,4];case 3:n.sent(),n.label=4;case 4:return"function"==typeof e?[2,Promise.resolve().then(function(){return e(c,i)}).then(function(){return o})]:[2,o]}})})});return c.open(),c.write(ol(document.doctype)+""),sl(this.referenceElement.ownerDocument,s,a),c.replaceChild(c.adoptNode(this.documentElement),c.documentElement),c.close(),u},e.prototype.createElementClone=function(e){if(Eo(e,2),xa(e))return this.createCanvasClone(e);if(ba(e))return this.createVideoClone(e);if(Ea(e))return this.createStyleClone(e);var t=e.cloneNode(!1);return wa(t)&&(wa(e)&&e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),"lazy"===t.loading&&(t.loading="eager")),Ma(t)?this.createCustomElementClone(t):t},e.prototype.createCustomElementClone=function(e){var t=document.createElement("html2canvascustomelement");return rl(e.style,t),t},e.prototype.createStyleClone=function(e){try{var t=e.sheet;if(t&&t.cssRules){var i=[].slice.call(t.cssRules,0).reduce(function(e,t){return t&&"string"==typeof t.cssText?e+t.cssText:e},""),n=e.cloneNode(!1);return n.textContent=i,n}}catch(e){if(this.context.logger.error("Unable to access cssRules property",e),"SecurityError"!==e.name)throw e}return e.cloneNode(!1)},e.prototype.createCanvasClone=function(e){var t;if(this.options.inlineImages&&e.ownerDocument){var i=e.ownerDocument.createElement("img");try{return i.src=e.toDataURL(),i}catch(t){this.context.logger.info("Unable to inline canvas contents, canvas is tainted",e)}}var n=e.cloneNode(!1);try{n.width=e.width,n.height=e.height;var r=e.getContext("2d"),o=n.getContext("2d");if(o)if(!this.options.allowTaint&&r)o.putImageData(r.getImageData(0,0,e.width,e.height),0,0);else{var s=null!==(t=e.getContext("webgl2"))&&void 0!==t?t:e.getContext("webgl");if(s){var a=s.getContextAttributes();!1===(null==a?void 0:a.preserveDrawingBuffer)&&this.context.logger.warn("Unable to clone WebGL context as it has preserveDrawingBuffer=false",e)}o.drawImage(e,0,0)}return n}catch(t){this.context.logger.info("Unable to clone canvas as it is tainted",e)}return n},e.prototype.createVideoClone=function(e){var t=e.ownerDocument.createElement("canvas");t.width=e.offsetWidth,t.height=e.offsetHeight;var i=t.getContext("2d");try{return i&&(i.drawImage(e,0,0,t.width,t.height),this.options.allowTaint||i.getImageData(0,0,t.width,t.height)),t}catch(t){this.context.logger.info("Unable to clone video as it is tainted",e)}var n=e.ownerDocument.createElement("canvas");return n.width=e.offsetWidth,n.height=e.offsetHeight,n},e.prototype.appendChildNode=function(e,t,i){da(t)&&(Ca(t)||t.hasAttribute(Ka)||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(t))||this.options.copyStyles&&da(t)&&Ea(t)||e.appendChild(this.cloneNode(t,i))},e.prototype.cloneChildNodes=function(e,t,i){for(var n=this,r=e.shadowRoot?e.shadowRoot.firstChild:e.firstChild;r;r=r.nextSibling)if(da(r)&&Ia(r)&&"function"==typeof r.assignedNodes){var o=r.assignedNodes();o.length&&o.forEach(function(e){return n.appendChildNode(t,e,i)})}else this.appendChildNode(t,r,i)},e.prototype.cloneNode=function(e,t){if(ha(e))return document.createTextNode(e.data);if(!e.ownerDocument)return e.cloneNode(!1);var i=e.ownerDocument.defaultView;if(i&&da(e)&&(pa(e)||fa(e))){var n=this.createElementClone(e);n.style.transitionProperty="none";var r=i.getComputedStyle(e),o=i.getComputedStyle(e,":before"),s=i.getComputedStyle(e,":after");this.referenceElement===e&&pa(n)&&(this.clonedReferenceElement=n),va(n)&&pl(n);var a=this.counters.parse(new xo(this.context,r)),l=this.resolvePseudoContent(e,n,o,qo.BEFORE);Ma(e)&&(t=!0),ba(e)||this.cloneChildNodes(e,n,t),l&&n.insertBefore(l,n.firstChild);var c=this.resolvePseudoContent(e,n,s,qo.AFTER);return c&&n.appendChild(c),this.counters.pop(a),(r&&(this.options.copyStyles||fa(e))&&!Ta(e)||t)&&rl(r,n),0===e.scrollTop&&0===e.scrollLeft||this.scrolledElements.push([n,e.scrollLeft,e.scrollTop]),(Sa(e)||Ba(e))&&(Sa(n)||Ba(n))&&(n.value=e.value),n}return e.cloneNode(!1)},e.prototype.resolvePseudoContent=function(e,t,i,n){var r=this;if(i){var o=i.content,s=t.ownerDocument;if(s&&o&&"none"!==o&&"-moz-alt-content"!==o&&"none"!==i.display){this.counters.parse(new xo(this.context,i));var a=new vo(this.context,i),l=s.createElement("html2canvaspseudoelement");rl(i,l),a.content.forEach(function(t){if(0===t.type)l.appendChild(s.createTextNode(t.value));else if(22===t.type){var i=s.createElement("img");i.src=t.value,i.style.opacity="1",l.appendChild(i)}else if(18===t.type){if("attr"===t.name){var n=t.values.filter(Ri);n.length&&l.appendChild(s.createTextNode(e.getAttribute(n[0].value)||""))}else if("counter"===t.name){var o=t.values.filter(Di),c=o[0],u=o[1];if(c&&Ri(c)){var h=r.counters.getCounterValue(c.value),d=u&&Ri(u)?Sr.parse(r.context,u.value):3;l.appendChild(s.createTextNode(qa(h,d,!1)))}}else if("counters"===t.name){var p=t.values.filter(Di),f=(c=p[0],p[1]);if(u=p[2],c&&Ri(c)){var m=r.counters.getCounterValues(c.value),g=u&&Ri(u)?Sr.parse(r.context,u.value):3,_=f&&0===f.type?f.value:"",A=m.map(function(e){return qa(e,g,!1)}).join(_);l.appendChild(s.createTextNode(A))}}}else if(20===t.type)switch(t.value){case"open-quote":l.appendChild(s.createTextNode(fo(a.quotes,r.quoteDepth++,!0)));break;case"close-quote":l.appendChild(s.createTextNode(fo(a.quotes,--r.quoteDepth,!1)));break;default:l.appendChild(s.createTextNode(t.value))}}),l.className=ul+" "+hl;var c=n===qo.BEFORE?" "+ul:" "+hl;return fa(t)?t.className.baseValue+=c:t.className+=c,l}}},e.destroy=function(e){return!!e.parentNode&&(e.parentNode.removeChild(e),!0)},e}();!function(e){e[e.BEFORE=0]="BEFORE",e[e.AFTER=1]="AFTER"}(qo||(qo={}));var Ja,Ya=function(e,t){var i=e.createElement("iframe");return i.className="html2canvas-container",i.style.visibility="hidden",i.style.position="fixed",i.style.left="-10000px",i.style.top="0px",i.style.border="0",i.width=t.width.toString(),i.height=t.height.toString(),i.scrolling="no",i.setAttribute(Ka,"true"),e.body.appendChild(i),i},el=function(e){return new Promise(function(t){e.complete?t():e.src?(e.onload=t,e.onerror=t):t()})},tl=function(e){return Promise.all([].slice.call(e.images,0).map(el))},il=function(e){return new Promise(function(t,i){var n=e.contentWindow;if(!n)return i("No window assigned for iframe");var r=n.document;n.onload=e.onload=function(){n.onload=e.onload=null;var i=setInterval(function(){r.body.childNodes.length>0&&"complete"===r.readyState&&(clearInterval(i),t(e))},50)}})},nl=["all","d","content"],rl=function(e,t){for(var i=e.length-1;i>=0;i--){var n=e.item(i);-1===nl.indexOf(n)&&t.style.setProperty(n,e.getPropertyValue(n))}return t},ol=function(e){var t="";return e&&(t+=""),t},sl=function(e,t,i){e&&e.defaultView&&(t!==e.defaultView.pageXOffset||i!==e.defaultView.pageYOffset)&&e.defaultView.scrollTo(t,i)},al=function(e){var t=e[0],i=e[1],n=e[2];t.scrollLeft=i,t.scrollTop=n},ll=":before",cl=":after",ul="___html2canvas___pseudoelement_before",hl="___html2canvas___pseudoelement_after",dl='{\n content: "" !important;\n display: none !important;\n}',pl=function(e){fl(e,"."+ul+ll+dl+"\n ."+hl+cl+dl)},fl=function(e,t){var i=e.ownerDocument;if(i){var n=i.createElement("style");n.textContent=t,e.appendChild(n)}},ml=function(){function e(){}return e.getOrigin=function(t){var i=e._link;return i?(i.href=t,i.href=i.href,i.protocol+i.hostname+i.port):"about:blank"},e.isSameOrigin=function(t){return e.getOrigin(t)===e._origin},e.setContext=function(t){e._link=t.document.createElement("a"),e._origin=e.getOrigin(t.location.href)},e._origin="about:blank",e}(),gl=function(){function e(e,t){this.context=e,this._options=t,this._cache={}}return e.prototype.addImage=function(e){var t=Promise.resolve();return this.has(e)?t:wl(e)||vl(e)?((this._cache[e]=this.loadImage(e)).catch(function(){}),t):t},e.prototype.match=function(e){return this._cache[e]},e.prototype.loadImage=function(e){return n(this,void 0,void 0,function(){var t,i,n,o,s=this;return r(this,function(r){switch(r.label){case 0:return t=ml.isSameOrigin(e),i=!xl(e)&&!0===this._options.useCORS&&Bs.SUPPORT_CORS_IMAGES&&!t,n=!xl(e)&&!t&&!wl(e)&&"string"==typeof this._options.proxy&&Bs.SUPPORT_CORS_XHR&&!i,t||!1!==this._options.allowTaint||xl(e)||wl(e)||n||i?(o=e,n?[4,this.proxy(o)]:[3,2]):[2];case 1:o=r.sent(),r.label=2;case 2:return this.context.logger.debug("Added image "+e.substring(0,256)),[4,new Promise(function(e,t){var n=new Image;n.onload=function(){return e(n)},n.onerror=t,(bl(o)||i)&&(n.crossOrigin="anonymous"),n.src=o,!0===n.complete&&setTimeout(function(){return e(n)},500),s._options.imageTimeout>0&&setTimeout(function(){return t("Timed out ("+s._options.imageTimeout+"ms) loading image")},s._options.imageTimeout)})];case 3:return[2,r.sent()]}})})},e.prototype.has=function(e){return void 0!==this._cache[e]},e.prototype.keys=function(){return Promise.resolve(Object.keys(this._cache))},e.prototype.proxy=function(e){var t=this,i=this._options.proxy;if(!i)throw new Error("No proxy defined");var n=e.substring(0,256);return new Promise(function(r,o){var s=Bs.SUPPORT_RESPONSE_TYPE?"blob":"text",a=new XMLHttpRequest;a.onload=function(){if(200===a.status)if("text"===s)r(a.response);else{var e=new FileReader;e.addEventListener("load",function(){return r(e.result)},!1),e.addEventListener("error",function(e){return o(e)},!1),e.readAsDataURL(a.response)}else o("Failed to proxy resource "+n+" with status code "+a.status)},a.onerror=o;var l=i.indexOf("?")>-1?"&":"?";if(a.open("GET",""+i+l+"url="+encodeURIComponent(e)+"&responseType="+s),"text"!==s&&a instanceof XMLHttpRequest&&(a.responseType=s),t._options.imageTimeout){var c=t._options.imageTimeout;a.timeout=c,a.ontimeout=function(){return o("Timed out ("+c+"ms) proxying "+n)}}a.send()})},e}(),_l=/^data:image\/svg\+xml/i,Al=/^data:image\/.*;base64,/i,yl=/^data:image\/.*/i,vl=function(e){return Bs.SUPPORT_SVG_DRAWING||!Tl(e)},xl=function(e){return yl.test(e)},bl=function(e){return Al.test(e)},wl=function(e){return"blob"===e.substr(0,4)},Tl=function(e){return"svg"===e.substr(-3).toLowerCase()||_l.test(e)},El=function(){function e(e,t){this.type=0,this.x=e,this.y=t}return e.prototype.add=function(t,i){return new e(this.x+t,this.y+i)},e}(),Cl=function(e,t,i){return new El(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},Sl=function(){function e(e,t,i,n){this.type=1,this.start=e,this.startControl=t,this.endControl=i,this.end=n}return e.prototype.subdivide=function(t,i){var n=Cl(this.start,this.startControl,t),r=Cl(this.startControl,this.endControl,t),o=Cl(this.endControl,this.end,t),s=Cl(n,r,t),a=Cl(r,o,t),l=Cl(s,a,t);return i?new e(this.start,n,s,l):new e(l,a,o,this.end)},e.prototype.add=function(t,i){return new e(this.start.add(t,i),this.startControl.add(t,i),this.endControl.add(t,i),this.end.add(t,i))},e.prototype.reverse=function(){return new e(this.end,this.endControl,this.startControl,this.start)},e}(),Bl=function(e){return 1===e.type},Il=function(){function e(e){var t=e.styles,i=e.bounds,n=Qi(t.borderTopLeftRadius,i.width,i.height),r=n[0],o=n[1],s=Qi(t.borderTopRightRadius,i.width,i.height),a=s[0],l=s[1],c=Qi(t.borderBottomRightRadius,i.width,i.height),u=c[0],h=c[1],d=Qi(t.borderBottomLeftRadius,i.width,i.height),p=d[0],f=d[1],m=[];m.push((r+a)/i.width),m.push((p+u)/i.width),m.push((o+f)/i.height),m.push((l+h)/i.height);var g=Math.max.apply(Math,m);g>1&&(r/=g,o/=g,a/=g,l/=g,u/=g,h/=g,p/=g,f/=g);var _=i.width-a,A=i.height-h,y=i.width-u,v=i.height-f,x=t.borderTopWidth,b=t.borderRightWidth,w=t.borderBottomWidth,T=t.borderLeftWidth,E=$i(t.paddingTop,e.bounds.width),C=$i(t.paddingRight,e.bounds.width),S=$i(t.paddingBottom,e.bounds.width),B=$i(t.paddingLeft,e.bounds.width);this.topLeftBorderDoubleOuterBox=r>0||o>0?Ml(i.left+T/3,i.top+x/3,r-T/3,o-x/3,Ja.TOP_LEFT):new El(i.left+T/3,i.top+x/3),this.topRightBorderDoubleOuterBox=r>0||o>0?Ml(i.left+_,i.top+x/3,a-b/3,l-x/3,Ja.TOP_RIGHT):new El(i.left+i.width-b/3,i.top+x/3),this.bottomRightBorderDoubleOuterBox=u>0||h>0?Ml(i.left+y,i.top+A,u-b/3,h-w/3,Ja.BOTTOM_RIGHT):new El(i.left+i.width-b/3,i.top+i.height-w/3),this.bottomLeftBorderDoubleOuterBox=p>0||f>0?Ml(i.left+T/3,i.top+v,p-T/3,f-w/3,Ja.BOTTOM_LEFT):new El(i.left+T/3,i.top+i.height-w/3),this.topLeftBorderDoubleInnerBox=r>0||o>0?Ml(i.left+2*T/3,i.top+2*x/3,r-2*T/3,o-2*x/3,Ja.TOP_LEFT):new El(i.left+2*T/3,i.top+2*x/3),this.topRightBorderDoubleInnerBox=r>0||o>0?Ml(i.left+_,i.top+2*x/3,a-2*b/3,l-2*x/3,Ja.TOP_RIGHT):new El(i.left+i.width-2*b/3,i.top+2*x/3),this.bottomRightBorderDoubleInnerBox=u>0||h>0?Ml(i.left+y,i.top+A,u-2*b/3,h-2*w/3,Ja.BOTTOM_RIGHT):new El(i.left+i.width-2*b/3,i.top+i.height-2*w/3),this.bottomLeftBorderDoubleInnerBox=p>0||f>0?Ml(i.left+2*T/3,i.top+v,p-2*T/3,f-2*w/3,Ja.BOTTOM_LEFT):new El(i.left+2*T/3,i.top+i.height-2*w/3),this.topLeftBorderStroke=r>0||o>0?Ml(i.left+T/2,i.top+x/2,r-T/2,o-x/2,Ja.TOP_LEFT):new El(i.left+T/2,i.top+x/2),this.topRightBorderStroke=r>0||o>0?Ml(i.left+_,i.top+x/2,a-b/2,l-x/2,Ja.TOP_RIGHT):new El(i.left+i.width-b/2,i.top+x/2),this.bottomRightBorderStroke=u>0||h>0?Ml(i.left+y,i.top+A,u-b/2,h-w/2,Ja.BOTTOM_RIGHT):new El(i.left+i.width-b/2,i.top+i.height-w/2),this.bottomLeftBorderStroke=p>0||f>0?Ml(i.left+T/2,i.top+v,p-T/2,f-w/2,Ja.BOTTOM_LEFT):new El(i.left+T/2,i.top+i.height-w/2),this.topLeftBorderBox=r>0||o>0?Ml(i.left,i.top,r,o,Ja.TOP_LEFT):new El(i.left,i.top),this.topRightBorderBox=a>0||l>0?Ml(i.left+_,i.top,a,l,Ja.TOP_RIGHT):new El(i.left+i.width,i.top),this.bottomRightBorderBox=u>0||h>0?Ml(i.left+y,i.top+A,u,h,Ja.BOTTOM_RIGHT):new El(i.left+i.width,i.top+i.height),this.bottomLeftBorderBox=p>0||f>0?Ml(i.left,i.top+v,p,f,Ja.BOTTOM_LEFT):new El(i.left,i.top+i.height),this.topLeftPaddingBox=r>0||o>0?Ml(i.left+T,i.top+x,Math.max(0,r-T),Math.max(0,o-x),Ja.TOP_LEFT):new El(i.left+T,i.top+x),this.topRightPaddingBox=a>0||l>0?Ml(i.left+Math.min(_,i.width-b),i.top+x,_>i.width+b?0:Math.max(0,a-b),Math.max(0,l-x),Ja.TOP_RIGHT):new El(i.left+i.width-b,i.top+x),this.bottomRightPaddingBox=u>0||h>0?Ml(i.left+Math.min(y,i.width-T),i.top+Math.min(A,i.height-w),Math.max(0,u-b),Math.max(0,h-w),Ja.BOTTOM_RIGHT):new El(i.left+i.width-b,i.top+i.height-w),this.bottomLeftPaddingBox=p>0||f>0?Ml(i.left+T,i.top+Math.min(v,i.height-w),Math.max(0,p-T),Math.max(0,f-w),Ja.BOTTOM_LEFT):new El(i.left+T,i.top+i.height-w),this.topLeftContentBox=r>0||o>0?Ml(i.left+T+B,i.top+x+E,Math.max(0,r-(T+B)),Math.max(0,o-(x+E)),Ja.TOP_LEFT):new El(i.left+T+B,i.top+x+E),this.topRightContentBox=a>0||l>0?Ml(i.left+Math.min(_,i.width+T+B),i.top+x+E,_>i.width+T+B?0:a-T+B,l-(x+E),Ja.TOP_RIGHT):new El(i.left+i.width-(b+C),i.top+x+E),this.bottomRightContentBox=u>0||h>0?Ml(i.left+Math.min(y,i.width-(T+B)),i.top+Math.min(A,i.height+x+E),Math.max(0,u-(b+C)),h-(w+S),Ja.BOTTOM_RIGHT):new El(i.left+i.width-(b+C),i.top+i.height-(w+S)),this.bottomLeftContentBox=p>0||f>0?Ml(i.left+T+B,i.top+v,Math.max(0,p-(T+B)),f-(w+S),Ja.BOTTOM_LEFT):new El(i.left+T+B,i.top+i.height-(w+S))}return e}();!function(e){e[e.TOP_LEFT=0]="TOP_LEFT",e[e.TOP_RIGHT=1]="TOP_RIGHT",e[e.BOTTOM_RIGHT=2]="BOTTOM_RIGHT",e[e.BOTTOM_LEFT=3]="BOTTOM_LEFT"}(Ja||(Ja={}));var Ml=function(e,t,i,n,r){var o=(Math.sqrt(2)-1)/3*4,s=i*o,a=n*o,l=e+i,c=t+n;switch(r){case Ja.TOP_LEFT:return new Sl(new El(e,c),new El(e,c-a),new El(l-s,t),new El(l,t));case Ja.TOP_RIGHT:return new Sl(new El(e,t),new El(e+s,t),new El(l,c-a),new El(l,c));case Ja.BOTTOM_RIGHT:return new Sl(new El(l,t),new El(l,t+a),new El(e+s,c),new El(e,c));case Ja.BOTTOM_LEFT:default:return new Sl(new El(l,c),new El(l-s,c),new El(e,t+a),new El(e,t))}},Pl=function(e){return[e.topLeftBorderBox,e.topRightBorderBox,e.bottomRightBorderBox,e.bottomLeftBorderBox]},Rl=function(e){return[e.topLeftContentBox,e.topRightContentBox,e.bottomRightContentBox,e.bottomLeftContentBox]},Ll=function(e){return[e.topLeftPaddingBox,e.topRightPaddingBox,e.bottomRightPaddingBox,e.bottomLeftPaddingBox]},Fl=function(){function e(e,t,i){this.offsetX=e,this.offsetY=t,this.matrix=i,this.type=0,this.target=6}return e}(),kl=function(){function e(e,t){this.path=e,this.target=t,this.type=1}return e}(),Dl=function(){function e(e){this.opacity=e,this.type=2,this.target=6}return e}(),Ol=function(e){return 0===e.type},zl=function(e){return 1===e.type},Ul=function(e){return 2===e.type},Nl=function(e,t){return e.length===t.length&&e.some(function(e,i){return e===t[i]})},Vl=function(e,t,i,n,r){return e.map(function(e,o){switch(o){case 0:return e.add(t,i);case 1:return e.add(t+n,i);case 2:return e.add(t+n,i+r);case 3:return e.add(t,i+r)}return e})},jl=function(){function e(e){this.element=e,this.inlineLevel=[],this.nonInlineLevel=[],this.negativeZIndex=[],this.zeroOrAutoZIndexOrTransformedOrOpacity=[],this.positiveZIndex=[],this.nonPositionedFloats=[],this.nonPositionedInlineLevel=[]}return e}(),Gl=function(){function e(e,t){if(this.container=e,this.parent=t,this.effects=[],this.curves=new Il(this.container),this.container.styles.opacity<1&&this.effects.push(new Dl(this.container.styles.opacity)),null!==this.container.styles.transform){var i=this.container.bounds.left+this.container.styles.transformOrigin[0].number,n=this.container.bounds.top+this.container.styles.transformOrigin[1].number,r=this.container.styles.transform;this.effects.push(new Fl(i,n,r))}if(0!==this.container.styles.overflowX){var o=Pl(this.curves),s=Ll(this.curves);Nl(o,s)?this.effects.push(new kl(o,6)):(this.effects.push(new kl(o,2)),this.effects.push(new kl(s,4)))}}return e.prototype.getEffects=function(e){for(var t=-1===[2,3].indexOf(this.container.styles.position),i=this.parent,n=this.effects.slice(0);i;){var r=i.effects.filter(function(e){return!zl(e)});if(t||0!==i.container.styles.position||!i.parent){if(n.unshift.apply(n,r),t=-1===[2,3].indexOf(i.container.styles.position),0!==i.container.styles.overflowX){var o=Pl(i.curves),s=Ll(i.curves);Nl(o,s)||n.unshift(new kl(s,6))}}else n.unshift.apply(n,r);i=i.parent}return n.filter(function(t){return ao(t.target,e)})},e}(),Hl=function(e,t,i,n){e.container.elements.forEach(function(r){var o=ao(r.flags,4),s=ao(r.flags,2),a=new Gl(r,e);ao(r.styles.display,2048)&&n.push(a);var l=ao(r.flags,8)?[]:n;if(o||s){var c=o||r.styles.isPositioned()?i:t,u=new jl(a);if(r.styles.isPositioned()||r.styles.opacity<1||r.styles.isTransformed()){var h=r.styles.zIndex.order;if(h<0){var d=0;c.negativeZIndex.some(function(e,t){return h>e.element.container.styles.zIndex.order?(d=t,!1):d>0}),c.negativeZIndex.splice(d,0,u)}else if(h>0){var p=0;c.positiveZIndex.some(function(e,t){return h>=e.element.container.styles.zIndex.order?(p=t+1,!1):p>0}),c.positiveZIndex.splice(p,0,u)}else c.zeroOrAutoZIndexOrTransformedOrOpacity.push(u)}else r.styles.isFloating()?c.nonPositionedFloats.push(u):c.nonPositionedInlineLevel.push(u);Hl(a,u,o?u:i,l)}else r.styles.isInlineLevel()?t.inlineLevel.push(a):t.nonInlineLevel.push(a),Hl(a,t,i,l);ao(r.flags,8)&&Ql(r,l)})},Ql=function(e,t){for(var i=e instanceof $s?e.start:1,n=e instanceof $s&&e.reversed,r=0;r0&&e.intrinsicHeight>0){var n=ec(e),r=Ll(t);this.path(r),this.ctx.save(),this.ctx.clip(),this.ctx.drawImage(i,0,0,e.intrinsicWidth,e.intrinsicHeight,n.left,n.top,n.width,n.height),this.ctx.restore()}},i.prototype.renderNodeContent=function(e){return n(this,void 0,void 0,function(){var t,n,o,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x;return r(this,function(r){switch(r.label){case 0:this.applyEffects(e.getEffects(4)),t=e.container,n=e.curves,o=t.styles,a=0,l=t.textNodes,r.label=1;case 1:return a0&&T>0&&(A=n.ctx.createPattern(m,"repeat"),n.renderRepeat(v,A,C,S))):Dn(i)&&(y=nc(e,t,[null,null,null]),v=y[0],x=y[1],b=y[2],w=y[3],T=y[4],E=0===i.position.length?[Gi]:i.position,C=$i(E[0],w),S=$i(E[E.length-1],T),B=xn(i,C,S,w,T),I=B[0],M=B[1],I>0&&M>0&&(P=n.ctx.createRadialGradient(x+C,b+S,0,x+C,b+S,I),gn(i.stops,2*I).forEach(function(e){return P.addColorStop(e.stop,rn(e.color))}),n.path(v),n.ctx.fillStyle=P,I!==M?(R=e.bounds.left+.5*e.bounds.width,L=e.bounds.top+.5*e.bounds.height,k=1/(F=M/I),n.ctx.save(),n.ctx.translate(R,L),n.ctx.transform(1,0,0,F,0,0),n.ctx.translate(-R,-L),n.ctx.fillRect(x,k*(b-L)+L,w,T*k),n.ctx.restore()):n.ctx.fill())),r.label=6;case 6:return t--,[2]}})},n=this,o=0,s=e.styles.backgroundImage.slice(0).reverse(),l.label=1;case 1:return o0?2!==c.style?[3,5]:[4,this.renderDashedDottedBorder(c.color,c.width,s,e.curves,2)]:[3,11]:[3,13];case 4:return r.sent(),[3,11];case 5:return 3!==c.style?[3,7]:[4,this.renderDashedDottedBorder(c.color,c.width,s,e.curves,3)];case 6:return r.sent(),[3,11];case 7:return 4!==c.style?[3,9]:[4,this.renderDoubleBorder(c.color,c.width,s,e.curves)];case 8:return r.sent(),[3,11];case 9:return[4,this.renderSolidBorder(c.color,s,e.curves)];case 10:r.sent(),r.label=11;case 11:s++,r.label=12;case 12:return a++,[3,3];case 13:return[2]}})})},i.prototype.renderDashedDottedBorder=function(e,t,i,o,s){return n(this,void 0,void 0,function(){var n,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x;return r(this,function(r){return this.ctx.save(),n=Kl(o,i),a=Zl(o,i),2===s&&(this.path(a),this.ctx.clip()),Bl(a[0])?(l=a[0].start.x,c=a[0].start.y):(l=a[0].x,c=a[0].y),Bl(a[1])?(u=a[1].end.x,h=a[1].end.y):(u=a[1].x,h=a[1].y),d=0===i||2===i?Math.abs(l-u):Math.abs(c-h),this.ctx.beginPath(),3===s?this.formatPath(n):this.formatPath(a.slice(0,2)),p=t<3?3*t:2*t,f=t<3?2*t:t,3===s&&(p=t,f=t),m=!0,d<=2*p?m=!1:d<=2*p+f?(p*=g=d/(2*p+f),f*=g):(_=Math.floor((d+f)/(p+f)),A=(d-_*p)/(_-1),f=(y=(d-(_+1)*p)/_)<=0||Math.abs(f-A){};return function(e,t){for(const{type:i,value:n,id:r}of e){if(document.getElementById(r))return void("script"===i&&t());const e=document.createElement(i);e.id=r,"script"===i?(e.async=!0,e.defer=!0,e.src=n,e.onload=()=>t()):(e.rel="stylesheet",e.href=n),document.body.appendChild(e)}}(i,()=>{r=function(e,t){const i=new window.MapboxGeocoder(e);i.addTo(`#${t.id}`),e.value&&i.setInput(e.value);return function(e,t,i,n){const r=[];for(const[o,s]of Object.entries(t)){const t=t=>{const[r,o]=s(e,t,i);n.dispatchEvent(new CustomEvent(r,{detail:o}))};e.on(o,t),r.push([o,t])}return()=>{for(const[t,i]of r)e.off(t,i)}}(i,XK,!1,t)}(t,e)}),{destroy(){r()}}}const XK={results:(e,t)=>["results",t],result:(e,t)=>["result",t],loading:(e,t)=>["loading",t],error:(e,t)=>["error",t],clear:(e,t)=>["clear",t],load:e=>["ready",{geocoder:e}]};function JK(e){let i,n,r;return{c(){i=b("div"),B(i,"id",e[0]),B(i,"class","svelte-1k1b3t4")},m(t,o){y(t,i,o),n||(r=[_(KK.call(null,i,e[1])),S(i,"ready",e[2]),S(i,"results",e[11]),S(i,"result",e[12]),S(i,"loading",e[13]),S(i,"error",e[14]),S(i,"clear",e[15]),S(i,"load",e[16])],n=!0)},p:t,i:t,o:t,d(e){e&&v(i),n=!1,o(r)}}}function YK(e,t,i){let{accessToken:n}=t,{options:r={}}=t,{version:o="v4.5.1"}=t,{types:s=["country","region","postcode","district","place","locality","neighborhood","address"]}=t,{placeholder:a="Search"}=t,{value:l=null}=t,{customStylesheetUrl:c=!1}=t,{geocoder:u}=t;const h=H(),d="bsm-"+Math.random().toString(36).substring(6),p=Object.assign({version:o,accessToken:n,types:s.join(","),placeholder:a,customStylesheetUrl:c,value:l},r);return e.$$set=e=>{"accessToken"in e&&i(4,n=e.accessToken),"options"in e&&i(5,r=e.options),"version"in e&&i(6,o=e.version),"types"in e&&i(7,s=e.types),"placeholder"in e&&i(8,a=e.placeholder),"value"in e&&i(9,l=e.value),"customStylesheetUrl"in e&&i(10,c=e.customStylesheetUrl),"geocoder"in e&&i(3,u=e.geocoder)},[d,p,function({detail:e}){i(3,u=e.geocoder),h("ready")},u,n,r,o,s,a,l,c,function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)}]}class eX extends ge{constructor(e){super(),me(this,e,YK,JK,a,{accessToken:4,options:5,version:6,types:7,placeholder:8,value:9,customStylesheetUrl:10,geocoder:3})}}function tX(e){let t,i,n;return i=new pq({props:{options:e[1].map(iX),activeValue:e[0],onSelect:e[2],direction:"down"}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"class","dropdown-container svelte-1yvkhcz")},m(e,r){y(e,t,r),pe(i,t,null),n=!0},p(e,[t]){const n={};2&t&&(n.options=e[1].map(iX)),1&t&&(n.activeValue=e[0]),4&t&&(n.onSelect=e[2]),i.$set(n)},i(e){n||(le(i.$$.fragment,e),n=!0)},o(e){ce(i.$$.fragment,e),n=!1},d(e){e&&v(t),fe(i)}}}const iX=e=>({label:e,value:e});function nX(e,t,i){let n,r;l(e,rt,e=>i(5,r=e));let{mode:o}=t,{mapsNum:s}=t;const a=H();let c=o??"",u=bu;const h=e=>{1===e&&i(1,u=bu.filter(e=>"swipe"!==e)),2===e&&i(1,u=bu.filter(e=>"responsive"!==e)),e>2&&e<=4&&i(1,u=bu.filter(e=>"swipe"!==e&&"responsive"!==e)),e>4&&i(1,u=bu.filter(e=>"swipe"!==e&&"phone"!==e&&"responsive"!==e)),r||i(1,u=["mirror"]),u.includes(c)||i(0,c=u[0])};return rt.subscribe(()=>{h(s)}),e.$$set=e=>{"mode"in e&&i(3,o=e.mode),"mapsNum"in e&&i(4,s=e.mapsNum)},e.$$.update=()=>{var t;16&e.$$.dirty&&h(s),1&e.$$.dirty&&(e=>{a("viewMode",{mode:e})})(c),8&e.$$.dirty&&(t=o)!==c&&i(0,c=t)},i(2,n=e=>{i(0,c=e)}),[c,u,n,o,s]}class rX extends ge{constructor(e){super(),me(this,e,nX,tX,a,{mode:3,mapsNum:4})}}function oX(e){let t,i,n;return i=new pq({props:{placeholder:"Go to...",options:e[3],activeValue:e[1],onSelect:e[2],direction:"down"}}),{c(){t=b("div"),de(i.$$.fragment),B(t,"class","dropdown-container svelte-1ho45wf")},m(e,r){y(e,t,r),pe(i,t,null),n=!0},p(e,t){const n={};8&t&&(n.options=e[3]),2&t&&(n.activeValue=e[1]),4&t&&(n.onSelect=e[2]),i.$set(n)},i(e){n||(le(i.$$.fragment,e),n=!0)},o(e){ce(i.$$.fragment,e),n=!1},d(e){e&&v(t),fe(i)}}}function sX(e){let t,i,n=e[0]&&oX(e);return{c(){n&&n.c(),t=C()},m(e,r){n&&n.m(e,r),y(e,t,r),i=!0},p(e,[i]){e[0]?n?(n.p(e,i),1&i&&le(n,1)):(n=oX(e),n.c(),le(n,1),n.m(t.parentNode,t)):n&&(se(),ce(n,1,1,()=>{n=null}),ae())},i(e){i||(le(n),i=!0)},o(e){ce(n),i=!1},d(e){n&&n.d(e),e&&v(t)}}}function aX(e,t,i){let n,r,{bearing:o}=t,{center:s}=t,{pitch:a}=t,{zoom:l}=t;const c=H();let u;it.subscribe(e=>i(0,({gazetteer:u}=e),u));const h=(e,t)=>Number.parseFloat(e).toFixed(t),d=e=>{if(!u)return"";const t=Object.keys(u).reduce((e,t)=>e=e.concat(u[t]),[]).find(t=>{const i=Object.values(t)[0];return Object.keys(i).every(t=>{if("center"===t&&e.center){const{lng:t,lat:n}=i.center,{lng:r,lat:o}=e.center;return h(t,4)===h(r,4)&&h(n,4)===h(o,4)}return h(i[t],2)===h(e[t],2)})});return t?JSON.stringify(t):""};let p=d({zoom:l,center:s,pitch:a,bearing:o});const f=()=>{const{options:e}=(e=>{if(!e)return{};try{const t=JSON.parse(e),i=Object.keys(t)[0],n=t[i];return c("mapState",{options:n}),{label:i,options:n}}catch(e){return console.error(e),{}}})(p);e&&c("mapState",{options:e})};return e.$$set=e=>{"bearing"in e&&i(4,o=e.bearing),"center"in e&&i(5,s=e.center),"pitch"in e&&i(6,a=e.pitch),"zoom"in e&&i(7,l=e.zoom)},e.$$.update=()=>{240&e.$$.dirty&&(e=>{const t=d(e);p!==t&&i(1,p=t??"")})({zoom:l,center:s,pitch:a,bearing:o}),2&e.$$.dirty&&f(),1&e.$$.dirty&&i(3,n=Object.entries(u).reduce((e,[t,i])=>{e.push({header:t});for(const t of i){let[i,n]=Object.entries(t)[0];e.push({label:i,value:JSON.stringify(t)})}return e},[]))},i(2,r=e=>{i(1,p=e)}),[u,p,r,n,o,s,a,l]}class lX extends ge{constructor(e){super(),me(this,e,aX,sX,a,{bearing:4,center:5,pitch:6,zoom:7})}}function cX(e){let t,i;return{c(){t=b("div"),i=T(e[0]),R(t,"top",e[3]+"px"),R(t,"left",e[2]+"px"),B(t,"class","tooltip svelte-1qc780y")},m(e,n){y(e,t,n),A(t,i)},p(e,n){1&n&&M(i,e[0]),8&n&&R(t,"top",e[3]+"px"),4&n&&R(t,"left",e[2]+"px")},d(e){e&&v(t)}}}function uX(e){let t,i,n,r,s,a;const l=e[8].default,u=c(l,e,e[7],null);let f=e[1]&&cX(e);return{c(){t=b("div"),u&&u.c(),i=E(),f&&f.c(),n=C()},m(o,l){y(o,t,l),u&&u.m(t,null),y(o,i,l),f&&f.m(o,l),y(o,n,l),r=!0,s||(a=[S(t,"mouseover",e[4]),S(t,"mouseleave",e[6]),S(t,"mousemove",e[5])],s=!0)},p(e,[t]){u&&u.p&&(!r||128&t)&&d(u,l,e,e[7],r?h(l,e[7],t,null):p(e[7]),null),e[1]?f?f.p(e,t):(f=cX(e),f.c(),f.m(n.parentNode,n)):f&&(f.d(1),f=null)},i(e){r||(le(u,e),r=!0)},o(e){ce(u,e),r=!1},d(e){e&&v(t),u&&u.d(e),e&&v(i),f&&f.d(e),e&&v(n),s=!1,o(a)}}}function hX(e,t,i){let n,r,{$$slots:o={},$$scope:s}=t,{title:a=""}=t,l=!1;return e.$$set=e=>{"title"in e&&i(0,a=e.title),"$$scope"in e&&i(7,s=e.$$scope)},[a,l,n,r,function(e){i(1,l=!0),i(2,n=e.pageX+5),i(3,r=e.pageY+5)},function(e){i(2,n=e.pageX+5),i(3,r=e.pageY+5)},function(){i(1,l=!1)},s,o]}class dX extends ge{constructor(e){super(),me(this,e,hX,uX,a,{title:0})}}function pX(e,t,i){const n=e.slice();return n[28]=t[i],n}function fX(e){let i,n,r,s,a;return n=new VW({props:{icon:CW}}),{c(){i=b("button"),de(n.$$.fragment),B(i,"class","fullscreen-btn show-ui svelte-1g6kozd"),B(i,"title","Show UI")},m(t,o){y(t,i,o),pe(n,i,null),r=!0,s||(a=[S(i,"click",e[14]),_(KW.call(null,i,{shift:!0,control:!0,code:"KeyF",callback:e[14]}))],s=!0)},p:t,i(e){r||(le(n.$$.fragment,e),r=!0)},o(e){ce(n.$$.fragment,e),r=!1},d(e){e&&v(i),fe(n),s=!1,o(a)}}}function mX(e){let t,n,r,s,a,l,c,u,h,d,p,f,m,g,x,w,C,I,M,P,L,F,k,D,O,z,U,N,V,j,G,H,Q,$,Z,W,q,K,X,J,Y,ee,te,ie,ne,re,oe,me,ge,_e,Ae,ye,ve,xe,be;a=new VW({props:{icon:e[8]?IW:LW}});let we=e[8]&&gX(e);d=new rX({props:{mode:e[4],mapsNum:e[5].length}}),d.$on("viewMode",e[22]);let Te=e[3]&&_X(e);const Ee=[e[6]];let Ce={};for(let e=0;e0&&vX(e);return{c(){t=b("div"),n=b("div"),r=b("div"),s=b("div"),de(a.$$.fragment),c=E(),we&&we.c(),u=E(),h=b("div"),de(d.$$.fragment),p=E(),f=b("div"),Te&&Te.c(),m=E(),g=b("div"),de(x.$$.fragment),w=E(),C=b("div"),I=b("div"),M=b("label"),P=b("span"),P.innerHTML='Label Collisions',L=E(),F=b("input"),k=E(),D=b("label"),O=b("span"),O.innerHTML='Tile Boundaries',z=E(),U=b("input"),N=E(),Se&&Se.c(),V=E(),j=b("div"),G=b("div"),H=b("button"),de(Q.$$.fragment),$=T(" Add map"),q=E(),K=b("button"),de(X.$$.fragment),J=T("\n Copy image"),te=E(),ie=b("button"),de(ne.$$.fragment),me=E(),ge=b("div"),_e=b("button"),de(Ae.$$.fragment),ye=E(),Be&&Be.c(),B(s,"class","link-button svelte-1g6kozd"),R(s,"margin-right","6px"),B(s,"title",l=e[8]?"Unlink locations":"Link locations"),B(r,"class","control-section svelte-1g6kozd"),B(h,"class","control-section svelte-1g6kozd"),B(f,"class","control-section svelte-1g6kozd"),B(g,"class","control-section svelte-1g6kozd"),B(P,"class","checkbox-label svelte-1g6kozd"),B(F,"type","checkbox"),B(M,"class","checkbox-container svelte-1g6kozd"),B(O,"class","checkbox-label svelte-1g6kozd"),B(U,"type","checkbox"),B(D,"class","checkbox-container svelte-1g6kozd"),B(I,"class","checkboxes svelte-1g6kozd"),B(C,"class","control-section svelte-1g6kozd"),R(H,"margin-right","6px"),H.disabled=Z=e[5].length>=8,B(H,"title",W=e[5].length>=8?"Maximum of 8 maps allowed.":""),K.disabled=Y="swipe"===e[4],B(K,"title",ee="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"),ie.disabled=re="swipe"===e[4],B(ie,"title",oe="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"),B(G,"class","buttons svelte-1g6kozd"),B(j,"class","control-section svelte-1g6kozd"),B(_e,"class","fullscreen-btn svelte-1g6kozd"),B(_e,"title","Hide UI"),B(ge,"class","control-section svelte-1g6kozd"),B(n,"class","control-row svelte-1g6kozd"),B(t,"class","map-controls svelte-1g6kozd")},m(i,o){y(i,t,o),A(t,n),A(n,r),A(r,s),pe(a,s,null),A(r,c),we&&we.m(r,null),A(n,u),A(n,h),pe(d,h,null),A(n,p),A(n,f),Te&&Te.m(f,null),A(n,m),A(n,g),pe(x,g,null),A(n,w),A(n,C),A(C,I),A(I,M),A(M,P),A(M,L),A(M,F),F.checked=e[0],A(I,k),A(I,D),A(D,O),A(D,z),A(D,U),U.checked=e[1],A(I,N),Se&&Se.m(I,null),A(n,V),A(n,j),A(j,G),A(G,H),pe(Q,H,null),A(H,$),A(G,q),A(G,K),pe(X,K,null),A(K,J),A(G,te),A(G,ie),pe(ne,ie,null),A(n,me),A(n,ge),A(ge,_e),pe(Ae,_e,null),A(t,ye),Be&&Be.m(t,null),ve=!0,xe||(be=[S(s,"click",e[15]),S(F,"change",e[24]),S(U,"change",e[25]),S(H,"click",e[11]),S(K,"click",e[13]),S(ie,"click",e[12]),S(_e,"click",e[14]),_(KW.call(null,_e,{shift:!0,control:!0,code:"KeyF",callback:e[14]}))],xe=!0)},p(e,i){const n={};256&i[0]&&(n.icon=e[8]?IW:LW),a.$set(n),(!ve||256&i[0]&&l!==(l=e[8]?"Unlink locations":"Link locations"))&&B(s,"title",l),e[8]?we?(we.p(e,i),256&i[0]&&le(we,1)):(we=gX(e),we.c(),le(we,1),we.m(r,null)):we&&(se(),ce(we,1,1,()=>{we=null}),ae());const o={};16&i[0]&&(o.mode=e[4]),32&i[0]&&(o.mapsNum=e[5].length),d.$set(o),e[3]?Te?(Te.p(e,i),8&i[0]&&le(Te,1)):(Te=_X(e),Te.c(),le(Te,1),Te.m(f,null)):Te&&(se(),ce(Te,1,1,()=>{Te=null}),ae());const c=64&i[0]?ue(Ee,[he(e[6])]):{};x.$set(c),1&i[0]&&(F.checked=e[0]),2&i[0]&&(U.checked=e[1]),"swipe"===e[4]?Se?(Se.p(e,i),16&i[0]&&le(Se,1)):(Se=AX(e),Se.c(),le(Se,1),Se.m(I,null)):Se&&(se(),ce(Se,1,1,()=>{Se=null}),ae()),(!ve||32&i[0]&&Z!==(Z=e[5].length>=8))&&(H.disabled=Z),(!ve||32&i[0]&&W!==(W=e[5].length>=8?"Maximum of 8 maps allowed.":""))&&B(H,"title",W),(!ve||16&i[0]&&Y!==(Y="swipe"===e[4]))&&(K.disabled=Y),(!ve||16&i[0]&&ee!==(ee="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"))&&B(K,"title",ee),(!ve||16&i[0]&&re!==(re="swipe"===e[4]))&&(ie.disabled=re),(!ve||16&i[0]&&oe!==(oe="swipe"===e[4]?"Must be in phone or mirror mode to screenshot.":"Copy image to clipboard"))&&B(ie,"title",oe),e[7].length>0?Be?Be.p(e,i):(Be=vX(e),Be.c(),Be.m(t,null)):Be&&(Be.d(1),Be=null)},i(e){ve||(le(a.$$.fragment,e),le(we),le(d.$$.fragment,e),le(Te),le(x.$$.fragment,e),le(Se),le(Q.$$.fragment,e),le(X.$$.fragment,e),le(ne.$$.fragment,e),le(Ae.$$.fragment,e),ve=!0)},o(e){ce(a.$$.fragment,e),ce(we),ce(d.$$.fragment,e),ce(Te),ce(x.$$.fragment,e),ce(Se),ce(Q.$$.fragment,e),ce(X.$$.fragment,e),ce(ne.$$.fragment,e),ce(Ae.$$.fragment,e),ve=!1},d(e){e&&v(t),fe(a),we&&we.d(),fe(d),Te&&Te.d(),fe(x),Se&&Se.d(),fe(Q),fe(X),fe(ne),fe(Ae),Be&&Be.d(),xe=!1,o(be)}}}function gX(e){let t,n;const r=[e[6]];let o={};for(let e=0;eDifferences',n=E(),r=b("input"),B(i,"class","checkbox-label svelte-1g6kozd"),B(r,"type","checkbox"),B(t,"class","checkbox-container svelte-1g6kozd")},m(a,l){y(a,t,l),A(t,i),A(t,n),A(t,r),r.checked=e[2],o||(s=S(r,"change",e[26]),o=!0)},p(e,t){4&t[0]&&(r.checked=e[2])},d(e){e&&v(t),o=!1,s()}}}function vX(e){let t,i=e[7],n=[];for(let t=0;t{l[o]=null}),ae(),i=l[t],i?i.p(e,r):(i=l[t]=a[t](e),i.c()),le(i,1),i.m(n.parentNode,n))},i(e){r||(le(i),r=!0)},o(e){ce(i),r=!1},d(e){l[t].d(e),e&&v(n),o=!1,s()}}}function wX(e,t,i){let n,r;l(e,rt,e=>i(8,n=e)),l(e,nt,e=>i(9,r=e));let{bearing:o}=t,{center:s}=t,{mapboxGlAccessToken:a}=t,{pitch:c}=t,{showCollisions:u}=t,{showBoundaries:h}=t,{showDiff:d}=t,{viewMode:p}=t,{zoom:f}=t;const m=H();let g,_=[],A=[];et.subscribe(e=>i(5,_=e));return e.$$set=e=>{"bearing"in e&&i(17,o=e.bearing),"center"in e&&i(18,s=e.center),"mapboxGlAccessToken"in e&&i(3,a=e.mapboxGlAccessToken),"pitch"in e&&i(19,c=e.pitch),"showCollisions"in e&&i(0,u=e.showCollisions),"showBoundaries"in e&&i(1,h=e.showBoundaries),"showDiff"in e&&i(2,d=e.showDiff),"viewMode"in e&&i(4,p=e.viewMode),"zoom"in e&&i(20,f=e.zoom)},e.$$.update=()=>{1966080&e.$$.dirty[0]&&i(6,g={bearing:o,center:s,pitch:c,zoom:f}),96&e.$$.dirty[0]&&i(7,A=((e,t)=>{const i=[],n=dK(e,t);return e.pitch>=n&&i.push({type:"warning",message:`Pitch capped at ${n} as that is the maximum for this zoom level.`}),i})(g,_)),20&e.$$.dirty[0]&&"swipe"!==p&&d&&i(2,d=!1),7&e.$$.dirty[0]&&m("mapState",{options:{showCollisions:u,showBoundaries:h,showDiff:d}})},[u,h,d,a,p,_,g,A,n,r,({detail:e})=>{const{result:t}=e,i={center:{lat:t.center[1],lng:t.center[0]},zoom:17};t.bbox&&(i.zoom=14),m("mapState",{options:i})},()=>{et.update(e=>{let t=e[e.length-1];t={...t,index:t.index+1};return e.concat([t])}),n||ot.update(e=>[...e,{...e[e.length-1]}])},async()=>{const e=document.getElementsByClassName("maps")[0];let t=[...document.getElementsByClassName("screenshot-label-transparent")];t.forEach(e=>{e.classList.remove("screenshot-label-transparent"),e.classList.add("screenshot-label")});let i=[];"mirror"===p&&(i=[...document.getElementsByClassName("map-container-border")],i.forEach(e=>{e.classList.remove("map-container-border"),e.classList.add("map-container-border-transparent")}));qK(e,{ignoreElements:e=>!(!e.className||"string"!=typeof e.className)&&e.className.includes("map-label")}).then(e=>{e.toBlob(e=>{const t=URL.createObjectURL(e),i=document.createElement("a");i.href=t;i.download=`screenshot-${g.zoom}_${g.center.lat}_${g.center.lng}_${g.pitch}_${g.bearing}.png`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)})}),t.forEach(e=>{e.classList.remove("screenshot-label"),e.classList.add("screenshot-label-transparent")}),"mirror"===p&&i.forEach(e=>{e.classList.remove("map-container-border-transparent"),e.classList.add("map-container-border")})},async()=>{const e=document.getElementsByClassName("maps")[0];let t=[...document.getElementsByClassName("screenshot-label-transparent")];t.forEach(e=>{e.classList.remove("screenshot-label-transparent"),e.classList.add("screenshot-label")});let i=[];"mirror"===p&&(i=[...document.getElementsByClassName("map-container-border")],i.forEach(e=>{e.classList.remove("map-container-border"),e.classList.add("map-container-border-transparent")}));qK(e,{ignoreElements:e=>!(!e.className||"string"!=typeof e.className)&&e.className.includes("map-label")}).then(e=>{e.toBlob(e=>navigator.clipboard.write([new ClipboardItem({"image/png":e})]))}),t.forEach(e=>{e.classList.remove("screenshot-label"),e.classList.add("screenshot-label-transparent")}),"mirror"===p&&i.forEach(e=>{e.classList.remove("map-container-border-transparent"),e.classList.add("map-container-border")})},()=>{nt.update(e=>!e)},()=>{rt.update(e=>!e)},function(e){"input"!==e.target.tagName.toLowerCase()&&("c"!==e.key&&"C"!==e.key||i(0,u=!u),"t"!==e.key&&"T"!==e.key||i(1,h=!h),"d"!==e.key&&"D"!==e.key||i(2,d=!d))},o,s,c,f,function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(t){Q.call(this,e,t)},function(){u=this.checked,i(0,u)},function(){h=this.checked,i(1,h)},function(){d=this.checked,i(2,d),i(4,p)}]}class TX extends ge{constructor(e){super(),me(this,e,wX,bX,a,{bearing:17,center:18,mapboxGlAccessToken:3,pitch:19,showCollisions:0,showBoundaries:1,showDiff:2,viewMode:4,zoom:20},null,[-1,-1])}}let EX;rt.subscribe(e=>EX=e);const CX=["locations"],SX=["showCollisions","showBoundaries","showDiff"],BX=["bearing","center","pitch","zoom"],IX=["bearing","lat","lng","pitch","zoom"],MX=["map","stylePresets"];const PX=(e,t)=>{const i=[...t.filter(e=>"sublist"!==e.type),...t.filter(e=>"sublist"===e.type).flatMap(e=>e.presets)];return i.find(t=>t.id===e)},RX=(e,t)=>{const i=t.find(t=>t.id===e.branchId);return i?{...i,url:xu(i.pattern,e.branch,e.branchStyle)}:null},LX=(e,t)=>{const i=JSON.parse(e).map(e=>{let i=PX(e.id,t?.stylePresets??[]);return i||(i=RX(e,t?.branchPatterns??[])),i?(i=je(i),e?.selectedPrecompileOption&&(i.selectedPrecompileOption=e?.selectedPrecompileOption),e?.landmarks3D&&(i.landmarks3D=e?.landmarks3D),{...i,...e}):e}).filter(e=>e);return i},FX=({zoom:e,center:t,pitch:i,bearing:n})=>[lt(e,2),lt(t.lat,4),lt(t.lng,4),lt(i??0,1),lt(n??0,1)].join("/"),kX=e=>{const[t,i,n,r,o]=e.split("/");return{bearing:o,center:{lat:i,lng:n},pitch:r,zoom:t}};const DX=(e,t)=>{let i=Object.fromEntries(Object.entries(e).filter(([e,t])=>!BX.includes(e)&&"locations"!==e).map(([e,i])=>{let n=i;return"maps"===e?n=((e,t)=>{const i=e.map(e=>{let i,n={id:e.id};if(e.branchId?(i=RX(e,t?.branchPatterns??[]),n={branchId:i.id,branchStyle:e.branchStyle,branch:e.branch}):i=PX(e.id,t.stylePresets),!i)return Object.fromEntries(Object.entries(e).filter(([e])=>"style"!==e));if(e.renderer!==i.renderer&&(n.renderer=e.renderer),e?.selectedPrecompileOption){const t=e.selectedPrecompileOption??[],r=i?.precompile?.options?.default??[];t.every(e=>r.includes(e))&&r.every(e=>t.includes(e))||(n.selectedPrecompileOption=e.selectedPrecompileOption)}return e?.landmarks3D&&(n.landmarks3D=e.landmarks3D),n});return JSON.stringify(i)})(i,t):CX.includes(e)&&(n=JSON.stringify(i)),[e,n]}));i=(e=>{let t=Object.keys(e).reduce((t,i)=>{const n=e[i];return SX.includes(i)&&!n||null!==n&&(t[i]=n),t},{});return t})(i);const n=OX(window.location.hash,t),r=Object.entries(i).some(e=>{let[t,i]=e;if(MX.includes(t))return!1;try{i=JSON.parse(i)}catch(e){}return!mK(i,n?.[t])});let o={...i};o=EX?{map:FX(e),...o}:{locations:JSON.stringify(e.locations.map(e=>FX(e))),...o};const s=function(e){let t=e.map?`map=${e.map}`:"";return Object.entries(e).forEach(([e,i],n)=>{if(MX.includes(e))return;let r=encodeURIComponent(i);t=`${t}${""!==t?"&":""}${e}=${r}`}),t}(o);return{nextHash:s,requiresHistoryItem:r}};function OX(e,t){let i=Object.fromEntries(Object.entries(function(e){const t=e.split("#")[1];if(!t)return{};let i=Object.fromEntries(t.split("&").map(e=>e.split("=").map(decodeURIComponent)));return i.map&&(i={...i,...kX(i.map)}),i.locations&&(i.locations=JSON.stringify(JSON.parse(i.locations).map(e=>kX(e)))),i}(e)).filter(([e,t])=>!!t).map(([e,i])=>"maps"===e?[e,LX(i,t)]:CX.includes(e)?[e,JSON.parse(i)]:SX.includes(e)?[e,"true"===i]:IX.includes(e)?[e,+i||0]:[e,i]));return i.map&&delete i.map,i}const zX=e=>{const{mapState:t,maps:i,viewMode:n,stylePresets:r}=e;return{...t,viewMode:n,maps:i,stylePresets:r,...OX(window.location.hash,e)}};var UX={};Object.defineProperty(UX,"__esModule",{value:!0}),UX.updateStyle=WX=UX.addLink=void 0;var NX={};Object.defineProperty(NX,"__esModule",{value:!0}),NX.stamenSvg=void 0;function VX(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==i)return;var n,r,o=[],s=!0,a=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return jX(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return jX(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jX(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i\n\n\n\n\n\n';var GX=function(e,t){Object.entries(t).forEach(function(t){var i=VX(t,2),n=i[0],r=i[1];e.style[n]=r})},HX=document.createElement("img");HX.src="data:image/svg+xml;charset=utf-8,".concat(NX.stamenSvg);var QX=document.createElement("a");QX.href="https://stamen.com";var $X=document.createElement("div");GX(HX,{height:"24px",position:"absolute",bottom:"-1px"});GX(QX,{width:"110px",position:"relative"});GX($X,{position:"fixed",bottom:"0px",right:"12px",zIndex:1e4,display:"flex",flexDirection:"row-reverse"}),QX.appendChild(HX),$X.appendChild(QX),document.body.appendChild($X);UX.updateStyle=function(e){for(var t=0,i=Object.entries(e);ti(9,n=e)),WX("https://stamen.com/blog/","Learn more"),WX("https://github.com/stamen/maperture","Fork on Github");let{localConfig:r}=t;const o=(e=>{const t=[{id:"mapbox-streets",name:"Mapbox Streets",type:"mapbox-gl",url:"mapbox://styles/mapbox/streets-v11"},{id:"mapbox-light",name:"Mapbox Light",type:"mapbox-gl",url:"mapbox://styles/mapbox/light-v10"}].map((t,i)=>e?.stylePresets?.[i]??t);return{maps:t,mapState:{bearing:0,center:{lng:-73.92169,lat:40.83962},pitch:0,showCollisions:!1,showBoundaries:!1,showDiff:!1,zoom:13.25},viewMode:"swipe",gazetteer:{Scenarios:[{"Zoomed out":{pitch:0,zoom:10}},{"Zoomed in/Tilted":{pitch:45,zoom:16}}],Locations:[{"San Francisco, CA":{zoom:18,center:{lng:-122.4193,lat:37.7648}}},{"Washington DC":{zoom:12,center:{lng:-77.0435,lat:38.9098}}}]},branchPatterns:[{pattern:"",styles:[]}],stylePresetUrls:[],...e}})(r),{mapboxGlAccessToken:s,stylePresetUrls:a}=o;it.set(o);let c=zX(o),u={},h=!1;const d=()=>location.hash.slice(1)!==DX(c,o)?.nextHash;et.set(c.maps.map((e,t)=>({...e,index:t}))),tt.set(c.stylePresets),ot.set(c?.locations??null),n&&n.length&&rt.set(!1);let p=[];j(()=>{a.length>0&&a.forEach(async e=>{const t=await(async e=>{const t=await fetch(e),i=await t.json();return at(i)?i:(console.warn(`Style presets at ${e} is not valid, check the format`),[])})(e);tt.update(e=>[...e,...t])})}),window.addEventListener("hashchange",()=>{if(!h&&d()){const e=zX(o);if(i(0,c=e),c.maps.length){const e=c.maps.map((e,t)=>({...e,index:t}));et.set(e)}}h=!1}),et.subscribe(e=>{const t=je(e).map(e=>(delete e.isPolling,e));i(0,c={...c,maps:t})}),ot.subscribe(e=>{i(0,c={...c,locations:e})}),rt.subscribe(e=>{if(!e&&!n){const e=p.map(()=>u);ot.set(e)}e&&n&&ot.set(null)});const f=Ct(()=>{d()&&(h=!0,function(e,t){const{nextHash:i,requiresHistoryItem:n}=DX(e,t);n?window.location.hash=i:window.location.replace(`${window.location.pathname}#${i}`)}(c,o))},250);return"unavailable"===Ze.getRTLTextPluginStatus()&&Ze.setRTLTextPlugin("https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.0/mapbox-gl-rtl-text.js"),"unavailable"===Ke.getRTLTextPluginStatus()&&Ke.setRTLTextPlugin("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js"),e.$$set=e=>{"localConfig"in e&&i(7,r=e.localConfig)},e.$$.update=()=>{5&e.$$.dirty&&(mK(p,c.maps)||i(2,p=c.maps)),6&e.$$.dirty&&i(1,u=pK(u,p)),1&e.$$.dirty&&c&&f(),1&e.$$.dirty&&(c||height||width)&&i(1,u=(()=>{const{bearing:e,center:t,pitch:i,showCollisions:n,showBoundaries:r,showDiff:o,zoom:s,height:a,width:l}=c;return{bearing:e,center:t,pitch:i,showCollisions:n,showBoundaries:r,showDiff:o,zoom:s,...a&&{height:a},...l&&{width:l}}})())},[c,u,p,s,e=>{let t={...u,...e.detail.options};i(0,c={...c,...pK(t,p)})},e=>{i(0,c={...c,viewMode:e.detail.mode})},e=>{i(0,c={...c,...e.detail})},r]}class XX extends ge{constructor(e){super(),me(this,e,KX,qX,a,{localConfig:7})}}const JX=(e,t)=>new XX({target:e,props:t});var YX=Object.freeze({__proto__:null,default:undefined}),eJ=Object.freeze({__proto__:null,default:undefined}),tJ={exports:{}};tJ.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const 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(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),n=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=n,this},_rotateAround(e,t){const i=Math.cos(e),n=Math.sin(e),r=t.y+n*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-n*(this.y-t.y),this.y=r,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function F(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";function oe(){return new Error(re)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(n=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new ce(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;if(i.signal.aborted)throw oe();return{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var n;return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(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 n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)fe(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof ge&&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 Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},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:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},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,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},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,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{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_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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)}function tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,nt=.82521,rt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,n]){let r,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?r=o=s:(r=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+rt}function ft([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*gt(r),o=it*gt(o),s=nt*gt(s),[mt(3.1338561*o-1.6168667*r-.4906146*s),mt(-.9787684*o+1.9161415*r+.033454*s),mt(.0719453*o-.2289914*r+1.4052427*s),n]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-rt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,n)=>Tt(e,t[n],i))}class Ct{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+r,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=ut(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=ht(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?ut(Math.atan2(n,i)*ct):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Et(e.rgb,t.rgb,i);return new Ct(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:Tt(r,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(n,r,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class St{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}}const Bt=["bottom","center","top"];class It{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof St||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof St)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let n=Vt(i);const r=t.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Gt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Ht[i],n++}else r=Ve;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],n++}i=qe(r,o)}else{if(!Ht[r])throw new Error(`Types doesn't contain name = ${r}`);i=Ht[r]}const o=[];for(;ne.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{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];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=$t[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Pt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Lt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new qt;try{n=new Gt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}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 n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{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 n=1;n=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,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,Ve),n=t.parse(e[2],2,Ve);return i&&n?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,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,Ve),n=t.parse(e[2],2,Ve);if(!i||!n)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ti(i,n,r):null}return new ti(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,Vt(e)))return null}else i=Vt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(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()}}class ni{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class ri{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}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,Ve),n=t.parse(e[2],2,ke);if(!i||!n)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ri(i.type,i,n,r):null}return new ri(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,n).join("");if(et(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new si(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;return n>=t[r-1]?i[r-1].evaluate(e):i[oi(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ci=1,li=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=pi(t,e.base,i,n);else if("linear"===e.name)r=pi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new hi(o[0],o[1],o[2],o[3]).solve(pi(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,ke),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,n,r,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=oi(t,n),s=di.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>Je(n,e.type));return new mi(o?Ve:i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,n){return 0===n.compare(t,i)}function Ai(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(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,je),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!_i(0,t,i,n)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(n,r,o)}evaluate(e){return new St(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}}class Ci{constructor(e,t,i,n,r){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,De),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,De),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,ke),!a)?null:new Ci(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ge,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Bt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Si(n)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Bi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,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 ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Mi),Math.round(n*r*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Mi+t.x)/i,360*r-180),(n=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Di(e,t,i,n){return 0!=(r=[n[0]-i[0],n[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-r[1]*o[0]&&!(!ji(e,t,i,n)||!ji(i,n,e,t));var r,o}function Oi(e,t,i){for(const n of i)for(let i=0;i(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}Li(t,e)}function $i(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Qi(n,t,i,r),s.push(n)}return s}function Zi(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Qi(n,t,i,r)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=Ji){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Xi(e,i,t),r(e[n],o)>0&&Xi(e,i,n);s0;)a--}0===r(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Xi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=tn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function an(e,t){return t[0]-e[0]}function ln(e){return e[1]-e[0]+1}function cn(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ln(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function hn(e,t){if(!cn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Li(i,e[n]);return i}function dn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function pn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fn(e,t,i){if(!pn(e)||!pn(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(Fi(r,o)){if(xn(e,t))return 0}else if(xn(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(ln(l)<=c){if(!cn(l,e.length))return NaN;if(t){const t=vn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=yn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=un(l,t);wn(s,o,n,e,a,i[0]),wn(s,o,n,e,a,i[1])}}return o}function Cn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],an);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(ln(l)<=u&&ln(c)<=h){if(!cn(l,e.length)&&cn(c,i.length))return NaN;let o;if(t&&n)o=_n(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=mn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=mn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=An(e,l,i,c,r),s=Math.min(s,o)}else{const o=un(l,t),u=un(c,n);Tn(a,s,r,e,i,o[0],u[0]),Tn(a,s,r,e,i,o[0],u[1]),Tn(a,s,r,e,i,o[1],u[0]),Tn(a,s,r,e,i,o[1],u[1])}}return s}function Sn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Bn{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Bn(t,t.features.map(e=>Sn(e.geometry)).flat());if("Feature"===t.type)return new Bn(t,Sn(t.geometry));if("type"in t&&"coordinates"in t)return new Bn(t,Sn(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new sn(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,En([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,En(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,bn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class In{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new In(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Mn={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ni,coalesce:mi,collator:Ei,format:Si,image:Bi,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ri,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Bn,"global-state":In};class Pn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Pn.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Dn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i{i=t?i&&Dn(e):i&&e instanceof Gt}),!!i&&On(e)&&Un(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function On(e){if(e instanceof Pn){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 Wi)return!1;if(e instanceof Bn)return!1;let t=!0;return e.eachChild(e=>{t&&!On(e)&&(t=!1)}),t}function zn(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!zn(e)&&(t=!1)}),t}function Un(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Un(e,t)&&(i=!1)}),i}function Nn(e){return{result:"success",value:e}}function Vn(e){return{result:"error",value:e}}function jn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hn(e){return!!e.expression&&e.expression.interpolated}function Qn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function $n(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function Zn(e){return e}function Wn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||(Hn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Jn;case"interval":return Xn;case"categorical":return Kn;case"identity":return Yn;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Jn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?qn(e.default,t.default):a(e,t,r,l,c)}}}function qn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return qn(typeof i===r?n[i]:void 0,e.default,t.default)}function Xn(e,t,i){if("number"!==Qn(i))return qn(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 r=oi(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Jn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Qn(i))return qn(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 o=oi(e.stops.map(e=>e[0]),i),s=function(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}(i,n,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||Zn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Yn(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return qn(i,e.default,t.default)}Pn.register(Mn,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[ze,[ke,ke,ke],Rn],rgba:[ze,[ke,ke,ke,ke],Rn],has:{type:Oe,overloads:[[[De],(e,[t])=>Ln(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Ln(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,kn(ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[ke,kn(ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,kn(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,kn(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,kn(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class er{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&$n(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 Ft(`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 tr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mn}function ir(e,t){const i=new Kt(Mn,Dn,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?Nn(new er(n,t)):Vn(i.errors)}class nr{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class rr{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function or(e,t){const i=ir(e,t);if("error"===i.result)return i;const n=i.value.expression,r=On(n);if(!r&&!jn(t))return Vn([new Re("","data expressions not supported")]);const o=Un(n,["zoom"]);if(!o&&!Gn(t))return Vn([new Re("","zoom expressions not supported")]);const s=ar(n);return s||o?s instanceof Re?Vn([s]):s instanceof di&&!Hn(t)?Vn([new Re("",'"interpolate" expressions cannot be used with this property')]):Nn(s?new rr(r?"camera":"composite",i.value,s.labels,s instanceof di?s.interpolation:void 0):new nr(r?"constant":"source",i.value)):Vn([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sr{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Wn(this._parameters,this._specification))}static deserialize(e){return new sr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ar(e){let t=null;if(e instanceof Xt)t=ar(e.result);else if(e instanceof mi){for(const i of e.args)if(t=ar(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=ar(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function lr(e,t=new Set){return e instanceof In&&t.add(e.key),e.eachChild(e=>{lr(e,t)}),t}function cr(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(!cr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const ur={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function hr(e){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};cr(e)||(e=fr(e));const t=ir(e,ur);if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,i,n)=>t.value.evaluate(e,i,{},n),needGeometry:pr(e),getGlobalStateRefs:()=>lr(t.value.expression)}}function dr(e,t){return et?1:0}function pr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?mr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(fr))):"all"===t?["all"].concat(e.slice(1).map(fr)):"none"===t?["all"].concat(e.slice(1).map(fr).map(Ar)):"in"===t?gr(e[1],e.slice(2)):"!in"===t?Ar(gr(e[1],e.slice(2))):"has"===t?_r(e[1]):"!has"!==t||Ar(_r(e[1]));var i}function mr(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 gr(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(dr)]]:["filter-in-small",e,["literal",t]]}}function _r(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ar(e){return["!",e]}function yr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${yr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new Me(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Sr(e){const t=e.valueSpec,i=br(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Qn(e.value.stops)&&"array"===Qn(e.value.stops[0])&&"object"===Qn(e.value.stops[0][0]),u=Tr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Er({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Qn(n)&&0===n.length&&t.push(new Me(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Hn(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jn(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!Gn(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Qn(n))return[new Me(a,n,`array expected, ${Qn(n)} found`)];if(2!==n.length)return[new Me(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Qn(n[0]))return[new Me(a,n,`object expected, ${Qn(n[0])} found`)];if(void 0===n[0].zoom)return[new Me(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Me(a,n,"object stop key must have value")];if(o&&o>br(n[0].zoom))return[new Me(a,n[0].zoom,"stop zoom values must appear in ascending order")];br(n[0].zoom)!==o&&(o=br(n[0].zoom),r=void 0,s={}),i=i.concat(Tr({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Cr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return tr(wr(n[1]))?i.concat([new Me(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Qn(e.value),l=br(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return jn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew Me(`${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 Me(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&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Un(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!On(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Ir(e){const t=e.key,i=e.value,n=Qn(i);return"string"!==n?[new Me(t,i,`color expected, ${n} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Mr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(br(i))&&r.push(new Me(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(br(i))&&r.push(new Me(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Pr(e){return cr(wr(e.value))?Br(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Rr(e)}function Rr(e){const t=e.value,i=e.key;if("array"!==Qn(t))return[new Me(i,t,`array expected, ${Qn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Mr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),br(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===br(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Qn(t[1]),"string"!==r&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new Me(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{br(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(n,i.ref,"ref cannot reference another ref layer")):s=br(e.type):t.push(new Me(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&br(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(n,i.source,`source "${i.source}" not found`))}else t.push(new Me(n,i,'missing required property "source"'));return t=t.concat(Tr({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Pr,layout:e=>Tr({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kr(Pe({layerType:s},e))}}),paint:e=>Tr({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Fr(Pe({layerType:s},e))}})}})),t}function Or(e){const t=e.value,i=e.key,n=Qn(t);return"string"!==n?[new Me(i,t,`string expected, ${n} found`)]:[]}const zr={promoteId:function({key:e,value:t}){if("string"===Qn(t))return Or({key:e,value:t});{const i=[];for(const n in t)i.push(...Or({key:`${e}.${n}`,value:t[n]}));return i}}};function Ur(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=br(t.type);let a;switch(s){case"vector":case"raster":return a=Tr({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:zr,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Qn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Me("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===br(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Me(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Me(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=Tr({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:zr}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Br({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Br({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Tr({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return Tr({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Mr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Nr(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function Vr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function jr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Gr(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Me(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(Tr({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return Or({key:n,value:i})}function Hr(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Qn(e.value)} found`)];var t}const Qr={"*":()=>[],array:Er,boolean:function(e){const t=e.value,i=e.key,n=Qn(t);return"boolean"!==n?[new Me(i,t,`boolean expected, ${n} found`)]:[]},number:Cr,color:Ir,constants:xr,enum:Mr,filter:Pr,function:Sr,layer:Dr,object:Tr,source:Ur,light:Nr,sky:Vr,terrain:jr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Qn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Me(t,i,`projection expected, invalid type "${n}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Or,formatted:function(e){return 0===Or(e).length?[]:Br(e)},resolvedImage:function(e){return 0===Or(e).length?[]:Br(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Qn(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(xr({key:"constants",value:e.constants}))),Kr(i)}function qr(e){return function(t){return e({...t,validateSpec:$r})}}function Kr(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Xr(e){return function(...t){return Kr(e.apply(this,t))}}Wr.source=Xr(qr(Ur)),Wr.sprite=Xr(qr(Gr)),Wr.glyphs=Xr(qr(Zr)),Wr.light=Xr(qr(Nr)),Wr.sky=Xr(qr(Vr)),Wr.terrain=Xr(qr(jr)),Wr.state=Xr(qr(Hr)),Wr.layer=Xr(qr(Dr)),Wr.filter=Xr(qr(Pr)),Wr.paintProperty=Xr(qr(Fr)),Wr.layoutProperty=Xr(qr(kr));const Jr=Wr,Yr=Jr.light,eo=Jr.sky,to=Jr.paintProperty,io=Jr.layoutProperty;function no(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new ge(new Error(n.message))),i=!0;return i}class ro{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e=c[l+0]&&n>=c[l+1])?(s[h]=!0,o.push(r[h])):s[h]=!1}}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[n];r[n]=oo[i].shallow.indexOf(n)>=0?o:uo(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function ho(e){if(co(e))return e;if(Array.isArray(e))return e.map(ho);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=lo(e)||"Object";if(!oo[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=oo[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const n=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=oo[t].shallow.indexOf(i)>=0?r:ho(r)}return n}class po{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoome>=128&&e<=255,"Hangul Jamo":e=>e>=4352&&e<=4607,Khmer:e=>e>=6016&&e<=6143,"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,"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,Kanbun:e=>e>=12688&&e<=12703,"CJK Strokes":e=>e>=12736&&e<=12783,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Hangul Syllables":e=>e>=44032&&e<=55215,"Private Use Area":e=>e>=57344&&e<=63743,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519};function mo(e){for(const t of e)if(xo(t.charCodeAt(0)))return!0;return!1}function go(e){for(const t of e)if(!yo(t.charCodeAt(0)))return!1;return!0}function _o(e){const t=e.map(e=>{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const Ao=_o(["Arab","Dupl","Mong","Ougr","Syrc"]);function yo(e){return!Ao.test(String.fromCodePoint(e))}const vo=_o(["Bopo","Hani","Hira","Kana","Kits","Nshu","Tang","Yiii"]);function xo(e){return!(746!==e&&747!==e&&(e<4352||!(fo["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||fo["CJK Compatibility"](e)||fo["CJK Strokes"](e)||!(!fo["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||fo["Enclosed CJK Letters and Months"](e)||fo["Ideographic Description Characters"](e)||fo.Kanbun(e)||fo.Katakana(e)&&12540!==e||!(!fo["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)||!(!fo["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||fo["Vertical Forms"](e)||fo["Yijing Hexagram Symbols"](e)||/\p{sc=Cans}/u.test(String.fromCodePoint(e))||/\p{sc=Hang}/u.test(String.fromCodePoint(e))||vo.test(String.fromCodePoint(e)))))}function bo(e){return!(xo(e)||function(e){return!!(fo["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||fo["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)||fo["Letterlike Symbols"](e)||fo["Number Forms"](e)||fo["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)||fo["Control Pictures"](e)&&9251!==e||fo["Optical Character Recognition"](e)||fo["Enclosed Alphanumerics"](e)||fo["Geometric Shapes"](e)||fo["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||fo["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||fo["CJK Symbols and Punctuation"](e)||fo.Katakana(e)||fo["Private Use Area"](e)||fo["CJK Compatibility Forms"](e)||fo["Small Form Variants"](e)||fo["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}const wo=_o(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function To(e){return wo.test(String.fromCodePoint(e))}function Eo(e,t){return!(!t&&To(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||fo.Khmer(e))}function Co(e){for(const t of e)if(To(t.charCodeAt(0)))return!0;return!1}const So=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(So.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Bo{constructor(e,t){this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new po,this.transition=t.transition||{},this.globalState=t.globalState||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new po,this.transition={},this.globalState={})}isSupportedScript(e){return function(e,t){for(const i of e)if(!Eo(i.charCodeAt(0),t))return!1;return!0}(e,"loaded"===So.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class Io{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if($n(e))return new sr(e,t);if(tr(e)){const i=or(e,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return i.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Mo{constructor(e){this.property=e,this.value=new Io(e,void 0)}transitioned(e,t){return new Ro(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Ro(this.property,this.value,null,{},0)}}class Po{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mo(this._values[e].property)),this._values[e].value=new Io(this._values[e].property,null===t?void 0:j(t))}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Mo(this._values[e].property)),this._values[e].transition=j(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 n=this.getTransition(t);void 0!==n&&(e[`${t}-transition`]=n)}return e}transitioned(e,t){const i=new Lo(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(e,t._values[n]);return i}untransitioned(){const e=new Lo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Ro{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,e.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const n=e.now||0,r=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nn.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class No{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Bo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Bo(Math.floor(t.zoom),t)),e.expression.evaluate(new Bo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Vo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class jo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Io(i,void 0),r=this.defaultTransitionablePropertyValues[t]=new Mo(i);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}so("DataDrivenProperty",zo),so("DataConstantProperty",Oo),so("CrossFadedDataDrivenProperty",Uo),so("CrossFadedProperty",No),so("ColorRampProperty",Vo);const Go="-transition";class Ho extends _e{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=hr(e.filter)),t.layout&&(this._unevaluatedLayout=new Fo(t.layout)),t.paint)){this._transitionablePaint=new Po(t.paint);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._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Do(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=hr(e)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}setLayoutProperty(e,t,i={}){null!=t&&this._validate(io,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Go)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(to,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Go))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,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()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&no(this,e.call(Jr,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof ko&&jn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}const Qo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class $o{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 Zo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(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")}}function Wo(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=Qo[e.type].BYTES_PER_ELEMENT,o=i=qo(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:qo(i,Math.max(n,t)),alignment:t}}function qo(e,t){return Math.ceil(e/t)*t}class Ko extends Zo{_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 n=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,e}}Ko.prototype.bytesPerElement=4,so("StructArrayLayout2i4",Ko);class Xo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.int16[r+0]=t,this.int16[r+1]=i,this.int16[r+2]=n,e}}Xo.prototype.bytesPerElement=6,so("StructArrayLayout3i6",Xo);class Jo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,e}}Jo.prototype.bytesPerElement=8,so("StructArrayLayout4i8",Jo);class Yo extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}Yo.prototype.bytesPerElement=12,so("StructArrayLayout2i4i12",Yo);class es extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}es.prototype.bytesPerElement=8,so("StructArrayLayout2i4ub8",es);class ts extends Zo{_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 n=2*e;return this.float32[n+0]=t,this.float32[n+1]=i,e}}ts.prototype.bytesPerElement=8,so("StructArrayLayout2f8",ts);class is extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}is.prototype.bytesPerElement=20,so("StructArrayLayout10ui20",is);class ns extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,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]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}ns.prototype.bytesPerElement=24,so("StructArrayLayout4i4ui4i24",ns);class rs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.float32[r+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}rs.prototype.bytesPerElement=12,so("StructArrayLayout3f12",rs);class os extends Zo{_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}}os.prototype.bytesPerElement=4,so("StructArrayLayout1ul4",os);class ss extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ss.prototype.bytesPerElement=20,so("StructArrayLayout6i1ul2ui20",ss);class as extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,e}}as.prototype.bytesPerElement=12,so("StructArrayLayout2i2i2i12",as);class ls extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,n,r)}emplace(e,t,i,n,r,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ls.prototype.bytesPerElement=16,so("StructArrayLayout2f1f2i16",ls);class cs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}cs.prototype.bytesPerElement=16,so("StructArrayLayout2ub2f2i16",cs);class us extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,this.uint16[r+2]=n,e}}us.prototype.bytesPerElement=6,so("StructArrayLayout3ui6",us);class hs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=n,this.uint16[A+3]=r,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}hs.prototype.bytesPerElement=48,so("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",hs);class ds extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=n,this.int16[I+3]=r,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=S,this.uint16[I+31]=B,e}}ds.prototype.bytesPerElement=64,so("StructArrayLayout8i15ui1ul2f2ui64",ds);class ps extends Zo{_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}}ps.prototype.bytesPerElement=4,so("StructArrayLayout1f4",ps);class fs extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=3*e;return this.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}fs.prototype.bytesPerElement=12,so("StructArrayLayout1ui2f12",fs);class ms extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i)}emplace(e,t,i,n){const r=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}ms.prototype.bytesPerElement=8,so("StructArrayLayout1ul2ui8",ms);class gs extends Zo{_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 n=2*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,e}}gs.prototype.bytesPerElement=4,so("StructArrayLayout2ui4",gs);class _s extends Zo{_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}}_s.prototype.bytesPerElement=2,so("StructArrayLayout1ui2",_s);class As extends Zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i,n)}emplace(e,t,i,n,r){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,e}}As.prototype.bytesPerElement=16,so("StructArrayLayout4f16",As);class ys extends $o{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}ys.prototype.size=20;class vs extends ss{get(e){return new ys(this,e)}}so("CollisionBoxArray",vs);class xs extends $o{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}xs.prototype.size=48;class bs extends hs{get(e){return new xs(this,e)}}so("PlacedSymbolArray",bs);class ws extends $o{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}ws.prototype.size=64;class Ts extends ds{get(e){return new ws(this,e)}}so("SymbolInstanceArray",Ts);class Es extends ps{getoffsetX(e){return this.float32[1*e+0]}}so("GlyphOffsetArray",Es);class Cs extends Xo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}so("SymbolLineVertexArray",Cs);class Ss extends $o{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Ss.prototype.size=12;class Bs extends fs{get(e){return new Ss(this,e)}}so("TextAnchorOffsetArray",Bs);class Is extends $o{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]}}Is.prototype.size=8;class Ms extends ms{get(e){return new Is(this,e)}}so("FeatureIndexArray",Ms);class Ps extends Ko{}class Rs extends Ko{}class Ls extends Ko{}class Fs extends Yo{}class ks extends es{}class Ds extends ts{}class Os extends is{}class zs extends ns{}class Us extends rs{}class Ns extends os{}class Vs extends as{}class js extends cs{}class Gs extends us{}class Hs extends gs{}const Qs=Wo([{name:"a_pos",components:2,type:"Int16"}],4),{members:$s}=Qs;class Zs{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return e>Zs.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${Zs.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${Zs.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>Zs.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}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,n){return new Zs([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function Ws(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}Zs.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,so("SegmentVector",Zs);const qs=Wo([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var Ks,Xs,Js,Ys={exports:{}},ea={exports:{}},ta={exports:{}},ia=function(){if(Js)return Ys.exports;Js=1;var e=(Ks||(Ks=1,ea.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>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:r^=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 r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ea.exports),t=(Xs||(Xs=1,ta.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=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),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ta.exports);return Ys.exports=e,Ys.exports.murmur3=e,Ys.exports.murmur2=t,Ys.exports}(),na=n(ia);class ra{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(oa(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=oa(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return sa(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new ra;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function oa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:na(String(e))}function sa(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;aa(e,o,s),aa(t,3*o,3*s),aa(t,3*o+1,3*s+1),aa(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new ha(e,t):new ca(e,t)}}class ma{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setUniform(e,t,i,n){const r="u_pattern_to"===n?this.patternTo:"u_pattern_from"===n?this.patternFrom:"u_pixel_ratio_to"===n?this.pixelRatioTo:"u_pixel_ratio_from"===n?this.pixelRatioFrom:null;r&&e.set(r)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)?new ua(e,t):new ca(e,t)}}class ga{constructor(e,t,i,n){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 n}populatePaintArray(e,t,i,n,r){const o=this.paintVertexArray.length,s=this.expression.evaluate(new Bo(0),t,{},n,[],r);this.paintVertexArray.resize(e),this._setPaintValue(o,e,s)}updatePaintArray(e,t,i,n){const r=this.expression.evaluate({zoom:0},i,n);this._setPaintValue(e,t,r)}_setPaintValue(e,t,i){if("color"===this.type){const n=pa(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=r,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,n,r){const o=this.expression.evaluate(new Bo(this.zoom),t,{},n,[],r),s=this.expression.evaluate(new Bo(this.zoom+1),t,{},n,[],r),a=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(a,e,o,s)}updatePaintArray(e,t,i,n){const r=this.expression.evaluate({zoom:this.zoom},i,n),o=this.expression.evaluate({zoom:this.zoom+1},i,n);this._setPaintValue(e,t,r,o)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=pa(i),o=pa(n);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof ga||i instanceof _a)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new ya(n,t,i);this.needsUpload=!1,this._featureMap=new ra,this._bufferOffset=0}populatePaintArrays(e,t,i,n,r,o){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,o);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||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()}}function xa(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"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_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function ba(e,t,i){const n={color:{source:ts,composite:As},number:{source:ps,composite:ts}},r=function(e){return{"line-pattern":{source:Os,composite:Os},"fill-pattern":{source:Os,composite:Os},"fill-extrusion-pattern":{source:Os,composite:Os}}[e]}(e);return r&&r[i]||n[t][i]}so("ConstantBinder",fa),so("CrossFadedConstantBinder",ma),so("SourceExpressionBinder",ga),so("CrossFadedCompositeBinder",Aa),so("CompositeExpressionBinder",_a),so("ProgramConfiguration",ya,{omit:["_buffers"]}),so("ProgramConfigurationSet",va);const wa=Math.pow(2,14)-1,Ta=-wa-1;function Ea(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Ca(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ea(e):[]}}const Sa=-32768;function Ba(e,t,i,n,r){e.emplaceBack(Sa+8*t+n,Sa+8*i+r)}class Ia{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Rs,this.indexArray=new Gs,this.segments=new Zs,this.programConfigurations=new va(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ca(t,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ea(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,$s),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())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=I||n<0||n>=I)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e1){if(Fa(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function za(e,t){let i,n,r,o=!1;for(let s=0;st.y!=r.y>t.y&&t.x<(r.x-n.x)*(t.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function Ua(e,t){let i=!1;for(let n=0,r=e.length-1;nt.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 Na(e,t,i){const n=i[0],r=i[2];if(e.xr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Va(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function ja(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ga(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(let t=0;tWa(e,t,i,n))}(l,r,s,a),d=u?c*o:c;for(const e of n)for(const t of e){const e=u?t:Wa(t,r,s,a);let i=d;const n=r.projectTileCoordinates(t.x,t.y,s,a).signedDistanceFromCamera;if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=n/r.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=r.cameraToCenterDistance/n),Pa(h,e,i))return!0}return!1}}function Wa(e,t,n,r){const o=t.projectTileCoordinates(e.x,e.y,n,r).point;return new i((.5*o.x+.5)*t.width,(.5*-o.y+.5)*t.height)}class qa extends Ia{}let Ka;so("HeatmapBucket",qa,{omit:["layers"]});var Xa={get paint(){return Ka=Ka||new jo({"heatmap-radius":new zo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new zo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Oo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Vo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Oo(Ae.paint_heatmap["heatmap-opacity"])})}};function Ja(e,{width:t,height:i},n,r){if(r){if(r instanceof Uint8ClampedArray)r=new Uint8Array(r.buffer);else if(r.length!==t*i*n)throw new RangeError(`mismatched image size. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function Ya(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=Ja({},{width:t,height:i},n);el(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function el(e,t,i,n,r,o){if(0===r.width||0===r.height)return t;if(r.width>e.width||r.height>e.height||i.x>e.width-r.width||i.y>e.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>t.width||r.height>t.height||n.x>t.width-r.width||n.y>t.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return pl(e,this.getUnpackVector())}getPixels(){return new il({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+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;t0)for(let r=t;r=t;r-=n)o=Vl(r/n|0,e[r],e[r+1],o);return o&&kl(o,o.next)&&(jl(o),o=o.next),o}function vl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!kl(n,n.next)&&0!==Fl(n.prev,n,n.next))n=n.next;else{if(jl(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function xl(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Il(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,i=1;do{let n,r=e;e=null;let o=null;for(t=0;r;){t++;let s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?wl(e,n,r,o):bl(e))t.push(l.i,e.i,c.i),jl(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?xl(e=Tl(vl(e),t),t,i,n,r,o,2):2===s&&El(e,t,i,n,r,o):xl(vl(e),t,i,n,r,o,1);break}}}function bl(e){const t=e.prev,i=e,n=e.next;if(Fl(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Rl(r,a,o,l,s,c,f.x,f.y)&&Fl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function wl(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Fl(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Il(p,f,t,i,n),A=Il(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Rl(a,u,l,h,c,d,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Rl(a,u,l,h,c,d,v.x,v.y)&&Fl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Rl(a,u,l,h,c,d,y.x,y.y)&&Fl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Rl(a,u,l,h,c,d,v.x,v.y)&&Fl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Tl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!kl(n,r)&&Dl(n,i,i.next,r)&&Ul(n,r)&&Ul(r,n)&&(t.push(n.i,i.i,r.i),jl(i),jl(i.next),i=e=r),i=i.next}while(i!==e);return vl(i)}function El(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Ll(s,e)){let a=Nl(s,e);return s=vl(s,s.next),a=vl(a,a.next),xl(s,t,i,n,r,o,0),void xl(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function Cl(e,t){let i=e.x-t.x;return 0===i&&(i=e.y-t.y,0===i)&&(i=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),i}function Sl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(kl(e,i))return i;do{if(kl(e,i.next))return i.next;if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const e=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Pl(ro.x||i.x===o.x&&Bl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=Nl(i,e);return vl(n,n.next),vl(i,i.next)}function Bl(e,t){return Fl(e.prev,e,t.prev)<0&&Fl(t.next,e,e.next)<0}function Il(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ml(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Rl(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Pl(e,t,i,n,r,o,s,a)}function Ll(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Dl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Ul(e,t)&&Ul(t,e)&&function(e,t){let i=e,n=!1;const r=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}(e,t)&&(Fl(e.prev,e,t.prev)||Fl(e,t.prev,t))||kl(e,t)&&Fl(e.prev,e,e.next)>0&&Fl(t.prev,t,t.next)>0)}function Fl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function kl(e,t){return e.x===t.x&&e.y===t.y}function Dl(e,t,i,n){const r=zl(Fl(e,t,i)),o=zl(Fl(e,t,n)),s=zl(Fl(i,n,e)),a=zl(Fl(i,n,t));return r!==o&&s!==a||!(0!==r||!Ol(e,i,t))||!(0!==o||!Ol(e,n,t))||!(0!==s||!Ol(i,e,n))||!(0!==a||!Ol(i,t,n))}function Ol(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 zl(e){return e>0?1:e<0?-1:0}function Ul(e,t){return Fl(e.prev,e,e.next)<0?Fl(e,t,e.next)>=0&&Fl(e,e.prev,t)>=0:Fl(e,t,e.prev)<0||Fl(e,e.next,t)<0}function Nl(e,t){const i=Gl(e.i,e.x,e.y),n=Gl(t.i,t.x,t.y),r=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function Vl(e,t,i,n){const r=Gl(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function jl(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 Gl(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class Hl{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n=1||y<=0)||m&&(ar)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),_=n+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=Kl(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;er!=(o===$l)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return xl(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let n=0;n0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(A-e),r=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?n/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function Jl(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(cZs.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=Yl(s,n,o,a,d,m,c),y=Yl(s,n,o,a,p,g,c),v=Yl(s,n,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;eZs.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=Yl(s,n,o,a,r,f,c),_=Yl(s,n,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function Yl(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class ec{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ls,this.indexArray=new Gs,this.indexArray2=new Hs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.segments2=new Zs,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasPattern=_l("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ca(s,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Ea(s),patterns:{},sortKey:h};o.push(d)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Al("fill",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gl),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,n,r,o){for(const e of Yi(t,500)){const t=ql(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;Jl((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,n)}}let tc,ic;so("FillBucket",ec,{omit:["layers","patternFeatures"]});var nc={get paint(){return ic=ic||new jo({"fill-antialias":new Oo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new zo(Ae.paint_fill["fill-opacity"]),"fill-color":new zo(Ae.paint_fill["fill-color"]),"fill-outline-color":new zo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Oo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Oo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Uo(Ae.paint_fill["fill-pattern"])})},get layout(){return tc=tc||new jo({"fill-sort-key":new zo(Ae.layout_fill["fill-sort-key"])})}};class rc extends Ho{constructor(e){super(e,nc)}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 ec(e)}queryRadius(){return ja(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ra(Ga(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const oc=Wo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),sc=Wo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:ac}=oc;class lc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(cc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+r)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/n)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new lc(this._pbf,t,this.extent,this._keys,this._values)}}function dc(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){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class pc{constructor(e,t){this.layers=e.readFields(fc,{},t)}}function fc(e,t,i){if(3===e){const e=new hc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const mc=Math.pow(2,13);function gc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*mc)+s,r*mc*2,o*mc*2,Math.round(a))}class _c{constructor(e){this.zoom=e.zoom,this.globalState=e.globalState,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new Fs,this.centroidVertexArray=new Ps,this.indexArray=new Gs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasPattern=_l("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Ca(n,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Ea(n),properties:n.properties,type:n.type,patterns:{}};this.hasPattern?this.features.push(Al("fill-extrusion",this.layers,l,this.zoom,t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ac),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,sc.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{gc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;nZs.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),gc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),gc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,gc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),gc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Ac(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function vc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let xc;so("FillExtrusionBucket",_c,{omit:["layers","features"]});var bc={get paint(){return xc=xc||new jo({"fill-extrusion-opacity":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Uo(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new zo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Oo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class wc extends Ho{constructor(e){super(e,bc)}createBucket(e){return new _c(e)}queryRadius(){return ja(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=Ga(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,n.push(C)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ra(i,t)&&(n=Ec(i,t[0]));for(let r=0;re.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ks,this.layoutVertexArray2=new Ds,this.indexArray=new Gs,this.programConfigurations=new va(e.layers,e.zoom),this.segments=new Zs,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasPattern=_l("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ca(t,e);if(!this.layers[0]._featureFilter.filter(new Bo(this.zoom,{globalState:this.globalState}),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Ea(t),patterns:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const e=Al("line",this.layers,n,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i)}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}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,Ic)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Sc),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&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap"),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,u,n,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,n)}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=Kl(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":n;if(w&&"round"===T&&(yr&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>Pc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Pc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(r?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}let Lc,Fc;so("LineBucket",Rc,{omit:["layers","patternFeatures"]});var kc={get paint(){return Fc=Fc||new jo({"line-opacity":new zo(Ae.paint_line["line-opacity"]),"line-color":new zo(Ae.paint_line["line-color"]),"line-translate":new Oo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Oo(Ae.paint_line["line-translate-anchor"]),"line-width":new zo(Ae.paint_line["line-width"]),"line-gap-width":new zo(Ae.paint_line["line-gap-width"]),"line-offset":new zo(Ae.paint_line["line-offset"]),"line-blur":new zo(Ae.paint_line["line-blur"]),"line-dasharray":new No(Ae.paint_line["line-dasharray"]),"line-pattern":new Uo(Ae.paint_line["line-pattern"]),"line-gradient":new Vo(Ae.paint_line["line-gradient"])})},get layout(){return Lc=Lc||new jo({"line-cap":new Oo(Ae.layout_line["line-cap"]),"line-join":new zo(Ae.layout_line["line-join"]),"line-miter-limit":new Oo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Oo(Ae.layout_line["line-round-limit"]),"line-sort-key":new zo(Ae.layout_line["line-sort-key"])})}};class Dc extends zo{possiblyEvaluate(e,t){return t=new Bo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let Oc;class zc extends Ho{constructor(e){super(e,kc),this.gradientVersion=0,Oc||(Oc=new Dc(kc.paint.properties["line-width"].specification),Oc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Oc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Rc(e)}queryRadius(e){const t=e,i=Uc(Va("line-width",this,t),Va("line-gap-width",this,t)),n=Va("line-offset",this,t);return i/2+Math.abs(n)+ja(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=Ga(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*Uc(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(let r=0;r=3)for(let t=0;t0?t+2*e:e}const Nc=Wo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Vc=Wo([{name:"a_projected_pos",components:3,type:"Float32"}],4);Wo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const jc=Wo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Wo([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Gc=Wo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Hc=Wo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Qc(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const n=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?e=e.toLocaleUpperCase():"lowercase"===n&&(e=e.toLocaleLowerCase()),So.applyArabicShaping&&(e=So.applyArabicShaping(e)),e}(e.text,t,i)}),e}Wo([{name:"triangle",components:3,type:"Uint16"}]),Wo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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"}]),Wo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{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",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Wo([{type:"Float32",name:"offsetX"}]),Wo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Wo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const $c={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var Zc=24;const Wc=4294967296,qc=1/Wc,Kc="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Xc{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Wc;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Wc;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(15&n)<<28,function(e,t,i){const n=i.buf;let r,o;if(o=n[i.pos++],r=(112&o)>>4,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Jc(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Jc(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Kc?Kc.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,n;if(e>=0?(i=e%4294967296|0,n=e/4294967296|0):(i=~(-e%4294967296),n=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+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){const 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)))))}(n,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(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):r=n;continue}if(n<56320){e[i++]=239,e[i++]=191,e[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(e[i++]=239,e[i++]=191,e[i++]=189,r=null);n<128?e[i++]=n:(n<2048?e[i++]=n>>6|192:(n<65536?e[i++]=n>>12|224:(e[i++]=n>>18|240,e[i++]=n>>12&63|128),e[i++]=n>>6&63|128),e[i++]=63&n|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Yc(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Yc(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,eu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,tu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,ru,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,iu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,nu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,ou,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,su,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,au,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,lu,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Jc(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Yc(e,t,i){const n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(n);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function eu(e,t){for(let i=0;it.h-e.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let r=0,o=0;for(const t of e)for(let e=n.length-1;e>=0;e--){const i=n[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),r=Math.max(r,t.x+t.w),t.w===i.w&&t.h===i.h){const t=n.pop();t&&e=0&&i>=e&&yu[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 _u;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)}getMaxImageSize(e){let t=0,i=0;for(let n=0;n=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Au(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=_u.fromFeature(t,o);let _;d===e.ao.vertical&&g.verticalizePunctuation();const{processBidirectionalText:A,processStyledBidirectionalText:y}=So;if(A&&1===g.sections.length){_=[];const e=A(g.toString(),Su(g,u,s,i,r,f));for(const t of e){const e=new _u;e.text=t,e.sections=g.sections;for(let i=0;i=0;let c=0;for(let i=0;ic){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function Ou(e,t,i,n,r,o){const s=e.image;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 u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}const zu=128,Uu=32640;function Nu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Bo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;re.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Nu(this.zoom,i["text-size"]),this.iconSizeData=Nu(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==Vu(n,"text-overlap","text-allow-overlap")||"never"!==Vu(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ao[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new $u(new va(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new $u(new va(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Es,this.lineVertexArray=new Cs,this.symbolInstances=new Ts,this.textAnchorOffsets=new Bs}calculateGlyphDependencies(e,t,i,n,r){for(let o=0;o0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Bo(this.zoom,{globalState:this.globalState});for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,_=Ca(i,t);if(!r._featureFilter.filter(m,_,n))continue;let A,y;if(t||(_.geometry=Ea(i)),c){const e=r.getValueAndResolveTokens("text-field",_,n,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||Qu(t);(!i||"unavailable"===So.getRTLTextPluginStatus()||i&&So.isParsed())&&(A=Qc(t,r,_))}if(u){const e=r.getValueAndResolveTokens("icon-image",_,n,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},n):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:lc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ao.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const n=mo(A.toString()),r=e.fontStack||t,o=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,o,i,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},n=[];let r=0;function o(t){n.push(e[t]),r++}function s(e,t,r){const o=i[e];return delete i[e],i[t]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(e,i,r){const o=t[i];return delete t[i],t[e]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(e,t,i){const n=i?t[0][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i))}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.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e0}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}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let qu,Ku;so("SymbolBucket",Wu,{omit:["layers","collisionBoxArray","features","compareText"]}),Wu.MAX_GLYPHS=65535,Wu.addDynamicAttributes=Hu;var Xu={get paint(){return Ku=Ku||new jo({"icon-opacity":new zo(Ae.paint_symbol["icon-opacity"]),"icon-color":new zo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new zo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new zo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new zo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Oo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Oo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new zo(Ae.paint_symbol["text-opacity"]),"text-color":new zo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new zo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new zo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new zo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Oo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Oo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return qu=qu||new jo({"symbol-placement":new Oo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Oo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Oo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new zo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Oo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Oo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Oo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Oo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Oo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Oo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new zo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Oo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Oo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new zo(Ae.layout_symbol["icon-image"]),"icon-rotate":new zo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new zo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Oo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new zo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new zo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Oo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Oo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Oo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new zo(Ae.layout_symbol["text-field"]),"text-font":new zo(Ae.layout_symbol["text-font"]),"text-size":new zo(Ae.layout_symbol["text-size"]),"text-max-width":new zo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Oo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new zo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new zo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new zo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Oo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new zo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new zo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Oo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Oo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new zo(Ae.layout_symbol["text-rotate"]),"text-padding":new Oo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Oo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new zo(Ae.layout_symbol["text-transform"]),"text-offset":new zo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Oo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Oo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Oo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Oo(Ae.layout_symbol["text-optional"])})}};class Ju{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}so("FormatSectionOverride",Ju,{omit:["defaultValue"]});class Yu extends Ho{constructor(e){super(e,Xu)}recalculate(e,t){if(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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||tr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new Wu(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Xu.paint.overridableProperties){if(!Yu.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new Ju(t),n=new er(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new nr("source",n):new rr("composite",n,t.value.zoomStops),this.paint._values[e]=new ko(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&Yu.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=Xu.paint.properties[t];let r=!1;const o=e=>{for(const t of e)if(n.overrides&&n.overrides.hasOverride(t))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Mt)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let eh;var th={get paint(){return eh=eh||new jo({"background-color":new Oo(Ae.paint_background["background-color"]),"background-pattern":new No(Ae.paint_background["background-pattern"]),"background-opacity":new Oo(Ae.paint_background["background-opacity"])})}};class ih extends Ho{constructor(e){super(e,th)}}let nh;var rh={get paint(){return nh=nh||new jo({"raster-opacity":new Oo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Oo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Oo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Oo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Oo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Oo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Oo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Oo(Ae.paint_raster["raster-fade-duration"])})}};class oh extends Ho{constructor(e){super(e,rh)}}class sh extends Ho{constructor(e){super(e,{}),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class ah{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const lh={once:!0},ch=6371008.8;class uh{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 uh(O(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,n=e.lat*t,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((e.lng-this.lng)*t);return ch*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof uh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new uh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new uh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const hh=2*Math.PI*ch;function dh(e){return hh*Math.cos(e*Math.PI/180)}function ph(e){return(180+e)/360}function fh(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function mh(e,t){return e/dh(t)}function gh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function _h(e,t){return e*dh(gh(t))}class Ah{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=uh.convert(e);return new Ah(ph(i.lng),fh(i.lat),mh(t,i.lat))}toLngLat(){return new uh(360*this.x-180,gh(this.y))}toAltitude(){return _h(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/hh*(e=gh(this.y),1/Math.cos(e*Math.PI/180));var e}}function yh(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class vh{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=wh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=yh(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=yh(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class xh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=wh(e,t.z,t.z,t.x,t.y)}}class bh{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new vh(i,+n,+r),this.key=wh(t,e,i,n,r)}clone(){return new bh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new bh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?wh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):wh(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>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new bh(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,n=2*this.canonical.y;return[new bh(t,this.wrap,t,i,n),new bh(t,this.wrap,t,i+1,n),new bh(t,this.wrap,t,i,n+1),new bh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Eh;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Eh;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}class Ch{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Sh{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=n,this.properties=e.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Bh{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new ro(I,16,0),this.grid3D=new ro(I,16,0),this.featureIndexArray=new Ms,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new pc(new Xc(this.rawTileData)).layers,this.sourceLayerCoder=new Ch(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=hr(o.filter),l=e.queryGeometry,c=e.queryPadding*s,u=Eh.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Eh.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(Ua(e,t))return!0;for(let t=0;t(d||(d=Ea(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=Ca(p,!0);if(!r.filter(new Bo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new Bo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof Do?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s})}function Mh(e,t){return t-e}function Ph(e,t,n,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}so("FeatureIndex",Bh,{omit:["rawTileData","sourceLayerCoder"]});class Rh extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new Rh(this.x,this.y,this.angle,this.segment)}}function Lh(e,t,i,n,r){if(void 0===t.segment||0===i)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(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Fh(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(n.x,r.x,u),d=fi.number(n.y,r.y,u),p=new Rh(h,d,r.angleTo(n),i);return p._round(),!s||Lh(e,p,a,s,t)?p:void 0}l+=o}}function zh(e,t,i,n,r,o,s,a,l){const c=kh(n,o,s),u=Dh(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Rh(_,A,m,t);i._round(),n&&!Lh(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=Uh(e,h/2,i,n,r,o,s,!0,l)),p}function Nh(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=Du(e)),A=Vh(h,0,t[0]),v=Vh(d,0,t[1]),y=Vh(h,t[0],t[2]),x=Vh(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=n-x}const C=u.x1,S=u.y1,B=u.x2-C,I=u.y2-S,M=(e,r,o,l)=>{const c=Gh(e.stretch-A,y,B,C),u=Hh(e.fixed-b,w,e.stretch,f),h=Gh(r.stretch-v,x,I,S),d=Hh(r.fixed-T,E,r.stretch,m),p=Gh(o.stretch-A,y,B,C),g=Hh(o.fixed-b,w,o.stretch,f),_=Gh(l.stretch-v,x,I,S),M=Hh(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=r.stretch+r.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/B,minFontScaleY:E/a/I,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=jh(h,g,f),t=jh(d,_,m);for(let i=0;i0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?Du(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class $h{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function Zh(e,t=1,n=!1){const r=Eh.fromPoints(e[0]),o=Math.min(r.width(),r.height());let s=o/2;const a=new $h([],Wh),{minX:l,minY:c,maxX:u,maxY:h}=r;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,n&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new qh(i.p.x-s,i.p.y-s,s,e)),a.push(new qh(i.p.x+s,i.p.y-s,s,e)),a.push(new qh(i.p.x-s,i.p.y+s,s,e)),a.push(new qh(i.p.x+s,i.p.y+s,s,e)),p+=4)}return n&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Wh(e,t){return t.max-e.max}function qh(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Oa(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Kh;e.aE=void 0,(Kh=e.aE||(e.aE={}))[Kh.center=1]="center",Kh[Kh.left=2]="left",Kh[Kh.right=3]="right",Kh[Kh.top=4]="top",Kh[Kh.bottom=5]="bottom",Kh[Kh["top-left"]=6]="top-left",Kh[Kh["top-right"]=7]="top-right",Kh[Kh["bottom-left"]=8]="bottom-left",Kh[Kh["bottom-right"]=9]="bottom-right";const Xh=Number.POSITIVE_INFINITY;function Jh(e,t){return t[1]!==Xh?function(e,t,i){let n=0,r=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":r=i-7;break;case"bottom-right":case"bottom-left":case"bottom":r=7-i}switch(e){case"top-right":case"bottom-right":case"right":n=-t;break;case"top-left":case"bottom-left":case"left":n=t}return[n,r]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Yh(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*Zc);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Dt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*Zc,Xh]:r.get("text-offset").evaluate(t,{},i).map(e=>e*Zc);const o=[];for(const e of s)o.push(e,Jh(e,n));return new Dt(o)}return null}function ed(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 td(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=nd(n.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=r&&r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),S=f.get("symbol-placement"),B=x/2,M=f.get("icon-text-fit");let P;r&&"none"!==M&&(t.allowVerticalPlacement&&n.vertical&&(P=Ou(r,n.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(r=Ou(r,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,n);let S,B,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=na("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new Qh(c,i,u,h,d,r.vertical,p,f,m,e),a&&(M=new Qh(c,i,u,h,d,a,_,A,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{}),r="none"!==l.layout.get("icon-text-fit"),s=Nh(o,n,w,r),p=a?Nh(a,n,w,r):void 0;B=new Qh(c,i,u,h,d,o,_,A,!1,n),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[zu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Uu&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[zu*b.compositeIconSizes[0].evaluate(x,{},T),zu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Uu||m[1]>Uu)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ao.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ao.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(r.horizontal);for(const n of U){const o=r.horizontal[n];if(!S){z=na(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);S=new Qh(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=id(t,i,o,s,l,m,x,g,C,r.vertical?e.ao.horizontal:e.ao.horizontalOnly,a?U:[n],O,k,b,T),a)break}r.vertical&&(F+=id(t,i,r.vertical,s,l,m,x,g,C,e.ao.vertical,["vertical"],O,D,b,T));const N=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=B?B.boxStartIndex:t.collisionBoxArray.length,$=B?B.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(S,q),q=K(I,q),q=K(B,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/Zc),t.glyphOffsetArray.length>=Wu.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Yh(l,x,T),[Y,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,n,r,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===S)for(const e of Ph(i.geometry,0,0,I,I)){const i=Kl(e,R),o=zh(i,x,T,n.vertical||g,r,24,y,t.overscaling,I);for(const e of o)g&&rd(t,g.text,B,e)||L(i,e)}else if("line-center"===S){for(const e of i.geometry)if(e.length>1){const t=Kl(e,R),i=Oh(t,T,n.vertical||g,r,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Zh(e,16);L(Kl(e[0],R,!0),new Rh(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=Kl(e,R);L(t,new Rh(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Rh(t.x,t.y,0))}function id(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(Zc-r.metrics.width*r.scale)/2:(r.scale-1)*Zc)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[r.x+g,r.y]:[0,0];let A=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=r.metrics.isDoubleResolution?2:1,x=(r.metrics.left-h)*r.scale-g+A[0],b=(-r.metrics.top-h)*r.scale+A[1],w=x+s.w/v*r.scale/p,T=b+s.h/v*r.scale/p,E=new i(x,b),C=new i(w,b),S=new i(x,T),B=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),S._matMult(i),B._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:S,br:B,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[zu*o.layout.get("text-size").evaluate(a,{})],A[0]>Uu&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[zu*f.compositeTextSizes[0].evaluate(a,{},m),zu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Uu||A[1]>Uu)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function nd(e){for(const t in e)return e[t];return null}function rd(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=od[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new sd(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){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 r=od.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,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+r]),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 ad(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),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:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)hd(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];hd(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function ad(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;ld(e,t,s,n,r,o),ad(e,t,i,n,s-1,1-o),ad(e,t,i,s+1,r,1-o)}function ld(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);ld(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(cd(e,t,n,i),t[2*r+o]>s&&cd(e,t,n,r);as;)l--}t[2*n+o]===s?cd(e,t,n,l):(l++,cd(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function cd(e,t,i,n){ud(e,i,n),ud(t,2*i,2*n),ud(t,2*i+1,2*n+1)}function ud(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function hd(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}var dd;e.cx=void 0,(dd=e.cx||(e.cx={})).create="create",dd.load="load",dd.fullLoad="fullLoad";let pd=null,fd=[];const md=1e3/60,gd="loadTime",_d="fullLoadTime",Ad={mark(e){performance.mark(e)},frame(e){const t=e;null!=pd&&fd.push(t-pd),pd=t},clearMetrics(){pd=null,fd=[],performance.clearMeasures(gd),performance.clearMeasures(_d);for(const t in e.cx)performance.clearMarks(e.cx[t])},getPerformanceMetrics(){performance.measure(gd,e.cx.create,e.cx.load),performance.measure(_d,e.cx.create,e.cx.fullLoad);const t=performance.getEntriesByName(gd)[0].duration,i=performance.getEntriesByName(_d)[0].duration,n=fd.length,r=1/(fd.reduce((e,t)=>e+t,0)/n/1e3),o=fd.filter(e=>e>md).reduce((e,t)=>e+(t-md)/md,0);return{loadTime:t,fullLoadTime:i,fps:r,percentDroppedFrames:o/(n+o)*100,totalFrames:n}}};e.$=I,e.A=p,e.B=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.C=fi,e.D=Oo,e.E=_e,e.F=Bo,e.G=eo,e.H=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.I=pu,e.J=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new ah(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},lh):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:uo(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(ho(i.error)):t.resolve(ho(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=ho(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?uo(t):null,data:uo(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.K=le,e.L=function(){var e=new p(16);return p!=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},e.M=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.N=function(e,t,i){var n=i[0],r=i[1],o=i[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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},e.O=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.P=i,e.Q=function(e,t){const i={};for(let n=0;n[e.id,e]));s.add=Array.from(i.values())}if(t.update){const e=new Map(null===(i=s.update)||void 0===i?void 0:i.map(e=>[e.id,e]));for(const i of t.update){const t=null!==(n=e.get(i.id))&&void 0!==n?n:{id:i.id};i.newGeometry&&(t.newGeometry=i.newGeometry),i.addOrUpdateProperties&&(t.addOrUpdateProperties=(null!==(r=t.addOrUpdateProperties)&&void 0!==r?r:[]).concat(i.addOrUpdateProperties)),i.removeProperties&&(t.removeProperties=(null!==(o=t.removeProperties)&&void 0!==o?o:[]).concat(i.removeProperties)),i.removeAllProperties&&(t.removeAllProperties=!0),e.set(i.id,t)}s.update=Array.from(e.values())}return s},e.a1=Ah,e.a2=Eh,e.a3=25,e.a4=vh,e.a5=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.a6=Me,e.a7=function(){return U++},e.a8=vs,e.a9=Wu,e.aA=function(e){let t=1/0,i=1/0,n=-1/0,r=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),n=Math.max(n,o.x),r=Math.max(r,o.y);return[t,i,n,r]},e.aB=Zc,e.aC=M,e.aD=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians: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]}return[r?i[0]:M(t,i[0],e.zoom),r?i[1]:M(t,i[1],e.zoom)]},e.aF=Vu,e.aG=ed,e.aH=Bu,e.aI=sd,e.aJ=Wo,e.aK=Ql,e.aL=Ps,e.aM=Zs,e.aN=Gs,e.aO=O,e.aP=te,e.aQ=_h,e.aR=v,e.aS=y,e.aT=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.aU=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.aV=function(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.aW=x,e.aX=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.aY=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},e.aZ=_,e.a_=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.aa=hr,e.ab=Ca,e.ac=Sh,e.ad=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,n,r)=>{const o=n||r;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},e.ae=ee,e.af=function(e){return Math.pow(2,e)},e.ag=m,e.ah=D,e.ai=85.051129,e.aj=mh,e.ak=function(e){return Math.log(e)/Math.LN2},e.al=function(e){var t=e[0],i=e[1];return t*t+i*i},e.am=function(e,t){const i=[];for(const n in e)n in t||i.push(n);return i},e.an=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?D(di.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.ap=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/zu:"composite"===e.kind?fi.number(n/zu,r/zu,i):t},e.aq=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.ar=S,e.as=function(e){return Math.hypot(e[0],e[1])},e.at=function(e){return e[0]=0,e[1]=0,e},e.au=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.av=Hu,e.aw=T,e.ax=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.ay=Ph,e.az=Ma,e.b=W,e.b$=class extends ls{},e.b0=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},e.b1=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]},e.b2=xh,e.b3=wh,e.b4=function(e,t,i,n,r){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!=r&&r!==1/0?(e[10]=(r+n)*(o=1/(n-r)),e[14]=2*r*n*o):(e[10]=-1,e[14]=-2*n),e},e.b5=function(e){var t=new p(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},e.b6=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e},e.b7=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e},e.b8=function(){const e=new Float32Array(16);return m(e),e},e.b9=function(){const e=new Float64Array(16);return m(e),e},e.bA=function(e,t){const i=P(e,360),n=P(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)0?s:-s},e.bD=function(e,t){const i=P(e,2*Math.PI),n=P(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bE=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const n=Ae.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bF=po,e.bG=ue,e.bH=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Be),r=t.map(Be),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bd=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),_=(a=n[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.be=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bf=Ct,e.bg=ca,e.bh=$l,e.bi=Zl,e.bj=Hl,e.bk=R,e.bl=L,e.bm=zt,e.bn=function(e,t,i,n,r){return R(n,r,D((e-t)/(i-t),0,1))},e.bo=P,e.bp=function(){return new Float64Array(3)},e.bq=function(e,t,i,n){return e[0]=t[0]+i[0]*n,e[1]=t[1]+i[1]*n,e[2]=t[2]+i[2]*n,e},e.br=C,e.bs=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=t[0],a=t[1],l=t[2],c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,d=r*h-o*u,p=o*c-n*h,f=n*u-r*c,m=2*i[3];return u*=m,h*=m,p*=2,f*=2,e[0]=s+(c*=m)+(d*=2),e[1]=a+u+p,e[2]=l+h+f,e},e.bt=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/n),f},e.bu=ch,e.bv=function(){return new Float64Array(4)},e.bw=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bx=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.by=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bz=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.c=oe,e.c0=Hc,e.c1=class extends us{},e.c2=rl,e.c3=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.c4=nl,e.c5=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return e[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.c6=class extends Jo{},e.c7=class extends _s{},e.c8=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.c9=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],S=t[8],B=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=d*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-S)<=d*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-B)<=d*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.cA=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cB=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cC=function(e,t){const i={};for(let n=0;ne*Zc)}let y=a?"center":n.get("text-justify").evaluate(r,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(r,{},t.canonical)*Zc:1/0,x=()=>{t.bucket.allowVerticalPlacement&&mo(o)&&(f.vertical=Au(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ao.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0);if((i.newGeometry||i.removeAllProperties||a)&&(t=Object.assign({},t),e.set(i.id,t),a&&(t.properties=Object.assign({},t.properties))),i.newGeometry&&(t.geometry=i.newGeometry),i.removeAllProperties)t.properties={};else if((null===(o=i.removeProperties)||void 0===o?void 0:o.length)>0)for(const e of i.removeProperties)Object.prototype.hasOwnProperty.call(t.properties,e)&&delete t.properties[e];if((null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0)for(const{key:e,value:n}of i.addOrUpdateProperties)t.properties[e]=n}},e.cX=So,e.ca=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},e.cb=e=>"symbol"===e.type,e.cc=e=>"circle"===e.type,e.cd=e=>"heatmap"===e.type,e.ce=e=>"line"===e.type,e.cf=e=>"fill"===e.type,e.cg=e=>"fill-extrusion"===e.type,e.ch=e=>"hillshade"===e.type,e.ci=e=>"color-relief"===e.type,e.cj=e=>"raster"===e.type,e.ck=e=>"background"===e.type,e.cl=e=>"custom"===e.type,e.cm=F,e.cn=function(e,t,i){const n=B(t.x-i.x,t.y-i.y),r=B(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.co=k,e.cp=function(e,t){return ne[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cq=function(e,t){return ie[t]&&"touches"in e},e.cr=function(e){return ie[e]||ne[e]},e.cs=function(e,t,i){var n=t[0],r=t[1];return e[0]=i[0]*n+i[4]*r+i[12],e[1]=i[1]*n+i[5]*r+i[13],e},e.ct=function(e,t){const{x:i,y:n}=Ah.fromLngLat(t);return!(e<0||e>25||n<0||n>=1||i<0||i>=1)},e.cu=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},e.cv=class extends Xo{},e.cw=Ad,e.cy=function(e){return e.message===re},e.cz=ce,e.d=de,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>{n.src=q})},n.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 r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new Xc(e).readFields(cu,[])},e.p=du,e.q=tl,e.r=jo,e.s=Y,e.t=Po,e.u=fo,e.v=Ae,e.w=H,e.x=Yr,e.y=no,e.z=Jr}),i("worker",["./shared"],function(e){class t{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,i){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bJ(i);t._featureFilter=e.aa(t.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=e.cC(Object.values(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map(e=>this._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.q({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.q.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cD("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.Z(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[],this.globalState=t.globalState}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.a8;const l=new e.cE(Object.keys(t.layers).sort()),c=new e.cF(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;e=i.maxzoom||"none"!==i.visibility&&(r(t,this.zoom,o),(u[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:t,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:s,sourceID:this.source,globalState:this.globalState})).populate(a,h,this.tileID.canonical),c.bucketLayerIDs.push(t.map(e=>e.id)))}}const p=e.bN(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const[y,v,x]=yield Promise.all([f,g,A]),b=new i(y),w=new e.cG(v,x);for(const t in u){const i=u[t];i instanceof e.a9?(r(i.layers,this.zoom,o),e.cH({bucket:i,glyphMap:y,glyphPositions:b.positions,imageMap:v,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasPattern&&(i instanceof e.cI||i instanceof e.cJ||i instanceof e.cK)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?y:null,iconMap:this.returnDependencies?v:null,glyphPositions:this.returnDependencies?b.positions:null}})}}function r(t,i,n){const r=new e.F(i);for(const e of t)e.recalculate(r,n)}class o{constructor(e,t,i){this.actor=e,this.layerIndex=t,this.availableImages=i,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(t,i){return e._(this,void 0,void 0,function*(){const n=yield e.n(t.request,i);try{return{vectorTile:new e.cL(new e.cM(n.data)),rawData:n.data,cacheControl:n.cacheControl,expires:n.expires}}catch(e){const i=new Uint8Array(n.data);let r=`Unable to parse the tile at ${t.request.url}, `;throw r+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${e.message}`,new Error(r)}})}loadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid,r=!!(t&&t.request&&t.request.collectResourceTiming)&&new e.cN(t.request),o=new n(t);this.loading[i]=o;const s=new AbortController;o.abort=s;try{const n=yield this.loadVectorTile(t,s);if(delete this.loading[i],!n)return null;const a=n.rawData,l={};n.expires&&(l.expires=n.expires),n.cacheControl&&(l.cacheControl=n.cacheControl);const c={};if(r){const e=r.finish();e&&(c.resourceTiming=JSON.parse(JSON.stringify(e)))}o.vectorTile=n.vectorTile;const u=o.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);this.loaded[i]=o,this.fetching[i]={rawTileData:a,cacheControl:l,resourceTiming:c};try{const t=yield u;return e.e({rawTileData:a.slice(0)},t,l,c)}finally{delete this.fetching[i]}}catch(e){throw delete this.loading[i],o.status="done",this.loaded[i]=o,e}})}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[i];if(n.showCollisionBoxes=t.showCollisionBoxes,n.globalState=t.globalState,"parsing"===n.status){const r=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:t,cacheControl:n,resourceTiming:s}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:t.slice(0)},r,n,s)}else o=r;return o}if("done"===n.status&&n.vectorTile)return n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class s{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.cO(r,-1,-1,c,u)):r,d=new e.cP(i,h,n,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var a,l,c=function(){if(l)return a;function e(e,i){if(0!==e.length){t(e[0],i);for(var n=1;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}return l=1,a=function t(i,n){var r,o=i&&i.type;if("FeatureCollection"===o)for(r=0;r>31}function A(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(g(1,i));const a=3===n?s.length-1:s.length;for(let e=0;ee},x=Math.fround||(b=new Float32Array(1),e=>(b[0]=+e,b[0]));var b;class w{constructor(e){this.options=Object.assign(Object.create(v),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(C(i),S(o),C(r),S(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?T(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?T(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=E(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=C(n),u=S(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.features.push(h)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function T(e,t,i){return{type:"Feature",id:e[t+3],properties:E(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),B(e[t+1])]}};var n}function E(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function C(e){return e/360+.5}function S(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function B(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function I(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&I(e,t,s,n),e[s+2]=r,i-s>3&&I(e,s,i,n))}function M(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function P(e,t,i,n){const r={id:null==e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)R(r,i);else if("Polygon"===t)R(r,i[0]);else if("MultiLineString"===t)for(const e of i)R(r,e);else if("MultiPolygon"===t)for(const e of i)R(r,e[0]);return r}function R(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,I(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function D(e,t,i,n){for(let r=0;r1?1:i}function U(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)N(e,u,i,n,r);else if("LineString"===o)V(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)G(e,u,i,n,r,!1);else if("Polygon"===o)G(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];G(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(P(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(P(t.id,o,u,t.tags))}}return l.length?l:null}function N(e,t,i,n,r){for(let o=0;o=i&&s<=n&&H(t,e[o],e[o+1],e[o+2])}}function V(e,t,i,n,r,o,s){let a=j(e);const l=0===r?Q:$;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=j(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&H(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&H(a,a[0],a[1],a[2]),a.length&&t.push(a)}function j(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function G(e,t,i,n,r,o){for(const s of e)V(s,t,i,n,r,o,!1)}function H(e,t,i,n){e.push(t,i,n)}function Q(e,t,i,n,r,o){const s=(o-t)/(n-t);return H(e,o,i+(r-i)*s,1),s}function $(e,t,i,n,r,o){const s=(o-i)/(r-i);return H(e,t+(n-t)*s,o,1),s}function Z(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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.");let n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=X(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));const e=`z${t}`;this.stats[e]=(this.stats[e]||0)+1,this.total++}if(d.source=e,null==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=U(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=U(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=U(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=U(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=U(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=U(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ie(c,u,h)];return l&&l.source?(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,h),console.time("drilling down")),this.splitTile(l.source,c,u,h,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?q(this.tiles[a],r):null):null}}function ie(e,t,i){return 32*((1<{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(t)).load(i.features):function(e,t){return new te(e,t)}(i,t.geojsonVtOptions),this.loaded={};const r={data:i};if(n){const e=n.finish();e&&(r.resourceTiming={},r.resourceTiming[t.source]=JSON.parse(JSON.stringify(e)))}return r}catch(t){if(delete this._pendingRequest,e.cy(t))return{abandoned:!0};throw t}})}getData(){return e._(this,void 0,void 0,function*(){return this._pendingData})}reloadTile(e){const t=this.loaded;return t&&t[e.uid]?super.reloadTile(e):this.loadTile(e)}loadAndProcessGeoJSON(t,i){return e._(this,void 0,void 0,function*(){let n=yield this.loadGeoJSON(t,i);if(delete this._pendingRequest,"object"!=typeof n)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(u(n,!0),t.filter){const i=e.cT(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=n.features.filter(e=>i.value.evaluate({zoom:0},e));n={type:"FeatureCollection",features:r}}return n})}loadGeoJSON(t,i){return e._(this,void 0,void 0,function*(){const{promoteId:n}=t;if(t.request){const r=yield e.j(t.request,i);return this._dataUpdateable=e.cV(r.data,n)?e.cU(r.data,n):void 0,r.data}if("string"==typeof t.data)try{const i=JSON.parse(t.data);return this._dataUpdateable=e.cV(i,n)?e.cU(i,n):void 0,i}catch(e){throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`)}if(!t.dataDiff)throw new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${t.source}`);return e.cW(this._dataUpdateable,t.dataDiff,n),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(e){return this._geoJSONIndex.getClusterExpansionZoom(e.clusterId)}getClusterChildren(e){return this._geoJSONIndex.getChildren(e.clusterId)}getClusterLeaves(e){return this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset)}}class re{constructor(t){this.self=t,this.actor=new e.J(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cA,this.self.removeProtocol=e.cB,this.self.registerRTLTextPlugin=t=>{e.cX.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t]})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds)})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i)}))}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.cX.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new o(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new ne(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new s),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new re(self)),re}),i("index",["exports","./shared"],function(e,t){var i="5.6.2";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o;const s={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frame(e,i,n){const r=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(r),n(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)}};class a{static testProp(e){if(!a.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",a.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=a.getScale(e);return a.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=a.getScale(e);for(let r=0;r{c&&p(c),c=null,d=!0},u.onerror=()=>{h=!0,c=null},u.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{l.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:l}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?c(i,l):t.m(i,l);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},c=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(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."))},o.src=s})}(f||(f={})),f.resetRequestQueue();class m{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function g(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:n,url:r}))}}return t}function _(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function A(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,r&&r.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,r&&r.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const n of e){let e=this.getImage(n);e||(this.fire(new t.l("styleimagemissing",{id:n})),e=this.getImage(n)),e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${n}" 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.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),A(e)&&this.updateImage(i,e)}}}const v=1e20;function x(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=v}for(let a=0,l=0;a65535)throw new Error("glyphs > 65535 not supported");if(t.ranges[r])return{stack:e,id:i,glyph:n};if(!this.url)throw new Error("glyphsUrl is not set");if(!t.requests[r]){const i=w.loadGlyphRange(e,r,this.url,this.requestManager);t.requests[r]=i}const o=yield t.requests[r];for(const e in o)this._doesCharSupportLocalGlyph(+e)||(t.glyphs[+e]=o[+e]);return t.ranges[r]=!0,{stack:e,id:i,glyph:o[i]||null}})}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(/\p{Ideo}|\p{sc=Hang}|\p{sc=Hira}|\p{sc=Kana}/u.test(String.fromCodePoint(e))||t.u["CJK Unified Ideographs"](e)||t.u["Hangul Syllables"](e)||t.u.Hiragana(e)||t.u.Katakana(e)||t.u["CJK Symbols and Punctuation"](e)||t.u["Halfwidth and Fullwidth Forms"](e))}_tinySDF(e,i,n){const r=this.localIdeographFontFamily;if(!r)return;if(!this._doesCharSupportLocalGlyph(n))return;let o=e.tinySDF;if(!o){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),o=e.tinySDF=new w.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:r,fontWeight:t})}const s=o.draw(String.fromCharCode(n));return{id:n,bitmap:new t.q({width:s.width||60,height:s.height||60},s.data),metrics:{width:s.glyphWidth/2||24,height:s.glyphHeight/2||24,left:s.glyphLeft/2+.5||0,top:s.glyphTop/2-27.5||-8,advance:s.glyphAdvance/2||24,isDoubleResolution:!0}}}}w.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},w.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(v,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}x(_,0,0,c,u,c,this.f,this.v,this.z),x(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],n=e[t+1];i.zeroLength?e.splice(t,1):n&&n.isDash===i.isDash&&(n.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[M]}numActive(){return Object.keys(this.active).length}}const R=Math.floor(s.hardwareConcurrency/2);let L,F;function k(){return L||(L=new P),L}P.workerCount=t.H(globalThis)?Math.max(Math.min(R,3),1):1;class D{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}}function O(){return F||(F=new D(k(),t.K),F.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),F}function z(e,i){const n=t.L();return t.M(n,n,[1,1,0]),t.N(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.O(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function U(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(N);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e._state,n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,z(e.transform,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])V(n,t);return e}(function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function N(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function V(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function j(e,i,n){return t._(this,void 0,void 0,function*(){let r=e;if(e.url?r=(yield t.j(i.transformRequest(e.url,"Source"),n)).data:yield s.frameAsync(n),!r)return null;const o=t.Q(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map(e=>e.id)),o})}class G{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):Array.isArray(e)&&(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 t.S?new t.S(e.lng,e.lat):t.S.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.S?new t.S(e.lng,e.lat):t.S.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.S)r=e,o=e;else{if(!(e instanceof G))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(G.convert(e)):this.extend(t.S.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.S.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.S(r.lng,r.lat),this._ne=new t.S(o.lng,o.lat)),this}getCenter(){return new t.S((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 t.S(this.getWest(),this.getNorth())}getSouthEast(){return new t.S(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:i,lat:n}=t.S.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return e instanceof G?e:e?new G(e):e}static fromLngLat(e,i=0){const n=360*i/40075017,r=n/Math.cos(Math.PI/180*e.lat);return new G(new t.S(e.lng-r,e.lat-n),new t.S(e.lng+r,e.lat+n))}adjustAntiMeridian(){const e=new t.S(this._sw.lng,this._sw.lat),i=new t.S(this._ne.lng,this._ne.lat);return new G(e,e.lng>i.lng?new t.S(i.lng+360,i.lat):i)}}class H{constructor(e,t,i){this.bounds=G.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 i=Math.pow(2,e.z),n=Math.floor(t.V(this.bounds.getWest())*i),r=Math.floor(t.U(this.bounds.getNorth())*i),o=Math.ceil(t.V(this.bounds.getEast())*i),s=Math.ceil(t.U(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class $ extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,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=t.e({type:"raster"},i),t.e(this,t.Q(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield j(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new H(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield f.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class Z extends ${constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield f.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.W()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.X()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.Y(e,-1,-1,i,n))}catch(e){}}return s.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.Z(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.Z(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.Z(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.Z(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.Z(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}getBounds(){return t._(this,void 0,void 0,function*(){const e=new G,t=yield this.getData();let i;switch(t.type){case"FeatureCollection":i=t.features.map(e=>this.getCoordinatesFromGeometry(e.geometry)).flat(1/0);break;case"Feature":i=this.getCoordinatesFromGeometry(t.geometry);break;default:i=this.getCoordinatesFromGeometry(t)}if(0==i.length)return e;for(let t=0;t0&&t.e(r,{resourceTiming:i}),this.fire(new t.l("data",Object.assign(Object.assign({},r),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},r),{sourceDataType:"content"})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{(this._pendingWorkerUpdate.data||this._pendingWorkerUpdate.diff)&&this._updateWorkerData()}})}loaded(){return!this._isUpdatingWorker&&void 0===this._pendingWorkerUpdate.data&&void 0===this._pendingWorkerUpdate.diff}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.actor?"RT":"LT";e.actor=this.actor;const i={type:this.type,uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,globalState:this.map.getGlobalState()};e.abortController=new AbortController;const n=yield this.actor.sendAsync({type:t,data:i},e.abortController);delete e.abortController,e.unloadVectorData(),e.aborted||e.loadVectorData(n,this.map.painter,"RT"===t)})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.aborted=!0})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return t.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}class q extends t.E{constructor(e,t,i,n){super(),this.flippedWindingOrder=!1,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.setEventedParent(n),this.options=t}load(e){return t._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const t=yield f.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,t&&t.data&&(this.image=t.data,e&&(this.coordinates=e),this._finishLoading())}catch(e){this._request=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}updateImage(e){return e.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=e.url,this.load(e.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.a1.fromLngLat);var n;return this.tileID=function(e){const i=t.a2.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.a4(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.a2.fromPoints(e),s={};for(let e=0;e<=t.a3;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class K extends q{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.a5(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.a6(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.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,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class X extends q{constructor(e,i,n,r){super(e,i,n,r),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 t.k(new t.a6(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.a6(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.a6(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.a6(`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 t.k(new t.a6(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(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 i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0});let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}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}}const J={},Y=e=>{switch(e){case"geojson":return W;case"image":return q;case"raster":return $;case"raster-dem":return Z;case"vector":return Q;case"video":return K;case"canvas":return X}return J[e]},ee="RTLPluginLoaded";class te extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=O()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=s.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(ee))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let ie=null;function ne(){return ie||(ie=new te),ie}class re{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=e,this.uid=t.a7(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a9){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.a9&&i.hasRTLText){this.hasRTLText=!0,ne().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new t.a8}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=r._geojsonTileLayer||r[o];if(!s)return;const a=t.aa(i&&i.filter),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class se{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,n){const r=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},t.e(this.stateChanges[e][r],n),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])n[t]||(this.deletedStates[e][r][t]=null)}else for(const t in n)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 n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,i){const n=String(i),r=t.e({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete r[e]}return r}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,i){const n={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const i={};for(const n in this.stateChanges[e])this.state[e][n]||(this.state[e][n]={}),t.e(this.state[e][n],this.stateChanges[e][n]),i[n]=this.state[e][n];n[e]=i}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const i={};if(null===this.deletedStates[e])for(const t in this.state[e])i[t]={},this.state[e][t]={};else for(const t in this.deletedStates[e]){if(null===this.deletedStates[e][t])this.state[e][t]={};else for(const i of Object.keys(this.deletedStates[e][t]))delete this.state[e][t][i];i[t]=this.state[e][t]}n[e]=n[e]||{},t.e(n[e],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(n).length)for(const t in e)e[t].setFeatureState(n,i)}}const ae=89.25;function le(e,i){const n=t.ah(i.lat,-t.ai,t.ai);return new t.P(t.V(i.lng)*e,t.U(n)*e)}function ce(e,i){return new t.a1(i.x/e,i.y/e).toLngLat()}function ue(e){return e.cameraToCenterDistance*Math.min(.85*Math.tan(t.ae(90-e.pitch)),Math.tan(t.ae(ae-e.pitch)))}function he(e,i){const n=e.canonical,r=i/t.af(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,s=t.ag(new Float64Array(16));return t.M(s,s,[o*r,n.y*r,0]),t.N(s,s,[r/t.$,r/t.$,1]),s}function de(e,i,n,r,o){const s=t.a1.fromLngLat(e,i),a=o*t.aj(1,e.lat),l=a*Math.cos(t.ae(n)),c=Math.sqrt(a*a-l*l),u=c*Math.sin(t.ae(-r)),h=c*Math.cos(t.ae(-r));return new t.a1(s.x+u,s.y+h,s.z+l)}function pe(e,t,i){const n=t.intersectsFrustum(e);if(!i||0===n)return n;const r=t.intersectsPlane(i);return 0===r?0:2===n&&2===r?2:1}function fe(e,t,i){let n=0;const r=(i-t)/10;for(let o=0;o<10;o++)n+=r*Math.pow(Math.cos(t+(o+.5)/10*(i-t)),e);return n}function me(e,i){return function(n,r,o,s,a){const l=2*((e-1)/t.ak(Math.cos(t.ae(ae-a))/Math.cos(t.ae(ae)))-1),c=Math.acos(o/s),u=2*fe(l-1,0,t.ae(a/2)),h=Math.min(t.ae(ae),c+t.ae(a/2)),d=fe(l-1,Math.min(h,c-t.ae(a/2)),h),p=Math.atan(r/o),f=Math.hypot(r,o);let m=n;return m+=t.ak(s/f/Math.max(.5,Math.cos(t.ae(a/2)))),m+=l*t.ak(Math.cos(p))/2,m-=t.ak(Math.max(1,d/u/i))/2,m}}const ge=me(9.314,3);function _e(e,i){const n=(i.roundZoom?Math.round:Math.floor)(e.zoom+t.ak(e.tileSize/i.tileSize));return Math.max(0,n)}function Ae(e,i){const n=e.getCameraFrustum(),r=e.getClippingPlane(),o=e.screenPointToMercatorCoordinate(e.getCameraPoint()),s=t.a1.fromLngLat(e.center,e.elevation);o.z=s.z+Math.cos(e.pitchInRadians)*e.cameraToCenterDistance/e.worldSize;const a=e.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(e,i),c=_e(e,i),u=i.minzoom||0,h=void 0!==i.maxzoom?i.maxzoom:e.maxZoom,d=Math.min(Math.max(0,c),h),p=Math.pow(2,d),f=[p*o.x,p*o.y,0],m=[p*s.x,p*s.y,0],g=Math.hypot(s.x-o.x,s.y-o.y),_=Math.abs(s.z-o.z),A=Math.hypot(g,_),y=e=>({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=pe(n,T,r);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||ge)(e.zoom+t.ak(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const S=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=S){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const ye=t.a2.fromPoints([new t.P(0,0),new t.P(t.$,t.$)]);class ve extends t.E{constructor(e,t,i){super(),this.id=e,this.dispatcher=i,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(Y(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,t,i,this),this._tiles={},this._cache=new oe(0,e=>this._unloadTile(e)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new se,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)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,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,n)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}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)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(xe).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const n=e.tileID,r=i.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(xe).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(e){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)e?this._reloadTile(t,"expired"):"errored"!==this._tiles[t].state&&this._reloadTile(t,"reloading")}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n){e.timeAdded=s.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!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]||e[a.canonical.key]){n[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),n=this._getLoadedTile(t);if(n)return n}}findLoadedSibling(e){return this._getLoadedTile(e)}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(e.wrapped().key)}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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])}}_updateCoveredAndRetainedTiles(e,t,i,n,r,o){const a={},l={},c=Object.keys(e),u=s.now();for(const i of c){const n=e[i],r=this._tiles[i];if(!r||0!==r.fadeEndTime&&r.fadeEndTime<=u)continue;const o=this.findLoadedParent(n,t),s=this.findLoadedSibling(n),c=o||s||null;c&&(this._addTile(c.tileID),a[c.tileID.key]=c.tileID),l[i]=n}this._retainLoadedChildren(l,n,i,e);for(const t in a)e[t]||(this._coveredTiles[t]=!0,e[t]=a[t]);if(o){const t={},i={};for(const e of r)this._tiles[e.key].hasData()?t[e.key]=e:i[e.key]=e;for(const n in i){const r=i[n].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=e[r[0].key]=r[0],t[r[1].key]=e[r[1].key]=r[1],t[r[2].key]=e[r[2].key]=r[2],t[r[3].key]=e[r[3].key]=r[3],delete i[n])}for(const n in i){const r=i[n],o=this.findLoadedParent(r,this._source.minzoom),s=this.findLoadedSibling(r),a=o||s||null;if(a){t[a.tileID.key]=e[a.tileID.key]=a.tileID;for(const e in t)t[e].isChildOf(a.tileID)&&delete t[e]}}for(const e in this._tiles)t[e]||(this._coveredTiles[e]=!0)}}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.Z(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ae(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[];const r=_e(e,this._source),o=Math.max(r-ve.maxOverzooming,this._source.minzoom),s=Math.max(r+ve.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const e={};for(const t of n)if(t.canonical.z>this._source.minzoom){const i=t.scaledTo(t.canonical.z-1);e[i.key]=i;const n=t.scaledTo(Math.max(this._source.minzoom,Math.min(t.canonical.z,5)));e[n.key]=n}n=n.concat(Object.values(e))}const a=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,a&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(n,r);be(this._source.type)&&this._updateCoveredAndRetainedTiles(l,o,s,r,n,i);for(const e in l)this._tiles[e].clearFadeHold();const c=t.am(this._tiles,l);for(const e of c){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(e)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n={},r={},o=Math.max(t-ve.maxOverzooming,this._source.minzoom),s=Math.max(t+ve.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);n[i.key]=i,e.hasData()||tthis._source.maxzoom){const e=s.children(this._source.maxzoom)[0],t=this.getTile(e);if(t&&t.hasData()){n[e.key]=e;continue}}else{const e=s.children(this._source.maxzoom);if(n[e[0].key]&&n[e[1].key]&&n[e[2].key]&&n[e[3].key])continue}let a=e.wasRequested();for(let t=s.overscaledZ-1;t>=o;--t){const o=s.scaledTo(t);if(r[o.key])break;if(r[o.key]=!0,e=this.getTile(o),!e&&a&&(e=this._addTile(o)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||a)&&(n[o.key]=o),a=e.wasRequested(),t)break}}}return n}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=e}for(const e of t)this._loadedParentTiles[e]=i}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const e in this._tiles){const t=this._tiles[e].tileID,i=this._getLoadedTile(t);this._loadedSiblingTiles[t.key]=i}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const n=i;return i||(i=new re(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,n||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_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))}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_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))))}_dataHandler(e){const t=e.sourceDataType;"source"===e.dataType&&"metadata"===t&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===t&&(this.reload(e.sourceDataChanged),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.a2.fromPoints(u);for(let e=0;ee.getTilePoint(new t.a1(i.x,i.y)));if(i.expandBy(p),i.intersects(ye)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.a2.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.a2.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.a1(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(be(this._source.type)){const e=s.now();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)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 n=this._tiles[e];n&&n.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))}}function xe(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function be(e){return"raster"===e||"image"===e||"video"===e}ve.maxOverzooming=10,ve.maxUnderzooming=3;class we{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Te(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Ee{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e0}hitTestCircle(e,t,i,n,r){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!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=r[h+2]&&t<=r[h+3]&&i>=r[h+0]&&n>=r[h+1]&&(!a||a(d))&&(!c||!Te(u,d.overlapMode))&&(o.push({key:d,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const d=this.circleCells[r];if(null!==d){const r=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Te(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Te(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Te(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,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,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Ce(e,i,r){const o=t.L();if(!e){const{vecSouth:e,vecEast:t}=Be(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.N(o,o,[1/r,1/r,1]),o}function Se(e,i,n,r){if(e){const e=t.L();if(!i){const{vecSouth:t,vecEast:i}=Be(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.N(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function Be(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.ar();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.as(a);l<1e-9?t.at(a):t.au(a,a,1/l);const c=t.ar();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.as(c);return u<1e-9?t.at(c):t.au(c,c,1/u),{vecEast:c,vecSouth:a}}function Ie(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aw(o,o,n)):(o=[e,i,0,1],$e(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Me(e,t){return.5+e/t*.5}function Pe(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Re(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.an(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let n=0;nMath.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ao.vertical?i.yn.x)?{needsFlipping:!0}:null}function ke(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=Le(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=Ue(c.first.point.x,c.first.point.y,i,n),_=Ue(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Fe(r.writingMode,g,_,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n0?a.point:De(i.tileAnchorPoint,s,e,1,i),c=Ue(e.x,e.y,i,n),h=Ue(l.x,l.y,i,n),d=Fe(r.writingMode,c,h,u);if(d)return d}const e=Ge(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.av(c,e.point,e.angle);return{}}function De(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=ze(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function Oe(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=ze(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded=r.anyProjectionOccluded||s.isOccluded,s.point;const a=e-n.direction;return De(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function ze(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=Ie(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function Ue(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aw(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function Ne(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function Ve(e,t,i){return e._unit()._perp()._mult(t*i)}function je(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=Oe(e+c.direction,l,c),d=Ve(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.ax(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ge(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=ze(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=Oe(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const n=g.sub(_);t=0===n.mag()?Ve(Oe(p+u,a,e).sub(g),i,u):Ve(n,i,u),m||(m=_.add(t)),f=je(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const He=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Qe(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.xr.x||i.yr.y?[]:t.ay([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=Ie(e.x,e.y,n,i.getElevation),r=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height,r})}(e,i);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;oi&&(i=r,t=n));return e.slice(t,t+i)}(n)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.a2;for(const r of e){const e=new t.P(r.x+Ze,r.y+Ze);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.az(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));I=e.some(e=>!e.isOccluded),B=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aA(B),allPointsOccluded:!I}}}class qe{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Ke{constructor(e,t,i,n,r){this.text=new qe(e?e.text:null,t,i,r),this.icon=new qe(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Xe{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class Je{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class Ye{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 et(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aH(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class tt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new We(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Ye(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.$,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aC(n,1,this.transform.zoom),m=t.aD(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aD(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Ce(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new Je(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.an(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aE[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=et(x,n,r,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:r,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aF(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aF(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!r.hasIconData()||g),C=v&&(A||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const S=this.retainedQueryData[r.bucketInstanceId].tileID,B=this._getTerrainElevationFunc(S),I=this.transform.getFastPathSimpleProjectionMatrix(S),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new Xe(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let n=t.ao.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ao.vertical?(k=n(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,u,S,l,b,x,s,f.predicate,B,void 0,I);return n&&n.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(G,t.ao.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ao.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aE[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ao.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ao.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.ap(r.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,b,f.predicate,e.collisionCircleDiameter,u,s,B),z.circles.length&&z.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,S,l,b,x,a,f.predicate,B,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),r.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),r.bucketInstanceId,N,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new Xe((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ao.horizontal||i===t.ao.horizontalOnly?i:0,o=i===t.ao.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new Ke(o,n,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Ke(null,n,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new Ke(t,n,!1,!1);r.isHidden()||(this.opacities[e]=r,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]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new Ke(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new Ke(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n0,A=this.placedOrientations[r.crossTileID],y=A===t.ao.vertical,v=A===t.ao.horizontal||A===t.ao.horizontalOnly;if(o>0||s>0){const t=ut(c.text);m(e.text,o,y?ht:t),m(e.text,s,v?ht:t);const i=c.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(e,n.anchor,r,A);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(e,"left",r,a),this.markUsedOrientation(e,a,r))}if(_){const t=ut(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:ht),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?ht:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=et(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=y),n.verticalTextBox&&(r=v),it(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,x.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!v&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),it(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),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.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],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.lastPlacementChangeTimee}setStale(){this.stale=!0}}function it(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-Ze,a=n[1]-Ze,l=n[2]-Ze,c=n[3]-Ze;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const nt=Math.pow(2,25),rt=Math.pow(2,24),ot=Math.pow(2,17),st=Math.pow(2,16),at=Math.pow(2,9),lt=Math.pow(2,8),ct=Math.pow(2,1);function ut(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*nt+t*rt+i*ot+t*st+i*at+t*lt+i*ct+t}const ht=0;class dt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&s.now()-n>2;for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new dt(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const ft=512/t.$/2;class mt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*ft),y:Math.floor(e.anchorY*ft)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aI(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=ft/Math.pow(2,l-o),u=(a*t.$+e.anchorY)*c,h=r*t.$*ft;return{x:Math.floor((s*t.$+e.anchorX)*c-n*t.$*ft),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.ze)}}class gt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class _t{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var yt="void main() {fragColor=vec4(1.0);}";const vt={prelude:xt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\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(unpack_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;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:xt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:xt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:xt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:xt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:xt("in 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\nvoid 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);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out 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\nvoid 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 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:xt(yt,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:xt("uniform 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);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out 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 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.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 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:xt("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));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:xt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:xt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;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);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:xt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:xt(yt,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:xt("#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\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\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=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:xt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\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);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\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=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:xt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:xt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:xt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);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((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","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:xt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;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_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:xt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;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 float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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\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;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:xt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\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);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\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\nvoid main() {\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\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;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:xt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;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#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.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_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;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#ifdef GLOBE\nout float v_depth;\n#endif\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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\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_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:xt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\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);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\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 floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\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 floorwidth\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;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;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);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:xt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;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;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(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);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:xt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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 highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:xt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;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\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\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 inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;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 vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:xt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;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\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\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=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;if (u_is_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);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform 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_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;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 vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;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\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\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];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 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.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(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp 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);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:xt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:xt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:xt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:xt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:xt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:xt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function xt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class bt{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var wt=t.aJ([{name:"a_pos",type:"Int16",components:2}]);const Tt="#define PROJECTION_MERCATOR",Et="mercator";class Ct{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Et}get shaderDefine(){return Tt}get shaderPreludeCode(){return vt.projectionMercator}get vertexShaderPreludeCode(){return vt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aL;s.emplaceBack(0,0),s.emplaceBack(t.$,0),s.emplaceBack(0,t.$),s.emplaceBack(t.$,t.$);const a=e.createVertexBuffer(s,wt.members),l=t.aM.simpleSegment(0,0,4,2),c=new t.aN;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new bt(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class St{constructor(e=0,t=0,i=0,n=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(n)||n<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=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.C.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.C.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.C.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.C.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.ah((this.left+e-this.right)/2,0,e),r=t.ah((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new St(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Bt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function It(e){return Math.max(0,Math.floor(e))}class Mt{constructor(e,i,n,r,o,s){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===s||!!s,this._minZoom=i||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==o?60:o,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.S(0,0),this._elevation=0,this._zoom=0,this._tileZoom=It(this._zoom),this._scale=t.af(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new St,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=It(this._zoom),this._scale=t.af(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new St(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.aO(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.ah(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aP(this._fovInRadians)}setFov(e){e=t.ah(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ae(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.getConstrained(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.af(i),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new G([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.ai,t.ai])}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.a2.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ag(new Float64Array(16));t.N(e,e,[this._width/2,-this._height/2,1]),t.M(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ag(new Float64Array(16)),t.N(e,e,[1,-1,1]),t.M(e,e,[-1,-1,0]),t.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,a=t.a1.fromLngLat(e,i),l=-Math.cos(t.ae(s)),c=Math.sin(t.ae(s)),u=c*Math.sin(t.ae(o)),h=-c*Math.cos(t.ae(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aQ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.a1(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.ak(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.aj(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/i,r=t.a1.fromLngLat(this.center,this.elevation),o=de(this.center,this.elevation,this.pitch,this.bearing,n);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aQ(o.z,r.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.aj(1,this.center.lat)*this.worldSize;return de(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Rt{distanceToTile2d(e,t,i,n){const r=n.distanceX([e,t]),o=n.distanceY([e,t]);return Math.hypot(r,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.Z(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Lt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),l=[[-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(n=>function(e,i,n,r){const o=t.aw([],e,i),s=1/o[3]/n*r;return t.aY(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.aU([],e[i+s],e[i+o]),r=t.aZ(n);t.aR(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.a_(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.aU([],e[i[0]],e[i[1]]),r=t.aU([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.aV(o,t.aW([],n,r)),o[3]=-t.aX(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.a$(e),r=t.b0([],e,1/n),o=t.aU([],i,t.aR([],r,t.aX(i,r))),s=t.a$(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.aR([],r,-r[3]),a=t.aS([],n,t.aR([],o,e/s));return t.b1(i,a)}return null}(n,u);if(null!==h){const e=h/t.aX(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.aU([],l[e[0]],l[e[1]]),n=t.aU([],l[e[2]],l[e[1]]),r=t.aV([],t.aW([],i,n)),o=-t.aX(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Lt(l,c,new Pt(u,h))}}class Ft{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,i,n,r){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,i,n,r),this._coveringTilesDetailsProvider=new Rt}clone(){const e=new Ft;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.b2(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.b2(n,e))}return i}getCameraFrustum(){return Lt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.aj(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.a1.fromLngLat(e),a=new t.a1(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.a1.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.a1.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aw(r,r,this._pixelMatrixInverse),t.aw(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.a1(t.C.number(r[0]/s,o[0]/a,d)/this.worldSize,t.C.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aw(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-ue(this));return(new G).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-ue(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=he(e,this.worldSize);t.O(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=he(e,this.worldSize);return t.O(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}getConstrained(e,i){i=t.ah(+i,this.minZoom,this.maxZoom);const n={center:new t.S(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.af(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.U(e[1])*o,a=t.U(e[0])*o,a-sa&&(_=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.aO(f,e-o/2,e+o/2));const n=d/2;i-nc&&(g=c-n)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);n.center=ce(o,e).wrap()}return n}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ae(this.fov)*(Math.abs(Math.cos(t.ae(this.roll)))*this.height+Math.abs(Math.sin(t.ae(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.ah(Math.PI-a-l,.01,Math.PI-.01)),u=ue(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ae(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.ah(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=le(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.aj(1,this.center.lat)*this.worldSize;const o=t.ae(Math.min(this.pitch,ae)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.b4(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aq(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.b5(a),t.N(a,a,[1,-1,1]),t.M(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.b6(a,a,-this.rollInRadians),t.b7(a,a,this.pitchInRadians),t.b6(a,a,-this.bearingInRadians),t.M(a,a,[-n,-r,0]),this._mercatorMatrix=t.N([],a,[this.worldSize,this.worldSize,this.worldSize]),t.N(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.M(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aq([],a);const l=[0,0,-1,1];t.aw(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.M(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.M(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.M(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.O(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+h*c+d*u,f=r-Math.round(r)+h*u+d*c,m=new Float64Array(a);if(t.M(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aq(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aw(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.aj(1,this.center.lat)*this.worldSize;return de(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.a1.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aw(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&r?i.terrainRttPosMatrix32f:s||t.b8(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.aT(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aw(s,s,o)):(s=[e,i,0,1],$e(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.a1.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.b9();return t.M(o,o,[n.x,n.y,n.z]),t.b6(o,o,Math.PI),t.b7(o,o,Math.PI/2),t.N(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.Z(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=he(i,this.worldSize);t.O(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.$,t.$,this.worldSize/this._helper.pixelsPerMeter],s=t.ba();return t.N(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function kt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Dt(e){if(e.useSlerp)if(e.k<1){const i=t.bb(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bb(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bc(r,i,n,e.k);const o=t.bd(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ot(e,i,n,r,o){const s=o.padding,a=le(o.worldSize,n.getNorthWest()),l=le(o.worldSize,n.getNorthEast()),c=le(o.worldSize,n.getSouthEast()),u=le(o.worldSize,n.getSouthWest()),h=t.ae(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void kt();const x=Math.min(t.ak(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ae(r)),T=b.add(w).mult(o.scale/t.af(x));return{center:ce(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:r}}class zt{get useGlobeControls(){return!1}handlePanInertia(e,t){return{easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Ot(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.S.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.getConstrained(t.S.convert(i.center||d),null!=u?u:n);Bt(e,p);const m=le(e.worldSize,d),g=le(e.worldSize,p).sub(m),_=t.af(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.C.number(n,f,a)),t.be(o,s)||Dt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.af(e.zoom-n),r=f>n?Math.min(2,_):Math.max(.5,_),o=Math.pow(r,1-a),s=ce(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.getConstrained(t.S.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;Bt(e,s);const l=le(e.worldSize,i.locationAtOffset),c=le(e.worldSize,s).sub(l),u=c.mag(),h=t.af(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.getConstrained(s,n).zoom;d=t.af(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.ak(n));const h=1===i?s:ce(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class Ut{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}Ut.Replace=[1,0],Ut.disabled=new Ut(Ut.Replace,t.bf.transparent,[!1,!1,!1,!1]),Ut.unblended=new Ut(Ut.Replace,t.bf.transparent,[!0,!0,!0,!0]),Ut.alphaBlended=new Ut([1,771],t.bf.transparent,[!0,!0,!0,!0]);const Nt=2305;class Vt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Vt.disabled=new Vt(!1,1029,Nt),Vt.backCCW=new Vt(!0,1029,Nt),Vt.frontCCW=new Vt(!0,1028,Nt);class jt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}jt.ReadOnly=!1,jt.ReadWrite=!0,jt.disabled=new jt(519,jt.ReadOnly,[0,1]);const Gt=7680;class Ht{constructor(e,t,i,n,r,o){this.test=e,this.ref=t,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Ht.disabled=new Ht({func:519,mask:0},0,0,Gt,Gt,Gt);const Qt=new WeakMap;function $t(e){var t;if(Qt.has(e))return Qt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Qt.set(e,i),i}}class Zt{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aL;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aN;o.emplaceBack(0,1,2),this._fullscreenTriangle=new bt(i.createVertexBuffer(r,wt.members),i.createIndexBuffer(o),t.aM.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),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.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),$t(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bf.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,jt.disabled,Ht.disabled,Ut.unblended,Vt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&$t(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&$t(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=Zt._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const Wt=t.$/128;function qt(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.$;-1===r&&(o=-Wt),r===n+1&&(o=t.$+Wt);let s=i/n*t.$;-1===i&&(s=e.extendToNorthPole?t.bh:-Wt),i===n+1&&(s=e.extendToSouthPole?t.bi:t.$+Wt),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ei(e){const t=ni(e.worldSize,e.center.lat);return 2*Math.PI*t}function ti(e,i,n,r,o){const s=1/(1<1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.S(t.aO(s,-180,180),i)}return new t.S(0,i)}function oi(e){return Math.cos(e*Math.PI/180)}function si(e,i){const n=oi(e),r=oi(i);return t.ak(r/n)}function ai(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+si(i.center.lat,0),o=t.bk(1/oi(i.center.lat),1/oi(Math.min(Math.abs(i.center.lat),60)),t.bn(r,7,3,0,1)),s=360/ei({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.S(i.center.lng-n.x*s*o,t.ah(i.center.lat+n.y*s,-t.ai,t.ai))}function li(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function ci(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=li(s+r*(a-s)),c=li(s),u=li(a);return new t.S(e.lng+i*((l-c)/(u-c)),o)}return new t.S(e.lng+i*r,o)}class ui{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class hi{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new hi(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.br([],n[0],n[1],n[2]),o=t.bs([],[i[0],0,0],r),s=t.bs([],[0,i[1],0],r),a=t.bs([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.aS(n,n,t.aR([],o,1&~i?-1:1)),t.aS(n,n,t.aR([],s,1==(i>>1&1)?1:-1)),t.aS(n,n,t.aR([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new hi(u,[[...o,-t.aX(o,u[0])],[...s,-t.aX(s,u[0])],[...a,-t.aX(a,u[0])],[-o[0],-o[1],-o[2],-t.aX(o,u[7])],[-s[0],-s[1],-s[2],-t.aX(s,u[7])],[-a[0],-a[1],-a[2],-t.aX(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n=0&&o++}if(0===o)return 0;o=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n=0&&i++}return i===t?2:0===i?0:1}}function di(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function pi(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>1?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,di(t,n,r))}class fi{constructor(){this._boundingVolumeCache=new ui(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.Z(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bu,l/=t.bu,a+=1,l+=1,e.z<=0)return hi.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return hi.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[ti(0,0,e.x,e.y,e.z),ti(t.$,0,e.x,e.y,e.z),ti(t.$,t.$,e.x,e.y,e.z),ti(0,t.$,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.aR([],e,l));if(l!==a)for(const e of i)n.push(t.aR([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<=(1<{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new fi}clone(){const e=new gi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bw(u,u,[0,0,0],-this.bearingInRadians),t.bx(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.by(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.aZ(u);return t.aR(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ii(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.aW(a,s,o),t.aV(s,s),t.aV(a,a);const l=[0,0,0];return t.aV(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<o&&(o=i),na&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new G(u)}getConstrained(e,i){const n=t.ah(e.lat,-t.ai,t.ai),r=t.ah(+i,this.minZoom+si(0,n),this.maxZoom);return{center:new t.S(e.lng,n),zoom:r}}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=ii(this.unprojectScreenPoint(i)),r=ii(e),o=t.bp();t.bB(o);const s=t.bp();t.by(s,n,o,-this.center.lng*Math.PI/180),t.bx(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bD(h,e)+t.bD(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bv();return t.aw(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const n=t.aX(e,i),r=t.bp(),o=t.bp();t.aR(o,i,n),t.aU(r,e,o);const s=1-t.aX(r,r);if(s<0)return null;const a=t.aX(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.bp();t.aS(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.bp();return t.aV(o,e),ri(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.b1(o,i)/s,l=t.bp();if(a>0)t.aS(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.bp();t.aS(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.b1(this._cachedClippingPlane,e);t.aU(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.bp();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return ri(function(e,i,n){const r=t.bp();t.aU(r,n,e);const o=t.bp();return t.bq(o,e,r,i/t.a$(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.S.convert(e),r=1/t.bu,o=t.b9();return t.bz(o,o,n.lng/180*Math.PI),t.b7(o,o,-n.lat/180*Math.PI),t.M(o,o,[0,0,1+i/t.bu]),t.b7(o,o,.5*Math.PI),t.N(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.Z(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class _i{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new Mt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Ft,this._verticalPerspectiveTransform=new gi}clone(){const e=new _i;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bk(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ai{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=ai(e,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bA(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bA(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.aX(h,u),p=t.bp();t.aS(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.aZ(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ni(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bn(g,.9,.5,1,.25),A=(1-t.af(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.S(i.center.lng+l*A,t.ah(i.center.lat+c*A,-t.ai,t.ai));i.setLocationAtPoint(r,n);const b=i.center,w=t.bn(Math.abs(a),45,85,0,1),T=t.bn(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bA(b.lng,x.lng),S=t.bA(b.lat,x.lat);i.setCenter(new t.S(b.lng+C*E,b.lat+S*E).wrap()),i.setZoom(v+si(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(ai(e.panDelta,t).wrap()),t.setZoom(r+si(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Ot(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bA(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bA(d,p),_=f+.5*t.bA(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ii(n.getNorthWest()),ii(n.getNorthEast()),ii(n.getSouthWest()),ii(n.getSouthEast()),ii(new t.S(p,_)),ii(new t.S(d,_)),ii(new t.S(g,f)),ii(new t.S(g,m))],x=ii(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ai.getLesserNonNegativeNonNull(b,Ai.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.ak(b),s;kt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.getConstrained(i.center?t.S.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+si(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.S.convert(i.center):r,d=e.getConstrained(h,n).center;Bt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+si(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.ah(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ah(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+si(r.lat,m.lat),_=n+si(r.lat,0),A=g+si(m.lat,0),y=t.bA(r.lng,m.lng),v=t.bA(r.lat,m.lat),x=t.af(A-_);return u=g!==n,{easeFunc:n=>{if(t.be(s,a)||Dt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-n),o=ci(r,y,v,n*i);e.setCenter(o.wrap())}if(u){const i=t.C.number(_,A,n)+si(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.getConstrained(t.S.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+si(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.ah(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.ah(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;Bt(e,d);const p=function(e,i,n){const r=ii(i),o=ii(n),s=t.aX(r,o),a=Math.acos(s),l=ei(e);return a/(2*Math.PI)*l}(e,r,d),f=o+si(r.lat,0),m=c+si(d.lat,0),g=t.af(m-f);let _;if("number"==typeof i.minZoom){const n=+i.minZoom+si(d.lat,0),r=Math.min(n,f,m)+si(0,d.lat),o=e.getConstrained(d,r).zoom+si(d.lat,0);_=t.af(o-f)}const A=t.bA(r.lng,d.lng),y=t.bA(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=ci(r,A,y,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.ak(o);e.setZoom(1===n?c:m+si(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.y(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),xi=t.bE();class bi extends t.E{constructor(e,i={}){super(),this._rtlPluginLoaded=()=>{for(const e in this.sourceCaches){const t=this.sourceCaches[e].getSource().type;"vector"!==t&&"geojson"!==t||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new D(k(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.imageManager=new y,this.imageManager.setEventedParent(this),this.glyphManager=new w(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new I(256,512),this.crossTileSymbolIndex=new At,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bF,this._loaded=!1,this._availableImages=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast("SR",t.bG()),ne().on(ee,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.sourceCaches[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bH(s,this._globalState[e]))return this;this._globalState[e]=s;const a=this._findGlobalStateAffectedSources([e]);for(const e in this.sourceCaches)a.has(e)&&(this._reloadSource(e),this._changed=!0)}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bH(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);const n=this._findGlobalStateAffectedSources(i);for(const e in this.sourceCaches)n.has(e)&&(this._reloadSource(e),this._changed=!0)}_findGlobalStateAffectedSources(e){if(0===e.length)return new Set;const t=new Set;for(const i in this._layers){const n=this._layers[i],r=n.getLayoutAffectingGlobalStateRefs();for(const i of e)r.has(i)&&t.add(n.source)}return t}loadURL(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const r=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(r,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,n)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,s.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(xi,{validate:!1})}_load(e,i,n){var r,o,s;const a=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!vi(this,t.z(a))){this._loaded=!0,this.stylesheet=a;for(const e in a.sources)this.addSource(e,a.sources[e],{validate:!1});a.sprite?this._loadSprite(a.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(a.glyphs),this._createLayers(),this.light=new C(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new B(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.setGlobalState(null!==(s=this.stylesheet.state)&&void 0!==s?s:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){const e=t.bI(this.stylesheet.layers);this.dispatcher.broadcast("SL",e),this._order=e.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const i of e){const e=t.bJ(i);e.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=e}}_loadSprite(e,i=!1,n=void 0){let r;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=g(e),a=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=i.transformRequest(_(n,a,".json"),"SpriteJSON");l[e]=t.j(o,r);const s=i.transformRequest(_(n,a,".png"),"SpriteImage");c[e]=f.getImage(s,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=s.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,r=e,this.fire(new t.k(r))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),n&&n(r)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(n))&&this.fire(new t.k(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bK(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bK(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())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}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.sourceCaches){const t=this.sourceCaches[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const e in n){const i=this.sourceCaches[e];!!n[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&vi(this,t.z(e)))return!1;(e=t.bK(e)).layers=t.bI(e.layers);const o=t.bL(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.z.source,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=this.sourceCaches[e]=new ve(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error(`There is no source with this ID=${e}`);const i=this.sourceCaches[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.k(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(vi(this,t.bM(e)))return;o=t.bJ(e)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bK(e),e=t.e(e,{source:r})),this._validate(t.z.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bJ(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.sourceCaches[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bH(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.z.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bK(i)),this._updateLayer(r)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bK(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bH(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bH(o.getPaintProperty(i),n)||(o.setPaintProperty(i,n,r)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0,this._serializedLayers=null):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.sourceCaches[n];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.sourceCaches[n];if(void 0===r)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.sourceCaches[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bN(this.sourceCaches,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bO({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.sourceCaches[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(N);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const n in e)for(const r of e[n])V(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.sourceCaches,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.z.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.sourceCaches[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((r=r||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(s.now(),e.zoom))&&(this.pauseablePlacement=new pt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(s.now()),a=!0),o&&this.pauseablePlacement.placement.setStale()),a||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(s.now())}_releaseSymbolFadeTiles(){for(const e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.sourceCaches[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.z.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...g(this.stylesheet.sprite),...o];this._validate(t.z.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=g(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.z.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}}var wi=t.aJ([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ti{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bf.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bf.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Ci={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Si(e){const t=[];for(let i=0;i({u_depth:new t.bP(e,i.u_depth),u_terrain:new t.bP(e,i.u_terrain),u_terrain_dim:new t.bg(e,i.u_terrain_dim),u_terrain_matrix:new t.bR(e,i.u_terrain_matrix),u_terrain_unpack:new t.bS(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bg(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.bR(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.bS(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bS(e,i.u_projection_clipping_plane),u_projection_transition:new t.bg(e,i.u_projection_transition),u_projection_fallback_matrix:new t.bR(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=n?n.getUniforms(e,E):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Ci[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const n=i.vaos||(i.vaos={});(n[c]||(n[c]=new Ti)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Ii(e,i,n){const r=1/t.aC(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Mi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.bV();"viewport"===o.properties.get("anchor")&&t.bW(l,e.transform.bearingInRadians),t.bX(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},Pi=(e,i,n,r,o,s,a)=>t.e(Mi(e,i,n,r),Ii(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ri=(e,i,n,r)=>t.e(Ii(i,e,n),{u_fill_translate:r}),Li=(e,t)=>({u_world:e,u_fill_translate:t}),Fi=(e,i,n,r,o)=>t.e(Ri(e,i,n,o),{u_world:r}),ki=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aC(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.$*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Di=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Oi=e=>({u_viewport_size:[e.width,e.height]}),zi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Ui=(e,i,n,r)=>{const o=t.aC(e,1,i)/(t.$*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aC(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},Ni=(e,i,n,r)=>{const o=t.L();t.bY(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},Vi=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t{const n=i.stride,r=t.L();return t.bY(r,0,t.$,-t.$,0,0,1),t.M(r,r,[0,-t.$,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Gi(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.a1(0,r/n).toLngLat().lat,new t.a1(0,(r+1)/n).toLngLat().lat]}const Hi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Qi=(e,i,n,r)=>{const o=e.transform;return{u_translation:Ki(e,i,n),u_ratio:r/t.aC(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},$i=(e,i,n,r,o)=>t.e(Qi(e,i,n,r),{u_image:0,u_image_height:o}),Zi=(e,i,n,r,o)=>{const s=e.transform,a=qi(i,s);return{u_translation:Ki(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aC(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},Wi=(e,i,n,r,o,s)=>{const a=e.lineAtlas,l=qi(i,e.transform),c="round"===n.layout.get("line-cap"),u=a.getDash(o.from,c),h=a.getDash(o.to,c),d=u.width*s.fromScale,p=h.width*s.toScale;return t.e(Qi(e,i,n,r),{u_patternscale_a:[l/d,-u.height/2],u_patternscale_b:[l/p,-h.height/2],u_sdfgamma:a.width/(256*Math.min(d,p)*e.pixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:h.y,u_mix:s.t})};function qi(e,i){return 1/t.aC(e,1,i.tileZoom)}function Ki(e,i,n){return t.aD(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Xi=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:Ji(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function Ji(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]}const Yi=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{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:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},en=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(Yi(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},tn=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(en(e,i,n,r,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),nn=(e,t)=>({u_opacity:e,u_color:t}),rn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aC(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),on=(e,t)=>{},sn={fillExtrusion:(e,i)=>({u_lightpos:new t.bT(e,i.u_lightpos),u_lightpos_globe:new t.bT(e,i.u_lightpos_globe),u_lightintensity:new t.bg(e,i.u_lightintensity),u_lightcolor:new t.bT(e,i.u_lightcolor),u_vertical_gradient:new t.bg(e,i.u_vertical_gradient),u_opacity:new t.bg(e,i.u_opacity),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.bT(e,i.u_lightpos),u_lightpos_globe:new t.bT(e,i.u_lightpos_globe),u_lightintensity:new t.bg(e,i.u_lightintensity),u_lightcolor:new t.bT(e,i.u_lightcolor),u_vertical_gradient:new t.bg(e,i.u_vertical_gradient),u_height_factor:new t.bg(e,i.u_height_factor),u_opacity:new t.bg(e,i.u_opacity),u_fill_translate:new t.bU(e,i.u_fill_translate),u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.bU(e,i.u_world),u_fill_translate:new t.bU(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.bU(e,i.u_world),u_image:new t.bP(e,i.u_image),u_texsize:new t.bU(e,i.u_texsize),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade),u_fill_translate:new t.bU(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bP(e,i.u_scale_with_map),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_extrude_scale:new t.bU(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bg(e,i.u_globe_extrude_scale),u_translate:new t.bU(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.bU(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.bU(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.bQ(e,i.u_color),u_overlay:new t.bP(e,i.u_overlay),u_overlay_scale:new t.bg(e,i.u_overlay_scale)}),depth:on,clippingMask:on,heatmap:(e,i)=>({u_extrude_scale:new t.bg(e,i.u_extrude_scale),u_intensity:new t.bg(e,i.u_intensity),u_globe_extrude_scale:new t.bg(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.bR(e,i.u_matrix),u_world:new t.bU(e,i.u_world),u_image:new t.bP(e,i.u_image),u_color_ramp:new t.bP(e,i.u_color_ramp),u_opacity:new t.bg(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bP(e,i.u_image),u_latrange:new t.bU(e,i.u_latrange),u_exaggeration:new t.bg(e,i.u_exaggeration),u_altitudes:new t.b_(e,i.u_altitudes),u_azimuths:new t.b_(e,i.u_azimuths),u_accent:new t.bQ(e,i.u_accent),u_method:new t.bP(e,i.u_method),u_shadows:new t.bZ(e,i.u_shadows),u_highlights:new t.bZ(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.bR(e,i.u_matrix),u_image:new t.bP(e,i.u_image),u_dimension:new t.bU(e,i.u_dimension),u_zoom:new t.bg(e,i.u_zoom),u_unpack:new t.bS(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bP(e,i.u_image),u_unpack:new t.bS(e,i.u_unpack),u_dimension:new t.bU(e,i.u_dimension),u_elevation_stops:new t.bP(e,i.u_elevation_stops),u_color_stops:new t.bP(e,i.u_color_stops),u_color_ramp_size:new t.bP(e,i.u_color_ramp_size),u_opacity:new t.bg(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_image:new t.bP(e,i.u_image),u_image_height:new t.bg(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_texsize:new t.bU(e,i.u_texsize),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_image:new t.bP(e,i.u_image),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_scale:new t.bT(e,i.u_scale),u_fade:new t.bg(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.bU(e,i.u_translation),u_ratio:new t.bg(e,i.u_ratio),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.bU(e,i.u_units_to_pixels),u_patternscale_a:new t.bU(e,i.u_patternscale_a),u_patternscale_b:new t.bU(e,i.u_patternscale_b),u_sdfgamma:new t.bg(e,i.u_sdfgamma),u_image:new t.bP(e,i.u_image),u_tex_y_a:new t.bg(e,i.u_tex_y_a),u_tex_y_b:new t.bg(e,i.u_tex_y_b),u_mix:new t.bg(e,i.u_mix)}),raster:(e,i)=>({u_tl_parent:new t.bU(e,i.u_tl_parent),u_scale_parent:new t.bg(e,i.u_scale_parent),u_buffer_scale:new t.bg(e,i.u_buffer_scale),u_fade_t:new t.bg(e,i.u_fade_t),u_opacity:new t.bg(e,i.u_opacity),u_image0:new t.bP(e,i.u_image0),u_image1:new t.bP(e,i.u_image1),u_brightness_low:new t.bg(e,i.u_brightness_low),u_brightness_high:new t.bg(e,i.u_brightness_high),u_saturation_factor:new t.bg(e,i.u_saturation_factor),u_contrast_factor:new t.bg(e,i.u_contrast_factor),u_spin_weights:new t.bT(e,i.u_spin_weights),u_coords_top:new t.bS(e,i.u_coords_top),u_coords_bottom:new t.bS(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texture:new t.bP(e,i.u_texture),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texture:new t.bP(e,i.u_texture),u_gamma_scale:new t.bg(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_is_halo:new t.bP(e,i.u_is_halo),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bP(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bP(e,i.u_is_size_feature_constant),u_size_t:new t.bg(e,i.u_size_t),u_size:new t.bg(e,i.u_size),u_camera_to_center_distance:new t.bg(e,i.u_camera_to_center_distance),u_pitch:new t.bg(e,i.u_pitch),u_rotate_symbol:new t.bP(e,i.u_rotate_symbol),u_aspect_ratio:new t.bg(e,i.u_aspect_ratio),u_fade_change:new t.bg(e,i.u_fade_change),u_label_plane_matrix:new t.bR(e,i.u_label_plane_matrix),u_coord_matrix:new t.bR(e,i.u_coord_matrix),u_is_text:new t.bP(e,i.u_is_text),u_pitch_with_map:new t.bP(e,i.u_pitch_with_map),u_is_along_line:new t.bP(e,i.u_is_along_line),u_is_variable_anchor:new t.bP(e,i.u_is_variable_anchor),u_texsize:new t.bU(e,i.u_texsize),u_texsize_icon:new t.bU(e,i.u_texsize_icon),u_texture:new t.bP(e,i.u_texture),u_texture_icon:new t.bP(e,i.u_texture_icon),u_gamma_scale:new t.bg(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,i.u_device_pixel_ratio),u_is_halo:new t.bP(e,i.u_is_halo),u_translation:new t.bU(e,i.u_translation),u_pitched_scale:new t.bg(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bg(e,i.u_opacity),u_color:new t.bQ(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bg(e,i.u_opacity),u_image:new t.bP(e,i.u_image),u_pattern_tl_a:new t.bU(e,i.u_pattern_tl_a),u_pattern_br_a:new t.bU(e,i.u_pattern_br_a),u_pattern_tl_b:new t.bU(e,i.u_pattern_tl_b),u_pattern_br_b:new t.bU(e,i.u_pattern_br_b),u_texsize:new t.bU(e,i.u_texsize),u_mix:new t.bg(e,i.u_mix),u_pattern_size_a:new t.bU(e,i.u_pattern_size_a),u_pattern_size_b:new t.bU(e,i.u_pattern_size_b),u_scale_a:new t.bg(e,i.u_scale_a),u_scale_b:new t.bg(e,i.u_scale_b),u_pixel_coord_upper:new t.bU(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.bU(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bg(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bP(e,i.u_texture),u_ele_delta:new t.bg(e,i.u_ele_delta),u_fog_matrix:new t.bR(e,i.u_fog_matrix),u_fog_color:new t.bQ(e,i.u_fog_color),u_fog_ground_blend:new t.bg(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bg(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.bQ(e,i.u_horizon_color),u_horizon_fog_blend:new t.bg(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bg(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bg(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bP(e,i.u_texture),u_terrain_coords_id:new t.bg(e,i.u_terrain_coords_id),u_ele_delta:new t.bg(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bg(e,i.u_input),u_output_expected:new t.bg(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.bT(e,i.u_sun_pos),u_atmosphere_blend:new t.bg(e,i.u_atmosphere_blend),u_globe_position:new t.bT(e,i.u_globe_position),u_globe_radius:new t.bg(e,i.u_globe_radius),u_inv_proj_matrix:new t.bR(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.bQ(e,i.u_sky_color),u_horizon_color:new t.bQ(e,i.u_horizon_color),u_horizon:new t.bU(e,i.u_horizon),u_horizon_normal:new t.bU(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bg(e,i.u_sky_horizon_blend),u_sky_blend:new t.bg(e,i.u_sky_blend)})};class an{constructor(e,t,i){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||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const ln={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class cn{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,jt.disabled,Ht.disabled,e.colorModeForRenderPass(),Vt.disabled,Di(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.b$;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:B,angle:I})}else Qe(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===n.layout.get("text-rotation-alignment");Re(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?Xn:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?tn(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):en(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):Yi(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:B,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aM([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,nr(i.buffers,t.segments,n,e,i.program,w,h,d,r,i.projectionData,t.terrainData)),r.u_is_halo=0}nr(i.buffers,t.segments,n,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function nr(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,Vt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function rr(e,i,n,r,o){const s=e.context,a=s.gl,l=Ht.disabled,c=new Ut([a.ONE,a.ONE],t.bf.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=sr(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bf.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,jt.disabled,l,c,Vt.disabled,Ui(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function or(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=ar(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,jt.disabled,Ht.disabled,e.colorModeForRenderPass(),Vt.disabled,Ni(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function sr(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function ar(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function lr(e,t,i,n,r){if(!i||!n||!n.imageAtlas)return;const o=n.imageAtlas.patternPositions;let s=o[i.to.toString()],a=o[i.from.toString()];if(!s&&a&&(s=a),!a&&s&&(a=s),!s||!a){const e=r.getPaintProperty(t);s=o[e],a=o[e]}s&&a&&e.setConstantPatternPositions(s,a)}function cr(e,i,n,r,o,s,a,l){const c=e.context.gl,u="fill-pattern",h=n.paint.get(u),d=h&&h.constantOr(1),p=n.getCrossfadeParameters();let f,m,g,_,A;const y=e.transform,v=n.paint.get("fill-translate"),x=n.paint.get("fill-translate-anchor");a?(m=d&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",f=c.LINES):(m=d?"fillPattern":"fill",f=c.TRIANGLES);const b=h.constantOr(null);for(const h of r){const r=i.getTile(h);if(d&&!r.patternsLoaded())continue;const w=r.getBucket(n);if(!w)continue;const T=w.programConfigurations.get(n.id),E=e.useProgram(m,T),C=e.style.map.terrain&&e.style.map.terrain.getTerrainData(h);d&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),T.updatePaintBuffers(p)),lr(T,u,b,r,n);const S=y.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),B=t.aD(y,r,v,x);if(a){_=w.indexBuffer2,A=w.segments2;const t=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===m&&d?Fi(e,p,r,t,B):Li(t,B)}else _=w.indexBuffer,A=w.segments,g=d?Ri(e,p,r,B):{u_fill_translate:B};const I=e.stencilModeForClipping(h);E.draw(e.context,f,o,I,s,Vt.backCCW,g,C,S,n.id,w.layoutVertexBuffer,_,A,n.paint,e.transform.zoom,T)}}function ur(e,i,n,r,o,s,a,l){const c=e.context,u=c.gl,h="fill-extrusion-pattern",d=n.paint.get(h),p=d.constantOr(1),f=n.getCrossfadeParameters(),m=n.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),_=e.transform;for(const d of r){const r=i.getTile(d),A=r.getBucket(n);if(!A)continue;const y=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d),v=A.programConfigurations.get(n.id),x=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",v);p&&(e.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),v.updatePaintBuffers(f));const b=_.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});lr(v,h,g,r,n);const w=t.aD(_,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),T=n.paint.get("fill-extrusion-vertical-gradient"),E=p?Pi(e,T,m,w,d,f,r):Mi(e,T,m,w);x.draw(c,c.gl.TRIANGLES,o,s,a,Vt.backCCW,E,y,b,n.id,A.layoutVertexBuffer,A.indexBuffer,A.segments,n.paint,e.transform.zoom,v,e.style.map.terrain&&A.centroidVertexBuffer)}}function hr(e,t,i,n,r,o,s,a,l){var c;const u=e.style.projection,h=e.context,d=e.transform,p=h.gl,f=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=e.useProgram("hillshade",null,!1,f),g=!e.options.moving;for(const f of n){const n=t.getTile(f),_=n.fbo;if(!_)continue;const A=u.getMeshFromTileID(h,f.canonical,a,!0,"raster"),y=null===(c=e.style.map.terrain)||void 0===c?void 0:c.getTerrainData(f);h.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,_.colorAttachment.get());const v=d.getProjectionData({overscaledTileID:f,aligned:g,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(h,p.TRIANGLES,o,r[f.overscaledZ],s,Vt.backCCW,Vi(e,n,i),y,v,i.id,A.vertexBuffer,A.indexBuffer,A.segments)}}function dr(e,i,n,r,o,s,a,l,c){var u;const h=e.style.projection,d=e.context,p=e.transform,f=d.gl,m=e.useProgram("colorRelief"),g=!e.options.moving;let _=!0,A=0;for(const y of r){const r=i.getTile(y),v=r.dem;if(_){const e=f.getParameter(f.MAX_TEXTURE_SIZE),{elevationTexture:t,colorTexture:i}=n.getColorRampTextures(d,e,v.getUnpackVector());d.activeTexture.set(f.TEXTURE1),t.bind(f.NEAREST,f.CLAMP_TO_EDGE),d.activeTexture.set(f.TEXTURE4),i.bind(f.LINEAR,f.CLAMP_TO_EDGE),_=!1,A=t.size[0]}if(!v||!v.data)continue;const x=v.stride,b=v.getPixels();if(d.activeTexture.set(f.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||e.getTileTexture(x),r.demTexture){const e=r.demTexture;e.update(b,{premultiply:!1}),e.bind(f.LINEAR,f.CLAMP_TO_EDGE)}else r.demTexture=new t.T(d,b,f.RGBA,{premultiply:!1}),r.demTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const w=h.getMeshFromTileID(d,y.canonical,l,!0,"raster"),T=null===(u=e.style.map.terrain)||void 0===u?void 0:u.getTerrainData(y),E=p.getProjectionData({overscaledTileID:y,aligned:g,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(d,f.TRIANGLES,s,o[y.overscaledZ],a,Vt.backCCW,Hi(n,r.dem,A),T,E,n.id,w.vertexBuffer,w.indexBuffer,w.segments)}}const pr=[new t.P(0,0),new t.P(t.$,0),new t.P(t.$,t.$),new t.P(0,t.$)];function fr(e,t,i,n,r,o,s,a,l=!1,c=!1){const u=n[n.length-1].overscaledZ,h=e.context,d=h.gl,p=e.useProgram("raster"),f=e.transform,m=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving;for(const A of n){const n=e.getDepthModeForSublayer(A.overscaledZ-u,1===i.paint.get("raster-opacity")?jt.ReadWrite:jt.ReadOnly,d.LESS),y=t.getTile(A);y.registerFadeDuration(i.paint.get("raster-fade-duration"));const v=t.findLoadedParent(A,0),x=t.findLoadedSibling(A),b=mr(y,v||x||null,t,i,e.transform,e.style.map.terrain);let w,T;const E="nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR;h.activeTexture.set(d.TEXTURE0),y.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),h.activeTexture.set(d.TEXTURE1),v?(v.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),w=Math.pow(2,v.tileID.overscaledZ-y.tileID.overscaledZ),T=[y.tileID.canonical.x*w%1,y.tileID.canonical.y*w%1]):y.texture.bind(E,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),y.texture.useMipmap&&h.extTextureFilterAnisotropic&&e.transform.pitch>20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const C=e.style.map.terrain&&e.style.map.terrain.getTerrainData(A),S=f.getProjectionData({overscaledTileID:A,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),B=Xi(T||[0,0],w||1,b,i,a),I=m.getMeshFromTileID(h,A.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,n,r?r[A.overscaledZ]:Ht.disabled,g,l?Vt.frontCCW:Vt.backCCW,B,C,S,i.id,I.vertexBuffer,I.indexBuffer,I.segments)}}function mr(e,i,n,r,o,a){const l=r.paint.get("raster-fade-duration");if(!a&&l>0){const r=s.now(),a=(r-e.timeAdded)/l,c=i?(r-i.timeAdded)/l:-1,u=n.getSource(),h=_e(o,{tileSize:u.tileSize,roundZoom:u.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),p=d&&e.refreshedUponExpiration?1:t.ah(d?a:1-c,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const gr=new t.bf(1,0,0,1),_r=new t.bf(0,1,0,1),Ar=new t.bf(0,0,1,1),yr=new t.bf(1,0,1,1),vr=new t.bf(0,1,1,1);function xr(e,t,i,n){wr(e,0,t+i/2,e.transform.width,i,n)}function br(e,t,i,n){wr(e,t-i/2,0,i,e.transform.height,n)}function wr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Tr(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("debug"),a=jt.disabled,l=Ht.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(n).tileSize,m=512/Math.min(f,512)*(n.overscaledZ/e.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=e.context.gl,r=e.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(t,5,5),r.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,o.TRIANGLES,a,l,Ut.alphaBlended,Vt.disabled,zi(t.bf.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(r,o.LINE_STRIP,a,l,c,Vt.disabled,zi(t.bf.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Er(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Ei(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Ht.disabled,l,Vt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Cr(e,i){if(!i.mesh){const n=new t.aL;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aN;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new bt(e.createVertexBuffer(n,wt.members),e.createIndexBuffer(r),t.aM.simpleSegment(0,0,n.length,r.length))}return i.mesh}class Sr{constructor(e,i){this.context=new Wn(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ag(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ve.maxUnderzooming+ve.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new At}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aL;i.emplaceBack(0,0),i.emplaceBack(t.$,0),i.emplaceBack(0,t.$),i.emplaceBack(t.$,t.$),this.tileExtentBuffer=e.createVertexBuffer(i,wt.members),this.tileExtentSegments=t.aM.simpleSegment(0,0,4,2);const n=new t.aL;n.emplaceBack(0,0),n.emplaceBack(t.$,0),n.emplaceBack(0,t.$),n.emplaceBack(t.$,t.$),this.debugBuffer=e.createVertexBuffer(n,wt.members),this.debugSegments=t.aM.simpleSegment(0,0,4,5);const r=new t.c6;r.emplaceBack(0,0,0,0),r.emplaceBack(t.$,0,t.$,0),r.emplaceBack(0,t.$,0,t.$),r.emplaceBack(t.$,t.$,t.$,t.$),this.rasterBoundsBuffer=e.createVertexBuffer(r,wi.members),this.rasterBoundsSegments=t.aM.simpleSegment(0,0,4,2);const o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(t.$,0),o.emplaceBack(0,t.$),o.emplaceBack(t.$,t.$),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,wt.members),this.rasterBoundsSegmentsPosOnly=t.aM.simpleSegment(0,0,4,5);const s=new t.aL;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,wt.members),this.viewportSegments=t.aM.simpleSegment(0,0,4,2);const a=new t.c7;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aN;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Ht({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new bt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.L();t.bY(n,0,this.width,this.height,0,0,1),t.N(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,jt.disabled,this.stencilClearMode,Ut.disabled,Vt.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode(Ut.disabled),n.setDepthMode(jt.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){const r=this.context,o=r.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,jt.disabled,new Ht({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),Ut.disabled,i?Vt.disabled:Vt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,n=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ae(n,{tileSize:n.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=n.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,t.TRIANGLES,o,Ht.disabled,Ut.disabled,Vt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Ht({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Ht({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i0};for(const e in a){const t=a[e];t.used&&t.prepare(this.context),l[e]=t.getVisibleCoordinates(!1),c[e]=l[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bf.black:t.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=ue(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new jt(n.LEQUAL,jt.ReadWrite,[0,1]),s=Ht.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Cr(i,t);l.draw(i,n.TRIANGLES,o,s,a,Vt.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=a[e.source],i=l[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Cr(r,i);s.draw(r,o.TRIANGLES,a,Ht.disabled,Ut.alphaBlended,Vt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.sourceCaches[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let n=0;nh.getElevation(o,e,t):null;er(s,d,p,c,u,g,i,f,_,t.aD(u,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&ir(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&ir(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(Kn(e,i,n,r,!0),Kn(e,i,n,r,!1))}(e,i,n,r,this.style.placement.variableOffsets,o):t.cc(n)?function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,jt.ReadOnly),m=Ht.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,d.TRIANGLES,f,m,g,Vt.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}}(e,i,n,r,o):t.cd(n)?function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?rr(e,r,n,t,l):"translucent"===e.renderPass&&or(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=Ht.disabled,c=new Ut([s.ONE,s.ONE],t.bf.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.c2);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=sr(e,i.width/4,i.height/4),n.heatmapFbos.set(t.c2,o))})(o,e,n),o.clear({color:t.bf.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=i?vt.projectionMercator:o.shaderPreludeCode,a=i?Tt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Et:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return this.cache[l]||(this.cache[l]=new Bi(this.context,vt[e],t,sn[e],this._showOverdrawInspector,r,s,a,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.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=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Br(e,t){let i,n=!1,r=null,o=null;const s=()=>{r=null,n&&(e.apply(o,i),r=setTimeout(s,t),n=!1)};return(...e)=>(n=!0,o=this,i=e,r||s(),r)}class Ir{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Br(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.S(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Mr={linearity:.3,easing:t.cm(0,0,.3,1)},Pr=t.e({deceleration:2500,maxSpeed:1400},Mr),Rr=t.e({deceleration:20,maxSpeed:1400},Mr),Lr=t.e({deceleration:1e3,maxSpeed:360},Mr),Fr=t.e({deceleration:1e3,maxSpeed:90},Mr),kr=t.e({deceleration:1e3,maxSpeed:360},Mr);class Dr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:s.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=s.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=zr(i.pan.mag(),n,t.e({},Pr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,Or(r,o)}if(i.zoom){const e=zr(i.zoom,n,Rr);r.zoom=this._map.transform.zoom+e.amount,Or(r,e)}if(i.bearing){const e=zr(i.bearing,n,Lr);r.bearing=this._map.transform.bearing+t.ah(e.amount,-179,179),Or(r,e)}if(i.pitch){const e=zr(i.pitch,n,Fr);r.pitch=this._map.transform.pitch+e.amount,Or(r,e)}if(i.roll){const e=zr(i.roll,n,kr);r.roll=this._map.transform.roll+t.ah(e.amount,-179,179),Or(r,e)}if(r.zoom||r.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;r.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(r,{noMoveStart:!0})}}function Or(e,t){(!e.duration||e.durationi.unproject(e)),l=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:n}),this._defaultPrevented=!1}}class Vr extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class jr{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Vr(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Ur(e.type,this._map,e))}mouseup(e){this._map.fire(new Ur(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Ur(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Ur(e.type,this._map,e))}mouseover(e){this._map.fire(new Ur(e.type,this._map,e))}mouseout(e){this._map.fire(new Ur(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Nr(e.type,this._map,e))}touchmove(e){this._map.fire(new Nr(e.type,this._map,e))}touchend(e){this._map.fire(new Nr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Nr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Gr{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Ur(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ur("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Ur(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Hr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Qr{constructor(e,t){this._map=e,this._tr=new Hr(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&&(a.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function $r(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=$r(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=$r(i,t);for(const e in this.touches){const t=n[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 Wr{constructor(e){this.singleTap=new Zr(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class qr{constructor(e){this._tr=new Hr(e),this._zoomIn=new Wr({numTouches:1,numTaps:2}),this._zoomOut=new Wr({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(r)},{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}}class Kr{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)!0}),t=new to){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const no=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class ro{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=$r(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class po extends oo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,ho(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return ho(e)&&ho(t)&&o}}const fo={panStep:100,bearingStep:15,pitchStep:10};class mo{constructor(e){this._tr=new Hr(e);const t=fo;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=0,r=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(),r=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),r=1);break;case 38:e.shiftKey?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:go,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:a.center},{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 go(e){return e*(2-e)}const _o=4.000244140625,Ao=1/450;class yo{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new Hr(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Ao}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)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=s.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%_o==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_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 i=a.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.S.convert(n.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>_o?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.af(this._targetZoom);this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.ak(r*n)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,a=!1;if("wheel"===this._type&&n&&r){const e=s.now()-this._lastWheelEventTime,l=Math.min((e+5)/200,1),c=r(l);o=t.C.number(n,i,c),l<1?this._frameId||(this._frameId=!0):a=!0}else o=i,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!a,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.co;if(this._prevEase){const e=this._prevEase,n=(s.now()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,a=Math.sqrt(.0729-o*o);i=t.cm(o,a,.25,1)}return this._prevEase={start:s.now(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class vo{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 xo{constructor(e){this._tr=new Hr(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class bo{constructor(){this._tap=new Wr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wo{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("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class To{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Eo{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,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("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Co{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=a.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(a.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const So=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Bo extends t.l{}function Io(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Mo{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:l,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;if(this._blockedByActive(s,u,l))c.reset();else if(c[i||e.type]){if(t.cp(e,i||e.type)){const t=a.mousePos(this._map.getCanvas(),e);h=c[i||e.type](e,t)}else if(t.cq(e,i||e.type)){const t=this._getMapTouches(e.touches),n=a.touchPos(this._map.getCanvas(),t);h=c[i||e.type](e,n,t)}else t.cr(i||e.type)||(h=c[i||e.type](e));this.mergeHandlerResult(r,o,h,l,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||c.isActive())&&(s[l]=c)}const l={};for(const e in this._previousActiveHandlers)s[e]||(l[e]=n);this._previousActiveHandlers=s,(Object.keys(l).length||Io(r))&&(this._changes.push([r,o,l]),this._triggerRenderFrame()),(Object.keys(s).length||Io(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=r;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Dr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)a.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)a.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new jr(i,e));const r=i.boxZoom=new Qr(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Co(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new qr(i),l=new xo(i);i.doubleClickZoom=new vo(l,s),this._add("tapZoom",s),this._add("clickZoom",l),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const c=new bo;this._add("tapDragZoom",c);const u=i.touchPitch=new po(i);this._add("touchPitch",u),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const l=new eo({checkCorrectEvent:e=>0===a.mouseButton(e)&&e.ctrlKey||2===a.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cn(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y0===a.mouseButton(e)&&e.ctrlKey||2===a.mouseButton(e)});return new Kr({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:no})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new eo({checkCorrectEvent:e=>2===a.mouseButton(e)&&e.ctrlKey});return new Kr({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y0===a.mouseButton(e)&&!e.ctrlKey});return new Kr({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:no})}(e),g=new ro(e,i);i.dragPan=new wo(n,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new uo,A=new lo;i.touchZoomRotate=new Eo(n,A,_,c),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate);const y=i.scrollZoom=new yo(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new mo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable(),this._add("blockableMapEvent",new Gr(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=[]}}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 Boolean(So(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(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),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(Io(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||n.transform.centerPoint,o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);o?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,r),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?r.setCenter(r.screenPointToLocation(r.centerPoint.sub(s))):this._map.cameraHelper.handleMapControlsPan(p,r,f):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,r,f))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,r),this._map.cameraHelper.handleMapControlsPan(p,r,f)),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_fireEvents(e,i,n){const r=So(this._eventsInProgress),o=So(e),a={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(a[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=So(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Bo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Po extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((s.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.S(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.l("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new t.l("zoomend",e)),r&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&s.prefersReducedMotion){const n=t.Q(e,["center","zoom","bearing","pitch","roll","elevation"]);return this.jumpTo(n,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.co},e);const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,a=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,a):a,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(n.width,n.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},S=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},B=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(B)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*B/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==a,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(s=>{const m=s*B,_=1/C(m),A=S(m);this._rotating&&n.setBearing(t.C.number(r,c,s)),this._pitching&&n.setPitch(t.C.number(o,u,s)),this._rolling&&n.setRoll(t.C.number(a,h,s)),this._padding&&(n.interpolatePadding(l,d,s),f=n.centerPoint.add(p)),g.easeFunc(s,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(s),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=s.now(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.aO(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class Lo{constructor(e=Ro){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.sourceCaches;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=a.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Fo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=a.create("div","maplibregl-ctrl");const t=a.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ko{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){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");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=[]}}var Do=t.aJ([{name:"a_pos3d",type:"Int16",components:3}]);class Oo extends t.E{constructor(e){super(),this._lastTilesetChange=s.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ae(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.bY(r.terrainRttPosMatrix32f,0,t.$,t.$,0,0,1),this._tiles[r.key]=new re(r,this.tileSize),this._lastTilesetChange=s.now());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.ba();if(r.canonical.equals(e.canonical))t.bY(s,0,t.$,t.$,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<>i<>i;t.bY(s,0,a,a,0,0,1),t.M(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i;t.bY(s,0,t.$,t.$,0,0,1),t.M(s,s,[n*a,o*a,0]),t.N(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.ba();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,n=e.canonical.y-o.canonical.y;t.bY(a,0,t.$,t.$,0,0,1),t.M(a,a,[i*t.$,n*t.$,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.$>>i;t.bY(a,0,c,c,0,0,1),t.M(a,a,[-n*c+s*t.$,-r*c+l*t.$,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.$<i.maxzoom&&(n=i.maxzoom),n=i.minzoom&&(!r||!r.dem);)r=this.sourceCache.getTileByID(e.scaledTo(n--).key);return r}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class zo{constructor(e,t,i){this._meshCache={},this.painter=e,this.sourceCache=new Oo(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,n,r=t.$){var o;if(!(i>=0&&i=0&&ne.canonical.z&&(e.canonical.z>=n?r=e.canonical.z-n:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>r<>r<>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.sourceCache.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const No={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class Vo{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Uo(e.context,30,t.sourceCache.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.sourceCaches){this._coordsAscending[t]={};const i=e.sourceCaches[t].getVisibleCoordinates(),n=e.sourceCaches[t].getSource(),r=n instanceof q?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.sourceCache.getTerrainCoords(e,r);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],n=i.source;if(No[i.type]&&!this._coordsAscendingStr[n]){this._coordsAscendingStr[n]={};for(const e in this._coordsAscending[n])this._coordsAscendingStr[n][e]=this._coordsAscending[n][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(No[r]&&(this._prevType&&No[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(No[this._prevType]||No[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(Er(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bf.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,a.mousePos(this.element,e)),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,a.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),a.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const r=new io;this._rotatePitchHandler=new Kr({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cn(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),a.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;a.removeEventListener(e,"mousedown",this.mousedown),a.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend),a.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend)}}let Zo;function Wo(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.S(e.lng,e.lat);if(e=new t.S(e.lng,e.lat),i){const r=new t.S(e.lng-360,e.lat),o=new t.S(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const qo={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%)"};function Ko(e,t,i){const n=e.classList;for(const e in qo)n.remove(`maplibregl-${i}-anchor-${e}`);n.add(`maplibregl-${i}-anchor-${t}`)}class Xo extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=Wo(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),a.setTransform(this._element,`${qo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`),s.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},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._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=a.create("div");const i=a.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=a.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=a.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const l=a.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of c){const t=a.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),l.appendChild(t)}const u=a.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"fill",this._color);const h=a.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),u.appendChild(h);const d=a.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=a.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=a.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=a.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=a.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=a.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(l),s.appendChild(u),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),Ko(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),a.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.S.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,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,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.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 this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const Jo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Yo=0,es=!1;const ts={maxWidth:100,unit:"metric"};function is(e,t,i){const n=i&&i.maxWidth||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?ns(t,c,i/5280,e._getUIString("ScaleControl.Miles")):ns(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?ns(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?ns(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):ns(t,c,u,e._getUIString("ScaleControl.Meters"))}function ns(e,t,i,n){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}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r} ${n}`}const rs={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},os=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ss(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ss(new t.P(0,0))}const as=i;e.AJAXError=t.cz,e.Event=t.l,e.Evented=t.E,e.LngLat=t.S,e.MercatorCoordinate=t.a1,e.Point=t.P,e.addProtocol=t.cA,e.config=t.a,e.removeProtocol=t.cB,e.AttributionControl=Lo,e.BoxZoomHandler=Qr,e.CanvasSource=X,e.CooperativeGesturesHandler=Co,e.DoubleClickZoomHandler=vo,e.DragPanHandler=wo,e.DragRotateHandler=To,e.EdgeInsets=St,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){a.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=a.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);a.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=W,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.S(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=G.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.S(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&es)return;this.options.trackUserLocation&&this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=a.create("button","maplibregl-ctrl-geolocate",this._container),a.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=a.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Xo({element:this._dotElement}),this._circleElement=a.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Xo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},Jo,e)}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==Zo&&!e)return Zo;if(void 0===window.navigator.permissions)return Zo=!!window.navigator.geolocation,Zo;try{const e=yield window.navigator.permissions.query({name:"geolocation"});Zo="denied"!==e.state}catch(e){Zo=!!window.navigator.geolocation}return Zo})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),a.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Yo=0,es=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const e=this._map.getBounds(),t=e.getSouthEast(),i=e.getNorthEast(),n=t.distanceTo(i),r=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}trigger(){if(!this._setup)return t.w("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 t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Yo--,es=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Yo++,Yo>1?(e={maximumAge:6e5,timeout:0},es=!0):(e=this.options.positionOptions,es=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=a.create("button","maplibregl-ctrl-globe",this._container),a.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=Ir,e.ImageSource=q,e.KeyboardHandler=mo,e.LngLatBounds=G,e.LogoControl=Fo,e.Map=class extends Po{constructor(e){var i,n;t.cw.mark(t.cx.create);const r=Object.assign(Object.assign(Object.assign({},Ho),e),{canvasContextAttributes:Object.assign(Object.assign({},Ho.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Ft,s=new zt;if(void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),super(o,s,{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new ko,this._controls=[],this._mapId=t.a7(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},jo),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this.transformCameraUpdate=r.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=f.addThrottleControl(()=>this.isMoving()),this._requestManager=new m(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Br(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Mo(this,r),this._hash=r.hash&&new Ir("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const a="string"==typeof r.style||!("globe"===(null===(n=null===(i=r.style)||void 0===i?void 0:i.projection)||void 0===n?void 0:n.type));this.resize(null,a),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new Lo("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Fo,r.logoPosition),this.on("style.load",()=>{if(a||this._resizeTransform(),this.transform.unmodified){const e=t.Q(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){const[n,r]=this._containerDimensions(),o=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,o),this.painter.resize(n,r,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,t),this.painter.resize(n,r,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(G.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),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.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.S.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new Ur(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new Ur(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new Ur(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const n=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:e)||{},o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new bi(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(null===(n=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new bi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const n=this._requestManager.transformRequest(e,"Style");t.j(n,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.sourceCaches[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.sourceCaches[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new zo(this.painter,i,e),this.painter.renderToTexture=new Vo(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.sourceCache.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=me(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.sourceCaches)this.style.sourceCaches[i].getSource().calculateTileZoom=me(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.sourceCaches[e];if(!n)throw new Error(`There is no source cache with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.a4(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(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`")));{const{width:n,height:s,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:s},new Uint8Array(d)),pixelRatio:r,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=s.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:a,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?s.getImageData(i):i,{width:o,height:a,data:l}=r;if(void 0===o||void 0===a)return this.fire(new t.k(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`")));if(o!==n.data.width||a!==n.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return f.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=a.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=a.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=a.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=a.create("div",`maplibregl-ctrl-${e} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Sr(i,this.transform),l.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(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)}_render(e){var i,n,r,o,a;const l=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=s.now();this.style.zoomHistory.update(e,i);const n=new t.F(e,{now:i,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(u=!0,this._crossFadingFactor=r),this.style.update(n)}const h=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==c;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(a=this.style.projection)||void 0===a?void 0:a.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cw.mark(t.cx.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cw.mark(t.cx.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),f.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),a.remove(this._canvasContainer),a.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cw.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,s.frame(this._frameRequest,e=>{t.cw.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cy(e)&&!function(e){return e.message===$n}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=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 version(){return Go}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Ur,e.MapTouchEvent=Nr,e.MapWheelEvent=Vr,e.Marker=Xo,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},Qo,e),this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),a.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),a.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=a.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new $o(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){a.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=a.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&a.remove(this._content),this._container&&(a.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=a.create("div","maplibregl-popup",this._map.getContainer()),this._tip=a.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=Wo(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const n=ss(this.options.offset);if(!i){const e=this._container.offsetWidth,r=this._container.offsetHeight;let o;o=t.y+n.bottom.ythis._map.transform.height-r?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let r=t.add(n[i]);this.options.subpixelPositioning||(r=r.round()),a.setTransform(this._container,`${qo[i]} translate(${r.x}px,${r.y}px)`),Ko(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(rs),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.S.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=a.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=a.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(os);e&&e.focus()}},e.RasterDEMTileSource=Z,e.RasterTileSource=$,e.ScaleControl=class{constructor(e){this._onMove=()=>{is(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,is(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ts),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){a.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=yo,e.Style=bi,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=a.create("button","maplibregl-ctrl-terrain",this._container),a.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){a.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=po,e.TwoFingersTouchRotateHandler=uo,e.TwoFingersTouchZoomHandler=lo,e.TwoFingersTouchZoomRotateHandler=Eo,e.VectorTileSource=Q,e.VideoSource=K,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(Y(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{J[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=L;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(M),L=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()"))},e.createTileMesh=qt,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ne().getRTLTextPluginStatus()},e.getVersion=function(){return as},e.getWorkerCount=function(){return P.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return O().broadcast("IS",e)},e.prewarm=function(){k().acquire(M)},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setRTLTextPlugin=function(e,t){return ne().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){P.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var n=e;return n}();var iJ=He(tJ.exports);const nJ="function"==typeof Buffer,rJ=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder&&new TextEncoder,Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=")),oJ=(()=>{let e={};return rJ.forEach((t,i)=>e[t]=i),e})(),sJ=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,aJ=String.fromCharCode.bind(String),lJ=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),e=>e.replace(/=/g,"").replace(/[+\/]/g,e=>"+"==e?"-":"_")),cJ=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),uJ=e=>{let t,i,n,r,o="";const s=e.length%3;for(let s=0;s255||(n=e.charCodeAt(s++))>255||(r=e.charCodeAt(s++))>255)throw new TypeError("invalid character found");t=i<<16|n<<8|r,o+=rJ[t>>18&63]+rJ[t>>12&63]+rJ[t>>6&63]+rJ[63&t]}return s?o.slice(0,s-3)+"===".substring(s):o},hJ="function"==typeof btoa?e=>btoa(e):nJ?e=>Buffer.from(e,"binary").toString("base64"):uJ,dJ=nJ?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let i=0,n=e.length;it?lJ(dJ(e)):dJ(e),fJ=e=>{if(e=e.replace(/\s+/g,""),!sJ.test(e))throw new TypeError("malformed base64.");let t,i,n;e+="==".slice(2-(3&e.length));let r=[];for(let o=0;o>16&255)):64===n?r.push(aJ(t>>16&255,t>>8&255)):r.push(aJ(t>>16&255,t>>8&255,255&t));return r.join("")},mJ=pJ;var gJ,_J={exports:{}},AJ="object"==typeof Reflect?Reflect:null,yJ=AJ&&"function"==typeof AJ.apply?AJ.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)};gJ=AJ&&"function"==typeof AJ.ownKeys?AJ.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var vJ=Number.isNaN||function(e){return e!=e};function xJ(){xJ.init.call(this)}_J.exports=xJ,_J.exports.once=function(e,t){return new Promise(function(i,n){function r(i){e.removeListener(t,o),n(i)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",r),i([].slice.call(arguments))}PJ(e,t,o,{once:!0}),"error"!==t&&function(e,t,i){"function"==typeof e.on&&PJ(e,"error",t,i)}(e,r,{once:!0})})},xJ.EventEmitter=xJ,xJ.prototype._events=void 0,xJ.prototype._eventsCount=0,xJ.prototype._maxListeners=void 0;var bJ=10;function wJ(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function TJ(e){return void 0===e._maxListeners?xJ.defaultMaxListeners:e._maxListeners}function EJ(e,t,i,n){var r,o,s,a;if(wJ(i),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,i.listener?i.listener:i),o=e._events),s=o[t]),void 0===s)s=o[t]=i,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[i,s]:[s,i]:n?s.unshift(i):s.push(i),(r=TJ(e))>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,a=l,console&&console.warn&&console.warn(a)}return e}function CJ(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function SJ(e,t,i){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:i},r=CJ.bind(n);return r.listener=i,n.wrapFn=r,r}function BJ(e,t,i){var n=e._events;if(void 0===n)return[];var r=n[t];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(e){for(var t=new Array(e.length),i=0;i0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=r[e];if(void 0===a)return!1;if("function"==typeof a)yJ(a,this,t);else{var l=a.length,c=MJ(a,l);for(i=0;i=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,r=o;break}if(r<0)return this;0===r?i.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},xJ.prototype.listeners=function(e){return BJ(this,e,!0)},xJ.prototype.rawListeners=function(e){return BJ(this,e,!1)},xJ.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):IJ.call(e,t)},xJ.prototype.listenerCount=IJ,xJ.prototype.eventNames=function(){return this._eventsCount>0?gJ(this._events):[]};var RJ=_J.exports;class LJ extends Map{#e=0;#t=new Map;#i=new Map;#n;#r;#o;constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.#n=e.maxSize,this.#r=e.maxAge||Number.POSITIVE_INFINITY,this.#o=e.onEviction}get __oldCache(){return this.#i}#s(e){if("function"==typeof this.#o)for(const[t,i]of e)this.#o(t,i.value)}#a(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.#o&&this.#o(e,t.value),this.delete(e))}#l(e,t){if(!1===this.#a(e,t))return t.value}#c(e,t){return t.expiry?this.#l(e,t):t.value}#u(e,t){const i=t.get(e);return this.#c(e,i)}#h(e,t){this.#t.set(e,t),this.#e++,this.#e>=this.#n&&(this.#e=0,this.#s(this.#i),this.#i=this.#t,this.#t=new Map)}#d(e,t){this.#i.delete(e),this.#h(e,t)}*#p(){for(const e of this.#i){const[t,i]=e;if(!this.#t.has(t)){!1===this.#a(t,i)&&(yield e)}}for(const e of this.#t){const[t,i]=e;!1===this.#a(t,i)&&(yield e)}}get(e){if(this.#t.has(e)){const t=this.#t.get(e);return this.#c(e,t)}if(this.#i.has(e)){const t=this.#i.get(e);if(!1===this.#a(e,t))return this.#d(e,t),t.value}}set(e,t,{maxAge:i=this.#r}={}){const n="number"==typeof i&&i!==Number.POSITIVE_INFINITY?Date.now()+i:void 0;return this.#t.has(e)?this.#t.set(e,{value:t,expiry:n}):this.#h(e,{value:t,expiry:n}),this}has(e){return this.#t.has(e)?!this.#a(e,this.#t.get(e)):!!this.#i.has(e)&&!this.#a(e,this.#i.get(e))}peek(e){return this.#t.has(e)?this.#u(e,this.#t):this.#i.has(e)?this.#u(e,this.#i):void 0}expiresIn(e){const t=this.#t.get(e)??this.#i.get(e);if(t)return t.expiry?t.expiry-Date.now():Number.POSITIVE_INFINITY}delete(e){const t=this.#t.delete(e);return t&&this.#e--,this.#i.delete(e)||t}clear(){this.#t.clear(),this.#i.clear(),this.#e=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this.#p()],i=t.length-e;i<0?(this.#t=new Map(t),this.#i=new Map,this.#e=t.length):(i>0&&this.#s(t.slice(0,i)),this.#i=new Map(t.slice(i)),this.#t=new Map,this.#e=0),this.#n=e}evict(e=1){const t=Number(e);if(!t||t<=0)return;const i=[...this.#p()],n=Math.trunc(Math.min(t,Math.max(i.length-1,0)));n<=0||(this.#s(i.slice(0,n)),this.#i=new Map(i.slice(n)),this.#t=new Map,this.#e=0)}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.#t){const[t,i]=e;!1===this.#a(t,i)&&(yield[t,i.value])}for(const e of this.#i){const[t,i]=e;if(!this.#t.has(t)){!1===this.#a(t,i)&&(yield[t,i.value])}}}*entriesDescending(){let e=[...this.#t];for(let t=e.length-1;t>=0;--t){const i=e[t],[n,r]=i;!1===this.#a(n,r)&&(yield[n,r.value])}e=[...this.#i];for(let t=e.length-1;t>=0;--t){const i=e[t],[n,r]=i;if(!this.#t.has(n)){!1===this.#a(n,r)&&(yield[n,r.value])}}}*entriesAscending(){for(const[e,t]of this.#p())yield[e,t.value]}get size(){if(!this.#e)return this.#i.size;let e=0;for(const t of this.#i.keys())this.#t.has(t)||e++;return Math.min(this.#e+e,this.#n)}get maxSize(){return this.#n}get maxAge(){return this.#r}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[i,n]of this.entriesAscending())e.call(t,n,i,this)}get[Symbol.toStringTag](){return"QuickLRU"}toString(){return`QuickLRU(${this.size}/${this.maxSize})`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}const FJ=new class{constructor(){this._apiKey="",this._fetch="undefined"!=typeof self?fetch.bind(self):"undefined"!=typeof global&&global.fetch?global.fetch:null,this.tileCacheSize=200}set apiKey(e){this._apiKey=e}get apiKey(){return this._apiKey}set fetch(e){this._fetch=e}get fetch(){return this._fetch}},kJ={AUTO:{code:null,flag:"auto",name:"Auto",latin:!1,isMode:!0,geocoding:!0},LATIN:{code:"latin",flag:"name:latin",name:"Latin",latin:!0,isMode:!1,geocoding:!1},NON_LATIN:{code:"nonlatin",flag:"name:nonlatin",name:"Non Latin",latin:!1,isMode:!1,geocoding:!1},LOCAL:{code:null,flag:"name",name:"Local",latin:!0,isMode:!1,geocoding:!1},ALBANIAN:{code:"sq",flag:"name:sq",name:"Albanian",latin:!0,isMode:!1,geocoding:!0},AMHARIC:{code:"am",flag:"name:am",name:"Amharic",latin:!1,isMode:!1,geocoding:!0},ARABIC:{code:"ar",flag:"name:ar",name:"Arabic",latin:!1,isMode:!1,geocoding:!0},ARMENIAN:{code:"hy",flag:"name:hy",name:"Armenian",latin:!1,isMode:!1,geocoding:!0},AZERBAIJANI:{code:"az",flag:"name:az",name:"Azerbaijani",latin:!0,isMode:!1,geocoding:!0},BASQUE:{code:"eu",flag:"name:eu",name:"Basque",latin:!0,isMode:!1,geocoding:!0},BELARUSIAN:{code:"be",flag:"name:be",name:"Belarusian",latin:!1,isMode:!1,geocoding:!0},BENGALI:{code:"bn",flag:"name:bn",name:"Bengali",latin:!0,isMode:!1,geocoding:!0},BOSNIAN:{code:"bs",flag:"name:bs",name:"Bosnian",latin:!0,isMode:!1,geocoding:!0},BRETON:{code:"br",flag:"name:br",name:"Breton",latin:!0,isMode:!1,geocoding:!0},BULGARIAN:{code:"bg",flag:"bg",name:"Bulgarian",latin:!1,isMode:!1,geocoding:!0},CATALAN:{code:"ca",flag:"name:ca",name:"Catalan",latin:!0,isMode:!1,geocoding:!0},CHINESE:{code:"zh",flag:"name:zh",name:"Chinese",latin:!1,isMode:!1,geocoding:!0},TRADITIONAL_CHINESE:{code:"zh-Hant",flag:"name:zh-Hant",name:"Chinese (traditional)",latin:!1,isMode:!1,geocoding:!1},SIMPLIFIED_CHINESE:{code:"zh-Hans",flag:"name:zh-Hans",name:"Chinese (simplified)",latin:!1,isMode:!1,geocoding:!1},CORSICAN:{code:"co",flag:"name:co",name:"Corsican",latin:!0,isMode:!1,geocoding:!0},CROATIAN:{code:"hr",flag:"name:hr",name:"Croatian",latin:!0,isMode:!1,geocoding:!0},CZECH:{code:"cs",flag:"name:cs",name:"Czech",latin:!0,isMode:!1,geocoding:!0},DANISH:{code:"da",flag:"name:da",name:"Danish",latin:!0,isMode:!1,geocoding:!0},DUTCH:{code:"nl",flag:"name:nl",name:"Dutch",latin:!0,isMode:!1,geocoding:!0},GERMAN:{code:"de",flag:"name:de",name:"German",latin:!0,isMode:!1,geocoding:!0},GREEK:{code:"el",flag:"name:el",name:"Greek",latin:!1,isMode:!1,geocoding:!0},ENGLISH:{code:"en",flag:"name:en",name:"English",latin:!0,isMode:!1,geocoding:!0},ESPERANTO:{code:"eo",flag:"name:eo",name:"Esperanto",latin:!0,isMode:!1,geocoding:!0},ESTONIAN:{code:"et",flag:"name:et",name:"Estonian",latin:!0,isMode:!1,geocoding:!0},FINNISH:{code:"fi",flag:"name:fi",name:"Finnish",latin:!0,isMode:!1,geocoding:!0},FRENCH:{code:"fr",flag:"name:fr",name:"French",latin:!0,isMode:!1,geocoding:!0},FRISIAN:{code:"fy",flag:"name:fy",name:"Frisian (West)",latin:!0,isMode:!1,geocoding:!0},GEORGIAN:{code:"ka",flag:"name:ka",name:"Georgian",latin:!1,isMode:!1,geocoding:!0},HEBREW:{code:"he",flag:"name:he",name:"Hebrew",latin:!1,isMode:!1,geocoding:!0},HINDI:{code:"hi",flag:"name:hi",name:"Hindi",latin:!1,isMode:!1,geocoding:!0},HUNGARIAN:{code:"hu",flag:"name:hu",name:"Hungarian",latin:!0,isMode:!1,geocoding:!0},ICELANDIC:{code:"is",flag:"name:is",name:"Icelandic",latin:!0,isMode:!1,geocoding:!0},INDONESIAN:{code:"id",flag:"name:id",name:"Indonesian",latin:!0,isMode:!1,geocoding:!0},IRISH:{code:"ga",flag:"name:ga",name:"Irish",latin:!0,isMode:!1,geocoding:!0},ITALIAN:{code:"it",flag:"name:it",name:"Italian",latin:!0,isMode:!1,geocoding:!0},JAPANESE:{code:"ja",flag:"name:ja",name:"Japanese",latin:!1,isMode:!1,geocoding:!0},JAPANESE_HIRAGANA:{code:"ja-Hira",flag:"name:ja-Hira",name:"Japanese Hiragana form",latin:!1,isMode:!1,geocoding:!1},JAPANESE_2018:{code:"ja-Latn",flag:"name:ja-Latn",name:"Japanese (Latin 2018)",latin:!0,isMode:!1,geocoding:!1},JAPANESE_KANA:{code:"ja_kana",flag:"name:ja_kana",name:"Japanese (Kana)",latin:!1,isMode:!1,geocoding:!1},JAPANESE_LATIN:{code:"ja_rm",flag:"name:ja_rm",name:"Japanese (Latin script)",latin:!0,isMode:!1,geocoding:!1},KANNADA:{code:"kn",flag:"name:kn",name:"Kannada",latin:!0,isMode:!1,geocoding:!0},KAZAKH:{code:"kk",flag:"name:kk",name:"Kazakh",latin:!1,isMode:!1,geocoding:!0},KOREAN:{code:"ko",flag:"name:ko",name:"Korean",latin:!1,isMode:!1,geocoding:!0},KOREAN_LATIN:{code:"ko-Latn",flag:"name:ko-Latn",name:"Korean (Latin script)",latin:!0,isMode:!1,geocoding:!1},KURDISH:{code:"ku",flag:"name:ku",name:"Kurdish",latin:!0,isMode:!1,geocoding:!0},CLASSICAL_LATIN:{code:"la",flag:"name:la",name:"Latin",latin:!0,isMode:!1,geocoding:!0},LATVIAN:{code:"lv",flag:"name:lv",name:"Latvian",latin:!0,isMode:!1,geocoding:!0},LITHUANIAN:{code:"lt",flag:"name:lt",name:"Lithuanian",latin:!0,isMode:!1,geocoding:!0},LUXEMBOURGISH:{code:"lb",flag:"name:lb",name:"Luxembourgish",latin:!0,isMode:!1,geocoding:!0},MACEDONIAN:{code:"mk",flag:"name:mk",name:"Macedonian",latin:!1,isMode:!1,geocoding:!0},MALAYALAM:{code:"ml",flag:"name:ml",name:"Malayalam",latin:!1,isMode:!1,geocoding:!0},MALTESE:{code:"mt",flag:"name:mt",name:"Maltese",latin:!0,isMode:!1,geocoding:!0},NORWEGIAN:{code:"no",flag:"name:no",name:"Norwegian",latin:!0,isMode:!1,geocoding:!0},OCCITAN:{code:"oc",flag:"name:oc",name:"Occitan",latin:!0,isMode:!1,geocoding:!0},PERSIAN:{code:"fa",flag:"name:fa",name:"Persian",latin:!1,isMode:!1,geocoding:!0},POLISH:{code:"pl",flag:"name:pl",name:"Polish",latin:!0,isMode:!1,geocoding:!0},PORTUGUESE:{code:"pt",flag:"name:pt",name:"Portuguese",latin:!0,isMode:!1,geocoding:!0},PUNJABI:{code:"pa",flag:"name:pa",name:"Punjabi",latin:!1,isMode:!1,geocoding:!0},WESTERN_PUNJABI:{code:"pnb",flag:"name:pnb",name:"Western Punjabi",latin:!1,isMode:!1,geocoding:!1},ROMANIAN:{code:"ro",flag:"name:ro",name:"Romanian",latin:!0,isMode:!1,geocoding:!0},ROMANSH:{code:"rm",flag:"name:rm",name:"Romansh",latin:!0,isMode:!1,geocoding:!0},RUSSIAN:{code:"ru",flag:"name:ru",name:"Russian",latin:!1,isMode:!1,geocoding:!0},SERBIAN_CYRILLIC:{code:"sr",flag:"name:sr",name:"Serbian (Cyrillic script)",latin:!1,isMode:!1,geocoding:!0},SERBIAN_LATIN:{code:"sr-Latn",flag:"name:sr-Latn",name:"Serbian (Latin script)",latin:!0,isMode:!1,geocoding:!1},SCOTTISH_GAELIC:{code:"gd",flag:"name:gd",name:"Scottish Gaelic",latin:!0,isMode:!1,geocoding:!0},SLOVAK:{code:"sk",flag:"name:sk",name:"Slovak",latin:!0,isMode:!1,geocoding:!0},SLOVENE:{code:"sl",flag:"name:sl",name:"Slovene",latin:!0,isMode:!1,geocoding:!0},SPANISH:{code:"es",flag:"name:es",name:"Spanish",latin:!0,isMode:!1,geocoding:!0},SWEDISH:{code:"sv",flag:"name:sv",name:"Swedish",latin:!0,isMode:!1,geocoding:!0},TAMIL:{code:"ta",flag:"name:ta",name:"Tamil",latin:!1,isMode:!1,geocoding:!0},TELUGU:{code:"te",flag:"name:te",name:"Telugu",latin:!1,isMode:!1,geocoding:!0},THAI:{code:"th",flag:"name:th",name:"Thai",latin:!1,isMode:!1,geocoding:!0},TURKISH:{code:"tr",flag:"name:tr",name:"Turkish",latin:!0,isMode:!1,geocoding:!0},UKRAINIAN:{code:"uk",flag:"name:uk",name:"Ukrainian",latin:!1,isMode:!1,geocoding:!0},VIETNAMESE:{code:"vi",flag:"name:vi",name:"Vietnamese (Latin script)",latin:!0,isMode:!1,geocoding:!0},WELSH:{code:"cy",flag:"name:cy",name:"Welsh",latin:!0,isMode:!1,geocoding:!0}};function DJ(e,t=kJ){return e in t?e[e]:null}function OJ(e,t=kJ){for(const i of Object.values(t))if(i.code===e)return i;return null}function zJ(e,t=kJ){for(const i of Object.values(t))if(i.flag===e)return i;return null}function UJ(){if("undefined"==typeof navigator){return OJ(Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0])??kJ.ENGLISH}const e=Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>OJ(e)).filter(e=>e);return e[0]??kJ.ENGLISH}function NJ(e){return null!==e&&"object"==typeof e&&"code"in e&&"flag"in e&&"name"in e&&"latin"in e&&"isMode"in e&&"geocoding"in e&&("string"==typeof e.code||null===e.code)&&"string"==typeof e.flag&&"string"==typeof e.name&&"boolean"==typeof e.latin&&"boolean"==typeof e.isMode&&"boolean"==typeof e.geocoding}function VJ(e,t=kJ){return NJ(e)?zJ(e.flag,t):"string"!=typeof e?null:DJ(e,t)||OJ(e,t)||zJ(e,t)||null}async function jJ(e,t={}){if(null===FJ.fetch)throw new Error("The fetch function was not found. If on NodeJS < 18 please specify the fetch function with config.fetch");if(""===new URL(e).searchParams.get("key").trim())throw new Error("The MapTiler Cloud API key is missing. Set it in `config.apiKey` or get one for free at https://maptiler.com");return FJ.fetch(e,t)}const GJ={maptilerApiURL:"https://api.maptiler.com/",mapStyle:"streets-v2"};Object.freeze(GJ);class HJ extends Error{constructor(e,t=""){super(`Call to enpoint ${e.url} failed with the status code ${e.status}. ${t}`),this.res=e}}const QJ={400:"Query too long / Invalid parameters",403:"Key is missing, invalid or restricted"};function $J(e,t){const{language:i}=t;if(void 0===i)return;const n=(Array.isArray(i)?i:[i]).map(e=>function(e){const t=e===kJ.AUTO.flag?UJ():"string"==typeof e?OJ(e):NJ(e)?e.flag===kJ.AUTO.flag?UJ():zJ(e.flag):null;return t?.geocoding?t.code:null}(e)).filter(e=>e),r=Array.from(new Set(n)).join(",");e.set("language",r)}function ZJ(e,t){const{apiKey:i,limit:n,types:r,excludeTypes:o}=t;e.set("key",i??FJ.apiKey),void 0!==n&&e.set("limit",String(n)),void 0!==r&&e.set("types",r.join(",")),void 0!==o&&e.set("excludeTypes",String(o)),$J(e,t)}function WJ(e,t){ZJ(e,t);const{bbox:i,proximity:n,country:r,fuzzyMatch:o,autocomplete:s}=t;void 0!==i&&e.set("bbox",i.join(",")),void 0!==n&&e.set("proximity","ip"===n?n:n.join(",")),void 0!==r&&e.set("country",r.join(",")),void 0!==o&&e.set("fuzzyMatch",o?"true":"false"),void 0!==s&&e.set("autocomplete",s?"true":"false")}const qJ={forward:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The query must be a non-empty string");const i=new URL(`geocoding/${encodeURIComponent(e)}.json`,GJ.maptilerApiURL);WJ(i.searchParams,t);const n=await jJ(i.toString());if(!n.ok)throw new HJ(n,QJ[n.status]??"");return await n.json()},reverse:async function(e,t={}){if(!Array.isArray(e)||e.length<2)throw new Error("The position must be an array of form [lng, lat].");const i=new URL(`geocoding/${e[0]},${e[1]}.json`,GJ.maptilerApiURL);ZJ(i.searchParams,t);const n=await jJ(i.toString());if(!n.ok)throw new HJ(n,QJ[n.status]??"");return await n.json()},byId:async function(e,t={}){const i=new URL(`geocoding/${e}.json`,GJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??FJ.apiKey),$J(i.searchParams,t);const n=await jJ(i.toString());if(!n.ok)throw new HJ(n,QJ[n.status]??"");return await n.json()},batch:async function(e,t={}){if(!e.length)return[];const i=e.map(e=>encodeURIComponent(e)).join(";"),n=new URL(`geocoding/${i}.json`,GJ.maptilerApiURL);WJ(n.searchParams,t);const r=await jJ(n.toString());if(!r.ok)throw new HJ(r,QJ[r.status]??"");const o=await r.json();return 1===e.length?[o]:o}},KJ={403:"Key is missing, invalid or restricted"};const XJ={info:async function(e={}){const t=new URL("geolocation/ip.json",GJ.maptilerApiURL);t.searchParams.set("key",e.apiKey??FJ.apiKey),"elevation"in e&&t.searchParams.set("elevation",e.elevation?"true":"false");const i=t.toString(),n=await jJ(i);if(!n.ok)throw new HJ(n,n.status in KJ?KJ[n.status]:"");return await n.json()}},JJ={403:"Key is missing, invalid or restricted"};const YJ={search:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The query must be a non-empty string");const i=new URL(`coordinates/search/${e}.json`,GJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??FJ.apiKey),"limit"in t&&i.searchParams.set("limit",t.limit.toString()),"transformations"in t&&i.searchParams.set("transformations",t.transformations.toString()),"exports"in t&&i.searchParams.set("exports",t.exports.toString());const n=i.toString(),r=await jJ(n);if(!r.ok)throw new HJ(r,r.status in JJ?JJ[r.status]:"");return await r.json()},transform:async function(e,t={}){const i=(Array.isArray(e[0])?e:[e]).map(e=>`${e[0]},${e[1]}`).join(";"),n=new URL(`coordinates/transform/${i}.json`,GJ.maptilerApiURL);n.searchParams.set("key",t.apiKey??FJ.apiKey),"sourceCrs"in t&&n.searchParams.set("s_srs",t.sourceCrs.toString()),"targetCrs"in t&&n.searchParams.set("t_srs",t.targetCrs.toString()),"operations"in t&&n.searchParams.set("ops",(Array.isArray(t.operations)?t.operations:[t.operations]).join("|"));const r=n.toString(),o=await jJ(r);if(!o.ok)throw new HJ(o,o.status in JJ?JJ[o.status]:"");return await o.json()}},eY={403:"Key is missing, invalid or restricted"};const tY={get:async function(e,t={}){if("string"!=typeof e||0===e.trim().length)throw new Error("The data ID must be a non-empty string");const i=new URL(`data/${encodeURIComponent(e)}/features.json`,GJ.maptilerApiURL);i.searchParams.set("key",t.apiKey??FJ.apiKey);const n=i.toString(),r=await jJ(n);if(!r.ok)throw new HJ(r,r.status in eY?eY[r.status]:"");return await r.json()}};function iY(e){let t;const i=e.trim();let n;return n=i.startsWith("http://")||i.startsWith("https://")?i:null!==(t=/^maptiler:\/\/(.*)/.exec(i))?`https://api.maptiler.com/maps/${t[1]}/style.json`:`https://api.maptiler.com/maps/${i}/style.json`,n}class nY{constructor(e,t,i,n,r,o,s=!1,a){this.name=e,this.variantType=t,this.id=i,this.referenceStyle=n,this.description=r,this.imageURL=o,this.deprecated=s,this.deprecationMessage=a}getName(){return this.name}getFullName(){return`${this.referenceStyle.getName()} ${this.name}`}getType(){return this.variantType}getId(){return this.id}getDescription(){return this.description}getReferenceStyle(){return this.referenceStyle}hasVariant(e){return this.referenceStyle.hasVariant(e)}getVariant(e){const t=this.referenceStyle.getVariant(e);return this.warnIfDeprecated(t),t}getVariants(){return this.referenceStyle.getVariants().filter(e=>e!==this).map(e=>(this.warnIfDeprecated(e),e))}getImageURL(){return this.imageURL}getExpandedStyleURL(){return iY(this.getId())}warnIfDeprecated(e=this){if(!e.deprecated)return e;if(e.deprecationMessage)console.warn(e.deprecationMessage);else{const t=e.getFullName();console.warn(`Style "${t}" is deprecated and will be removed in a future version.`)}return e}}class rY{constructor(e,t){this.name=e,this.id=t,this.variants={},this.orderedVariants=[]}getName(){return this.name}getId(){return this.id}addVariant(e){this.variants[e.getType()]=e,this.orderedVariants.push(e)}hasVariant(e){return e in this.variants}getVariant(e){return e in this.variants?this.variants[e]:this.orderedVariants[0]}getVariants(){return Object.values(this.variants)}getDefaultVariant(){return this.orderedVariants[0].warnIfDeprecated()}}const oY=[{referenceStyleID:"STREETS_V2",name:"Streets",description:"",variants:[{id:"streets-v2",name:"Default v2",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2" is deprecated, use "streets-v4" instead'},{id:"streets-v2-dark",name:"Dark v2",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-dark" is deprecated, use "streets-v4-dark" instead'},{id:"streets-v2-light",name:"Light v2",variantType:"LIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-light" is deprecated, use "streets-v4-light" instead'},{id:"streets-v2-night",name:"Night v2",variantType:"NIGHT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-night" is deprecated, use "streets-v4-night" instead'},{id:"streets-v2-pastel",name:"Pastel v2",variantType:"PASTEL",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"streets-v2-pastel" is deprecated, use "streets-v4-pastel" instead'}]},{referenceStyleID:"STREETS_V4",name:"Streets",description:"",variants:[{id:"streets-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"streets-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"streets-v4-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"BASE_V4",name:"Base",description:"",variants:[{id:"base-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"base-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"base-v4-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"base-v4-ai",name:"Base AI",variantType:"NIGHT",description:"",imageURL:""}]},{referenceStyleID:"OUTDOOR",name:"Outdoor",description:"",variants:[{id:"outdoor-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"outdoor-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"WINTER",name:"Winter",description:"",variants:[{id:"winter-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"winter-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""}]},{referenceStyleID:"SATELLITE",name:"Satellite",description:"",variants:[{id:"satellite",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"HYBRID",name:"Hybrid",description:"",variants:[{id:"hybrid",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"BASIC_V2",name:"Basic",description:"",variants:[{id:"basic-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"basic-v2" is deprecated, use "basic-v4" instead'},{id:"basic-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"basic-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BRIGHT",name:"Bright",description:"",variants:[{id:"bright-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"bright-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"bright-v2-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""},{id:"bright-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""}]},{referenceStyleID:"OPENSTREETMAP",name:"OpenStreetMap",description:"",variants:[{id:"openstreetmap",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"TOPO",name:"Topo",description:"",variants:[{id:"topo-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"topo-v2-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"topo-v2-shiny",name:"Shiny",deprecated:!0,variantType:"SHINY",description:"",imageURL:""},{id:"topo-v2-pastel",name:"Pastel",variantType:"PASTEL",description:"",imageURL:""},{id:"topo-v2-topographique",name:"Topographique",variantType:"TOPOGRAPHIQUE",description:"",imageURL:""}]},{referenceStyleID:"VOYAGER",name:"Voyager",description:"",variants:[{id:"voyager-v2",name:"Default",deprecated:!0,variantType:"DEFAULT",description:"",imageURL:""},{id:"voyager-v2-darkmatter",name:"Darkmatter",deprecated:!0,variantType:"DARK",description:"",imageURL:""},{id:"voyager-v2-positron",name:"Positron",deprecated:!0,variantType:"LIGHT",description:"",imageURL:""},{id:"voyager-v2-vintage",name:"Vintage",deprecated:!0,variantType:"VINTAGE",description:"",imageURL:""}]},{referenceStyleID:"TONER",name:"Toner",description:"",variants:[{id:"toner-v2",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"toner-v2-background",name:"Background",variantType:"BACKGROUND",deprecated:!0,description:"",imageURL:""},{id:"toner-v2-lite",name:"Lite",variantType:"LITE",description:"",imageURL:""},{id:"toner-v2-lines",name:"Lines",variantType:"LINES",deprecated:!0,description:"",imageURL:""}]},{referenceStyleID:"DATAVIZ",name:"Dataviz",description:"",variants:[{id:"dataviz",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"dataviz-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"dataviz-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"BACKDROP",name:"Backdrop",description:"",variants:[{id:"backdrop",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"backdrop-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"backdrop-light",name:"Light",variantType:"LIGHT",description:"",imageURL:""}]},{referenceStyleID:"OCEAN",name:"Ocean",description:"",variants:[{id:"ocean",name:"Default",variantType:"DEFAULT",description:"",imageURL:""}]},{referenceStyleID:"AQUARELLE",name:"Aquarelle",description:"Watercolor map for creative use",variants:[{id:"aquarelle",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"aquarelle-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"aquarelle-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]},{referenceStyleID:"LANDSCAPE_V2",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape",name:"Default",variantType:"DEFAULT",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape" is deprecated, use "landscape-v4" instead'},{id:"landscape-dark",name:"Dark",variantType:"DARK",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-dark" is deprecated, use "landscape-v4-dark" instead'},{id:"landscape-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:"",deprecated:!0,deprecationMessage:'"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead'}]},{referenceStyleID:"LANDSCAPE_V4",name:"Landscape",description:"Terrain map for data overlays and visualisations",variants:[{id:"landscape-v4",name:"Default",variantType:"DEFAULT",description:"",imageURL:""},{id:"landscape-v4-dark",name:"Dark",variantType:"DARK",description:"",imageURL:""},{id:"landscape-v4-vivid",name:"Vivid",variantType:"VIVID",description:"",imageURL:""}]}];function sY(e){return new Proxy(e,{get(t,i,n){if(t.hasVariant(i))return t.getVariant(i);if(i.toString().toUpperCase()===i)return e.getDefaultVariant();return Reflect.get(t,i,n)}})}function aY(e){return e?"string"==typeof e||e instanceof String?e.trim().toLowerCase():e instanceof nY?e.getId():e instanceof rY?e.getDefaultVariant().getId():void 0:lY[oY[0].referenceStyleID].getDefaultVariant().getId()}Object.entries({STREETS:"STREETS_V2",BASIC:"BASIC_V2",LANDSCAPE:"LANDSCAPE_V2"}).forEach(([e,t])=>{!function(e,t){oY.find(t=>t.referenceStyleID===e)&&console.warn(`Default reference style ${e} already exists, it will be overwritten...`);const i=oY.find(e=>e.referenceStyleID===t);if(!i)throw new Error(`Versioned map style not found for reference style: ${t}`);const n={...i,referenceStyleID:e};oY.push(n)}(e,t)});const lY=function(){const e={};for(let t=0;t1?(n=i[0],r=i[1]):t>0&&(n+=o*t,r+=s*t)}return o=e[0]-n,s=e[1]-r,o*o+s*s}function uY(e,t,i,n,r){let o,s=n;for(let n=t+1;ns&&(o=n,s=r)}s>n&&(o-t>1&&uY(e,t,o,n,r),r.push(e[o]),i-o>1&&uY(e,o,i,n,r))}function hY(e,t){const i=e.length-1,n=[e[0]];return uY(e,0,i,t,n),n.push(e[i]),n}const dY={extractLineStrings:function(e){const t=[];function i(e){"LineString"!==e.type&&"MultiLineString"!==e.type||t.push(e)}function n(e){e.geometry&&i(e.geometry)}return"Feature"===e.type?n(e):"FeatureCollection"===e.type?function e(t){for(const i of t.features)"Feature"===i.type?n(i):"FeatureCollection"===i.type&&e(i)}(e):i(e),t},simplify:function(e,t){return e.length<=2?e:hY(e,void 0!==t?t*t:1)}};function pY(e,t=!0){let i=`${e[0]},${e[1]}`;return 3===e.length&&t&&(i+=`,${e[2]}`),i}function fY(e,t=3e3){let i=e.map(e=>e.join(",")).join("|"),n=5e-6;for(;i.length>t;){i=dY.simplify(e,n).map(e=>`${e[0]},${e[1]}`).join("|"),n+=1e-5}return i}const mY={centered:function(e,t,i={}){const n=aY(i.style),r=i.hiDPI?"@2x":"",o=i.format??"png";let s=~~(i.width??1024),a=~~(i.height??1024);i.hiDPI&&(s=~~(s/2),a=~~(a/2));const l=new URL(`maps/${encodeURIComponent(n)}/static/${e[0]},${e[1]},${t}/${s}x${a}${r}.${o}`,GJ.maptilerApiURL);if("attribution"in i&&l.searchParams.set("attribution",i.attribution.toString()),"markers"in i){let e="";const t="markerIcon"in i;t&&(e+=`icon:${i.markerIcon}|`),t&&"markerAnchor"in i&&(e+=`anchor:${i.markerAnchor}|`),t&&i.hiDPI&&(e+="scale:2|");e+=(Array.isArray(i.markers[0])?i.markers:[i.markers]).map(e=>pY(e,!t)).join("|"),l.searchParams.set("markers",e)}if("path"in i){let e="";if(e+=`fill:${i.pathFillColor??"none"}|`,"pathStrokeColor"in i&&(e+=`stroke:${i.pathStrokeColor}|`),"pathWidth"in i){e+=`width:${(i.pathWidth/(i.hiDPI?2:1)).toString()}|`}e+=fY(i.path),l.searchParams.set("path",e)}return l.searchParams.set("key",i.apiKey??FJ.apiKey),l.toString()},bounded:function(e,t={}){const i=aY(t.style),n=t.hiDPI?"@2x":"",r=t.format??"png";let o=~~(t.width??1024),s=~~(t.height??1024);t.hiDPI&&(o=~~(o/2),s=~~(s/2));const a=new URL(`maps/${encodeURIComponent(i)}/static/${e[0]},${e[1]},${e[2]},${e[3]}/${o}x${s}${n}.${r}`,GJ.maptilerApiURL);if("attribution"in t&&a.searchParams.set("attribution",t.attribution.toString()),"padding"in t&&a.searchParams.set("padding",t.padding.toString()),"markers"in t){let e="";const i="markerIcon"in t;i&&(e+=`icon:${t.markerIcon}|`),i&&"markerAnchor"in t&&(e+=`anchor:${t.markerAnchor}|`),i&&t.hiDPI&&(e+="scale:2|");e+=(Array.isArray(t.markers[0])?t.markers:[t.markers]).map(e=>pY(e,!i)).join("|"),a.searchParams.set("markers",e)}if("path"in t){let e="";if(e+=`fill:${t.pathFillColor??"none"}|`,"pathStrokeColor"in t&&(e+=`stroke:${t.pathStrokeColor}|`),"pathWidth"in t){e+=`width:${(t.pathWidth/(t.hiDPI?2:1)).toString()}|`}e+=fY(t.path),a.searchParams.set("path",e)}return a.searchParams.set("key",t.apiKey??FJ.apiKey),a.toString()},automatic:function(e={}){if(!("markers"in e)&&!("path"in e))throw new Error("Automatic static maps require markers and/or path to be created.");const t=aY(e.style),i=e.hiDPI?"@2x":"",n=e.format??"png";let r=~~(e.width??1024),o=~~(e.height??1024);e.hiDPI&&(r=~~(r/2),o=~~(o/2));const s=new URL(`maps/${encodeURIComponent(t)}/static/auto/${r}x${o}${i}.${n}`,GJ.maptilerApiURL);if("attribution"in e&&s.searchParams.set("attribution",e.attribution.toString()),"padding"in e&&s.searchParams.set("padding",e.padding.toString()),"markers"in e){let t="";const i="markerIcon"in e;i&&(t+=`icon:${e.markerIcon}|`),i&&"markerAnchor"in e&&(t+=`anchor:${e.markerAnchor}|`),i&&e.hiDPI&&(t+="scale:2|");t+=(Array.isArray(e.markers[0])?e.markers:[e.markers]).map(e=>pY(e,!i)).join("|"),s.searchParams.set("markers",t)}if("path"in e){let t="";if(t+=`fill:${e.pathFillColor??"none"}|`,"pathStrokeColor"in e&&(t+=`stroke:${e.pathStrokeColor}|`),"pathWidth"in e){t+=`width:${(e.pathWidth/(e.hiDPI?2:1)).toString()}|`}t+=fY(e.path),s.searchParams.set("path",t)}return s.searchParams.set("key",e.apiKey??FJ.apiKey),s.toString()}},gY=6371008.8,_Y=2*Math.PI*gY;function AY(e){return(180+e)/360}function yY(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function vY(e){const t=TY(e);return[AY(t[0]),yY(t[1])]}function xY(e){return 360*e-180}function bY(e){const t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function wY(e,t){const i=Math.PI/180,n=e[1]*i,r=t[1]*i,o=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((t[0]-e[0])*i);return gY*Math.acos(Math.min(o,1))}function TY(e){const t=((e[0]+180)%360+360)%360-180;return[-180===t?180:t,e[1]]}function EY(e){return _Y*Math.cos(e*Math.PI/180)}function CY(e,t,i=!0){const n=2**t,r=[e[0]*n,e[1]*n];return i?[~~r[0],~~r[1]]:r}function SY(e){return e*Math.PI/180}function BY(e){return 180*e/Math.PI}const IY={EARTH_RADIUS:gY,EARTH_CIRCUMFERENCE:_Y,longitudeToMercatorX:AY,latitudeToMercatorY:yY,wgs84ToMercator:vY,mercatorXToLongitude:xY,mercatorYToLatitude:bY,mercatorToWgs84:function(e){return[xY(e[0]),bY(e[1])]},haversineDistanceWgs84:wY,wrapWgs84:TY,circumferenceAtLatitude:EY,mercatorToTileIndex:CY,wgs84ToTileIndex:function(e,t,i=!0){return CY(vY(e),t,i)},toRadians:SY,toDegrees:BY,haversineIntermediateWgs84:function(e,t,i){const n=wY(e,t),r=SY(e[0]),o=SY(e[1]),s=SY(t[0]),a=SY(t[1]),l=n/gY,c=Math.sin((1-i)*l)/Math.sin(l),u=Math.sin(i*l)/Math.sin(l),h=c*Math.cos(o)*Math.cos(r)+u*Math.cos(a)*Math.cos(s),d=c*Math.cos(o)*Math.sin(r)+u*Math.cos(a)*Math.sin(s),p=c*Math.sin(o)+u*Math.sin(a),f=Math.atan2(p,Math.sqrt(h*h+d*d));return[BY(Math.atan2(d,h)),BY(f)]},haversineCumulatedDistanceWgs84:function(e){const t=Array(e.length);t[0]=0;const i=t.length;for(let n=1;ns||a<0)&&(a=s);const l=e.map(e=>IY.wgs84ToTileIndex(e,a,!1)),c=l.map(e=>[~~e[0],~~e[1]]),u=c.map(e=>`terrain_${a.toString()}_${e[0].toString()}_${e[1].toString()}`),h=Array.from(new Set(u.filter(e=>!o.has(e)))).map(e=>e.split("_").slice(1)),d=h.map(e=>r.replace("{x}",e[1].toString()).replace("{y}",e[2].toString()).replace("{z}",e[0].toString())).map(e=>jJ(e)),p=(await Promise.allSettled(d)).map(e=>"fulfilled"===e.status?e.value:null).filter(e=>e),f=p.filter(e=>!e.ok);if(p.length!==d.length)throw new Error("Some tiles could not be fetched.");if(f.length)throw new HJ(f[0],DY[f[0].status]??"");const m=await Promise.all(p.map(e=>e.arrayBuffer()));if(!m.every(e=>e.byteLength>0))throw new Error("Some tiles are not available.");(await Promise.all(m.map(e=>n(e)))).forEach((e,t)=>{const i=h[t],n=`terrain_${i[0].toString()}_${i[1].toString()}_${i[2].toString()}`;o.set(n,e)});const g=e.map((e,t)=>{const i=u[t],n=l[t],r=o.get(i),s=Math.min(Math.round(r.width*(n[0]%1)),r.width-1),a=(Math.min(Math.round(r.height*(n[1]%1)),r.height-1)*r.width+s)*r.components,c=.1*(256*r.pixels[a]*256+256*r.pixels[a+1]+r.pixels[a+2])-1e4;return[e[0],e[1],~~(1e3*c)/1e3]});return g}(e,i,t.zoom):await async function(e,t){e.length>1e3&&console.warn("Computing elevation for complex geometries is discouraged - simplify the geometry before proceeding");const i=Math.ceil(e.length/50),n=Array.from({length:i},()=>null).map((i,n)=>{const r=50*n,o=e.slice(r,r+50).map(e=>e.join(",")).join(";"),s=new URL(`elevation/${o}.json`,GJ.maptilerApiURL);return s.searchParams.set("key",t),jJ(s.toString())}),r=await Promise.allSettled(n);return(await Promise.all(r.map(async e=>{if("rejected"===e.status)throw new Error(`Some segments could not be fetched, error: ${e.reason}`);if(!e.value.ok)throw new Error(`Some segments could not be fetched, response: ${e.value.status} ${await e.value.text()}, url: ${e.value.url}`);return e.value.json()}))).flat()}(e,i);if(t.smoothingKernelSize){const e=2*~~(t.smoothingKernelSize/2)+1,i=n.map(e=>e[2]),r=~~(e/2);for(let t=r;te.length),r=i.coordinates.flat(),o=await OY(r,t),s=[];let a=0;for(const e of n)s.push(o.slice(a,a+e)),a+=e;return i.coordinates=s,i}},UY=[];for(let e=0;e<256;++e)UY.push((e+256).toString(16).slice(1));let NY;const VY=new Uint8Array(16);var jY={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};var GY=Object.defineProperty,HY=e=>{throw TypeError(e)},QY=(e,t,i)=>((e,t,i)=>t in e?GY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i),$Y=(e,t,i)=>t.has(e)||HY("Cannot "+i),ZY=(e,t,i)=>($Y(e,t,"read from private field"),i?i.call(e):t.get(e)),WY=(e,t,i)=>t.has(e)?HY("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),qY=(e,t,i,n)=>($Y(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),KY=(e,t,i)=>($Y(e,t,"access private method"),i);let XY=class extends iJ.Marker{addTo(e){return super.addTo(e)}};class JY extends iJ.Popup{addTo(e){return super.addTo(e)}}class YY extends iJ.Style{constructor(e,t={}){super(e,t)}}class e0 extends iJ.CanvasSource{onAdd(e){super.onAdd(e)}}class t0 extends iJ.GeoJSONSource{onAdd(e){super.onAdd(e)}}class i0 extends iJ.ImageSource{onAdd(e){super.onAdd(e)}}class n0 extends iJ.RasterTileSource{onAdd(e){super.onAdd(e)}}class r0 extends iJ.RasterDEMTileSource{onAdd(e){super.onAdd(e)}}class o0 extends iJ.VectorTileSource{onAdd(e){super.onAdd(e)}}class s0 extends iJ.VideoSource{onAdd(e){super.onAdd(e)}}class a0 extends iJ.NavigationControl{onAdd(e){return super.onAdd(e)}}class l0 extends iJ.GeolocateControl{onAdd(e){return super.onAdd(e)}}class c0 extends iJ.AttributionControl{onAdd(e){return super.onAdd(e)}}class u0 extends iJ.LogoControl{onAdd(e){return super.onAdd(e)}}class h0 extends iJ.ScaleControl{onAdd(e){return super.onAdd(e)}}class d0 extends iJ.FullscreenControl{onAdd(e){return super.onAdd(e)}}class p0 extends iJ.TerrainControl{onAdd(e){return super.onAdd(e)}}class f0 extends iJ.BoxZoomHandler{constructor(e,t){super(e,t)}}class m0 extends iJ.ScrollZoomHandler{constructor(e,t){super(e,t)}}class g0 extends iJ.CooperativeGesturesHandler{constructor(e,t){super(e,t)}}class _0 extends iJ.KeyboardHandler{constructor(e){super(e)}}class A0 extends iJ.TwoFingersTouchPitchHandler{constructor(e){super(e)}}class y0 extends iJ.MapWheelEvent{constructor(e,t,i){super(e,t,i)}}class v0 extends iJ.MapTouchEvent{constructor(e,t,i){super(e,t,i)}}class x0 extends iJ.MapMouseEvent{constructor(e,t,i,n={}){super(e,t,i,n)}}const b0={VISITOR:{code:null,flag:"visitor",name:"Visitor",latin:!0,isMode:!0,geocoding:!1},VISITOR_ENGLISH:{code:null,flag:"visitor_en",name:"Visitor English",latin:!0,isMode:!0,geocoding:!1},STYLE:{code:null,flag:"style",name:"Style",latin:!1,isMode:!0,geocoding:!1},STYLE_LOCK:{code:null,flag:"style_lock",name:"Style Lock",latin:!1,isMode:!0,geocoding:!1},...kJ};function w0(){if(typeof navigator>"u"){return OJ(Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0])||b0.ENGLISH}return Array.from(new Set(navigator.languages.map(e=>e.split("-")[0]))).map(e=>OJ(e)).filter(e=>e)[0]??b0.LOCAL}const T0={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",telemetryURL:"https://api.maptiler.com/metrics",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:b0.STYLE,secondaryLanguage:b0.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(T0);const E0=function(e,t,i){if(jY.randomUUID&&!t&&!e)return jY.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!NY){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");NY=crypto.getRandomValues.bind(crypto)}return NY(VY)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((i=i||0)<0||i+16>t.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[i+e]=n[e];return t}return function(e,t=0){return(UY[e[t+0]]+UY[e[t+1]]+UY[e[t+2]]+UY[e[t+3]]+"-"+UY[e[t+4]]+UY[e[t+5]]+"-"+UY[e[t+6]]+UY[e[t+7]]+"-"+UY[e[t+8]]+UY[e[t+9]]+"-"+UY[e[t+10]]+UY[e[t+11]]+UY[e[t+12]]+UY[e[t+13]]+UY[e[t+14]]+UY[e[t+15]]).toLowerCase()}(n)}();class C0 extends RJ{constructor(){super(...arguments),QY(this,"primaryLanguage",T0.primaryLanguage),QY(this,"secondaryLanguage"),QY(this,"session",!0),QY(this,"caching",!0),QY(this,"telemetry",!0),QY(this,"_unit","metric"),QY(this,"_apiKey","")}set unit(e){this._unit=e,this.emit("unit",e)}get unit(){return this._unit}set apiKey(e){this._apiKey=e,FJ.apiKey=e,this.emit("apiKey",e)}get apiKey(){return this._apiKey}set fetch(e){FJ.fetch=e}get fetch(){return FJ.fetch}}const S0=new C0;class B0 extends u0{constructor(e={}){super(e),QY(this,"logoURL",""),QY(this,"linkURL",""),this.logoURL=e.logoURL??T0.maptilerLogoURL,this.linkURL=e.linkURL??T0.maptilerURL}onAdd(e){this._map=e,this._compact=this.options.compact??!1,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const t=window.document.createElement("a");return t.style.backgroundRepeat="no-repeat",t.style.cursor="pointer",t.style.display="block",t.style.height="23px",t.style.margin="0 0 -4px -4px",t.style.overflow="hidden",t.style.width="88px",t.style.backgroundImage=`url(${this.logoURL})`,t.style.backgroundSize="100px 30px",t.style.width="100px",t.style.height="30px",t.target="_blank",t.rel="noopener",t.href=this.linkURL,t.setAttribute("aria-label","MapTiler logo"),t.setAttribute("rel","noopener"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}const I0="localcache_source",M0="localcache",P0=typeof caches<"u",{addProtocol:R0}=iJ;function L0(e,t){if(P0&&S0.caching&&S0.session&&e.host===T0.maptilerApiHost){if("Source"===t&&e.href.includes("tiles.json"))return e.href.replace("https://",`${I0}://`);if("Tile"===t||"Glyphs"===t)return e.href.replace("https://",`${M0}://`)}return e.href}let F0;async function k0(){return F0||(F0=await caches.open("maptiler_sdk")),F0}let D0=0;function O0(){R0(I0,async(e,t)=>{if(!e.url)throw new Error("");e.url=e.url.replace(`${I0}://`,"https://");const i=e;i.signal=t.signal;const n=await fetch(e.url,i),r=await n.json();return r.tiles&&r.tiles.length>0&&(r.tiles[0]+=`&last-modified=${n.headers.get("Last-Modified")}`),{data:r,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}}),R0(M0,async(e,t)=>{if(!e.url)throw new Error("");e.url=e.url.replace(`${M0}://`,"https://");const i=new URL(e.url),n=new URL(i);n.searchParams.delete("mtsid"),n.searchParams.delete("key");const r=n.toString(),o=new URL(i);o.searchParams.delete("last-modified");const s=o.toString(),a=async e=>({data:await e.arrayBuffer(),cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires")}),l=await k0(),c=await l.match(r);if(c)return a(c);const u=e;u.signal=t.signal;const h=await fetch(s,u);return h.status>=200&&h.status<300&&(l.put(r,h.clone()).catch(()=>{}),++D0>100&&(async function(){const e=await k0(),t=await e.keys(),i=t.slice(0,Math.max(t.length-1e3,0));for(const t of i)e.delete(t)}(),D0=0)),a(h)})}function z0(e,t){let i=null;try{i=new URL(e)}catch{return{url:e}}return i.host===T0.maptilerApiHost&&(i.searchParams.has("key")||i.searchParams.append("key",S0.apiKey),S0.session&&i.searchParams.append("mtsid",E0)),{url:L0(i,t)}}function U0(e){return(t,i)=>{if(null!=e){const n=e(t,i),r=z0((null==n?void 0:n.url)??"",i);return{...n,...r}}return z0(t,i)}}function N0(){return Math.random().toString(36).substring(2)}function V0(e){return/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(e)}function j0(){return document.createElement("canvas").getContext("webgl2")?null:typeof WebGL2RenderingContext<"u"?"Graphic rendering with WebGL2 has been disabled or is not supported by your graphic card. The map cannot be displayed.":"Your browser does not support graphic rendering with WebGL2. The map cannot be displayed."}function G0(e,t){return!(!Array.isArray(e)||2!==e.length||"get"!==e[0]||"string"!=typeof e[1]||t&&!e[1].startsWith("name:")||!t&&"name"!==e[1])}function H0(e,t,i){const n=structuredClone(e),r=e=>{if("string"!=typeof e)for(let n=0;ni===r.length-1?[e]:[e,t])]}function Z0(e){var t;const i=/\{name(?::(?\S+))?\}/g,n=[];for(;;){const r=i.exec(e);if(!r)break;const o=(null==(t=r.groups)?void 0:t.language)??null;n.push(o)}return n}function W0(e){return Array.isArray(e)&&2===e.length&&"get"===e[0]&&"string"==typeof e[1]?"name"===e[1].trim()?{isLanguage:!0,localization:null}:e[1].trim().startsWith("name:")?{isLanguage:!0,localization:e[1].trim().split(":").pop()}:null:null}function q0(e){const t=[],i=structuredClone(e),n=e=>{if("string"!=typeof e)for(let i=0;i":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},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:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};class X0{constructor(e,t,i,n){this.message=(e?`${e}: `:"")+i,n&&(this.identifier=n),null!=t&&t.__line__&&(this.line=t.__line__)}}function J0(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}class Y0 extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class e1{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new e1(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)}}const t1={kind:"null"},i1={kind:"number"},n1={kind:"string"},r1={kind:"boolean"},o1={kind:"color"},s1={kind:"projectionDefinition"},a1={kind:"object"},l1={kind:"value"},c1={kind:"collator"},u1={kind:"formatted"},h1={kind:"padding"},d1={kind:"colorArray"},p1={kind:"numberArray"},f1={kind:"resolvedImage"},m1={kind:"variableAnchorOffsetCollection"};function g1(e,t){return{kind:"array",itemType:e,N:t}}function _1(e){if("array"===e.kind){const t=_1(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const A1=[t1,i1,n1,r1,o1,s1,u1,a1,g1(l1),h1,p1,d1,f1,m1];function y1(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!y1(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 A1)if(!y1(e,t))return null}return`Expected ${_1(e)} but found ${_1(t)} instead.`}function v1(e,t){return t.some(t=>t.kind===e.kind)}function x1(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)}function b1(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const w1=.96422,T1=.82521,E1=4/29,C1=6/29,S1=3*C1*C1,B1=C1*C1*C1,I1=Math.PI/180,M1=180/Math.PI;function P1(e){return(e%=360)<0&&(e+=360),e}function R1([e,t,i,n]){let r,o;const s=F1((.2225045*(e=L1(e))+.7168786*(t=L1(t))+.0606169*(i=L1(i)))/1);e===t&&t===i?r=o=s:(r=F1((.4360747*e+.3850649*t+.1430804*i)/w1),o=F1((.0139322*e+.0971045*t+.7141733*i)/T1));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function L1(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function F1(e){return e>B1?Math.pow(e,1/3):e/S1+E1}function k1([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*O1(r),o=w1*O1(o),s=T1*O1(s),[D1(3.1338561*o-1.6168667*r-.4906146*s),D1(-.9787684*o+1.9161415*r+.033454*s),D1(.0719453*o-.2289914*r+1.4052427*s),n]}function D1(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function O1(e){return e>C1?e*e*e:S1*(e-E1)}const z1=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function U1(e,t){return z1(e,t)?e[t]:void 0}function N1(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=U1(Q1,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[V1(e.slice(i,i+=t)),V1(e.slice(i,i+=t)),V1(e.slice(i,i+=t)),V1(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/,i=e.match(t);if(i){const[e,t,n,r,o,s,a,l,c,u,h,d]=i,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),i="%%%"===e?100:""===e?255:0;if(i){const e=[G1(+t/i,0,1),G1(+o/i,0,1),G1(+l/i,0,1),h?j1(+h,d):1];if(H1(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,G1(+r,0,100),G1(+s,0,100),l?j1(+l,c):1];if(H1(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=P1(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}function V1(e){return parseInt(e.padEnd(2,e),16)/255}function j1(e,t){return G1(t?e/100:e,0,1)}function G1(e,t,i){return Math.min(Math.max(t,e),i)}function H1(e){return!e.some(Number.isNaN)}const Q1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function $1(e,t,i){return e+i*(t-e)}function Z1(e,t,i){return e.map((e,n)=>$1(e,t[n],i))}class W1{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof W1)return e;if("string"!=typeof e)return;const t=N1(e);return t?new W1(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=R1(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?P1(Math.atan2(n,i)*M1):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",R1(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Z1(e.rgb,t.rgb,i);return new W1(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,(1===o||0===o)&&(d=l)):(h=n,(1===c||0===c)&&(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*I1,k1([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,d??$1(r,l,i),$1(o,c,i),$1(s,u,i)]);return new W1(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=k1(Z1(e.lab,t.lab,i));return new W1(n,r,o,s,!1)}}}}W1.black=new W1(0,0,0,1),W1.white=new W1(1,1,1,1),W1.transparent=new W1(0,0,0,0),W1.red=new W1(1,0,0,1);class q1{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}}const K1=["bottom","center","top"];class X1{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class J1{constructor(e){this.sections=e}static fromString(e){return new J1([new X1(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof J1?e:J1.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Y1{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Y1)return e;if("number"==typeof e)return new Y1([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Y1(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Y1(Z1(e.values,t.values,i))}}class e2{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof e2)return e;if("number"==typeof e)return new e2([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new e2(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new e2(Z1(e.values,t.values,i))}}class t2{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof t2)return e;if("string"==typeof e){const t=W1.parse(e);return t?new t2([t]):void 0}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=W1.parse(i);if(!e)return;t.push(e)}return new t2(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?typeof n>"u"||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[e,t,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[e,t,i,n]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function l2(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof s2||e instanceof W1||e instanceof q1||e instanceof J1||e instanceof Y1||e instanceof e2||e instanceof t2||e instanceof r2||e instanceof o2)return!0;if(Array.isArray(e)){for(const t of e)if(!l2(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!l2(e[t]))return!1;return!0}return!1}function c2(e){if(null===e)return t1;if("string"==typeof e)return n1;if("boolean"==typeof e)return r1;if("number"==typeof e)return i1;if(e instanceof W1)return o1;if(e instanceof s2)return s1;if(e instanceof q1)return c1;if(e instanceof J1)return u1;if(e instanceof Y1)return h1;if(e instanceof e2)return p1;if(e instanceof t2)return d1;if(e instanceof r2)return m1;if(e instanceof o2)return f1;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=c2(t);if(i){if(i===e)continue;i=l1;break}i=e}return g1(i||l1,t)}return a1}function u2(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof W1||e instanceof s2||e instanceof J1||e instanceof Y1||e instanceof e2||e instanceof t2||e instanceof r2||e instanceof o2?e.toString():JSON.stringify(e)}class h2{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(!l2(e[1]))return t.error("invalid value");const i=e[1];let n=c2(i);const r=t.expectedType;return"array"===n.kind&&0===n.N&&r&&"array"===r.kind&&("number"!=typeof r.N||0===r.N)&&(n=r),new h2(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const d2={string:n1,number:i1,boolean:r1,object:a1};class p2{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,n=1;const r=e[0];if("array"===r){let r,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in d2)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=d2[i],n++}else r=l1;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],n++}i=g1(r,o)}else{if(!d2[r])throw new Error(`Types doesn't contain name = ${r}`);i=d2[r]}const o=[];for(;ne.outputDefined())}}const f2={"to-boolean":r1,"to-color":o1,"to-number":i1,"to-string":n1};class m2{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];if(!f2[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=f2[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:a2(t[0],t[1],t[2],t[3]),!i))return new W1(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new i2(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Y1.parse(t);if(n)return n}throw new i2(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=e2.parse(t);if(n)return n}throw new i2(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=t2.parse(t);if(n)return n}throw new i2(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=r2.parse(t);if(n)return n}throw new i2(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new i2(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return J1.fromString(u2(this.args[0].evaluate(e)));case"resolvedImage":return o2.fromString(u2(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return u2(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const g2=["Unknown","Point","LineString","Polygon"];class _2{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?g2[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||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=W1.parse(e),this._parseColorCache.set(e,t)),t}}class A2{constructor(e,t,i=[],n,r=new e1,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new p2(t,[e]):"coerce"===i?new m2(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 n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];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("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof h2)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new _2;try{n=new h2(n.type,n.evaluate(e))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return typeof e>"u"?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new A2(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Y0(i,e))}checkSubtype(e,t){const i=y1(e,t);return i&&this.error(i),i}}class y2{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 n=1;n=i.length)throw new i2(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new i2(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class b2{constructor(e,t){this.type=r1,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,l1),n=t.parse(e[2],2,l1);return i&&n?v1(i.type,[r1,n1,i1,t1,l1])?new b2(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${_1(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!x1(t,["boolean","string","number","null"]))throw new i2(`Expected first argument to be of type boolean, string, number or null, but found ${_1(c2(t))} instead.`);if(!x1(i,["string","array"]))throw new i2(`Expected second argument to be of type array or string, but found ${_1(c2(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class w2{constructor(e,t,i){this.type=i1,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,l1),n=t.parse(e[2],2,l1);if(!i||!n)return null;if(!v1(i.type,[r1,n1,i1,t1,l1]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${_1(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,i1);return r?new w2(i,n,r):null}return new w2(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!x1(t,["boolean","string","number","null"]))throw new i2(`Expected first argument to be of type boolean, string, number or null, but found ${_1(c2(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),x1(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(x1(i,["array"]))return i.indexOf(t,n);throw new i2(`Expected second argument to be of type array or string, but found ${_1(c2(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class T2{constructor(e,t,i,n,r,o){this.inputType=e,this.type=t,this.input=i,this.cases=n,this.outputs=r,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,n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r={},o=[];for(let s=2;sNumber.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,c2(e)))return null}else i=c2(e);if(typeof r[String(e)]<"u")return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,l1);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return!a||"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new T2(i,n,s,r,o,a)}evaluate(e){const t=this.input.evaluate(e);return(c2(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()}}class E2{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 n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class C2{constructor(e,t,i,n){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=n}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,l1),n=t.parse(e[2],2,i1);if(!i||!n)return null;if(!v1(i.type,[g1(l1),n1,l1]))return t.error(`Expected first argument to be of type array or string, but found ${_1(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,i1);return r?new C2(i.type,i,n,r):null}return new C2(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),x1(t,["string"]))return[...t].slice(i,n).join("");if(x1(t,["array"]))return t.slice(i,n);throw new i2(`Expected first argument to be of type array or string, but found ${_1(c2(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function S2(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new i2("Input is not a number.");s=a-1}return 0}class B2{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,i1);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=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,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new B2(r,i,n)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);return i[S2(t,n)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function I2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var M2,P2;var R2=function(){if(P2)return M2;function e(e,t,i,n){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*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return P2=1,M2=e,e.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,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},M2}(),L2=I2(R2);class F2{constructor(e,t,i,n,r){this.type=e,this.operator=t,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[e,t]of r)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,n){let r=0;if("exponential"===e.name)r=k2(t,e.base,i,n);else if("linear"===e.name)r=k2(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new L2(o[0],o[1],o[2],o[3]).solve(k2(t,1,i,n))}return r}static parse(e,t){let[i,n,r,...o]=e;if(!Array.isArray(n)||0===n.length)return t.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const e=n[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:e}}else{if("cubic-bezier"!==n[0])return t.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const e=n.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);n={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(r=t.parse(r,2,i1),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==d1?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=o1;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return b1(a,i1)||b1(a,s1)||b1(a,o1)||b1(a,h1)||b1(a,p1)||b1(a,d1)||b1(a,m1)||b1(a,g1(i1))?new F2(a,i,n,r,s):t.error(`Type ${_1(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const n=this.input.evaluate(e);if(n<=t[0])return i[0].evaluate(e);const r=t.length;if(n>=t[r-1])return i[r-1].evaluate(e);const o=S2(t,n),s=t[o],a=t[o+1],l=F2.interpolationFactor(this.interpolation,n,s,a),c=i[o].evaluate(e),u=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return $1(c,u,l);case"color":return W1.interpolate(c,u,l);case"padding":return Y1.interpolate(c,u,l);case"colorArray":return t2.interpolate(c,u,l);case"numberArray":return e2.interpolate(c,u,l);case"variableAnchorOffsetCollection":return r2.interpolate(c,u,l);case"array":return Z1(c,u,l);case"projectionDefinition":return s2.interpolate(c,u,l)}case"interpolate-hcl":switch(this.type.kind){case"color":return W1.interpolate(c,u,l,"hcl");case"colorArray":return t2.interpolate(c,u,l,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return W1.interpolate(c,u,l,"lab");case"colorArray":return t2.interpolate(c,u,l,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function k2(e,t,i,n){const r=n-i,o=e-i;return 0===r?0:1===t?o/r:(Math.pow(t,o)-1)/(Math.pow(t,r)-1)}W1.interpolate,Y1.interpolate,e2.interpolate,t2.interpolate,r2.interpolate;class D2{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=null;const n=t.expectedType;n&&"value"!==n.kind&&(i=n);const r=[];for(const n of e.slice(1)){const e=t.parse(n,1+r.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,r.push(e)}if(!i)throw new Error("No output type");return n&&r.some(e=>y1(n,e.type))?new D2(l1,r):new D2(i,r)}evaluate(e){let t,i=null,n=0;for(const r of this.args)if(n++,i=r.evaluate(e),i&&i instanceof o2&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function O2(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 z2(e,t,i,n){return 0===n.compare(t,i)}function U2(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=r1,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,l1);if(!o)return null;if(!O2(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${_1(o.type)}'.`);let s=t.parse(e[2],2,l1);if(!s)return null;if(!O2(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${_1(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${_1(o.type)}' and '${_1(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new p2(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new p2(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,c1),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=c2(o),i=c2(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new i2(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const e=c2(o),i=c2(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const N2=U2("==",function(e,t,i){return t===i},z2),V2=U2("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!z2(0,t,i,n)}),j2=U2("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),H2=U2("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Q2=U2(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class $2{constructor(e,t,i){this.type=c1,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 n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,r1);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,r1);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,n1),!o)?null:new $2(n,r,o)}evaluate(e){return new q1(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}}class Z2{constructor(e,t,i,n,r){this.type=n1,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,i1);if(!i)return null;const n=e[2];if("object"!=typeof n||Array.isArray(n))return t.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=t.parse(n.locale,1,n1),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,n1),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,i1),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,i1),!a)?null:new Z2(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class W2{constructor(e){this.type=u1,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 n=[];let r=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,i1),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,g1(n1)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,o1),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!K1.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,n1),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,l1);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'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new W2(n)}evaluate(e){return new J1(this.sections.map(t=>{const i=t.content.evaluate(e);return c2(i)===f1?new X1("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new X1(u2(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.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),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class q2{constructor(e){this.type=f1,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,n1);return i?new q2(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=o2.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class K2{constructor(e){this.type=i1,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 ${_1(i.type)} instead.`):new K2(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 i2(`Expected value to be of type string or array, but found ${_1(c2(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const X2=8192;function J2(e,t){const i=function(e){return(180+e)/360}(e[0]),n=function(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}(e[1]),r=Math.pow(2,t.z);return[Math.round(i*r*X2),Math.round(n*r*X2)]}function Y2(e,t){const i=Math.pow(2,t.z),n=(e[0]/X2+t.x)/i,r=(e[1]/X2+t.y)/i;return[e3(n),t3(r)]}function e3(e){return 360*e-180}function t3(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function i3(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 n3(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function r3(e,t,i){return t[1]>e[1]!=i[1]>e[1]&&e[0]<(i[0]-t[0])*(e[1]-t[1])/(i[1]-t[1])+t[0]}function o3(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r===0&&n*o<=0&&r*s<=0}function s3(e,t,i,n){const r=[t[0]-e[0],t[1]-e[1]];return 0!==function(e,t){return e[0]*t[1]-e[1]*t[0]}([n[0]-i[0],n[1]-i[1]],r)&&!(!d3(e,t,i,n)||!d3(i,n,e,t))}function a3(e,t,i){for(const n of i)for(let i=0;i0&&h<0||u<0&&h>0}function p3(e,t,i){const n=[];for(let r=0;ri[2]){const t=.5*n;let r=e[0]-i[0]>t?-n:i[0]-e[0]>t?n:0;0===r&&(r=e[0]-i[2]>t?-n:i[2]-e[0]>t?n:0),e[0]+=r}i3(t,e)}function g3(e,t,i,n){const r=Math.pow(2,n.z)*X2,o=[n.x*X2,n.y*X2],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];m3(n,t,i,r),s.push(n)}return s}function _3(e,t,i,n){const r=Math.pow(2,n.z)*X2,o=[n.x*X2,n.y*X2],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];i3(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){!function(e){e[0]=e[1]=1/0,e[2]=e[3]=-1/0}(t);for(const e of s)for(const n of e)m3(n,t,i,r)}return s}class A3{constructor(e,t){this.type=r1,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(l2(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length){return new A3(t,{type:"MultiPolygon",coordinates:e})}}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new A3(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new A3(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=p3(t.coordinates,n,r),s=g3(e.geometry(),i,n,r);if(!n3(i,n))return!1;for(const e of s)if(!l3(e,o))return!1}if("MultiPolygon"===t.type){const o=f3(t.coordinates,n,r),s=g3(e.geometry(),i,n,r);if(!n3(i,n))return!1;for(const e of s)if(!c3(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],n=[1/0,1/0,-1/0,-1/0],r=e.canonicalID();if("Polygon"===t.type){const o=p3(t.coordinates,n,r),s=_3(e.geometry(),i,n,r);if(!n3(i,n))return!1;for(const e of s)if(!u3(e,o))return!1}if("MultiPolygon"===t.type){const o=f3(t.coordinates,n,r),s=_3(e.geometry(),i,n,r);if(!n3(i,n))return!1;for(const e of s)if(!h3(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class y3{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,n=t[e];for(;e>0;){const r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n}_down(e){const{data:t,compare:i}=this,n=this.length>>1,r=t[e];for(;e=0)break;t[e]=t[n],e=n}t[e]=r}}function v3(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function E3(e,t){return t[0]-e[0]}function C3(e){return e[1]-e[0]+1}function S3(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=C3(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function I3(e,t){if(!S3(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)i3(i,e[n]);return i}function M3(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)i3(t,e);return t}function P3(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function R3(e,t,i){if(!P3(e)||!P3(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(n3(r,o)){if(U3(e,t))return 0}else if(U3(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(C3(l)<=c){if(!S3(l,e.length))return NaN;if(t){const t=z3(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=O3(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=B3(l,t);V3(s,o,n,e,a,i[0]),V3(s,o,n,e,a,i[1])}}return o}function H3(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new y3([[0,[0,e.length-1],[0,i.length-1]]],E3);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(C3(l)<=u&&C3(c)<=h){if(!S3(l,e.length)&&S3(c,i.length))return NaN;let o;if(t&&n)o=k3(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=L3(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=L3(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=D3(e,l,i,c,r),s=Math.min(s,o)}else{const o=B3(l,t),u=B3(c,n);j3(a,s,r,e,i,o[0],u[0]),j3(a,s,r,e,i,o[0],u[1]),j3(a,s,r,e,i,o[1],u[0]),j3(a,s,r,e,i,o[1],u[1])}}return s}function Q3(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=function(e){if(e.length<=1)return[e];const t=[];let i,n;for(const r of e){const e=v3(r);0!==e&&(r.area=Math.abs(e),void 0===n&&(n=e<0),n===e<0?(i&&t.push(i),i=[r]):i.push(r))}return i&&t.push(i),t}(i).map(t=>t.map(t=>t.map(t=>Y2([t.x,t.y],e.canonical)))),r=new T3(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,G3([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,G3(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,N3(t,e.coordinates,r,o))}if(0===o)return o}return o}function $3(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Z3{constructor(e,t){this.type=i1,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(l2(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Z3(t,t.features.map(e=>$3(e.geometry)).flat());if("Feature"===t.type)return new Z3(t,$3(t.geometry));if("type"in t&&"coordinates"in t)return new Z3(t,$3(t))}return t.error("'distance' 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=e.geometry(),n=i.flat().map(t=>Y2([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new T3(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,H3(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,H3(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,G3(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Y2([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new T3(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,H3(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,H3(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,G3(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return Q3(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class W3{constructor(e){this.type=l1,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new W3(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?U1(i,this.key):null}eachChild(){}outputDefined(){return!1}}const q3={"==":N2,"!=":V2,">":G2,"<":j2,">=":Q2,"<=":H2,array:p2,at:x2,boolean:p2,case:E2,coalesce:D2,collator:$2,format:W2,image:q2,in:b2,"index-of":w2,interpolate:F2,"interpolate-hcl":F2,"interpolate-lab":F2,length:K2,let:y2,literal:h2,match:T2,number:p2,"number-format":Z2,object:p2,slice:C2,step:B2,string:p2,"to-boolean":m2,"to-color":m2,"to-number":m2,"to-string":m2,var:v2,within:A3,distance:Z3,"global-state":W3};class K3{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=K3.definitions[i];if(!n)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new A2(t.registry,t4,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;tfunction(e){return Array.isArray(e)?`(${e.map(_1).join(", ")})`:`(${_1(e.type)}...)`}(e)).join(" | "),n=[];for(let i=1;i"u"?null:i}function e4(e){return{type:e}}function t4(e){if(e instanceof v2)return t4(e.boundExpression);if(e instanceof K3&&"error"===e.name)return!1;if(e instanceof $2)return!1;if(e instanceof A3)return!1;if(e instanceof Z3)return!1;if(e instanceof W3)return!1;const t=e instanceof m2||e instanceof p2;let i=!0;return e.eachChild(e=>{i=t?i&&t4(e):i&&e instanceof h2}),!!i&&(i4(e)&&r4(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"]))}function i4(e){if(e instanceof K3){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 A3||e instanceof Z3)return!1;let t=!0;return e.eachChild(e=>{t&&!i4(e)&&(t=!1)}),t}function n4(e){if(e instanceof K3&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!n4(e)&&(t=!1)}),t}function r4(e,t){if(e instanceof K3&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!r4(e,t)&&(i=!1)}),i}function o4(e){return{result:"success",value:e}}function s4(e){return{result:"error",value:e}}function a4(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function l4(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function c4(e){return!!e.expression&&e.expression.interpolated}function u4(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function h4(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&c2(e)===a1}K3.register(q3,{error:[{kind:"error"},[n1],(e,[t])=>{throw new i2(t.evaluate(e))}],typeof:[n1,[l1],(e,[t])=>_1(c2(t.evaluate(e)))],"to-rgba":[g1(i1,4),[o1],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[o1,[i1,i1,i1],X3],rgba:[o1,[i1,i1,i1,i1],X3],has:{type:r1,overloads:[[[n1],(e,[t])=>J3(t.evaluate(e),e.properties())],[[n1,a1],(e,[t,i])=>J3(t.evaluate(e),i.evaluate(e))]]},get:{type:l1,overloads:[[[n1],(e,[t])=>Y3(t.evaluate(e),e.properties())],[[n1,a1],(e,[t,i])=>Y3(t.evaluate(e),i.evaluate(e))]]},"feature-state":[l1,[n1],(e,[t])=>Y3(t.evaluate(e),e.featureState||{})],properties:[a1,[],e=>e.properties()],"geometry-type":[n1,[],e=>e.geometryType()],id:[l1,[],e=>e.id()],zoom:[i1,[],e=>e.globals.zoom],"heatmap-density":[i1,[],e=>e.globals.heatmapDensity||0],elevation:[i1,[],e=>e.globals.elevation||0],"line-progress":[i1,[],e=>e.globals.lineProgress||0],accumulated:[l1,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[i1,e4(i1),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[i1,e4(i1),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:i1,overloads:[[[i1,i1],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[i1],(e,[t])=>-t.evaluate(e)]]},"/":[i1,[i1,i1],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[i1,[i1,i1],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[i1,[],()=>Math.LN2],pi:[i1,[],()=>Math.PI],e:[i1,[],()=>Math.E],"^":[i1,[i1,i1],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[i1,[i1],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[i1,[i1],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[i1,[i1],(e,[t])=>Math.log(t.evaluate(e))],log2:[i1,[i1],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[i1,[i1],(e,[t])=>Math.sin(t.evaluate(e))],cos:[i1,[i1],(e,[t])=>Math.cos(t.evaluate(e))],tan:[i1,[i1],(e,[t])=>Math.tan(t.evaluate(e))],asin:[i1,[i1],(e,[t])=>Math.asin(t.evaluate(e))],acos:[i1,[i1],(e,[t])=>Math.acos(t.evaluate(e))],atan:[i1,[i1],(e,[t])=>Math.atan(t.evaluate(e))],min:[i1,e4(i1),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[i1,e4(i1),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[i1,[i1],(e,[t])=>Math.abs(t.evaluate(e))],round:[i1,[i1],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[i1,[i1],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[i1,[i1],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[r1,[n1,l1],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[r1,[l1],(e,[t])=>e.id()===t.value],"filter-type-==":[r1,[n1],(e,[t])=>e.geometryType()===t.value],"filter-<":[r1,[n1,l1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[r1,[n1,l1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[r1,[l1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[r1,[n1,l1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[r1,[l1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[r1,[n1,l1],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[r1,[l1],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[r1,[l1],(e,[t])=>t.value in e.properties()],"filter-has-id":[r1,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[r1,[g1(n1)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[r1,[g1(l1)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[r1,[n1,g1(l1)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[r1,[n1,g1(l1)],(e,[t,i])=>function(e,t,i,n){for(;i<=n;){const r=i+n>>1;if(t[r]===e)return!0;t[r]>e?n=r-1:i=r+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:r1,overloads:[[[r1,r1],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[e4(r1),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:r1,overloads:[[[r1,r1],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[e4(r1),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[r1,[r1],(e,[t])=>!t.evaluate(e)],"is-supported-script":[r1,[n1],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[n1,[n1],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[n1,[n1],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[n1,e4(l1),(e,t)=>t.map(t=>u2(t.evaluate(e))).join("")],"resolved-locale":[n1,[c1],(e,[t])=>t.evaluate(e).resolvedLocale()]});class d4{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new _2,this._defaultValue=t?function(e){if("color"===e.type&&h4(e.default))return new W1(0,0,0,0);switch(e.type){case"color":return W1.parse(e.default)||null;case"padding":return Y1.parse(e.default)||null;case"numberArray":return e2.parse(e.default)||null;case"colorArray":return t2.parse(e.default)||null;case"variableAnchorOffsetCollection":return r2.parse(e.default)||null;case"projectionDefinition":return s2.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||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 i2(`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,typeof console<"u"&&console.warn(e.message)),this._defaultValue}}}function p4(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in q3}function f4(e,t){const i=new A2(q3,t4,[],t?function(e){const t={color:o1,string:n1,number:i1,enum:n1,boolean:r1,formatted:u1,padding:h1,numberArray:p1,colorArray:d1,projectionDefinition:s1,resolvedImage:f1,variableAnchorOffsetCollection:m1};return"array"===e.type?g1(t[e.value]||l1,e.length):t[e.type]}(t):void 0),n=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?o4(new d4(n,t)):s4(i.errors)}class m4{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!n4(t.expression),this.globalStateRefs=y4(t.expression)}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}}class g4{constructor(e,t,i,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!n4(t.expression),this.globalStateRefs=y4(t.expression),this.interpolationType=n}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?F2.interpolationFactor(this.interpolationType,e,t,i):0}}function _4(e,t){const i=f4(e,t);if("error"===i.result)return i;const n=i.value.expression,r=i4(n);if(!r&&!a4(t))return s4([new Y0("","data expressions not supported")]);const o=r4(n,["zoom"]);if(!o&&!l4(t))return s4([new Y0("","zoom expressions not supported")]);const s=A4(n);if(!s&&!o)return s4([new Y0("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof Y0)return s4([s]);if(s instanceof F2&&!c4(t))return s4([new Y0("",'"interpolate" expressions cannot be used with this property')]);if(!s)return o4(new m4(r?"constant":"source",i.value));const a=s instanceof F2?s.interpolation:void 0;return o4(new g4(r?"camera":"composite",i.value,s.labels,a))}function A4(e){let t=null;if(e instanceof y2)t=A4(e.result);else if(e instanceof D2){for(const i of e.args)if(t=A4(i),t)break}else(e instanceof B2||e instanceof F2)&&e.input instanceof K3&&"zoom"===e.input.name&&(t=e);return t instanceof Y0||e.eachChild(e=>{const i=A4(e);i instanceof Y0?t=i:!t&&i?t=new Y0("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Y0("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function y4(e,t=new Set){return e instanceof W3&&t.add(e.key),e.eachChild(e=>{y4(e,t)}),t}function v4(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(!v4(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function x4(e){const t=e.key,i=e.value;return i?[new X0(t,i,"constants have been deprecated as of v8")]:[]}function b4(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function w4(e){if(Array.isArray(e))return e.map(w4);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=w4(e[i]);return t}return b4(e)}function T4(e){const t=e.key,i=e.value,n=e.valueSpec||{},r=e.objectElementValidators||{},o=e.style,s=e.styleSpec,a=e.validateSpec;let l=[];const c=u4(i);if("object"!==c)return[new X0(t,i,`object expected, ${c} found`)];for(const e in i){const c=e.split(".")[0],u=U1(n,c)||n["*"];let h;if(U1(r,c))h=r[c];else if(U1(n,c))h=a;else if(r["*"])h=r["*"];else{if(!n["*"]){l.push(new X0(t,i[e],`unknown property "${e}"`));continue}h=a}l=l.concat(h({key:(t&&`${t}.`)+e,value:i[e],valueSpec:u,style:o,styleSpec:s,object:i,objectKey:e,validateSpec:a},i))}for(const e in n)r[e]||n[e].required&&void 0===n[e].default&&void 0===i[e]&&l.push(new X0(t,i,`missing required property "${e}"`));return l}function E4(e){const t=e.value,i=e.valueSpec,n=e.validateSpec,r=e.style,o=e.styleSpec,s=e.key,a=e.arrayElementValidator||n;if("array"!==u4(t))return[new X0(s,t,`array expected, ${u4(t)} found`)];if(i.length&&t.length!==i.length)return[new X0(s,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.lengthn.maximum?[new X0(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function S4(e){const t=e.valueSpec,i=b4(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===u4(e.value.stops)&&"array"===u4(e.value.stops[0])&&"object"===u4(e.value.stops[0][0]),u=T4({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new X0(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(E4({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===u4(n)&&0===n.length&&t.push(new X0(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new X0(e.key,e.value,'missing required property "property"')),"identity"!==i&&!e.value.stops&&u.push(new X0(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!c4(e.valueSpec)&&u.push(new X0(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!a4(e.valueSpec)?u.push(new X0(e.key,e.value,"property functions not supported")):a&&!l4(e.valueSpec)&&u.push(new X0(e.key,e.value,"zoom functions not supported"))),("categorical"===i||c)&&void 0===e.value.property&&u.push(new X0(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==u4(n))return[new X0(a,n,`array expected, ${u4(n)} found`)];if(2!==n.length)return[new X0(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==u4(n[0]))return[new X0(a,n,`object expected, ${u4(n[0])} found`)];if(void 0===n[0].zoom)return[new X0(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new X0(a,n,"object stop key must have value")];if(o&&o>b4(n[0].zoom))return[new X0(a,n[0].zoom,"stop zoom values must appear in ascending order")];b4(n[0].zoom)!==o&&(o=b4(n[0].zoom),r=void 0,s={}),i=i.concat(T4({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:C4,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return p4(w4(n[1]))?i.concat([new X0(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=u4(e.value),l=b4(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new X0(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new X0(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return a4(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new X0(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew X0(`${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 X0(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&&!n4(i))return[new X0(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!n4(i))return[new X0(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!r4(i,["zoom","feature-state"]))return[new X0(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!i4(i))return[new X0(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function I4(e){const t=e.key,i=e.value,n=u4(i);return"string"!==n?[new X0(t,i,`color expected, ${n} found`)]:W1.parse(String(i))?[]:[new X0(t,i,`color expected, "${i}" found`)]}function M4(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(b4(i))&&r.push(new X0(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(b4(i))&&r.push(new X0(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function P4(e){return v4(w4(e.value))?B4(J0({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):R4(e)}function R4(e){const t=e.value,i=e.key;if("array"!==u4(t))return[new X0(i,t,`array expected, ${u4(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new X0(i,t,"filter array must have at least 1 element")];switch(o=o.concat(M4({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),b4(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===b4(t[1])&&o.push(new X0(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new X0(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=u4(t[1]),"string"!==r&&o.push(new X0(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new X0(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{b4(t.id)===a&&(e=t)}),e?e.ref?t.push(new X0(n,i.ref,"ref cannot reference another ref layer")):s=b4(e.type):t.push(new X0(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&b4(e.type);e?"vector"===o&&"raster"===s?t.push(new X0(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new X0(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new X0(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new X0(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===s&&i.paint&&i.paint["line-gradient"]&&("geojson"!==o||!e.lineMetrics)&&t.push(new X0(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new X0(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new X0(n,i.source,`source "${i.source}" not found`))}else t.push(new X0(n,i,'missing required property "source"'));return t=t.concat(T4({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:P4,layout:e=>T4({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>k4(J0({layerType:s},e))}}),paint:e=>T4({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>F4(J0({layerType:s},e))}})}})),t}function O4(e){const t=e.value,i=e.key,n=u4(t);return"string"!==n?[new X0(i,t,`string expected, ${n} found`)]:[]}const z4={promoteId:function({key:e,value:t}){if("string"===u4(t))return O4({key:e,value:t});{const i=[];for(const n in t)i.push(...O4({key:`${e}.${n}`,value:t[n]}));return i}}};function U4(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new X0(i,t,'"type" is required')];const s=b4(t.type);let a;switch(s){case"vector":case"raster":return a=T4({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:z4,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=u4(n);if(void 0===n)return a;if("object"!==l)return a.push(new X0("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===b4(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new X0(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new X0(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=T4({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:z4}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...B4({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...B4({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return T4({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return T4({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new X0(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return M4({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function N4(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=u4(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new X0("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=a&&n[a[1]]&&n[a[1]].transition?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i})):n[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i})):o.concat([new X0(s,t[s],`unknown property "${s}"`)])}return o}function V4(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=u4(t);if(void 0===t)return[];if("object"!==o)return[new X0("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=n[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i})):s.concat([new X0(o,t[o],`unknown property "${o}"`)]);return s}function j4(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=u4(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new X0("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=n[s]?o.concat(e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i})):o.concat([new X0(s,t[s],`unknown property "${s}"`)]);return o}function G4(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i){i[s].id&&r.includes(i[s].id)&&t.push(new X0(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new X0(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url);const a={id:{type:"string",required:!0},url:{type:"string",required:!0}};t=t.concat(T4({key:`${n}[${s}]`,value:i[s],valueSpec:a,validateSpec:e.validateSpec}))}return t}return O4({key:n,value:i})}function H4(e){return function(e){return!!e&&e.constructor===Object}(e.value)?[]:[new X0(e.key,e.value,`object expected, ${u4(e.value)} found`)]}const Q4={"*":()=>[],array:E4,boolean:function(e){const t=e.value,i=e.key,n=u4(t);return"boolean"!==n?[new X0(i,t,`boolean expected, ${n} found`)]:[]},number:C4,color:I4,constants:x4,enum:M4,filter:P4,function:S4,layer:D4,object:T4,source:U4,light:N4,sky:V4,terrain:j4,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=u4(t);if(void 0===t)return[];if("object"!==o)return[new X0("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=n[o]?s.concat(e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i})):s.concat([new X0(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=u4(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new X0(t,i,`projection expected, invalid type "${n}" found`)]:[new X0(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:O4,formatted:function(e){return 0===O4(e).length?[]:B4(e)},resolvedImage:function(e){return 0===O4(e).length?[]:B4(e)},padding:function(e){const t=e.key,i=e.value;if("array"===u4(i)){if(i.length<1||i.length>4)return[new X0(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(x4({key:"constants",value:e.constants}))),K4(i)}function q4(e){return function(t){return e({...t,validateSpec:$4})}}function K4(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function X4(e){return function(...t){return K4(e.apply(this,t))}}function J4(e){if(!e)return{style:lY[oY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0};if("string"==typeof e){const t=function(e){try{const t=JSON.parse(e),i=W4(t);return{isValidJSON:!0,isValidStyle:0===i.length,styleObject:0===i.length?t:null}}catch{return{isValidJSON:!1,isValidStyle:!1,styleObject:null}}}(e);return t.isValidStyle?{style:t.styleObject,requiresUrlMonitoring:!1,isFallback:!1}:t.isValidJSON?{style:lY[oY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0}:e.startsWith("http")?{style:e,requiresUrlMonitoring:!0,isFallback:!1}:e.toLowerCase().includes(".json")?{style:Y4(e),requiresUrlMonitoring:!0,isFallback:!1}:{style:iY(e),requiresUrlMonitoring:!0,isFallback:!1}}return e instanceof nY?{style:e.getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!1}:e instanceof rY?{style:e.getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!1}:0===W4(e).length?{style:e,requiresUrlMonitoring:!1,isFallback:!1,isJSON:!0}:{style:lY[oY[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL(),requiresUrlMonitoring:!1,isFallback:!0}}function Y4(e){try{return new URL(e).href}catch{}return new URL(e,location.origin).href}function e5(e,t,i){const n=window.document.createElement(e);return void 0!==t&&(n.className=t),i&&i.appendChild(n),n}function t5(e){e.parentNode&&e.parentNode.removeChild(e)}W4.source=X4(q4(U4)),W4.sprite=X4(q4(G4)),W4.glyphs=X4(q4(Z4)),W4.light=X4(q4(N4)),W4.sky=X4(q4(V4)),W4.terrain=X4(q4(j4)),W4.state=X4(q4(H4)),W4.layer=X4(q4(D4)),W4.filter=X4(q4(P4)),W4.paintProperty=X4(q4(F4)),W4.layoutProperty=X4(q4(k4));class i5{constructor(){QY(this,"_map"),QY(this,"_container"),QY(this,"_terrainButton"),function(e,t){for(const i of e)"function"==typeof t[i]&&(t[i]=t[i].bind(t))}(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(e){return this._map=e,this._container=e5("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=e5("button","maplibregl-ctrl-terrain",this._container),e5("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){t5(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){n5(this._map),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))}}function n5(e){e.hasTerrain()?e.disableTerrain():e.enableTerrain()}class r5 extends a0{constructor(e={}){super({showCompass:e.showCompass??!0,showZoom:e.showZoom??!0,visualizePitch:e.visualizePitch??!0}),QY(this,"_rotateCompassArrow",()=>{const e=this._map.getBearing(),t=this._map.getPitch(),i=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.cos(t*(Math.PI/180))**.5)}) rotateX(${Math.min(70,t)}deg) rotateZ(${-e}deg)`:`rotate(${-e}deg)`;this._compassIcon.style.transform=i}),this._compass&&(this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",e=>{0===this._map.getPitch()?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}))}_createButton(e,t){const i=super._createButton(e,t);return i.clickFunction=t,i}}const o5=iJ.Marker,s5=iJ.LngLat,a5=iJ.LngLatBounds;class l5 extends l0{constructor(){super(...arguments),QY(this,"lastUpdatedCenter",new s5(0,0)),QY(this,"_updateCamera",e=>{var t;const i=new s5(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r={bearing:this._map.getBearing(),...this.options.fitBoundsOptions,linear:!0},o=this._map.getZoom();o>((null==(t=this.options.fitBoundsOptions)?void 0:t.maxZoom)??30)&&(r.zoom=o),this._map.fitBounds(a5.fromLngLat(i,n),r,{geolocateSource:!0});let s=!1;const a=()=>{s=!0};this._map.once("click",a),this._map.once("dblclick",a),this._map.once("dragstart",a),this._map.once("mousedown",a),this._map.once("touchstart",a),this._map.once("wheel",a),this._map.once("moveend",()=>{this._map.off("click",a),this._map.off("dblclick",a),this._map.off("dragstart",a),this._map.off("mousedown",a),this._map.off("touchstart",a),this._map.off("wheel",a),!s&&(this.lastUpdatedCenter=this._map.getCenter())})}),QY(this,"_finishSetupUI",e=>{if(this._map){if(!1===e){const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=e5("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new o5({element:this._dotElement}),this._circleElement=e5("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new o5({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",e=>{const t=e.originalEvent&&"resize"===e.originalEvent.type,i=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!e.geolocateSource&&"ACTIVE_LOCK"===this._watchState&&!t&&i>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})}}),QY(this,"_onZoom",()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()})}_updateCircleRadius(){if("BACKGROUND"!==this._watchState&&"ACTIVE_LOCK"!==this._watchState)return;const e=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],t=this._map.project(e),i=this._map.unproject([t.x,t.y]),n=this._map.unproject([t.x+20,t.y]),r=i.distanceTo(n)/20,o=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}}var c5,u5,h5,d5,p5;class f5{constructor(e,t,i){if(WY(this,c5),WY(this,u5),WY(this,h5),WY(this,d5),WY(this,p5),"string"==typeof e){const t=document.querySelector(e);if(!t)throw new Error(`No element has been found with selector "${e}" when creating an external control.`);qY(this,u5,t)}else qY(this,u5,e);t&&qY(this,h5,e=>{t(ZY(this,c5),ZY(this,u5),e)}),i&&qY(this,d5,e=>{i(ZY(this,c5),ZY(this,u5),e)}),qY(this,p5,ZY(this,u5).parentElement)}onAdd(e){return qY(this,c5,e),ZY(this,h5)&&ZY(this,u5).addEventListener("click",ZY(this,h5)),ZY(this,d5)&&ZY(this,c5).on("render",ZY(this,d5)),t5(ZY(this,u5)),ZY(this,u5)}onRemove(){ZY(this,h5)&&ZY(this,u5).removeEventListener("click",ZY(this,h5)),ZY(this,d5)&&ZY(this,c5).off("render",ZY(this,d5)),ZY(this,p5)?ZY(this,p5).appendChild(ZY(this,u5)):t5(ZY(this,u5))}}c5=new WeakMap,u5=new WeakMap,h5=new WeakMap,d5=new WeakMap,p5=new WeakMap;class m5{constructor(){QY(this,"map"),QY(this,"container"),QY(this,"projectionButton")}onAdd(e){return this.map=e,this.container=e5("div","maplibregl-ctrl maplibregl-ctrl-group"),this.projectionButton=e5("button","maplibregl-ctrl-projection",this.container),e5("span","maplibregl-ctrl-icon",this.projectionButton).setAttribute("aria-hidden","true"),this.projectionButton.type="button",this.projectionButton.addEventListener("click",this.toggleProjection.bind(this)),e.on("projectiontransition",this.updateProjectionIcon.bind(this)),this.updateProjectionIcon(),this.container}onRemove(){t5(this.container),this.map.off("projectiontransition",this.updateProjectionIcon),this.map=void 0}toggleProjection(){g5(this.map),this.updateProjectionIcon()}updateProjectionIcon(){this.projectionButton.classList.remove("maplibregl-ctrl-projection-globe"),this.projectionButton.classList.remove("maplibregl-ctrl-projection-mercator"),this.map.isGlobeProjection()?(this.projectionButton.classList.add("maplibregl-ctrl-projection-mercator"),this.projectionButton.title="Enable Mercator projection"):(this.projectionButton.classList.add("maplibregl-ctrl-projection-globe"),this.projectionButton.title="Enable Globe projection")}}function g5(e){void 0===e.getProjection()&&e.setProjection({type:"mercator"}),e.isGlobeProjection()?e.enableMercatorProjection():e.enableGlobeProjection()}const _5={"zoom-in":e=>e.zoomIn(),"zoom-out":e=>e.zoomOut(),"toggle-projection":g5,"toggle-terrain":n5,"reset-view":e=>{0===e.getPitch()?e.easeTo({pitch:Math.min(e.getMaxPitch(),80)}):e.resetNorthPitch()},"reset-bearing":e=>{e.rotateTo(0)},"reset-pitch":e=>{e.setPitch(0)},"reset-roll":e=>{e.setRoll(0)}};var A5,y5,v5,x5,b5,w5,T5,E5,C5,S5,B5,I5;class M5 extends f5{constructor(e,t){if(t&&!(t in _5))throw new Error(`data-maptiler-control value "${t}" is invalid.`);super(e,t&&_5[t]),WY(this,A5),WY(this,y5,new Map)}onAdd(e){return qY(this,A5,e),super.onAdd(e)}onRemove(){for(const[e,t]of ZY(this,y5)){const i=e.deref();i&&i.removeEventListener("click",t)}ZY(this,y5).clear(),super.onRemove()}configureGroupItem(e,t){if(!t)return;if(!(t in _5))throw new Error(`data-maptiler-control value "${t}" is invalid.`);const i=i=>{_5[t](ZY(this,A5),e,i)};e.addEventListener("click",i),ZY(this,y5).set(new WeakRef(e),i)}}A5=new WeakMap,y5=new WeakMap,QY(M5,"controlCallbacks",_5);class P5{constructor(e,t){WY(this,C5),WY(this,v5),QY(this,"map"),WY(this,x5),WY(this,b5),WY(this,w5),WY(this,T5,!1),WY(this,E5),void 0!==e.style&&qY(this,T5,!0),qY(this,v5,{zoomAdjust:-4,position:"top-right",...t,forceNoAttributionControl:!0,attributionControl:!1,navigationControl:!1,geolocateControl:!1,maptilerLogo:!1,minimap:!1,hash:!1,pitchAdjust:!1,...e,containerStyle:{border:"1px solid #000",width:"400px",height:"300px",...e.containerStyle??{}}}),void 0!==e.lockZoom&&(ZY(this,v5).minZoom=e.lockZoom,ZY(this,v5).maxZoom=e.lockZoom)}setStyle(e,t){ZY(this,T5)||this.map.setStyle(e,t),KY(this,C5,B5).call(this)}addLayer(e,t){return ZY(this,T5)||this.map.addLayer(e,t),KY(this,C5,B5).call(this),this.map}moveLayer(e,t){return ZY(this,T5)||this.map.moveLayer(e,t),KY(this,C5,B5).call(this),this.map}removeLayer(e){return ZY(this,T5)||this.map.removeLayer(e),KY(this,C5,B5).call(this),this}setLayerZoomRange(e,t,i){return ZY(this,T5)||this.map.setLayerZoomRange(e,t,i),KY(this,C5,B5).call(this),this}setFilter(e,t,i){return ZY(this,T5)||this.map.setFilter(e,t,i),KY(this,C5,B5).call(this),this}setPaintProperty(e,t,i,n){return ZY(this,T5)||this.map.setPaintProperty(e,t,i,n),KY(this,C5,B5).call(this),this}setLayoutProperty(e,t,i,n){return ZY(this,T5)||this.map.setLayoutProperty(e,t,i,n),KY(this,C5,B5).call(this),this}setGlyphs(e,t){return ZY(this,T5)||this.map.setGlyphs(e,t),KY(this,C5,B5).call(this),this}onAdd(e){qY(this,x5,e),qY(this,b5,e5("div","maplibregl-ctrl maplibregl-ctrl-group"));for(const[e,t]of Object.entries(ZY(this,v5).containerStyle))ZY(this,b5).style.setProperty(e,t);return ZY(this,v5).container=ZY(this,b5),ZY(this,v5).zoom=e.getZoom()+ZY(this,v5).zoomAdjust,this.map=new k6(ZY(this,v5)),this.map.once("style.load",()=>{this.map.resize()}),this.map.once("load",()=>{KY(this,C5,S5).call(this,ZY(this,v5).parentRect),qY(this,E5,KY(this,C5,I5).call(this))}),ZY(this,b5)}onRemove(){var e;null==(e=ZY(this,E5))||e.call(this),t5(ZY(this,b5))}}v5=new WeakMap,x5=new WeakMap,b5=new WeakMap,w5=new WeakMap,T5=new WeakMap,E5=new WeakMap,C5=new WeakSet,S5=function(e){void 0===e||void 0===e.linePaint&&void 0===e.fillPaint||(qY(this,w5,{type:"Feature",properties:{name:"parentRect"},geometry:{type:"Polygon",coordinates:[[[],[],[],[],[]]]}}),this.map.addSource("parentRect",{type:"geojson",data:ZY(this,w5)}),(void 0!==e.lineLayout||void 0!==e.linePaint)&&this.map.addLayer({id:"parentRectOutline",type:"line",source:"parentRect",layout:{...e.lineLayout},paint:{"line-color":"#FFF","line-width":1,"line-opacity":.85,...e.linePaint}}),void 0!==e.fillPaint&&this.map.addLayer({id:"parentRectFill",type:"fill",source:"parentRect",layout:{},paint:{"fill-color":"#08F","fill-opacity":.135,...e.fillPaint}}),KY(this,C5,B5).call(this))},B5=function(){if(void 0===ZY(this,w5))return;const{devicePixelRatio:e}=window,t=ZY(this,x5).getCanvas(),i=t.width/e,n=t.height/e,r=ZY(this,x5).unproject.bind(ZY(this,x5)),o=r([0,0]),s=r([i,0]),a=r([0,n]),l=r([i,n]);ZY(this,w5).geometry.coordinates=[[a.toArray(),l.toArray(),s.toArray(),o.toArray(),a.toArray()]];const c=this.map.getSource("parentRect");void 0!==c&&c.setData(ZY(this,w5))},I5=function(){const{pitchAdjust:e}=ZY(this,v5),t=()=>{o("parent")},i=()=>{o("minimap")},n=()=>{ZY(this,x5).on("move",t),this.map.on("move",i)},r=()=>{ZY(this,x5).off("move",t),this.map.off("move",i)},o=t=>{r();const i="parent"===t?ZY(this,x5):this.map,o="parent"===t?this.map:ZY(this,x5),s=i.getCenter(),a=i.getZoom()+ZY(this,v5).zoomAdjust*("parent"===t?1:-1),l=i.getBearing(),c=i.getPitch();o.jumpTo({center:s,zoom:a,bearing:l,pitch:e?c:0}),KY(this,C5,B5).call(this),n()};return n(),()=>{r()}};class R5{constructor(e,t=2e3){QY(this,"map"),QY(this,"registeredModules",new Set),QY(this,"viewerType"),this.map=e,this.viewerType="Map",setTimeout(async()=>{if(!S0.telemetry)return;const e=this.preparePayload();try{(await fetch(e,{method:"POST"})).ok||console.warn("The metrics could not be sent to MapTiler Cloud")}catch(e){console.warn("The metrics could not be sent to MapTiler Cloud",e)}},Math.max(1e3,t))}registerModule(e,t){this.registeredModules.add(`${e}:${t}`)}registerViewerType(e="Map"){this.viewerType=e}preparePayload(){const e=new URL(T0.telemetryURL);return e.searchParams.append("sdk","3.9.0"),e.searchParams.append("key",S0.apiKey),e.searchParams.append("mtsid",E0),e.searchParams.append("session",S0.session?"1":"0"),e.searchParams.append("caching",S0.caching?"1":"0"),e.searchParams.append("lang-updated",this.map.isLanguageUpdated()?"1":"0"),e.searchParams.append("terrain",this.map.getTerrain()?"1":"0"),e.searchParams.append("globe",this.map.isGlobeProjection()?"1":"0"),e.searchParams.append("viewerType",this.viewerType),this.registeredModules.size>0&&e.searchParams.append("modules",Array.from(this.registeredModules).join("|")),e.href}}var L5=typeof Float32Array<"u"?Float32Array:Array;function F5(){var e=new L5(16);return L5!=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}function k5(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=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*r+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function D5(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=t[5],h=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*r+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}var O5,z5,U5,N5,V5,j5,G5,H5,Q5=function(e,t,i,n,r){var o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,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!=r&&r!==1/0){var s=1/(n-r);e[10]=(r+n)*s,e[14]=2*r*n*s}else e[10]=-1,e[14]=-2*n;return e};function $5(){var e=new L5(3);return L5!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Z5(e,t){var i=t[0],n=t[1],r=t[2],o=i*i+n*n+r*r;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function W5(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}function q5(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function K5(){if(N5)return U5;N5=1;const e=(z5||(z5=1,O5={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}),O5),t={};for(const i of Object.keys(e))t[e[i]]=i;const i={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};U5=i;for(const e of Object.keys(i)){if(!("channels"in i[e]))throw new Error("missing channels property: "+e);if(!("labels"in i[e]))throw new Error("missing channel labels property: "+e);if(i[e].labels.length!==i[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:n}=i[e];delete i[e].channels,delete i[e].labels,Object.defineProperty(i[e],"channels",{value:t}),Object.defineProperty(i[e],"labels",{value:n})}function n(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}return i.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(t,i,n),o=Math.max(t,i,n),s=o-r;let a,l;o===r?a=0:t===o?a=(i-n)/s:i===o?a=2+(n-t)/s:n===o&&(a=4+(t-i)/s),a=Math.min(60*a,360),a<0&&(a+=360);const c=(r+o)/2;return l=o===r?0:c<=.5?s/(o+r):s/(2-o-r),[a,100*l,100*c]},i.rgb.hsv=function(e){let t,i,n,r,o;const s=e[0]/255,a=e[1]/255,l=e[2]/255,c=Math.max(s,a,l),u=c-Math.min(s,a,l),h=function(e){return(c-e)/6/u+.5};return 0===u?(r=0,o=0):(o=u/c,t=h(s),i=h(a),n=h(l),s===c?r=n-i:a===c?r=1/3+t-n:l===c&&(r=2/3+i-t),r<0?r+=1:r>1&&(r-=1)),[360*r,100*o,100*c]},i.rgb.hwb=function(e){const t=e[0],n=e[1];let r=e[2];const o=i.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(n,r));return r=1-1/255*Math.max(t,Math.max(n,r)),[o,100*s,100*r]},i.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(1-t,1-i,1-n);return[100*((1-t-r)/(1-r)||0),100*((1-i-r)/(1-r)||0),100*((1-n-r)/(1-r)||0),100*r]},i.rgb.keyword=function(i){const r=t[i];if(r)return r;let o,s=1/0;for(const t of Object.keys(e)){const r=n(i,e[t]);r.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,n=n>.04045?((n+.055)/1.055)**2.4:n/12.92;return[100*(.4124*t+.3576*i+.1805*n),100*(.2126*t+.7152*i+.0722*n),100*(.0193*t+.1192*i+.9505*n)]},i.rgb.lab=function(e){const t=i.rgb.xyz(e);let n=t[0],r=t[1],o=t[2];n/=95.047,r/=100,o/=108.883,n=n>.008856?n**(1/3):7.787*n+16/116,r=r>.008856?r**(1/3):7.787*r+16/116,o=o>.008856?o**(1/3):7.787*o+16/116;return[116*r-16,500*(n-r),200*(r-o)]},i.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let r,o,s;if(0===i)return s=255*n,[s,s,s];r=n<.5?n*(1+i):n+i-n*i;const a=2*n-r,l=[0,0,0];for(let e=0;e<3;e++)o=t+1/3*-(e-1),o<0&&o++,o>1&&o--,s=6*o<1?a+6*(r-a)*o:2*o<1?r:3*o<2?a+(r-a)*(2/3-o)*6:a,l[e]=255*s;return l},i.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,r=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,r*=o<=1?o:2-o;return[t,100*(0===n?2*r/(o+r):2*i/(n+i)),100*((n+i)/2)]},i.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const r=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,r){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},i.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,r=Math.max(n,.01);let o,s;s=(2-i)*n;const a=(2-i)*r;return o=i*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},i.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const r=i+n;let o;r>1&&(i/=r,n/=r);const s=Math.floor(6*t),a=1-n;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},i.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},i.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let r,o,s;return r=3.2406*t+-1.5372*i+-.4986*n,o=-.9689*t+1.8758*i+.0415*n,s=.0557*t+-.204*i+1.057*n,r=r>.0031308?1.055*r**(1/2.4)-.055:12.92*r,o=o>.0031308?1.055*o**(1/2.4)-.055:12.92*o,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,r=Math.min(Math.max(0,r),1),o=Math.min(Math.max(0,o),1),s=Math.min(Math.max(0,s),1),[255*r,255*o,255*s]},i.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>.008856?t**(1/3):7.787*t+16/116,i=i>.008856?i**(1/3):7.787*i+16/116,n=n>.008856?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},i.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const r=i**3,o=t**3,s=n**3;return i=r>.008856?r:(i-16/116)/7.787,t=o>.008856?o:(t-16/116)/7.787,n=s>.008856?s:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},i.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let r;r=360*Math.atan2(n,i)/2/Math.PI,r<0&&(r+=360);return[t,Math.sqrt(i*i+n*n),r]},i.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},i.rgb.ansi16=function(e,t=null){const[n,r,o]=e;let s=null===t?i.rgb.hsv(e)[2]:t;if(s=Math.round(s/50),0===s)return 30;let a=30+(Math.round(o/255)<<2|Math.round(r/255)<<1|Math.round(n/255));return 2===s&&(a+=60),a},i.hsv.ansi16=function(e){return i.rgb.ansi16(i.hsv.rgb(e),e[2])},i.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];return t===i&&i===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},i.ansi16.rgb=function(e){let t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(1+~~(e>50));return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},i.ansi256.rgb=function(e){if(e>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},i.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},i.hex.rgb=function(e){const t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=i.split("").map(e=>e+e).join(""));const n=parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},i.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),s=r-o;let a,l;return a=s<1?o/(1-s):0,l=s<=0?0:r===t?(i-n)/s%6:r===i?2+(n-t)/s:4+(t-i)/s,l/=6,l%=1,[360*l,100*s,100*a]},i.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let r=0;return n<1&&(r=(i-.5*n)/(1-n)),[e[0],100*n,100*r]},i.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},i.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const r=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return l=(1-i)*n,[255*(i*r[0]+l),255*(i*r[1]+l),255*(i*r[2]+l)]},i.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},i.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},i.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},i.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},i.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},i.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},i.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},i.gray.hsl=function(e){return[0,0,e[0]]},i.gray.hsv=i.gray.hsl,i.gray.hwb=function(e){return[0,100,e[0]]},i.gray.cmyk=function(e){return[0,0,0,e[0]]},i.gray.lab=function(e){return[e[0],0,0]},i.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(i.length)+i},i.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]},U5}function X5(){if(j5)return V5;j5=1;const e=K5();function t(t){const i=function(){const t={},i=Object.keys(e);for(let e=i.length,n=0;n{i[n]={},Object.defineProperty(i[n],"channels",{value:e[n].channels}),Object.defineProperty(i[n],"labels",{value:e[n].labels});const r=t(n);Object.keys(r).forEach(e=>{const t=r[e];i[n][e]=function(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let e=n.length,t=0;t1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(t)})}),G5=i}();const Y5=q5(J5);function e6({gl:e,type:t,source:i}){const n=e.createShader(t);if(null===n)throw new Error("Cannot create shader");if(e.shaderSource(n,i),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw console.error("Shader compilation error:",e.getShaderInfoLog(n)),e.deleteShader(n),new Error("Cannot compile shader");return n}function t6({gl:e,vertexShaderSource:t,fragmentShaderSource:i,attributesKeys:n,uniformsKeys:r,vertices:o,indices:s}){const a=function({gl:e,vertexShaderSource:t,fragmentShaderSource:i}){const n=e6({gl:e,type:e.VERTEX_SHADER,source:t}),r=e6({gl:e,type:e.FRAGMENT_SHADER,source:i}),o=e.createProgram();if(e.attachShader(o,n),e.attachShader(o,r),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw console.error("Error: ",e.getProgramInfoLog(o)),new Error("Cannot link shader program");return o}({gl:e,vertexShaderSource:t,fragmentShaderSource:i}),l=n.reduce((t,i)=>(t[i]=e.getAttribLocation(a,`a_${i}`),t),{}),c=r.reduce((t,i)=>(t[i]=function(e,t,i){const n=e.getUniformLocation(t,i);if(null===n)throw new Error(`Cannot get uniform location for ${i}`);return n}(e,a,`u_${i}`),t),{}),u=e.createBuffer();let h,d;return e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,new Float32Array(o),e.STATIC_DRAW),void 0!==s&&(h=e.createBuffer(),d=s.length,e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h),e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(s),e.STATIC_DRAW)),{shaderProgram:a,programInfo:{attributesLocations:l,uniformsLocations:c},positionBuffer:u,indexBuffer:h,indexBufferLength:d}}function i6(e){if(!e)return[1,1,1,0];if("transparent"===e)return[1,1,1,0];try{const t=function(e){return n6=n6??document.createElement("canvas").getContext("2d"),n6?(n6.fillStyle=e,n6.fillStyle):"#000000"}(e),i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(t);if(null!=i&&i.length){const e=!!i[4];return[...Y5.hex.rgb(t).map(e=>e/255),e?parseInt(i[4],16)/255:1]}const n=t.match(/(\d\.\d(\d+)?|\d{3}|\d{2}|\d{1})/gi)??["0","0","0"];if(t.includes("rgb")){const e=t.includes("rgba"),i=[...n.map(e=>parseFloat(e)).map((e,t)=>t<3?e/255:e)];return e||i.push(1),i}}catch{}return console.warn([`[parseColorStringToVec4]: Color ${e} is either not a valid color or its type is not supported, defaulting to black`]),[0,0,0,1]}let n6;const r6=.5,o6=.5,s6=.5,a6=[...[-.5,-.5,s6,r6,-.5,s6,r6,o6,s6,-.5,o6,s6],...[-.5,-.5,-.5,-.5,o6,-.5,r6,o6,-.5,r6,-.5,-.5],...[-.5,o6,-.5,-.5,o6,s6,r6,o6,s6,r6,o6,-.5],...[-.5,-.5,-.5,r6,-.5,-.5,r6,-.5,s6,-.5,-.5,s6],...[r6,-.5,-.5,r6,o6,-.5,r6,o6,s6,r6,-.5,s6],...[-.5,-.5,-.5,-.5,-.5,s6,-.5,o6,s6,-.5,o6,-.5]],l6=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],c6="precision mediump float;\n\nvarying vec3 vTextureCoord;\n\n%USE_TEXTURE_MACRO_MARKER%\n\n# ifdef USE_TEXTURE\nuniform samplerCube u_cubeSampler;\nuniform float u_fadeOpacity;\n# endif\n\nuniform vec4 u_bgColor;\n\nvoid main(void) {\n #ifdef USE_TEXTURE\n vec4 texColor = textureCube(u_cubeSampler, vTextureCoord);\n\n gl_FragColor = mix(\n u_bgColor,\n texColor,\n min(texColor.a, u_fadeOpacity)\n );\n\n gl_FragColor.a = max(gl_FragColor.a, u_fadeOpacity);\n\n #else\n gl_FragColor = u_bgColor;\n #endif\n}\n";var u6=(e=>(e.UNIVERSE_DARK="universe-dark",e))(u6||{});const h6={stars:{color:"hsl(233,100%,92%)",preset:"stars"},space:{color:"hsl(210, 100%, 4%)",preset:"space"},milkyway:{color:"hsl(233,100%,92%)",preset:"milkyway"},"milkyway-subtle":{color:"hsl(233,100%,92%)",preset:"milkyway-subtle"},"milkyway-bright":{color:"hsl(233,100%,92%)",preset:"milkyway-bright"},"milkyway-colored":{color:"black",preset:"milkyway-colored"}};var d6=(e=>(e.POSITIVE_X="pX",e.NEGATIVE_X="nX",e.POSITIVE_Y="pY",e.NEGATIVE_Y="nY",e.POSITIVE_Z="pZ",e.NEGATIVE_Z="nZ",e))(d6||{});const p6=new Map,f6=new Map;let m6;function g6(e,t){if(t===d6.POSITIVE_X)return e.TEXTURE_CUBE_MAP_POSITIVE_X;if(t===d6.NEGATIVE_X)return e.TEXTURE_CUBE_MAP_NEGATIVE_X;if(t===d6.POSITIVE_Y)return e.TEXTURE_CUBE_MAP_POSITIVE_Y;if(t===d6.NEGATIVE_Y)return e.TEXTURE_CUBE_MAP_NEGATIVE_Y;if(t===d6.POSITIVE_Z)return e.TEXTURE_CUBE_MAP_POSITIVE_Z;if(t===d6.NEGATIVE_Z)return e.TEXTURE_CUBE_MAP_NEGATIVE_Z;throw new Error(`[CubemapLayer][loadCubemapTexture]: Invalid key ${t}`)}function _6(e,t,i){return e+(t-e)*i}function A6(e){if(!e)return{};const t=Object.keys(e).sort().map(t=>[t,e[t]]);return Object.fromEntries(t)}const y6="https://api.maptiler.com/resources/space",v6=["vertexPosition"],x6=["projectionMatrix","modelViewMatrix","cubeSampler","bgColor","fadeOpacity"],b6="%USE_TEXTURE_MACRO_MARKER%",w6=h6.stars;class T6{constructor(e){QY(this,"id","Cubemap Layer"),QY(this,"type","custom"),QY(this,"renderingMode","3d"),QY(this,"map"),QY(this,"faces"),QY(this,"useCubemapTexture",!0),QY(this,"currentFadeOpacity",0),QY(this,"cubeMapNeedsUpdate",!1),QY(this,"bgColor"),QY(this,"previousBgColor",[0,0,0,0]),QY(this,"targetBgColor",[0,0,0,0]),QY(this,"transitionDelta",0),QY(this,"gl"),QY(this,"cubemap"),QY(this,"texture"),QY(this,"currentFacesDefinitionKey",""),QY(this,"options"),QY(this,"animationActive",!0),QY(this,"imageIsAnimating",!1),QY(this,"imageFadeInDelta",0);const t=function(e,t){if(!E6(e))return{color:"transparent"};if(!0===e)return t;const i={...e};if(e.faces||e.path)return delete i.preset,i;const n=e.preset;if(void 0!==n&&!(n in h6))throw new Error(`[CubemapLayer]: Invalid preset "${n}". Available presets: ${Object.keys(h6).join(", ")}`);return{...i,color:i.color??h6[n].color??"hsl(233,100%,92%)"}}(e,w6);this.options=t,this.currentFacesDefinitionKey=JSON.stringify(t.faces??t.preset??t.path),this.bgColor=[0,0,0,0],this.targetBgColor=i6(t.color),this.faces=C6(t),this.useCubemapTexture=null!==this.faces}updateCubemap({facesNeedUpdate:e}={facesNeedUpdate:!0}){this.useCubemapTexture=null!==this.faces;const t=x6.filter(e=>"cubeSampler"!==e&&"fadeOpacity"!==e||this.useCubemapTexture);this.cubemap=t6({gl:this.gl,vertexShaderSource:"attribute vec3 a_vertexPosition;\nvarying vec3 vTextureCoord;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_modelViewMatrix;\n \nvoid main(void) {\n vTextureCoord = vec3(-a_vertexPosition.x, a_vertexPosition.y, a_vertexPosition.z);\n gl_Position = u_projectionMatrix * u_modelViewMatrix * vec4(a_vertexPosition, 1.0);\n}\n",fragmentShaderSource:this.useCubemapTexture?c6.replace(b6,"#define USE_TEXTURE"):c6.replace(b6,""),attributesKeys:v6,uniformsKeys:t,vertices:a6,indices:l6}),this.cubeMapNeedsUpdate=e,this.useCubemapTexture&&this.updateTexture(this.gl,this.faces),this.animateColorChange()}onAdd(e,t){this.map=e,this.gl=t,this.updateCubemap()}onRemove(e,t){this.cubemap&&(this.texture&&t.deleteTexture(this.texture),t.deleteProgram(this.cubemap.shaderProgram),t.deleteBuffer(this.cubemap.positionBuffer),this.texture=void 0)}updateTexture(e,t){if(!0===this.cubeMapNeedsUpdate&&!this.imageIsAnimating){if(this.cubeMapNeedsUpdate=!1,!this.useCubemapTexture)return;!function({gl:e,faces:t,onReady:i,forceRefresh:n}){if(p6.get(e)&&!n&&m6===JSON.stringify(t))return void i(p6.get(e),f6.get(e));m6=JSON.stringify(t);const r=p6.get(e)??e.createTexture();if(!t)return void console.warn("[CubemapLayer][loadCubemapTexture]: Faces are null");const o=Object.keys(t).length;if(6!==o)return void console.warn(`[CubemapLayer][loadCubemapTexture]: Faces should contain exactly 6 images, but found ${o}`);const s=Object.entries(t).map(([e,t])=>new Promise((i,n)=>{const r=e;if(void 0===t)return void n(new Error(`[CubemapLayer][loadCubemapTexture]: Face ${e} is undefined`));const o=new Image;o.crossOrigin="anonymous";const s=()=>{i({image:o,key:r})};o.src=t,o.complete&&o.naturalWidth>0?s():o.onload=s,o.onerror=()=>{n(new Error(`[CubemapLayer][loadCubemapTexture]: Error loading image ${t}`))}}));Promise.all(s).then(t=>{for(let i=0;ie.image);i(r,n),f6.set(e,n),p6.set(e,r)}).catch(e=>{console.error("[CubemapLayer][loadCubemapTexture]: Error loading cubemap texture",e)})}({gl:e,faces:t,onReady:e=>{this.texture=e,this.animateIn()}})}}prerender(e,t){this.faces&&this.updateTexture(this.gl,this.faces)}animateColorChange(){const e=()=>{this.transitionDelta<1&&(requestAnimationFrame(e),this.bgColor=function(e,t,i){return[_6(e[0],t[0],i),_6(e[1],t[1],i),_6(e[2],t[2],i),_6(e[3],t[3],i)]}(this.previousBgColor,this.targetBgColor,this.transitionDelta),this.transitionDelta+=.075,this.map.triggerRepaint())};requestAnimationFrame(e)}async animateIn(){if(!this.imageIsAnimating)return this.animationActive?new Promise(e=>{this.imageIsAnimating=!0;const t=()=>{this.imageFadeInDelta=Math.min(this.imageFadeInDelta+.05,1),this.currentFadeOpacity=_6(0,1,this.imageFadeInDelta),this.map.triggerRepaint(),this.imageFadeInDelta<1?requestAnimationFrame(t):(this.imageIsAnimating=!1,this.imageFadeInDelta=0,e())};requestAnimationFrame(t)}):(this.currentFadeOpacity=1,this.imageFadeInDelta=1,void this.map.triggerRepaint())}async animateOut(){if(!this.imageIsAnimating&&this.animationActive)return new Promise(e=>{const t=()=>{if(this.imageFadeInDelta=Math.min(this.imageFadeInDelta+.05,1),this.currentFadeOpacity=_6(1,0,this.imageFadeInDelta),this.map.triggerRepaint(),this.imageFadeInDelta>=1)return this.imageIsAnimating=!1,this.imageFadeInDelta=0,void e();requestAnimationFrame(t)};requestAnimationFrame(t)})}setAnimationActive(e){this.animationActive=e}render(e,t){if(!this.map.isGlobeProjection())return;if(void 0===this.map)throw new Error("[CubemapLayer]: Map is undefined");if(void 0===this.cubemap)throw new Error("[CubemapLayer]: Cubemap is undefined");this.texture,e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.DST_ALPHA),e.useProgram(this.cubemap.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.cubemap.positionBuffer),e.vertexAttribPointer(this.cubemap.programInfo.attributesLocations.vertexPosition,3,e.FLOAT,!1,0,0),e.enableVertexAttribArray(this.cubemap.programInfo.attributesLocations.vertexPosition);const i=e.canvas,n=i.clientWidth/i.clientHeight,r=this.map.transform,o=r.fov*(Math.PI/180),s=F5();Q5(s,o,n,.1,1e4),D5(s,s,r.rollInRadians),k5(s,s,-r.pitchInRadians),D5(s,s,r.bearingInRadians);const a=r.center.lat*Math.PI/180,l=r.center.lng*Math.PI/180;k5(s,s,a),function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];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*r-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r}(s,s,-l),e.uniformMatrix4fv(this.cubemap.programInfo.uniformsLocations.projectionMatrix,!1,s);const c=F5();if(e.uniformMatrix4fv(this.cubemap.programInfo.uniformsLocations.modelViewMatrix,!1,c),e.uniform4fv(this.cubemap.programInfo.uniformsLocations.bgColor,new Float32Array(this.bgColor)),e.uniform1f(this.cubemap.programInfo.uniformsLocations.fadeOpacity,this.currentFadeOpacity),this.useCubemapTexture&&this.texture&&(e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,this.texture),e.uniform1i(this.cubemap.programInfo.uniformsLocations.cubeSampler,0)),void 0===this.cubemap.indexBuffer)throw new Error("Index buffer is undefined");if(void 0===this.cubemap.indexBufferLength)throw new Error("Index buffer length is undefined");e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.cubemap.indexBuffer),e.drawElements(e.TRIANGLES,this.cubemap.indexBufferLength,e.UNSIGNED_SHORT,0)}setBgColor(e){this.targetBgColor=e,this.previousBgColor=this.bgColor,this.transitionDelta=0}getConfig(){return this.options}shouldUpdate(e){const t=this.getConfig();if(void 0===e&&t)return!1;const i=A6(e),n=A6(t);return JSON.stringify(i)!==JSON.stringify(n)}async setCubemapFaces(e){if(await this.animateOut(),!e.faces&&!e.preset&&!e.path)return this.faces=null,this.useCubemapTexture=!1,this.currentFacesDefinitionKey="empty",void await this.animateIn();this.faces=C6(e),this.currentFacesDefinitionKey=JSON.stringify(e.faces??e.preset??e.path)}async setCubemap(e){const t="boolean"==typeof e?w6:e;this.options=t;const i=JSON.stringify(t.faces??t.preset??t.path),n=this.currentFacesDefinitionKey!==i;n&&(await this.setCubemapFaces(t),this.cubeMapNeedsUpdate=!0);const r=i6(t.color);if(t.color&&this.targetBgColor.toString()!==r.toString())this.setBgColor(r);else if(!t.color&&t.preset&&t.preset in h6){const e=h6[t.preset];this.setBgColor(i6(e.color))}this.updateCubemap({facesNeedUpdate:n})}show(){this.map.setLayoutProperty(this.id,"visibility","visible")}hide(){this.map.setLayoutProperty(this.id,"visibility","none")}}function E6(e){return!!e&&("boolean"==typeof e||!(!e.path&&!e.preset&&!e.faces&&!e.color||e.preset&&!(e.preset in h6)||e.faces&&(!e.faces.pX||!e.faces.nX||!e.faces.pY||!e.faces.nY||!e.faces.pZ||!e.faces.nZ)))}function C6(e){if(e.faces)return e.faces;if(e.preset)return{pX:`${y6}/${e.preset}/px.webp`,nX:`${y6}/${e.preset}/nx.webp`,pY:`${y6}/${e.preset}/py.webp`,nY:`${y6}/${e.preset}/ny.webp`,pZ:`${y6}/${e.preset}/pz.webp`,nZ:`${y6}/${e.preset}/nz.webp`};if(e.path){const t=e.path.baseUrl,i=e.path.format??"png";return{pX:`${t}/px.${i}`,nX:`${t}/nx.${i}`,pY:`${t}/py.${i}`,nY:`${t}/ny.${i}`,pZ:`${t}/pz.${i}`,nZ:`${t}/nz.${i}`}}return null}const S6=["position"],B6=["matrix","rotationMatrix","stopsNumber","stops","colors","maxDistance","scale"],I6=[-2,-2,0,2,-2,0,-2,2,0,2,2,0],M6={scale:.9,stops:[[0,"rgba(176, 208, 240, 1)"],[.1,"rgba(98, 168, 229, 0.3)"],[.2,"rgba(98, 168, 229, 0.0)"]]};class P6{constructor(e){if(QY(this,"id","Halo Layer"),QY(this,"type","custom"),QY(this,"renderingMode","3d"),QY(this,"gradient"),QY(this,"scale",0),QY(this,"animationDelta",0),QY(this,"map"),QY(this,"plane"),QY(this,"animationActive",!0),"boolean"==typeof e)return void(this.gradient=M6);const t=L6(e);if(t.length>0)throw new Error(`[RadialGradientLayer]: Invalid Halo specification:\n - ${t.join("\n - ")}\n `);this.gradient={...M6,...e}}onAdd(e,t){this.map=e,this.plane=t6({gl:t,vertexShaderSource:"attribute vec3 a_position;\n\nuniform mat4 u_matrix;\nuniform mat4 u_rotationMatrix;\n\nuniform float u_scale;\n\nvarying vec2 v_pos;\nvarying float v_scale;\n\nvoid main() {\n v_scale = u_scale;\n v_pos = a_position.xy * u_scale;\n gl_Position = u_matrix * u_rotationMatrix * vec4(a_position, 1.0);\n}\n",fragmentShaderSource:"precision mediump float;\nvarying vec2 v_pos;\n \nuniform int u_stopsNumber;\nuniform float u_stops[100];\nuniform vec4 u_colors[100];\nuniform float u_maxDistance;\n\nvarying float v_scale;\n\nconst float EPSILON = 0.000001;\n\nvec2 center = vec2(0.0, 0.0);\nvoid main() {\n float rawDistance = distance(center, v_pos);\n float distanceFromGlobeEdge = rawDistance - 1.0;\n\n vec4 color = u_colors[0];\n\n // if we're further than the max distance, we should not render anything.\n // This is to always render a circle, otherwise we end up rendering\n // to the corners of the plane.\n if (distance(center, v_pos) > u_maxDistance * v_scale) {\n discard;\n }\n\n for (int i = 1; i < 100; i++) {\n // if we're past the last stop\n // we should fill to the end with the last stop color\n if (i >= u_stopsNumber) {\n color = u_colors[i - 1];\n break;\n }\n\n float scaledStopPosition = u_stops[i] * pow(v_scale, 1.6);\n float lastStopValue = u_stops[i - 1];\n float thisStopValue = u_stops[i];\n\n // this is to avoid blending errors when the stops are the same\n // eg when you would want a sharp edge between two stops.\n // `numbersAreEqual` will be 1.0 if the numbers are equal, 0.0 if they are not.\n // We then subtract EPSILON from the last stop making the stop value _almost_ equal\n // to the next stop but not enough to cause blending issues.\n // It's more efficient to do this than an if / else statement.\n float numbersAreEqual = 1.0 - step(EPSILON, abs(lastStopValue - thisStopValue));\n lastStopValue = lastStopValue - numbersAreEqual * EPSILON;\n\n float lastScaledStopPosition = lastStopValue * pow(v_scale, 1.6);\n\n if (distanceFromGlobeEdge <= scaledStopPosition) {\n float stopBlendFactor = (distanceFromGlobeEdge - lastScaledStopPosition) / (scaledStopPosition - lastScaledStopPosition);\n color = mix(u_colors[i - 1], u_colors[i], stopBlendFactor);\n break;\n }\n }\n \n // gl_FragColor = color;\n gl_FragColor = vec4(color.rgb * color.a, color.a);\n}\n",attributesKeys:S6,uniformsKeys:B6,vertices:I6}),this.animateIn()}getConfig(){return this.gradient}shouldUpdate(e){const t=this.getConfig();if(void 0===e&&t)return!1;const i=A6(e),n=A6(t);return JSON.stringify(i)!==JSON.stringify(n)}async animateIn(){return this.animationActive?new Promise(e=>{this.animationDelta=0;const t=()=>{if(this.animationDelta<1)return this.scale=_6(0,this.gradient.scale,this.animationDelta),this.animationDelta+=.06,this.map.triggerRepaint(),void requestAnimationFrame(t);e()};requestAnimationFrame(t)}):(this.scale=this.gradient.scale,this.animationDelta=1,void this.map.triggerRepaint())}async animateOut(){if(this.animationActive)return this.animationDelta=0,new Promise(e=>{const t=()=>{if(this.animationDelta<1)return this.scale=_6(this.gradient.scale,0,this.animationDelta),this.animationDelta+=.06,this.map.triggerRepaint(),void requestAnimationFrame(t);e()};t()})}onRemove(e,t){void 0!==this.plane&&(t.deleteProgram(this.plane.shaderProgram),t.deleteBuffer(this.plane.positionBuffer))}prerender(e,t){}render(e,t){if(void 0===this.map)throw new Error("[RadialGradientLayer]: Map is undefined");if(!this.map.isGlobeProjection())return;if(void 0===this.plane)throw new Error("[RadialGradientLayer]: Plane is undefined");e.disable(e.DEPTH_TEST),e.enable(e.BLEND),e.useProgram(this.plane.shaderProgram),e.bindBuffer(e.ARRAY_BUFFER,this.plane.positionBuffer);const i=this.plane.programInfo.attributesLocations.position;e.enableVertexAttribArray(i),e.vertexAttribPointer(i,3,e.FLOAT,!1,0,0);const n=F5(),r=this.scale;!function(e,t,i){var n=i[0],r=i[1],o=i[2];e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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]}(n,n,[r,r,r]);const o=F5();!function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*n+v*a+x*h+b*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*n+v*a+x*h+b*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*n+v*a+x*h+b*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A}(o,t.defaultProjectionData.mainMatrix,n);const s=this.plane.programInfo.uniformsLocations.matrix;e.uniformMatrix4fv(s,!1,o);const a=F5(),l=this.map.transform.cameraPosition,c=Z5($5(),l),u=function(e,t,i){var n=new L5(3);return n[0]=e,n[1]=t,n[2]=i,n}(0,1,0),h=$5();W5(h,u,c),Z5(h,h);const d=$5();W5(d,c,h),Z5(d,d),function(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){e[0]=t,e[1]=i,e[2]=n,e[3]=r,e[4]=o,e[5]=s,e[6]=a,e[7]=l,e[8]=c,e[9]=u,e[10]=h,e[11]=d,e[12]=p,e[13]=f,e[14]=m,e[15]=g}(a,h[0],h[1],h[2],0,d[0],d[1],d[2],0,c[0],c[1],c[2],0,0,0,0,1);const p=this.plane.programInfo.uniformsLocations.rotationMatrix;e.uniformMatrix4fv(p,!1,a);const f=this.gradient.stops.length,m=[],g=[];for(let e=0;e<=f;e++)if(e0)throw new Error(`[RadialGradientLayer]: Invalid Halo specification:\n - ${t.join("\n - ")}\n `);!0===e?(this.gradient.scale=M6.scale,this.gradient.stops=M6.stops):(this.gradient.scale=e.scale??M6.scale,this.gradient.stops=e.stops??M6.stops),await this.animateIn()}setAnimationActive(e){this.animationActive=e}show(){this.map.setLayoutProperty(this.id,"visibility","visible")}hide(){this.map.setLayoutProperty(this.id,"visibility","none")}}const R6=["scale","stops"];function L6(e){var t;const i=[];if("boolean"==typeof e)return[];try{const t=Object.keys(e).filter(e=>!R6.includes(e));t.length>0&&i.push(`Properties ${t.map(e=>`\`${e}\``).join(", ")} are not supported.`)}catch{i.push("Halo specification is not an object.")}return"number"!=typeof e.scale&&i.push("Halo `scale` property is not a number."),(!e.stops||0===e.stops.length)&&i.push("Halo `stops` property is not an array."),null!=(t=e.stops)&&t.some(e=>"number"!=typeof e[0]||"string"!=typeof e[1])&&i.push("Halo `stops` property is not an array of [number, string]"),i}const F6={POINT:"POINT",COUNTRY:"COUNTRY"};let k6=class e extends iJ.Map{constructor(e){(function(e){const t=j0();if(!t)return;let i=null;if("string"==typeof e?i=document.getElementById(e):e instanceof HTMLElement&&(i=e),!i)throw new Error("The Map container must be provided.");const n=document.createElement("div");throw n.innerHTML=t,n.classList.add("webgl-warning-div"),i.appendChild(n),new Error(t)})(e.container),e.apiKey&&(S0.apiKey=e.apiKey);const{style:t,requiresUrlMonitoring:i,isFallback:n}=J4(e.style);n&&console.warn("Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Fallback to default MapTiler style."),S0.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!");const r=location.hash;let o={compact:!1};e.customAttribution?o.customAttribution=e.customAttribution:e.attributionControl&&"object"==typeof e.attributionControl&&(o={...o,...e.attributionControl});const s={...e,style:t,maplibreLogo:!1,transformRequest:U0(e.transformRequest),attributionControl:!0!==e.forceNoAttributionControl&&o};delete s.style,super(s),QY(this,"telemetry"),QY(this,"space"),QY(this,"halo"),QY(this,"options"),QY(this,"isTerrainEnabled",!1),QY(this,"terrainExaggeration",1),QY(this,"primaryLanguage"),QY(this,"terrainGrowing",!1),QY(this,"terrainFlattening",!1),QY(this,"minimap"),QY(this,"forceLanguageUpdate"),QY(this,"languageAlwaysBeenStyle"),QY(this,"isReady",!1),QY(this,"terrainAnimationDuration",1e3),QY(this,"monitoredStyleUrls"),QY(this,"styleInProcess",!1),QY(this,"curentProjection"),QY(this,"originalLabelStyle",new window.Map),QY(this,"isStyleLocalized",!1),QY(this,"languageIsUpdated",!1),this.options=e,this.setStyle(t),i&&this.monitorStyleUrl(t);const a=()=>{let e="The distant style could not be loaded.";this.getStyle()?e+=" Leaving the style as is.":(this.setStyle(lY.STREETS),e+=`Loading default MapTiler Cloud style "${lY.STREETS.getDefaultVariant().getId()}" as a fallback.`),console.warn(e)};if(this.on("style.load",()=>{this.styleInProcess=!1}),this.on("error",e=>{if(console.error(e.error),e.error instanceof iJ.AJAXError){const t=e.error.url,i=new URL(t);i.search="";const n=i.href;return void(this.monitoredStyleUrls&&this.monitoredStyleUrls.has(n)&&(this.monitoredStyleUrls.delete(n),a()))}this.styleInProcess&&a()}),S0.caching&&!P0&&console.warn("The cache API is only available in secure contexts. More info at https://developer.mozilla.org/en-US/docs/Web/API/Cache"),S0.caching&&P0&&O0(),typeof e.language>"u")this.primaryLanguage=S0.primaryLanguage;else{const t=VJ(e.language,b0);this.primaryLanguage=t??S0.primaryLanguage}this.forceLanguageUpdate=!(this.primaryLanguage===b0.STYLE||this.primaryLanguage===b0.STYLE_LOCK),this.languageAlwaysBeenStyle=this.primaryLanguage===b0.STYLE,this.terrainExaggeration=e.terrainExaggeration??this.terrainExaggeration,this.curentProjection=e.projection,this.on("style.load",e=>{"mercator"===this.curentProjection?this.setProjection({type:"mercator"}):"globe"===this.curentProjection&&this.setProjection({type:"globe"})}),this.once("styledata",async()=>{if(!e.geolocate||e.center||e.hash&&r)return;try{if(e.geolocate===F6.COUNTRY)return void await this.fitToIpBounds()}catch(e){console.warn(e.message)}let t;try{await this.centerOnIpPoint(e.zoom),t=this.getCameraHash()}catch(e){console.warn(e.message)}"granted"===(await navigator.permissions.query({name:"geolocation"})).state&&navigator.geolocation.getCurrentPosition(i=>{t===this.getCameraHash()&&(this.terrain?this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:e.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[i.coords.longitude,i.coords.latitude],zoom:e.zoom||12,duration:2e3})}))},null,{maximumAge:864e5,timeout:5e3,enableHighAccuracy:!1})}),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage)}),this.on("styledata",()=>{null===this.getTerrain()&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",async()=>{let t={logo:null};try{const e=Object.keys(this.style.sourceCaches).map(e=>this.getSource(e)).filter(e=>e&&"url"in e&&"string"==typeof e.url&&e.url.includes("tiles.json")),i=new URL(e[0].url);i.searchParams.has("key")||i.searchParams.append("key",S0.apiKey),t=await(await fetch(i.href)).json()}catch{}if(e.customControls){const t="[data-maptiler-control-group]",i="[data-maptiler-control]",n=e=>{let t=e.dataset.maptilerControl;return("true"===t||""===t)&&(t=void 0),t},r=e=>e.dataset.maptilerPosition;let o=[...this._container.ownerDocument.querySelectorAll(t)],s=[...this._container.ownerDocument.querySelectorAll(i)].filter(e=>null===e.closest(t));if("string"==typeof e.customControls){const t=e.customControls;o=o.filter(e=>e.matches(t)||null!==e.closest(t)),s=s.filter(e=>e.matches(t)||null!==e.closest(t))}for(const e of o){const t=new M5(e);this.addControl(t,r(e));for(const r of e.querySelectorAll(i))t.configureGroupItem(r,n(r))}for(const e of s)this.addControl(new M5(e,n(e)),r(e));const a=()=>{const{lng:e,lat:t}=this.getCenter();this._container.style.setProperty("--maptiler-center-lng",String(e)),this._container.style.setProperty("--maptiler-center-lat",String(t)),this._container.style.setProperty("--maptiler-zoom",String(this.getZoom())),this._container.style.setProperty("--maptiler-bearing",String(this.getBearing())),this._container.style.setProperty("--maptiler-pitch",String(this.getPitch())),this._container.style.setProperty("--maptiler-roll",String(this.getRoll())),this._container.style.setProperty("--maptiler-is-globe-projection",String(this.isGlobeProjection())),this._container.style.setProperty("--maptiler-has-terrain",String(this.hasTerrain()))};a(),this.on("render",a)}if(!0!==e.forceNoAttributionControl)if("logo"in t&&t.logo){const i=t.logo;this.addControl(new B0({logoURL:i}),e.logoPosition)}else e.maptilerLogo&&this.addControl(new B0,e.logoPosition);if(e.scaleControl){const t=!0===e.scaleControl||void 0===e.scaleControl?"bottom-right":e.scaleControl,i=new h0({unit:S0.unit});this.addControl(i,t),S0.on("unit",e=>{i.setUnit(e)})}if(!1!==e.navigationControl){const t=!0===e.navigationControl||void 0===e.navigationControl?"top-right":e.navigationControl;this.addControl(new r5,t)}if(!1!==e.geolocateControl){const t=!0===e.geolocateControl||void 0===e.geolocateControl?"top-right":e.geolocateControl;this.addControl(new l5({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),t)}if(e.terrainControl){const t=!0===e.terrainControl||void 0===e.terrainControl?"top-right":e.terrainControl;this.addControl(new i5,t)}if(e.projectionControl){const t=!0===e.projectionControl||void 0===e.projectionControl?"top-right":e.projectionControl;this.addControl(new m5,t)}if(e.fullscreenControl){const t=!0===e.fullscreenControl||void 0===e.fullscreenControl?"top-right":e.fullscreenControl;this.addControl(new d0({}),t)}this.isReady=!0,this.fire("ready",{target:this})});let l,c=!1,u=!1;this.once("ready",()=>{c=!0,u&&this.fire("loadWithTerrain",l)}),this.once("style.load",()=>{const{minimap:t}=e;if("object"==typeof t){const{zoom:i,center:n,style:r,language:o,apiKey:s,maptilerLogo:a,canvasContextAttributes:l,refreshExpiredTiles:c,maxBounds:u,scrollZoom:h,minZoom:d,maxZoom:p,boxZoom:f,locale:m,fadeDuration:g,crossSourceCollisions:_,clickTolerance:A,bounds:y,fitBoundsOptions:v,pixelRatio:x,validateStyle:b}=e;this.minimap=new P5(t,{zoom:i,center:n,style:r,language:o,apiKey:s,container:"null",maptilerLogo:a,canvasContextAttributes:l,refreshExpiredTiles:c,maxBounds:u,scrollZoom:h,minZoom:d,maxZoom:p,boxZoom:f,locale:m,fadeDuration:g,crossSourceCollisions:_,clickTolerance:A,bounds:y,fitBoundsOptions:v,pixelRatio:x,validateStyle:b}),this.addControl(this.minimap,t.position??"bottom-left")}else!0===t?(this.minimap=new P5({},e),this.addControl(this.minimap,"bottom-left")):void 0!==t&&!1!==t&&(this.minimap=new P5({},e),this.addControl(this.minimap,t))});const h=e=>{e.terrain&&(u=!0,l={type:"loadWithTerrain",target:this,terrain:e.terrain},this.off("terrain",h),c&&this.fire("loadWithTerrain",l))};this.on("terrain",h),e.terrain&&this.enableTerrain(e.terrainExaggeration??this.terrainExaggeration),this.once("load",()=>{this.getCanvas().addEventListener("webglcontextlost",e=>{!0!==this._removed?(console.warn("[webglcontextlost]","Unexpected loss of WebGL context!"),this.fire("webglContextLost",e)):console.warn("[webglcontextlost]","WebGL context lost after map removal. This is harmless.")}),e.halo&&this.initHalo({options:e,before:this.getLayersOrder()[0]}),e.space&&this.initSpace({options:e,before:this.getLayersOrder()[0]})}),this.telemetry=new R5(this)}getSpace(){return this.space}setSpace(e,t=!0){if(t&&(this.options.space=e),!1!==e)return this.space?(this.space.setCubemap(e),void(this.getLayer(this.space.id)||this.addLayer(this.space,this.getLayersOrder()[0]))):(this.space=new T6(e),void this.once("load",()=>{const e=this.getLayersOrder()[0];this.space&&this.addLayer(this.space,e)}));this.space=void 0}enableSpaceAnimations(){this.setSpaceAnimationActive(!0)}disableSpaceAnimations(){this.setSpaceAnimationActive(!1)}enableHaloAnimations(){this.setHaloAnimationActive(!0)}disableHaloAnimations(){this.setHaloAnimationActive(!1)}setHaloAnimationActive(e){this.halo?this.halo.setAnimationActive(e):this.once("load",()=>{var t;null==(t=this.halo)||t.setAnimationActive(e)})}setSpaceAnimationActive(e){this.space?this.space.setAnimationActive(e):this.once("load",()=>{var t;null==(t=this.space)||t.setAnimationActive(e)})}setSpaceFromSpec({spec:e}){var t;if(!1===this.options.space)return;if("boolean"==typeof e)return void this.setSpace(e,!0);if(!0!==this.options.space&&E6(this.options.space))return void this.setSpace(this.options.space,!0);const i=E6(e);if(JSON.stringify(null==(t=this.space)?void 0:t.getConfig())!==JSON.stringify(e))i?this.setSpace(e,!1):!0!==this.options.space?(()=>{this.space&&this.isGlobeProjection()&&this.space.setCubemap(e)})():this.setSpace(!0);else if(this.space&&!this.getLayer(this.space.id)){const e=this.getLayersOrder()[0];this.addLayer(this.space,e)}}setHaloFromSpec({spec:e}){var t,i;if(!1!==this.options.halo){if("boolean"==typeof e)return console.log("spec is boolean",e),void this.setHalo(e);if(JSON.stringify(null==(t=this.halo)?void 0:t.getConfig())!==JSON.stringify(e)){if(!e&&!this.options.halo)return console.log("spec is false, and options.halo is false"),void this.setHalo({stops:[[0,"transparent"],[1,"transparent"]],scale:1});(()=>{var t;if(console.log("updateHalo",e),this.halo){if(console.log("halo exists",this.getLayer(this.halo.id)),!this.getLayer(this.halo.id)){console.log("halo not in map, adding it");const e=this.getLayersOrder().indexOf((null==(t=this.space)?void 0:t.id)??"")+1,i=this.getLayersOrder()[e];this.addLayer(this.halo,i)}e&&(console.log("SET HALO FROM SPEC",e),this.halo.setGradient(e))}})()}else if(console.log("HALO IS THE SAME",e),this.halo&&!this.getLayer(this.halo.id)){const e=this.getLayersOrder().indexOf((null==(i=this.space)?void 0:i.id)??"")+1,t=this.getLayersOrder()[e];this.addLayer(this.halo,t)}}else console.log("options.halo is false")}initSpace({options:e=this.options,before:t=this.getLayersOrder()[0],spec:i}){if(this.space)return void(this.getLayer(this.space.id)||this.addLayer(this.space,t));if(!1===e.space)return;const n=i;if(e.space)return this.space=new T6(e.space),void this.addLayer(this.space,t);n&&(this.space=new T6(n),this.addLayer(this.space,t))}initHalo({options:e=this.options,before:t=this.getLayersOrder()[0],spec:i}){if(this.halo&&this.getLayer(this.halo.id)||!1===e.halo)return;const n=i;if(e.halo)return this.halo=new P6(e.halo),void this.addLayer(this.halo,t);n&&(this.halo=new P6(n),this.addLayer(this.halo,t))}getHalo(){return this.halo}setHalo(e){if(this.options.halo=e,this.isGlobeProjection()){if(this.halo)return void this.halo.setGradient(e);this.halo=new P6(e),this.once("load",()=>{var e;const t=this.getLayersOrder(),i=t[0],n=t.indexOf((null==(e=this.space)?void 0:e.id)??"")+2,r=t[n];this.halo&&this.addLayer(this.halo,this.space?r:i)})}}recreate(){const t={center:this.getCenter(),zoom:this.getZoom(),bearing:this.getBearing(),pitch:this.getPitch()};this.remove(),Object.assign(this,new e({...this.options})),this.once("load",()=>{this.jumpTo(t)})}setTerrainAnimationDuration(e){this.terrainAnimationDuration=Math.max(e,0)}async onLoadAsync(){return new Promise(e=>{this.loaded()?e(this):this.once("load",()=>{e(this)})})}async onReadyAsync(){return new Promise(e=>{this.isReady?e(this):this.once("ready",()=>{e(this)})})}async onLoadWithTerrainAsync(){return new Promise(e=>{this.isReady&&this.terrain?e(this):this.once("loadWithTerrain",()=>{e(this)})})}monitorStyleUrl(e){typeof this.monitoredStyleUrls>"u"&&(this.monitoredStyleUrls=new Set);const t=new URL(e);t.search="",this.monitoredStyleUrls.add(t.href)}setStyle(e,t={}){var i,n,r,o,s;const a={transformStyle:(e,t)=>{var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w;const T=!(null!=(n=null==(i=null==t?void 0:t.metadata)?void 0:i.maptiler)&&n.space||null==(o=null==(r=null==e?void 0:e.metadata)?void 0:r.maptiler)||!o.space),E=!(null!=(a=null==(s=null==t?void 0:t.metadata)?void 0:s.maptiler)&&a.halo||null==(c=null==(l=null==e?void 0:e.metadata)?void 0:l.maptiler)||!c.halo);T&&(console.trace("space has been removed from style, removing it"),null==(u=this.space)||u.onRemove(this,this.getCanvas().getContext("webgl2")),this.space=void 0),E&&(console.trace("halo has been removed from style, removing it"),null==(h=this.halo)||h.onRemove(this,this.getCanvas().getContext("webgl2")),this.halo=void 0);const C=!this.space||this.space.shouldUpdate(null==(p=null==(d=null==t?void 0:t.metadata)?void 0:d.maptiler)?void 0:p.space),S=!this.halo||this.halo.shouldUpdate(null==(m=null==(f=null==t?void 0:t.metadata)?void 0:f.maptiler)?void 0:m.halo),B=(null==(g=null==e?void 0:e.terrain)?void 0:g.source)!==(null==(_=null==t?void 0:t.terrain)?void 0:_.source)||(null==(A=null==e?void 0:e.terrain)?void 0:A.exaggeration)!==(null==(y=null==t?void 0:t.terrain)?void 0:y.exaggeration),I=S||B;if(C||B)try{const e=(null==(x=null==(v=null==t?void 0:t.metadata)?void 0:v.maptiler)?void 0:x.space)??!1;this.once("style.load",()=>{var t;this.getLayer((null==(t=this.space)?void 0:t.id)??"")?this.setSpaceFromSpec({spec:e}):this.initSpace({spec:e})})}catch(e){console.error(e)}if(I)try{const e=(null==(w=null==(b=null==t?void 0:t.metadata)?void 0:b.maptiler)?void 0:w.halo)??!1;this.once("style.load",()=>{var t;this.getLayer((null==(t=this.halo)?void 0:t.id)??"")?this.setHaloFromSpec({spec:e}):this.initHalo({spec:e})})}catch(e){console.error(e)}return{...t}},diff:!0,...t};this.originalLabelStyle.clear(),null==(i=this.minimap)||i.setStyle(e,{}),this.forceLanguageUpdate=!0,this.once("idle",()=>{this.forceLanguageUpdate=!1});const l=J4(e);if(l.requiresUrlMonitoring&&this.monitorStyleUrl(l.style),l.isFallback){if(this.getStyle())return console.warn("[Map.setStyle]: Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Keeping the curent style instead."),this;console.warn("[Map.setStyle]: Invalid style. A style must be a valid URL to a style.json, a JSON string representing a valid StyleSpecification or a valid StyleSpecification object. Fallback to default MapTiler style.")}try{super.setStyle(l.style,a),this.styleInProcess=!0}catch(e){this.styleInProcess=!1,console.error("[Map.setStyle]: Error while setting style:",e)}try{if(l.isJSON){const e=null==(r=null==(n=l.style.metadata)?void 0:n.maptiler)?void 0:r.halo,t=null==(s=null==(o=l.style.metadata)?void 0:o.maptiler)?void 0:s.space;e&&this.setHalo(e),t&&this.setSpace(t)}}catch(e){console.error("[Map.setStyle]: Error while setting halo or space from style:",e)}return this}addLayer(e,t){var i;return null==(i=this.minimap)||i.addLayer(e,t),super.addLayer(e,t)}moveLayer(e,t){var i;return null==(i=this.minimap)||i.moveLayer(e,t),super.moveLayer(e,t)}removeLayer(e){var t;return null==(t=this.minimap)||t.removeLayer(e),super.removeLayer(e)}setLayerZoomRange(e,t,i){var n;return null==(n=this.minimap)||n.setLayerZoomRange(e,t,i),super.setLayerZoomRange(e,t,i)}setFilter(e,t,i){var n;return null==(n=this.minimap)||n.setFilter(e,t,i),super.setFilter(e,t,i)}setPaintProperty(e,t,i,n){var r;return null==(r=this.minimap)||r.setPaintProperty(e,t,i,n),super.setPaintProperty(e,t,i,n)}setLayoutProperty(e,t,i,n){var r;return null==(r=this.minimap)||r.setLayoutProperty(e,t,i,n),super.setLayoutProperty(e,t,i,n)}setGlyphs(e,t){var i;return null==(i=this.minimap)||i.setGlyphs(e,t),super.setGlyphs(e,t)}getStyleLanguage(){return this.style&&this.style.stylesheet&&this.style.stylesheet.metadata&&"object"==typeof this.style.stylesheet.metadata&&"maptiler:language"in this.style.stylesheet.metadata&&"string"==typeof this.style.stylesheet.metadata["maptiler:language"]?zJ(this.style.stylesheet.metadata["maptiler:language"]):null}setLanguage(e){var t;null==(t=this.minimap)||t.map.setLanguage(e),this.onStyleReady(()=>{this.setPrimaryLanguage(e)})}setPrimaryLanguage(e){const t=this.getStyleLanguage(),i=VJ(e,b0);if(!i)return void console.warn(`The language "${i}" is not supported.`);if((i.flag!==b0.STYLE.flag||!t||t.flag!==b0.AUTO.flag&&t.flag!==b0.VISITOR.flag)&&(i.flag!==b0.STYLE.flag&&(this.languageAlwaysBeenStyle=!1),this.languageAlwaysBeenStyle||this.primaryLanguage===i&&!this.forceLanguageUpdate))return;if(this.primaryLanguage.flag===b0.STYLE_LOCK.flag)return void console.warn("The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag.");this.primaryLanguage=i;let n=i;if(i.flag===b0.STYLE.flag){if(!t)return void console.warn("The style has no default languages or has an invalid one.");n=t}let r=b0.LOCAL.flag,o=["get",r];n.flag===b0.VISITOR.flag?(r=w0().flag,o=["case",["all",["has",r],["has",b0.LOCAL.flag]],["case",["==",["get",r],["get",b0.LOCAL.flag]],["get",b0.LOCAL.flag],["format",["get",r],{"font-scale":.8},"\n",["get",b0.LOCAL.flag],{"font-scale":1.1}]],["get",b0.LOCAL.flag]]):n.flag===b0.VISITOR_ENGLISH.flag?(r=b0.ENGLISH.flag,o=["case",["all",["has",r],["has",b0.LOCAL.flag]],["case",["==",["get",r],["get",b0.LOCAL.flag]],["get",b0.LOCAL.flag],["format",["get",r],{"font-scale":.8},"\n",["get",b0.LOCAL.flag],{"font-scale":1.1}]],["get",b0.LOCAL.flag]]):n.flag===b0.AUTO.flag?(r=w0().flag,o=["coalesce",["get",r],["get",b0.LOCAL.flag]]):n===b0.LOCAL?(r=b0.LOCAL.flag,o=["get",r]):(r=n.flag,o=["coalesce",["get",r],["get",b0.LOCAL.flag]]);const{layers:s}=this.getStyle(),a=0===this.originalLabelStyle.size;if(a){const e=function(e,t){const i=[];for(const n of e){if("symbol"!==n.type)continue;const e=n,{id:r,layout:o}=e;if(!o||!("text-field"in o))continue;const s=t.getLayoutProperty(r,"text-field");if(s)if("string"==typeof s){const e=Z0(s);i.push(e)}else{const e=q0(s);i.push(e)}}const n=i.flat(),r={unlocalized:0,localized:{}};for(const e of n)null===e?r.unlocalized+=1:(e in r.localized||(r.localized[e]=0),r.localized[e]+=1);return r}(s,this);this.isStyleLocalized=Object.keys(e.localized).length>0}for(const e of s){if("symbol"!==e.type)continue;const t=e,i=this.getSource(t.source);if(!i||!("url"in i)||"string"!=typeof i.url||new URL(i.url).host!==T0.maptilerApiHost)continue;const{id:n,layout:r}=t;if(!r||!("text-field"in r))continue;let s;if(a?(s=this.getLayoutProperty(n,"text-field"),this.originalLabelStyle.set(n,s)):s=this.originalLabelStyle.get(n),"string"==typeof s){const{contains:e,exactMatch:t}=Q0(s,this.isStyleLocalized);if(!e)continue;if(t)this.setLayoutProperty(n,"text-field",o);else{const e=$0(s,o,this.isStyleLocalized);this.setLayoutProperty(n,"text-field",e)}}else{const e=H0(s,o,this.isStyleLocalized);this.setLayoutProperty(n,"text-field",e)}}this.languageIsUpdated=!0}getPrimaryLanguage(){return this.primaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(e){if(!this.terrain)return;const t=performance.now(),i=this.terrain.exaggeration,n=e-i,r=()=>{if(!this.terrain||this.terrainFlattening)return;const o=(performance.now()-t)/this.terrainAnimationDuration;if(o<.99){const e=i+(1-(1-o)**4)*n;this.terrain.exaggeration=e,requestAnimationFrame(r)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=e,this.fire("terrainAnimationStop",{terrain:this.terrain});this._elevationFreeze=!1,this.triggerRepaint()};!this.terrainGrowing&&!this.terrainFlattening&&this.fire("terrainAnimationStart",{terrain:this.terrain}),this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(r)}enableTerrain(e=this.terrainExaggeration){if(e<0)return void console.warn("Terrain exaggeration cannot be negative.");const t=i=>{!this.terrain||"data"!==i.type||"source"!==i.dataType||!("source"in i)||"maptiler-terrain"!==i.sourceId||"raster-dem"!==i.source.type||i.isSourceLoaded&&(this.off("data",t),this.growTerrain(e))},i=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=e,this.on("data",t),this.addSource(T0.terrainSourceId,{type:"raster-dem",url:T0.terrainSourceURL}),this.setTerrain({source:T0.terrainSourceId,exaggeration:0})};if(this.getTerrain())return this.isTerrainEnabled=!0,void this.growTerrain(e);if(this.loaded()||this.isTerrainEnabled)i();else{const e=()=>{this.getTerrain()&&this.getSource(T0.terrainSourceId)||i()};this.once("load",()=>{e()}),this.once("moveend",()=>{e()})}}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const e=performance.now(),t=this.terrain.exaggeration,i=()=>{if(!this.terrain||this.terrainGrowing)return;const n=(performance.now()-e)/this.terrainAnimationDuration;if(this._elevationFreeze=!1,n<.99){const e=t*(1-n)**4;this.terrain.exaggeration=e,requestAnimationFrame(i)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(),this.getSource(T0.terrainSourceId)&&this.removeSource(T0.terrainSourceId),this.fire("terrainAnimationStop",{terrain:null});this.triggerRepaint()};!this.terrainGrowing&&!this.terrainFlattening&&this.fire("terrainAnimationStart",{terrain:this.terrain}),this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(i)}setTerrainExaggeration(e,t=!0){!t&&this.terrain?(this.terrainExaggeration=e,this.terrain.exaggeration=e,this.triggerRepaint()):this.enableTerrain(e)}onStyleReady(e){this.isStyleLoaded()?e():this.once("styledata",()=>{e()})}async fitToIpBounds(){const e=await XJ.info();this.fitBounds(e.country_bounds,{duration:0,padding:100})}async centerOnIpPoint(e){const t=await XJ.info();this.jumpTo({center:[t.longitude??0,t.latitude??0],zoom:e||11})}getCameraHash(){const e=new Float32Array(5),t=this.getCenter();return e[0]=t.lng,e[1]=t.lat,e[2]=this.getZoom(),e[3]=this.getPitch(),e[4]=this.getBearing(),mJ(new Uint8Array(e.buffer))}getSdkConfig(){return S0}getMaptilerSessionId(){return E0}setTransformRequest(e){return super.setTransformRequest(U0(e)),this}getProjection(){const e=this.style.getProjection();return void 0===!e&&this.style.projection?{type:this.style.projection.name}:e}isGlobeProjection(){const e=this.getProjection();return!!e&&"globe"===e.type}enableGlobeProjection(){!0!==this.isGlobeProjection()&&(this.setProjection({type:"globe"}),this.curentProjection="globe")}enableMercatorProjection(){!1!==this.isGlobeProjection()&&(this.setProjection({type:"mercator"}),this.curentProjection="mercator")}setProjection(e){return this.fire("projection.change",{target:this,projection:e}),super.setProjection(e)}isLanguageUpdated(){return this.languageIsUpdated}};class D6{constructor(e,t,i,n={}){QY(this,"type"),QY(this,"target"),QY(this,"originalEvent"),QY(this,"imageX"),QY(this,"imageY"),QY(this,"isOutOfBounds"),this.type=e,this.target=t,this.originalEvent=i??null,Object.assign(this,n)}}const O6=["idle","render","load","remove","idle"],z6=["error"],U6=["resize"],N6=["webglcontextlost","webglcontextrestored"],V6=["moveend","movestart","move","zoomend","zoomstart","zoom","rotatestart","rotateend","rotate","dragstart","dragend","drag","boxzoomcancel","boxzoomend","boxzoomstart"],j6=["click","dblclick","mousedown","mouseup","mousemove","mouseout","mouseover","contextmenu","touchstart","touchend","touchmove","touchcancel"],G6=["cooperativegestureprevented"],H6=["data","dataloading","sourcedata","sourcedataloading","dataabort","sourcedataabort"],Q6=[...O6,...z6,...U6,...N6,...V6,...j6,...H6,...G6],$6=["lngLat","_defaultPrevented"];class Z6 extends Error{constructor(e,t,i){const n=`[${i}]: Failed to fetch ${t} at ${e.url}: ${e.status.toString()}: ${e.statusText}`;super(n),QY(this,"status"),QY(this,"statusText"),this.name="FetchError",this.message=n,this.status=e.status,this.statusText=e.statusText}}function W6(e,t,i){return Math.min(i,Math.max(t,e))}function q6(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function K6(e){return(180+e)/360}function X6(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function J6(e){e.transform.getConstrained=function(e,t){t=W6(+t,this.minZoom,this.maxZoom);const i={center:new z9(e.lng,e.lat),zoom:t};let n=this._helper._lngRange;null===n&&(n=[-179.9999999999,179.9999999999]);const r=this.tileSize*function(e){return Math.pow(2,e)}(i.zoom);let o=0,s=r,a=0,l=r,c=0,u=0;const{x:h,y:d}=this.size,p=.5;if(this._helper._latRange){const e=this._helper._latRange;o=q6(e[1])*r,s=q6(e[0])*r,s-os&&(_=s-e)}if(n){const e=w*h/2;f-el&&(g=l-e)}if(void 0!==g||void 0!==_){const e=new $9(g??f,_??m);i.center=function(e,t){return new N9(t.x/e,t.y/e).toLngLat()}(r,e).wrap()}return i}}const Y6={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 e8{constructor({imageViewer:e}){if(QY(this,"viewer"),QY(this,"container"),QY(this,"handleClick",()=>{this.viewer.fitImageToViewport({ease:!0})}),!e)throw new Error("ImageViewerFitImageToBoundsControl: an instance of 'ImageViewer' is required");this.viewer=e}onAdd(e){const t=document.createElement("button");this.container=document.createElement("div"),this.container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),t.classList.add("maplibregl-ctrl-fit-image-to-bounds");const i=document.createElement("span");return i.classList.add("maplibregl-ctrl-icon"),t.title="Zoom image to viewport bounds",t.appendChild(i),t.addEventListener("click",this.handleClick),this.container.appendChild(t),this.container}onRemove(){this.container.remove()}}const t8=Symbol("MapTiler:ImageViewer:Internal:lngLatToPxInternal"),i8=Symbol("MapTiler:ImageViewer:Internal:pxToLngLatInternal"),{Evented:n8}=iJ,r8={style:{version:8,sources:{},layers:[]},minPitch:0,maxPitch:0,pitch:0,bearing:0,projection:"mercator",geolocateControl:!1,navigationControl:!1,projectionControl:!1,hash:!1,renderWorldCopies:!1,terrain:!1,space:!1,halo:!1},o8={debug:!1,fitToBoundsControl:!0,navigationControl:!0};var s8,a8,l8;class c8 extends(l8=n8,a8=t8,s8=i8,l8){constructor(e){if(super(),QY(this,"imageUUID"),QY(this,"debug"),QY(this,"imageMetadata"),QY(this,"sdk"),QY(this,"options"),QY(this,"imageSize"),QY(this,"paddedSizeMax"),QY(this,"fitToBoundsControlInstance"),QY(this,"shouldFitImageToViewport",!0),QY(this,a8,this.lngLatToPx.bind(this)),QY(this,s8,this.pxToLngLat.bind(this)),!e.imageUUID)throw new Error("[ImageViewer]: `imageUUID` is required");if("string"!=typeof e.container&&!(e.container instanceof HTMLElement))throw new Error("[ImageViewer]: `container` is required and must be a string or HTMLElement");this.options={...o8,...e};const t={...this.options,...r8};delete t.center,this.sdk=new k6(t),this.sdk.telemetry.registerViewerType("ImageViewer");const{imageUUID:i,debug:n}=e;this.imageUUID=i,this.debug=n??!1,this.debug&&(this.sdk.showTileBoundaries=this.debug,this.sdk.showPadding=this.debug,this.sdk.showCollisionBoxes=this.debug,this.sdk.repaint=this.debug),this.init()}get version(){return this.sdk.version}async onReadyAsync(){try{await this.sdk.onReadyAsync(),await Promise.race([new Promise((e,t)=>{this.once("imageviewerready",t=>{e(t)}),this.once("imagevieweriniterror",e=>{t(e.error)})}),new Promise((e,t)=>{setTimeout(()=>{t(new Error("Timeout waiting for image viewer to be ready"))},5e3)})])}catch(e){throw e}}async init(){var e,t,i;try{await this.fetchImageMetadata(),this.addImageSource(),this.options.navigationControl&&this.sdk.addControl(new a0({visualizePitch:!1,visualizeRoll:!1})),this.fitToBoundsControlInstance=new e8({imageViewer:this}),this.options.fitToBoundsControl&&this.sdk.addControl(this.fitToBoundsControlInstance),function({map:e,viewer:t,lngLatToPx:i}){Q6.forEach(n=>{try{e.on(n,e=>{const r=n;if(j6.includes(r)){const r=e,o=r.lngLat&&i(r.lngLat),s=t.getImageMetadata(),a={isOutOfBounds:!s||o[0]<0||o[0]>s.width||o[1]<0||o[1]>s.height,imageX:o[0],imageY:o[1],...Object.fromEntries(Object.entries(e).filter(([e])=>!$6.includes(e)))};return void t.fire(new D6(n,t,r.originalEvent,a))}const o=n;if(V6.includes(o)){const i=e;return void t.fire(new D6(n,t,i.originalEvent,i))}const s=n;if(z6.includes(s)){const i=e;return void t.fire(new D6(n,t,null,i))}const a=n;if(U6.includes(a)){const i=e;return void t.fire(new D6(n,t,null,i))}const l=n;if(N6.includes(l)){const i=e;return void t.fire(new D6(n,t,i.originalEvent,i))}const c=n;if(H6.includes(c)){const i=e;return void t.fire(new D6(n,t,null,i))}const u=n;if(G6.includes(u)){const i=e;return void t.fire(new D6(n,t,null,i))}const h=n;O6.includes(h)&&t.fire(new D6(n,t))})}catch(e){console.error(`Error forwarding event to ImageViewer, event of type "${n}" is not supported`,e)}})}({map:this.sdk,viewer:this,lngLatToPx:e=>this.lngLatToPx(e)}),J6(this.sdk);const{center:n,zoom:r,bearing:o}=this.options,s=n??[((null==(e=this.imageMetadata)?void 0:e.width)??0)/2,((null==(t=this.imageMetadata)?void 0:t.height)??0)/2];this.setCenter(s),this.setBearing(o??0),this.options.zoom?this.setZoom(r??(null==(i=this.imageMetadata)?void 0:i.maxzoom)??5):this.fitImageToViewport(),this.sdk.on("wheel",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("touchstart",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("drag",()=>{this.shouldFitImageToViewport=!1}),this.sdk.on("resize",()=>{var e,t;const i=this.getCenter(),n=(null==(e=this.imageMetadata)?void 0:e.width)??0,r=(null==(t=this.imageMetadata)?void 0:t.height)??0;this.shouldFitImageToViewport&&this.fitImageToViewport(),(i[0]!==n/2||i[1]!==r/2)&&this.setCenter(i)}),this.fire("imageviewerready",new D6("imageviewerready",this))}catch(e){this.fire("imagevieweriniterror",{error:e})}}fitImageToViewport({ease:e=!1}={}){if(!this.imageMetadata)throw new Error("[ImageViewer]: Image metadata not found");const t=this.pxToLngLat([0,0]),i=this.pxToLngLat([this.imageMetadata.width??0,this.imageMetadata.height??0]),n=this.sdk.cameraForBounds([t,i],{padding:50});n&&(e?this.sdk.easeTo({...n,pitch:0},null):this.sdk.jumpTo({...n,pitch:0},null)),this.shouldFitImageToViewport=!0}async fetchImageMetadata(){const e=function(e){return`https://api.maptiler.com/images/${e}/image.json?key=${S0.apiKey}`}(this.imageUUID),t=await fetch(e);if(!t.ok)throw new Z6(t,"image metadata","ImageViewer");const i=await t.json();this.imageMetadata=i,Object.freeze(this.imageMetadata)}addImageSource(){if(!this.imageMetadata)throw this.fire("error",new D6("error",this,null,{error:new Error("[ImageViewer]: Image metadata not found")})),new Error("[ImageViewer]: Image metadata not found");const e=function(e){return`https://api.maptiler.com/images/${e}/{z}/{x}/{y}?key=${S0.apiKey}`}(this.imageUUID),t=e=>Math.pow(2,Math.ceil(Math.log(e)/Math.LN2));this.imageSize=[this.imageMetadata.width,this.imageMetadata.height],this.paddedSizeMax=Math.max(t(this.imageSize[0]),t(this.imageSize[1]));const i=this.pxToLngLat([0,0]),n=this.pxToLngLat(this.imageSize),r=[i.lng,n.lat,n.lng,i.lat];this.sdk.addSource("image",{...this.imageMetadata,type:"raster",bounds:r,tiles:[e]}),this.sdk.addLayer({id:"image",type:"raster",source:"image"})}triggerRepaint(){this.sdk.triggerRepaint()}get scrollZoom(){return this.sdk.scrollZoom}set scrollZoom(e){this.sdk.scrollZoom=e}get boxZoom(){return this.sdk.boxZoom}set boxZoom(e){this.sdk.boxZoom=e}get dragPan(){return this.sdk.dragPan}set dragPan(e){this.sdk.dragPan=e}get keyboard(){return this.sdk.keyboard}set keyboard(e){this.sdk.keyboard=e}get doubleClickZoom(){return this.sdk.doubleClickZoom}set doubleClickZoom(e){this.sdk.doubleClickZoom=e}get touchZoomRotate(){return this.sdk.touchZoomRotate}set touchZoomRotate(e){this.sdk.touchZoomRotate=e}get cooperativeGestures(){return this.sdk.cooperativeGestures}set cooperativeGestures(e){this.sdk.cooperativeGestures=e}lngLatToPx(e){if(!this.paddedSizeMax){const e="[ImageViewer]: Unable to convert LngLat to px, padded size max not set";throw this.fire("error",new D6("error",this,null,{error:new Error(e)})),new Error(e)}const t=N9.fromLngLat(e);return[t.x*this.paddedSizeMax,t.y*this.paddedSizeMax]}pxToLngLat(e){if(!this.paddedSizeMax){const e="[ImageViewer]: Unable to convert px to LngLat, padded size max not set";throw this.fire("error",new D6("error",this,null,{error:new Error(e)})),new Error(e)}return new N9(e[0]/this.paddedSizeMax,e[1]/this.paddedSizeMax).toLngLat()}getSDKInternal(){return this.sdk}getCanvas(){return this.sdk.getCanvas()}flyTo(e,t){const i=this.pxToLngLat(e.center);return this.sdk.flyTo({...e,pitch:0,center:i},t),this}jumpTo(e,t){const i=this.pxToLngLat(e.center);return this.sdk.jumpTo({...e,pitch:0,center:i},t),this}setZoom(e){return this.sdk.setZoom(e),this}getZoom(){return this.sdk.getZoom()}getCenter(){const e=this.sdk.getCenter();return this.lngLatToPx(e)}setCenter(e){return this.sdk.setCenter(this.pxToLngLat(e)),this}setBearing(e){return this.sdk.setBearing(e),this}getBearing(){return this.sdk.getBearing()}panBy(e,t,i){return this.sdk.panBy(e,{...t,pitch:0},i),this}panTo(e,t,i){return this.sdk.panTo(this.pxToLngLat(e),{...t,pitch:0},i),this}getImageMetadata(){return this.imageMetadata}getImageBounds(){const e=this.sdk.getBounds().toArray().map(e=>this.lngLatToPx(z9.convert(e)));return[[e[0][0],e[1][1]],[e[1][0],e[0][1]]]}fitImageBounds([e,t]){const i=this.pxToLngLat(e),n=this.pxToLngLat(t),r=U9.convert([i,n]);return this.sdk.fitBounds(r),this}remove(){this.fire("beforeremove",new D6("beforeremove",this)),this.sdk.remove(),this._listeners&&Object.entries(this._listeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this._oneTimeListeners&&Object.entries(this._oneTimeListeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})})}pointIsWithinImageBounds(e){const t=this.getImageMetadata();if(!t)return!1;const i=[[0,0],[t.width,t.height]];return e[0]>=i[0][0]&&e[0]<=i[1][0]&&e[1]>=i[0][1]&&e[1]<=i[1][1]}}const{Evented:u8}=iJ;const h8=["dragstart","drag","dragend"],d8=["lngLat","_defaultPrevented","target"];class p8{constructor(e,t,i){QY(this,"type"),QY(this,"target"),this.type=e,this.target=t,Object.assign(this,i)}}function f8(e){if(typeof DOMParser<"u"){const t=(new DOMParser).parseFromString(e,"application/xml");if(t.querySelector("parsererror"))throw new Error("The provided string is not valid XML");return t}throw new Error("No XML parser found")}function m8(e,t){if(!e.hasChildNodes())return!1;for(const i of Array.from(e.childNodes)){const e=i.nodeName;if("string"==typeof e&&e.trim().toLowerCase()===t.toLowerCase())return!0}return!1}function g8(e){if(typeof XMLSerializer<"u")return(new XMLSerializer).serializeToString(e);throw new Error("No XML serializer found")}function _8(e){const t="string"==typeof e?f8(e):e;if(!m8(t,"gpx"))throw new Error("The XML document is not valid GPX");const i=P8(t,"trk"),n=P8(t,"rte"),r=P8(t,"wpt"),o={type:"FeatureCollection",features:[]};for(const e of Array.from(i)){const t=E8(e);t&&o.features.push(t)}for(const e of Array.from(n)){const t=C8(e);t&&o.features.push(t)}for(const e of Array.from(r))o.features.push(S8(e));return o}function A8(e,t){let i=e;if("string"==typeof i&&(i=f8(i)),!m8(i,"kml"))throw new Error("The XML document is not valid KML");const n={type:"FeatureCollection",features:[]},r={},o={},s={},a=P8(i,"Placemark"),l=P8(i,"Style"),c=P8(i,"StyleMap");for(const e of Array.from(l)){const i=M8(void 0!==t?t(e):g8(e)).toString(16);r[`#${R8(e,"id")}`]=i,o[i]=e}for(const e of Array.from(c)){r[`#${R8(e,"id")}`]=M8(void 0!==t?t(e):g8(e)).toString(16);const i=P8(e,"Pair"),n={};for(const e of Array.from(i))n[D8(F8(e,"key"))??""]=D8(F8(e,"styleUrl"));s[`#${R8(e,"id")}`]=n}for(const e of Array.from(a))n.features=n.features.concat(w8(e,r,o,s));return n}function y8(e){if(null===e)return["#000000",1];let t="",i=1,n=e;return n.startsWith("#")&&(n=n.substring(1)),(6===n.length||3===n.length)&&(t=n),8===n.length&&(i=Number.parseInt(n.substring(0,2),16)/255,t=`#${n.substring(6,8)}${n.substring(4,6)}${n.substring(2,4)}`),[t??"#000000",i??1]}function v8(e){return k8(e.split(" "))}function x8(e){let t=P8(e,"coord");const i=[],n=[];0===t.length&&(t=P8(e,"gx:coord"));for(const e of Array.from(t))i.push(v8(D8(e)??""));const r=P8(e,"when");for(const e of Array.from(r))n.push(D8(e));return{coords:i,times:n}}function b8(e){const t=["Polygon","LineString","Point","Track","gx:Track"];let i,n,r,o,s;const a=[],l=[];if(null!==F8(e,"MultiGeometry"))return b8(F8(e,"MultiGeometry"));if(null!==F8(e,"MultiTrack"))return b8(F8(e,"MultiTrack"));if(null!==F8(e,"gx:MultiTrack"))return b8(F8(e,"gx:MultiTrack"));for(r=0;rNumber.isNaN(e)?null:e)}function D8(e){return e&&function(e){e.normalize&&e.normalize()}(e),e&&e.textContent}function O8(e,t){const i={};let n,r;for(r=0;r=e[e.length-1].zoom)return e[e.length-1].value;for(let i=0;i=e[i].zoom&&t[e.zoom,e.value])]}function W8(e){return["interpolate",["linear"],["zoom"],...e.flatMap(e=>[e.zoom,e.value])]}function q8(e,t){if("number"==typeof t&&"number"==typeof e)return 2*t+e;if("number"==typeof t&&Array.isArray(e))return["interpolate",["linear"],["zoom"],...e.flatMap(e=>[e.zoom,2*t+e.value])];if("number"==typeof e&&Array.isArray(t))return["interpolate",["linear"],["zoom"],...t.flatMap(t=>[t.zoom,2*t.value+e])];if(Array.isArray(e)&&Array.isArray(t)){const i=Array.from(new Set([...e.map(e=>e.zoom),...t.map(e=>e.zoom)])).sort((e,t)=>e[i,2*$8(t,i)+$8(e,i)])]}return 0}function K8(e,t){return["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]}function X8(e){const t=e.trimStart(),i=`${t}${" ".repeat(e.length-t.length)}`,n=Array.from(i);if(!n.every(e=>" "===e||"_"===e))throw new Error("A dash pattern must be composed only of whitespace and underscore characters.");if(!n.some(e=>"_"===e)||!n.some(e=>" "===e))throw new Error("A dash pattern must contain at least one underscore and one whitespace character");const r=[1];for(let e=1;e[e.value,e.color])]}function Y8(e,t,i=!0){return i?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.025*e.pointRadius])],2,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.05*e.pointRadius])],4,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.1*e.pointRadius])],8,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,.25*e.pointRadius])],16,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,e.pointRadius])]]:["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.value,e.pointRadius])]}function e9(e,t,i=!0){return i?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.025*e.value])],2,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.05*e.value])],4,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.1*e.value])],8,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,.25*e.value])],16,["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]]:["interpolate",["linear"],["get",t],...e.flatMap(e=>[e.propertyValue,e.value])]}function t9(e,t){return e.every(t=>t.color[3]===e[0].color[3])?e[0].color[3]?e[0].color[3]/255:1:["interpolate",["linear"],["get",t],...e.getRawColorStops().flatMap(e=>{const t=e.value,i=e.color;return[t,4===i.length?i[3]/255:1]})]}function i9(e,t=10){return["interpolate",["linear"],["heatmap-density"],...Array.from({length:t+1},(i,n)=>{const r=n/t;return[r,e.getColorHex(r)]}).flat()]}function n9(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}class r9 extends Array{constructor(e={}){super(),QY(this,"min",0),QY(this,"max",1),"min"in e&&(this.min=e.min),"max"in e&&(this.max=e.max),"stops"in e&&this.setStops(e.stops,{clone:!1})}static fromArrayDefinition(e){return new r9({stops:e.map(e=>({value:e[0],color:e[1]}))})}setStops(e,t={clone:!0}){const i=t.clone?this.clone():this;i.length=0;let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let t=0;te.value=this.at(-1).value)return this.at(-1).color;for(let i=0;ithis[i+1].value)continue;const n=this[i].color;if(!t.smooth)return n.slice();const r=this[i].value,o=this[i+1].value,s=this[i+1].color,a=(o-e)/(o-r);return n.map((e,t)=>Math.round(e*a+s[t]*(1-a)))}return[0,0,0]}getColorHex(e,t={smooth:!0,withAlpha:!1}){return function(e){return`#${n9(e[0])}${n9(e[1])}${n9(e[2])}${4===e.length?n9(e[3]):""}`}(this.getColor(e,t))}getColorRelative(e,t={smooth:!0}){const i=this.getBounds();return this.getColor(i.min+e*(i.max-i.min),t)}getCanvasStrip(e={horizontal:!0,size:512,smooth:!0}){const t=document.createElement("canvas");t.width=e.horizontal?e.size:1,t.height=e.horizontal?1:e.size;const i=t.getContext("2d");if(!i)throw new Error("Canvs context is missing");const n=i.getImageData(0,0,t.width,t.height),r=n.data,o=e.size,s=this[0].value,a=(this.at(-1).value-s)/o;for(let t=0;t3?i[3]:255}return i.putImageData(n,0,0),t}resample(e,t=15){const i=this.getBounds(),n=this.scale(0,1),r=1/(t-1);let o;if("ease-in-square"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=i**2;return{value:i,color:n.getColor(o)}});else if("ease-out-square"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-(1-i)**2;return{value:i,color:n.getColor(o)}});else if("ease-out-sqrt"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=i**.5;return{value:i,color:n.getColor(o)}});else if("ease-in-sqrt"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-(1-i)**.5;return{value:i,color:n.getColor(o)}});else if("ease-out-exp"===e)o=Array.from({length:t},(e,t)=>{const i=t*r,o=1-2**(-10*i);return{value:i,color:n.getColor(o)}});else{if("ease-in-exp"!==e)throw new Error("Invalid ressampling method.");o=Array.from({length:t},(e,t)=>{const i=t*r,o=2**(10*i-10);return{value:i,color:n.getColor(o)}})}return new r9({stops:o}).scale(i.min,i.max)}transparentStart(){const e=this.getRawColorStops();e.unshift({value:e[0].value,color:e[0].color.slice()}),e[1].value+=.001;for(const t of e)3===t.color.length&&t.color.push(255);return e[0].color[3]=0,new r9({stops:e})}hasTransparentStart(){return 4===this[0].color.length&&0===this[0].color[3]}}const o9={NULL:new r9({stops:[{value:0,color:[0,0,0,0]},{value:1,color:[0,0,0,0]}]}),GRAY:new r9({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),JET:new r9({stops:[{value:0,color:[0,0,131]},{value:.125,color:[0,60,170]},{value:.375,color:[5,255,255]},{value:.625,color:[255,255,0]},{value:.875,color:[250,0,0]},{value:1,color:[128,0,0]}]}),HSV:new r9({stops:[{value:0,color:[255,0,0]},{value:.169,color:[253,255,2]},{value:.173,color:[247,255,2]},{value:.337,color:[0,252,4]},{value:.341,color:[0,252,10]},{value:.506,color:[1,249,255]},{value:.671,color:[2,0,253]},{value:.675,color:[8,0,253]},{value:.839,color:[255,0,251]},{value:.843,color:[255,0,245]},{value:1,color:[255,0,6]}]}),HOT:new r9({stops:[{value:0,color:[0,0,0]},{value:.3,color:[230,0,0]},{value:.6,color:[255,210,0]},{value:1,color:[255,255,255]}]}),SPRING:new r9({stops:[{value:0,color:[255,0,255]},{value:1,color:[255,255,0]}]}),SUMMER:new r9({stops:[{value:0,color:[0,128,102]},{value:1,color:[255,255,102]}]}),AUTOMN:new r9({stops:[{value:0,color:[255,0,0]},{value:1,color:[255,255,0]}]}),WINTER:new r9({stops:[{value:0,color:[0,0,255]},{value:1,color:[0,255,128]}]}),BONE:new r9({stops:[{value:0,color:[0,0,0]},{value:.376,color:[84,84,116]},{value:.753,color:[169,200,200]},{value:1,color:[255,255,255]}]}),COPPER:new r9({stops:[{value:0,color:[0,0,0]},{value:.804,color:[255,160,102]},{value:1,color:[255,199,127]}]}),GREYS:new r9({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),YIGNBU:new r9({stops:[{value:0,color:[8,29,88]},{value:.125,color:[37,52,148]},{value:.25,color:[34,94,168]},{value:.375,color:[29,145,192]},{value:.5,color:[65,182,196]},{value:.625,color:[127,205,187]},{value:.75,color:[199,233,180]},{value:.875,color:[237,248,217]},{value:1,color:[255,255,217]}]}),GREENS:new r9({stops:[{value:0,color:[0,68,27]},{value:.125,color:[0,109,44]},{value:.25,color:[35,139,69]},{value:.375,color:[65,171,93]},{value:.5,color:[116,196,118]},{value:.625,color:[161,217,155]},{value:.75,color:[199,233,192]},{value:.875,color:[229,245,224]},{value:1,color:[247,252,245]}]}),YIORRD:new r9({stops:[{value:0,color:[128,0,38]},{value:.125,color:[189,0,38]},{value:.25,color:[227,26,28]},{value:.375,color:[252,78,42]},{value:.5,color:[253,141,60]},{value:.625,color:[254,178,76]},{value:.75,color:[254,217,118]},{value:.875,color:[255,237,160]},{value:1,color:[255,255,204]}]}),BLUERED:new r9({stops:[{value:0,color:[0,0,255]},{value:1,color:[255,0,0]}]}),RDBU:new r9({stops:[{value:0,color:[5,10,172]},{value:.35,color:[106,137,247]},{value:.5,color:[190,190,190]},{value:.6,color:[220,170,132]},{value:.7,color:[230,145,90]},{value:1,color:[178,10,28]}]}),PICNIC:new r9({stops:[{value:0,color:[0,0,255]},{value:.1,color:[51,153,255]},{value:.2,color:[102,204,255]},{value:.3,color:[153,204,255]},{value:.4,color:[204,204,255]},{value:.5,color:[255,255,255]},{value:.6,color:[255,204,255]},{value:.7,color:[255,153,255]},{value:.8,color:[255,102,204]},{value:.9,color:[255,102,102]},{value:1,color:[255,0,0]}]}),RAINBOW:new r9({stops:[{value:0,color:[150,0,90]},{value:.125,color:[0,0,200]},{value:.25,color:[0,25,255]},{value:.375,color:[0,152,255]},{value:.5,color:[44,255,150]},{value:.625,color:[151,255,0]},{value:.75,color:[255,234,0]},{value:.875,color:[255,111,0]},{value:1,color:[255,0,0]}]}),PORTLAND:new r9({stops:[{value:0,color:[12,51,131]},{value:.25,color:[10,136,186]},{value:.5,color:[242,211,56]},{value:.75,color:[242,143,56]},{value:1,color:[217,30,30]}]}),BLACKBODY:new r9({stops:[{value:0,color:[0,0,0]},{value:.2,color:[230,0,0]},{value:.4,color:[230,210,0]},{value:.7,color:[255,255,255]},{value:1,color:[160,200,255]}]}),EARTH:new r9({stops:[{value:0,color:[0,0,130]},{value:.1,color:[0,180,180]},{value:.2,color:[40,210,40]},{value:.4,color:[230,230,50]},{value:.6,color:[120,70,20]},{value:1,color:[255,255,255]}]}),ELECTRIC:new r9({stops:[{value:0,color:[0,0,0]},{value:.15,color:[30,0,100]},{value:.4,color:[120,0,100]},{value:.6,color:[160,90,0]},{value:.8,color:[230,200,0]},{value:1,color:[255,250,220]}]}),VIRIDIS:new r9({stops:[{value:0,color:[68,1,84]},{value:.13,color:[71,44,122]},{value:.25,color:[59,81,139]},{value:.38,color:[44,113,142]},{value:.5,color:[33,144,141]},{value:.63,color:[39,173,129]},{value:.75,color:[92,200,99]},{value:.88,color:[170,220,50]},{value:1,color:[253,231,37]}]}),INFERNO:new r9({stops:[{value:0,color:[0,0,4]},{value:.13,color:[31,12,72]},{value:.25,color:[85,15,109]},{value:.38,color:[136,34,106]},{value:.5,color:[186,54,85]},{value:.63,color:[227,89,51]},{value:.75,color:[249,140,10]},{value:.88,color:[249,201,50]},{value:1,color:[252,255,164]}]}),MAGMA:new r9({stops:[{value:0,color:[0,0,4]},{value:.13,color:[28,16,68]},{value:.25,color:[79,18,123]},{value:.38,color:[129,37,129]},{value:.5,color:[181,54,122]},{value:.63,color:[229,80,100]},{value:.75,color:[251,135,97]},{value:.88,color:[254,194,135]},{value:1,color:[252,253,191]}]}),PLASMA:new r9({stops:[{value:0,color:[13,8,135]},{value:.13,color:[75,3,161]},{value:.25,color:[125,3,168]},{value:.38,color:[168,34,150]},{value:.5,color:[203,70,121]},{value:.63,color:[229,107,93]},{value:.75,color:[248,148,65]},{value:.88,color:[253,195,40]},{value:1,color:[240,249,33]}]}),WARM:new r9({stops:[{value:0,color:[125,0,179]},{value:.13,color:[172,0,187]},{value:.25,color:[219,0,170]},{value:.38,color:[255,0,130]},{value:.5,color:[255,63,74]},{value:.63,color:[255,123,0]},{value:.75,color:[234,176,0]},{value:.88,color:[190,228,0]},{value:1,color:[147,255,0]}]}),COOL:new r9({stops:[{value:0,color:[125,0,179]},{value:.13,color:[116,0,218]},{value:.25,color:[98,74,237]},{value:.38,color:[68,146,231]},{value:.5,color:[0,204,197]},{value:.63,color:[0,247,146]},{value:.75,color:[0,255,88]},{value:.88,color:[40,255,8]},{value:1,color:[147,255,0]}]}),RAINBOW_SOFT:new r9({stops:[{value:0,color:[125,0,179]},{value:.1,color:[199,0,180]},{value:.2,color:[255,0,121]},{value:.3,color:[255,108,0]},{value:.4,color:[222,194,0]},{value:.5,color:[150,255,0]},{value:.6,color:[0,255,55]},{value:.7,color:[0,246,150]},{value:.8,color:[50,167,222]},{value:.9,color:[103,51,235]},{value:1,color:[124,0,186]}]}),BATHYMETRY:new r9({stops:[{value:0,color:[40,26,44]},{value:.13,color:[59,49,90]},{value:.25,color:[64,76,139]},{value:.38,color:[63,110,151]},{value:.5,color:[72,142,158]},{value:.63,color:[85,174,163]},{value:.75,color:[120,206,163]},{value:.88,color:[187,230,172]},{value:1,color:[253,254,204]}]}),CDOM:new r9({stops:[{value:0,color:[47,15,62]},{value:.13,color:[87,23,86]},{value:.25,color:[130,28,99]},{value:.38,color:[171,41,96]},{value:.5,color:[206,67,86]},{value:.63,color:[230,106,84]},{value:.75,color:[242,149,103]},{value:.88,color:[249,193,135]},{value:1,color:[254,237,176]}]}),CHLOROPHYLL:new r9({stops:[{value:0,color:[18,36,20]},{value:.13,color:[25,63,41]},{value:.25,color:[24,91,59]},{value:.38,color:[13,119,72]},{value:.5,color:[18,148,80]},{value:.63,color:[80,173,89]},{value:.75,color:[132,196,122]},{value:.88,color:[175,221,162]},{value:1,color:[215,249,208]}]}),DENSITY:new r9({stops:[{value:0,color:[54,14,36]},{value:.13,color:[89,23,80]},{value:.25,color:[110,45,132]},{value:.38,color:[120,77,178]},{value:.5,color:[120,113,213]},{value:.63,color:[115,151,228]},{value:.75,color:[134,185,227]},{value:.88,color:[177,214,227]},{value:1,color:[230,241,241]}]}),FREESURFACE_BLUE:new r9({stops:[{value:0,color:[30,4,110]},{value:.13,color:[47,14,176]},{value:.25,color:[41,45,236]},{value:.38,color:[25,99,212]},{value:.5,color:[68,131,200]},{value:.63,color:[114,156,197]},{value:.75,color:[157,181,203]},{value:.88,color:[200,208,216]},{value:1,color:[241,237,236]}]}),FREESURFACE_RED:new r9({stops:[{value:0,color:[60,9,18]},{value:.13,color:[100,17,27]},{value:.25,color:[142,20,29]},{value:.38,color:[177,43,27]},{value:.5,color:[192,87,63]},{value:.63,color:[205,125,105]},{value:.75,color:[216,162,148]},{value:.88,color:[227,199,193]},{value:1,color:[241,237,236]}]}),OXYGEN:new r9({stops:[{value:0,color:[64,5,5]},{value:.13,color:[106,6,15]},{value:.25,color:[144,26,7]},{value:.38,color:[168,64,3]},{value:.5,color:[188,100,4]},{value:.63,color:[206,136,11]},{value:.75,color:[220,174,25]},{value:.88,color:[231,215,44]},{value:1,color:[248,254,105]}]}),PAR:new r9({stops:[{value:0,color:[51,20,24]},{value:.13,color:[90,32,35]},{value:.25,color:[129,44,34]},{value:.38,color:[159,68,25]},{value:.5,color:[182,99,19]},{value:.63,color:[199,134,22]},{value:.75,color:[212,171,35]},{value:.88,color:[221,210,54]},{value:1,color:[225,253,75]}]}),PHASE:new r9({stops:[{value:0,color:[145,105,18]},{value:.13,color:[184,71,38]},{value:.25,color:[186,58,115]},{value:.38,color:[160,71,185]},{value:.5,color:[110,97,218]},{value:.63,color:[50,123,164]},{value:.75,color:[31,131,110]},{value:.88,color:[77,129,34]},{value:1,color:[145,105,18]}]}),SALINITY:new r9({stops:[{value:0,color:[42,24,108]},{value:.13,color:[33,50,162]},{value:.25,color:[15,90,145]},{value:.38,color:[40,118,137]},{value:.5,color:[59,146,135]},{value:.63,color:[79,175,126]},{value:.75,color:[120,203,104]},{value:.88,color:[193,221,100]},{value:1,color:[253,239,154]}]}),TEMPERATURE:new r9({stops:[{value:0,color:[4,35,51]},{value:.13,color:[23,51,122]},{value:.25,color:[85,59,157]},{value:.38,color:[129,79,143]},{value:.5,color:[175,95,130]},{value:.63,color:[222,112,101]},{value:.75,color:[249,146,66]},{value:.88,color:[249,196,65]},{value:1,color:[232,250,91]}]}),TURBIDITY:new r9({stops:[{value:0,color:[34,31,27]},{value:.13,color:[65,50,41]},{value:.25,color:[98,69,52]},{value:.38,color:[131,89,57]},{value:.5,color:[161,112,59]},{value:.63,color:[185,140,66]},{value:.75,color:[202,174,88]},{value:.88,color:[216,209,126]},{value:1,color:[233,246,171]}]}),VELOCITY_BLUE:new r9({stops:[{value:0,color:[17,32,64]},{value:.13,color:[35,52,116]},{value:.25,color:[29,81,156]},{value:.38,color:[31,113,162]},{value:.5,color:[50,144,169]},{value:.63,color:[87,173,176]},{value:.75,color:[149,196,189]},{value:.88,color:[203,221,211]},{value:1,color:[254,251,230]}]}),VELOCITY_GREEN:new r9({stops:[{value:0,color:[23,35,19]},{value:.13,color:[24,64,38]},{value:.25,color:[11,95,45]},{value:.38,color:[39,123,35]},{value:.5,color:[95,146,12]},{value:.63,color:[152,165,18]},{value:.75,color:[201,186,69]},{value:.88,color:[233,216,137]},{value:1,color:[255,253,205]}]}),CUBEHELIX:new r9({stops:[{value:0,color:[0,0,0]},{value:.07,color:[22,5,59]},{value:.13,color:[60,4,105]},{value:.2,color:[109,1,135]},{value:.27,color:[161,0,147]},{value:.33,color:[210,2,142]},{value:.4,color:[251,11,123]},{value:.47,color:[255,29,97]},{value:.53,color:[255,54,69]},{value:.6,color:[255,85,46]},{value:.67,color:[255,120,34]},{value:.73,color:[255,157,37]},{value:.8,color:[241,191,57]},{value:.87,color:[224,220,93]},{value:.93,color:[218,241,142]},{value:1,color:[227,253,198]}]}),CIVIDIS:new r9({stops:[{value:0,color:[0,32,77,255]},{value:.125,color:[5,54,110,255]},{value:.25,color:[65,77,108,255]},{value:.375,color:[97,100,111,255]},{value:.5,color:[125,124,121,255]},{value:.625,color:[156,149,120,255]},{value:.75,color:[190,175,111,255]},{value:.875,color:[225,204,94,255]},{value:1,color:[255,235,70,255]}]}),TURBO:new r9({stops:[{value:0,color:[48,18,59,255]},{value:.125,color:[70,107,227,255]},{value:.25,color:[40,187,236,255]},{value:.375,color:[49,242,153,255]},{value:.5,color:[162,252,60,255]},{value:.625,color:[237,208,58,255]},{value:.75,color:[251,128,34,255]},{value:.875,color:[210,49,5,255]},{value:1,color:[122,4,3,255]}]}),ROCKET:new r9({stops:[{value:0,color:[250,235,221,0]},{value:.133,color:[250,235,221,255]},{value:.266,color:[246,170,130,255]},{value:.4,color:[240,96,67,255]},{value:.533,color:[203,27,79,255]},{value:.666,color:[132,30,90,255]},{value:.8,color:[63,27,68,255]},{value:1,color:[3,5,26,255]}]}),MAKO:new r9({stops:[{value:0,color:[11,4,5,255]},{value:.125,color:[43,28,53,255]},{value:.25,color:[62,53,107,255]},{value:.375,color:[59,86,152,255]},{value:.5,color:[53,123,162,255]},{value:.625,color:[53,158,170,255]},{value:.75,color:[73,193,173,255]},{value:.875,color:[150,221,181,255]},{value:1,color:[222,245,229,255]}]})};const s9=Object.freeze(Object.defineProperty({__proto__:null,addHeatmap:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??H8(),n=t.layerId??Q8(),r=t.minzoom??0,o=t.maxzoom??23,s=t.zoomCompensation??!0,a=t.opacity??[{zoom:r,value:0},{zoom:r+.25,value:1},{zoom:o-.25,value:1},{zoom:o,value:0}];let l=Array.isArray(t.colorRamp)?t.colorRamp:o9.TURBO.transparentStart();const c=l.getBounds();(0!==c.min||1!==c.max)&&(l=l.scale(0,1)),l.hasTransparentStart()||(l=l.transparentStart());const u=t.intensity??[{zoom:0,value:.01},{zoom:4,value:.2},{zoom:16,value:1}],h=t.property??null,d=t.weight??1;let p=1;h?"number"==typeof d?(p=d,"number"==typeof t.weight&&console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`")):Array.isArray(d)?p=K8(d,h):console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`"):"number"==typeof d?p=d:Array.isArray(d)&&console.warn("The options `.propertyValueWeights` can only be used when `.property` is provided.");const f=[{zoom:0,value:1.25},{zoom:2,value:2.5},{zoom:4,value:5},{zoom:8,value:12.5},{zoom:16,value:50}],m=t.radius??(s?f:10);let g=1;"number"==typeof m?g=m:Array.isArray(m)&&"zoom"in m[0]?g=W8(m):h&&Array.isArray(m)&&"propertyValue"in m[0]?g=e9(m,h,s):!h&&Array.isArray(m)&&"propertyValue"in m[0]?(g=W8(f),console.warn("The option `.radius` can only be property-driven if the option `.property` is provided.")):g=W8(f);const _={heatmapLayerId:n,heatmapSourceId:i};if(t.data&&!e.getSource(i)){let n=t.data;"string"==typeof n&&V0(n)&&(n=`https://api.maptiler.com/data/${n}/features.json?key=${S0.apiKey}`),e.addSource(i,{type:"geojson",data:n})}return e.addLayer({id:n,type:"heatmap",source:i,minzoom:r,maxzoom:o,paint:{"heatmap-weight":p,"heatmap-intensity":"number"==typeof u?u:W8(u),"heatmap-color":i9(l),"heatmap-radius":g,"heatmap-opacity":"number"==typeof a?a:W8(a)}},t.beforeId),_},addPoint:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.minPointRadius??10,n=t.maxPointRadius??50,r=t.cluster??!1,o=20,s=Array.isArray(t.pointColor)?t.pointColor:o9.TURBO.scale(10,t.cluster?1e4:1e3).resample("ease-out-square"),a=s.getBounds(),l=t.sourceId??H8(),c=t.layerId??Q8(),u=t.showLabel??r,h=t.alignOnViewport??!0,d=t.outline??!1,p=t.outlineOpacity??1,f=t.outlineWidth??1,m=t.outlineColor??"#FFFFFF";let g;const _=t.zoomCompensation??!0,A=t.minzoom??0,y=t.maxzoom??23;g="number"==typeof t.pointOpacity?t.pointOpacity:Array.isArray(t.pointOpacity)?W8(t.pointOpacity):t.cluster?t9(s,"point_count"):t.property?t9(s,t.property):W8([{zoom:A,value:0},{zoom:A+.25,value:1},{zoom:y-.25,value:1},{zoom:y,value:0}]);const v={pointLayerId:c,clusterLayerId:"",labelLayerId:"",pointSourceId:l};if(t.data&&!e.getSource(l)){let i=t.data;"string"==typeof i&&V0(i)&&(i=`https://api.maptiler.com/data/${i}/features.json?key=${S0.apiKey}`),e.addSource(l,{type:"geojson",data:i,cluster:r})}if(r){v.clusterLayerId=`${c}_cluster`;const r=Array.from({length:o},(e,t)=>{const r=a.min+t*(a.max-a.min)/19;return{value:r,pointRadius:i+(n-i)*(t/19)**.5,color:s.getColorHex(r)}});e.addLayer({id:v.clusterLayerId,type:"circle",source:l,filter:["has","point_count"],paint:{"circle-color":"string"==typeof t.pointColor?t.pointColor:J8(r,"point_count"),"circle-radius":"number"==typeof t.pointRadius?t.pointRadius:Array.isArray(t.pointRadius)?W8(t.pointRadius):Y8(r,"point_count",!1),"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-opacity":g,...d&&{"circle-stroke-opacity":"number"==typeof p?p:W8(p),"circle-stroke-width":"number"==typeof f?f:W8(f),"circle-stroke-color":"string"==typeof m?m:Z8(m)}},minzoom:A,maxzoom:y},t.beforeId),e.addLayer({id:v.pointLayerId,type:"circle",source:l,filter:["!",["has","point_count"]],paint:{"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-color":"string"==typeof t.pointColor?t.pointColor:s.getColorHex(s.getBounds().min),"circle-radius":"number"==typeof t.pointRadius?t.pointRadius:Array.isArray(t.pointRadius)?W8(t.pointRadius):.75*r[0].pointRadius,"circle-opacity":g,...d&&{"circle-stroke-opacity":"number"==typeof p?p:W8(p),"circle-stroke-width":"number"==typeof f?f:W8(f),"circle-stroke-color":"string"==typeof m?m:Z8(m)}},minzoom:A,maxzoom:y},t.beforeId)}else{let r="string"==typeof t.pointColor?t.pointColor:Array.isArray(t.pointColor)?t.pointColor.getColorHex(t.pointColor.getBounds().min):G8(),c="number"==typeof t.pointRadius?_?W8([{zoom:0,value:.025*t.pointRadius},{zoom:2,value:.05*t.pointRadius},{zoom:4,value:.1*t.pointRadius},{zoom:8,value:.25*t.pointRadius},{zoom:16,value:1*t.pointRadius}]):t.pointRadius:Array.isArray(t.pointRadius)?W8(t.pointRadius):_?W8([{zoom:0,value:.05*i},{zoom:2,value:.1*i},{zoom:4,value:.2*i},{zoom:8,value:.5*i},{zoom:16,value:1*i}]):i;if(t.property&&Array.isArray(t.pointColor)){const e=Array.from({length:o},(e,r)=>{const o=a.min+r*(a.max-a.min)/19;return{value:o,pointRadius:"number"==typeof t.pointRadius?t.pointRadius:i+(n-i)*(r/19)**.5,color:"string"==typeof t.pointColor?t.pointColor:s.getColorHex(o)}});r=J8(e,t.property),c=Y8(e,t.property,_)}e.addLayer({id:v.pointLayerId,type:"circle",source:l,layout:{"circle-sort-key":t.property?["/",1,["get",t.property]]:0},paint:{"circle-pitch-alignment":h?"viewport":"map","circle-pitch-scale":"map","circle-color":r,"circle-opacity":g,"circle-radius":c,...d&&{"circle-stroke-opacity":"number"==typeof p?p:W8(p),"circle-stroke-width":"number"==typeof f?f:W8(f),"circle-stroke-color":"string"==typeof m?m:Z8(m)}},minzoom:A,maxzoom:y},t.beforeId)}if(!1!==u&&(t.cluster||t.property)){v.labelLayerId=`${c}_label`;const i=t.labelColor??"#fff",n=t.labelSize??12;e.addLayer({id:v.labelLayerId,type:"symbol",source:l,filter:["has",t.cluster?"point_count":t.property],layout:{"text-field":t.cluster?"{point_count_abbreviated}":`{${t.property}}`,"text-font":["Noto Sans Regular"],"text-size":n,"text-pitch-alignment":h?"viewport":"map","symbol-sort-key":["/",1,["get",t.cluster?"point_count":t.property]]},paint:{"text-color":i,"text-opacity":g},minzoom:A,maxzoom:y},t.beforeId)}return v},addPolygon:function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??H8(),n=t.layerId??Q8(),r={polygonLayerId:n,polygonOutlineLayerId:t.outline?`${n}_outline`:"",polygonSourceId:i};if(t.data&&!e.getSource(i)){let n=t.data;"string"==typeof n&&V0(n)&&(n=`https://api.maptiler.com/data/${n}/features.json?key=${S0.apiKey}`),e.addSource(i,{type:"geojson",data:n})}let o=t.outlineDashArray??null;const s=t.outlineWidth??1,a=t.outlineColor??"#FFFFFF",l=t.outlineOpacity??1,c=t.outlineBlur??0,u=t.fillColor??G8(),h=t.fillOpacity??1,d=t.outlinePosition??"center",p=t.pattern??null;"string"==typeof o&&(o=X8(o));const f=(p=null)=>{if(e.addLayer({id:n,type:"fill",source:i,minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"fill-color":"string"==typeof u?u:Z8(u),"fill-opacity":"number"==typeof h?h:W8(h),...p&&{"fill-pattern":p}}},t.beforeId),!0===t.outline){let n;n="inside"===d?"number"==typeof s?.5*s:W8(s.map(({zoom:e,value:t})=>({zoom:e,value:.5*t}))):"outside"===d?"number"==typeof s?-.5*s:W8(s.map(e=>({zoom:e.zoom,value:-.5*e.value}))):0,e.addLayer({id:r.polygonOutlineLayerId,type:"line",source:i,layout:{"line-join":t.outlineJoin??"round","line-cap":t.outlineCap??"butt"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof l?l:W8(l),"line-color":"string"==typeof a?a:Z8(a),"line-width":"number"==typeof s?s:W8(s),"line-blur":"number"==typeof c?c:W8(c),"line-offset":n,...o&&{"line-dasharray":o}}},t.beforeId)}};return p?e.hasImage(p)?f(p):e.loadImage(p).then(t=>{e.addImage(p,t.data),f(p)}).catch(e=>{console.error("Could not load the pattern image.",e.message),f()}):f(),r},addPolyline:async function(e,t,i={}){var n,r;if(!t.sourceId&&!t.data)throw new Error("Creating a polyline layer requires an existing .sourceId or a valid .data property");let o=t.data;if("string"==typeof o){if(V0(o))o=`https://api.maptiler.com/data/${t.data}/features.json?key=${S0.apiKey}`;else if("gpx"===(null==(n=o.split(".").pop())?void 0:n.toLowerCase().trim())){o=_8(await(await fetch(o,i)).text())}else if("kml"===(null==(r=o.split(".").pop())?void 0:r.toLowerCase().trim())){o=A8(await(await fetch(o,i)).text())}else{const e=function(e){try{return JSON.parse(e)}catch{}return null}(o)??V8(o);e&&(o=e)}if(!o)throw new Error("Polyline data was provided as string but is incompatible with valid formats.")}return function(e,t){if(t.layerId&&e.getLayer(t.layerId))throw new Error(`A layer already exists with the layer id: ${t.layerId}`);const i=t.sourceId??H8(),n=t.layerId??Q8(),r={polylineLayerId:n,polylineOutlineLayerId:"",polylineSourceId:i};t.data&&!e.getSource(i)&&e.addSource(i,{type:"geojson",data:t.data});const o=t.lineWidth??3,s=t.lineColor??G8(),a=t.lineOpacity??1,l=t.lineBlur??0,c=t.lineGapWidth??0;let u=t.lineDashArray??null;const h=t.outlineWidth??1,d=t.outlineColor??"#FFFFFF",p=t.outlineOpacity??1,f=t.outlineBlur??0;if("string"==typeof u&&(u=X8(u)),!0===t.outline){const s=`${n}_outline`;r.polylineOutlineLayerId=s,e.addLayer({id:s,type:"line",source:i,layout:{"line-join":t.lineJoin??"round","line-cap":t.lineCap??"round"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof p?p:W8(p),"line-color":"string"==typeof d?d:Z8(d),"line-width":q8(o,h),"line-blur":"number"==typeof f?f:W8(f)}},t.beforeId)}return e.addLayer({id:n,type:"line",source:i,layout:{"line-join":t.lineJoin??"round","line-cap":t.lineCap??"round"},minzoom:t.minzoom??0,maxzoom:t.maxzoom??23,paint:{"line-opacity":"number"==typeof a?a:W8(a),"line-color":"string"==typeof s?s:Z8(s),"line-width":"number"==typeof o?o:W8(o),"line-blur":"number"==typeof l?l:W8(l),"line-gap-width":"number"==typeof c?c:W8(c),...u&&{"line-dasharray":u}}},t.beforeId),r}(e,{...t,data:o})},colorDrivenByProperty:J8,colorPalettes:j8,computeRampedOutlineWidth:q8,dashArrayMaker:X8,generateRandomLayerName:Q8,generateRandomSourceName:H8,getRandomColor:G8,heatmapIntensityFromColorRamp:i9,lerpZoomNumberValues:$8,opacityDrivenByProperty:t9,paintColorOptionsToPaintSpec:Z8,radiusDrivenByProperty:Y8,radiusDrivenByPropertyHeatmap:e9,rampedOptionsToLayerPaintSpec:W8,rampedPropertyValueWeight:K8,takeScreenshot:async function(e,t={}){const i=t.download??!1,n=await function(e){return new Promise((t,i)=>{e.redraw(),e.once("idle",()=>{e.getCanvas().toBlob(e=>{e?t(e):i(Error("Screenshot could not be created."))},"image/png")})})}(e);if(i){const e=t.filename??"maptiler_screenshot.png",i=document.createElement("a");i.style.display="none",document.body.appendChild(i),i.href=URL.createObjectURL(n),i.download=e,i.click(),setTimeout(()=>{document.body.removeChild(i),URL.revokeObjectURL(i.href)},0)}return n}},Symbol.toStringTag,{value:"Module"}));function a9(){return"3.9.0"}const l9=iJ.Map,c9=iJ.Marker,u9=iJ.Popup,h9=iJ.Style,d9=iJ.CanvasSource,p9=iJ.GeoJSONSource,f9=iJ.ImageSource,m9=iJ.RasterTileSource,g9=iJ.RasterDEMTileSource,_9=iJ.VectorTileSource,A9=iJ.VideoSource,y9=iJ.NavigationControl,v9=iJ.GeolocateControl,x9=iJ.AttributionControl,b9=iJ.LogoControl,w9=iJ.ScaleControl,T9=iJ.FullscreenControl,E9=iJ.TerrainControl,C9=iJ.BoxZoomHandler,S9=iJ.ScrollZoomHandler,B9=iJ.CooperativeGesturesHandler,I9=iJ.KeyboardHandler,M9=iJ.TwoFingersTouchPitchHandler,P9=iJ.MapWheelEvent,R9=iJ.MapTouchEvent,L9=iJ.MapMouseEvent,F9=iJ.config,k9=iJ.getVersion,{setRTLTextPlugin:D9,getRTLTextPluginStatus:O9,LngLat:z9,LngLatBounds:U9,MercatorCoordinate:N9,Evented:V9,AJAXError:j9,prewarm:G9,clearPrewarmedResources:H9,Hash:Q9,Point:$9,EdgeInsets:Z9,DragRotateHandler:W9,DragPanHandler:q9,TwoFingersTouchZoomRotateHandler:K9,DoubleClickZoomHandler:X9,TwoFingersTouchZoomHandler:J9,TwoFingersTouchRotateHandler:Y9,getWorkerCount:e7,setWorkerCount:t7,getMaxParallelImageRequests:i7,setMaxParallelImageRequests:n7,getWorkerUrl:r7,setWorkerUrl:o7,addSourceType:s7,importScriptInWorkers:a7,addProtocol:l7,removeProtocol:c7}=iJ;var u7=Object.freeze({__proto__:null,AJAXError:j9,AttributionControl:c0,AttributionControlMLGL:x9,BoxZoomHandler:f0,BoxZoomHandlerMLGL:C9,CanvasSource:e0,CanvasSourceMLGL:d9,ColorRamp:r9,ColorRampCollection:o9,CooperativeGesturesHandler:g0,CooperativeGesturesHandlerMLGL:B9,CubemapFaceNames:d6,CubemapImagesPresets:u6,CubemapLayer:T6,DOMcreate:e5,DOMremove:t5,DoubleClickZoomHandler:X9,DragPanHandler:q9,DragRotateHandler:W9,EdgeInsets:Z9,Evented:V9,FullscreenControl:d0,FullscreenControlMLGL:T9,GeoJSONSource:t0,GeoJSONSourceMLGL:p9,GeolocateControl:l0,GeolocateControlMLGL:v9,GeolocationType:F6,Hash:Q9,ImageSource:i0,ImageSourceMLGL:f9,ImageViewer:c8,ImageViewerEvent:D6,ImageViewerMarker:class extends u8{constructor({...e}){super(),QY(this,"viewer"),QY(this,"marker"),QY(this,"position",[0,0]),this.marker=new XY(e)}addTo(e){if(!(e instanceof c8))throw new Error("[ImageViewerMarker]: an ImageViewerMarker must be added to an instance of ImageViewer");this.viewer=e,function(e,t,i){h8.forEach(n=>{e.on(n,e=>{var r,o;if(null==(r=e.target)?void 0:r.getLngLat()){const n=i(null==(o=e.target)?void 0:o.getLngLat());t.setPosition(n)}t.fire(n,new p8(n,t,{...Object.fromEntries(Object.entries(e).filter(([e])=>!d8.includes(e)))}))})})}(this.marker,this,this.viewer[t8]);const t=this.viewer.getSDKInternal();return this.setPosition(this.position),function(e){e._update=function(e){if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),!this._subpixelPositioning&&(!e||"moveend"===e.type)&&(this._pos=this._pos.round());const r=`${Y6[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`;this._element.style.transform=r}.bind(e)}(this.marker),this.marker.addTo(t),this}addClassName(e){return this.marker.addClassName(e),this}getElement(){return this.marker.getElement()}getPosition(){return this.position}getOffset(){return this.marker.getOffset()}getPitchAlignment(){return this.marker.getPitchAlignment()}getPopup(){return this.marker.getPopup()}getRotation(){return this.marker.getRotation()}getRotationAlignment(){return this.marker.getRotationAlignment()}isDraggable(){return this.marker.isDraggable()}fire(e,t){return super.fire(e,t),this}off(e,t){return super.off(e,t),this}on(e,t){return super.on(e,t)}isWithinImageBounds(){return this.viewer.pointIsWithinImageBounds(this.position)}remove(){return this.marker.remove(),this.marker._listeners&&Object.entries(this.marker._listeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this.marker._oneTimeListeners&&Object.entries(this.marker._oneTimeListeners).forEach(([e,t])=>{t.forEach(t=>{this.off(e,t)})}),this}removeClassName(e){return this.marker.removeClassName(e),this}setDraggable(e){return this.marker.setDraggable(e),this}setPosition(e){if(this.position[0]=e[0],this.position[1]=e[1],!this.viewer)return this;const t=this.viewer[i8](e);return this.marker.setLngLat(t),this}setOffset(e){return this.marker.setOffset(e),this}setOpacity(e,t){return this.marker.setOpacity(e,t),this}setPitchAlignment(e){return this.marker.setPitchAlignment(e),this}setPopup(e){return this.marker.setPopup(e),this}setRotation(e){return this.marker.setRotation(e),this}setRotationAlignment(e){return this.marker.setRotationAlignment(e),this}setSubpixelPositioning(e){return this.marker.setSubpixelPositioning(e),this}toggleClassName(e){return this.marker.toggleClassName(e),this}togglePopup(){return this.marker.togglePopup(),this}},ImageViewerMarkerEvent:p8,KeyboardHandler:_0,KeyboardHandlerMLGL:I9,Language:b0,LngLat:z9,LngLatBounds:U9,LogoControl:u0,LogoControlMLGL:b9,Map:k6,MapMLGL:l9,MapMouseEvent:x0,MapMouseEventMLGL:L9,MapStyle:lY,MapStyleVariant:nY,MapTouchEvent:v0,MapTouchEventMLGL:R9,MapWheelEvent:y0,MapWheelEventMLGL:P9,MaptilerCustomControl:f5,MaptilerExternalControl:M5,MaptilerGeolocateControl:l5,MaptilerLogoControl:B0,MaptilerNavigationControl:r5,MaptilerProjectionControl:m5,MaptilerTerrainControl:i5,Marker:XY,MarkerMLGL:c9,MercatorCoordinate:N9,NavigationControMLGL:y9,NavigationControl:a0,Point:$9,Popup:JY,PopupMLGL:u9,RadialGradientLayer:P6,RasterDEMTileSource:r0,RasterDEMTileSourceMLGL:g9,RasterTileSource:n0,RasterTileSourceMLGL:m9,ReferenceMapStyle:rY,ScaleControl:h0,ScaleControlMLGL:w9,ScrollZoomHandler:m0,ScrollZoomHandlerMLGL:S9,SdkConfig:C0,ServiceError:HJ,Style:YY,StyleMLGL:h9,TerrainControMLGL:E9,TerrainControl:p0,TwoFingersTouchPitchHandler:A0,TwoFingersTouchPitchHandlerMLGL:M9,TwoFingersTouchRotateHandler:Y9,TwoFingersTouchZoomHandler:J9,TwoFingersTouchZoomRotateHandler:K9,VectorTileSource:o0,VectorTileSourceMLGL:_9,VideoSource:s0,VideoSourceMLGL:A9,addProtocol:l7,addSourceType:s7,areSameLanguages:function(e,t,i=kJ){const n=VJ(e,i),r=VJ(t,i);return n&&r&&n.flag===r.flag},bufferToPixelDataBrowser:RY,canParsePixelData:FY,circumferenceAtLatitude:EY,clearPrewarmedResources:H9,config:S0,configMLGL:F9,coordinates:YJ,cubemapPresets:h6,data:tY,displayWebGLContextLostWarning:function(e){const t=e.getContainer(),i=document.createElement("div");i.innerHTML="The WebGL context was lost.",i.classList.add("webgl-warning-div"),t.appendChild(i)},elevation:zY,expandMapStyle:iY,geocoding:qJ,geolocation:XJ,getAutoLanguage:UJ,getBrowserLanguage:w0,getBufferToPixelDataParser:LY,getLanguageInfoFromCode:OJ,getLanguageInfoFromFlag:zJ,getLanguageInfoFromKey:DJ,getMapLibreVersion:k9,getMaxParallelImageRequests:i7,getRTLTextPluginStatus:O9,getTileCache:PY,getVersion:a9,getWebGLSupportError:j0,getWorkerCount:e7,getWorkerUrl:r7,gpx:_8,gpxOrKml:V8,hasChildNodeWithName:m8,helpers:s9,importScriptInWorkers:a7,isLanguageInfo:NJ,kml:A8,mapStylePresetList:oY,math:IY,misc:dY,prewarm:G9,removeProtocol:c7,setMaxParallelImageRequests:n7,setRTLTextPlugin:D9,setWorkerCount:t7,setWorkerUrl:o7,staticMaps:mY,str2xml:f8,styleToStyle:aY,toLanguageInfo:VJ,toggleProjection:g5,toggleTerrain:n5,xml2str:g8}),h7=Object.freeze({__proto__:null,default:undefined});export{JX as startApp}; //# sourceMappingURL=bundle.js.map diff --git a/dist/bundle.js.map b/dist/bundle.js.map index a775709..38eb12b 100644 --- a/dist/bundle.js.map +++ b/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/svelte/internal/index.mjs","../node_modules/es-toolkit/dist/compat/_internal/tags.mjs","../node_modules/es-toolkit/dist/object/cloneDeepWith.mjs","../node_modules/es-toolkit/dist/predicate/isPrimitive.mjs","../node_modules/es-toolkit/dist/predicate/isTypedArray.mjs","../node_modules/es-toolkit/dist/compat/_internal/getTag.mjs","../node_modules/es-toolkit/dist/compat/_internal/getSymbols.mjs","../node_modules/es-toolkit/dist/compat/object/cloneDeepWith.mjs","../node_modules/es-toolkit/dist/compat/object/cloneDeep.mjs","../node_modules/mapbox-gl/dist/mapbox-gl.js","../node_modules/maplibre-gl/dist/maplibre-gl.js","../node_modules/svelte/store/index.mjs","../src/stores.js","../src/presets-utils.js","../src/math.js","../node_modules/lodash.throttle/index.js","../node_modules/object-keys/implementation.js","../node_modules/object-keys/isArguments.js","../node_modules/object-keys/index.js","../node_modules/es-define-property/index.js","../node_modules/es-errors/syntax.js","../node_modules/es-errors/type.js","../node_modules/gopd/index.js","../node_modules/gopd/gOPD.js","../node_modules/define-data-property/index.js","../node_modules/has-property-descriptors/index.js","../node_modules/define-properties/index.js","../node_modules/dunder-proto/get.js","../node_modules/es-object-atoms/index.js","../node_modules/es-errors/index.js","../node_modules/es-errors/eval.js","../node_modules/es-errors/range.js","../node_modules/es-errors/ref.js","../node_modules/es-errors/uri.js","../node_modules/math-intrinsics/abs.js","../node_modules/math-intrinsics/floor.js","../node_modules/math-intrinsics/max.js","../node_modules/math-intrinsics/min.js","../node_modules/math-intrinsics/pow.js","../node_modules/math-intrinsics/round.js","../node_modules/math-intrinsics/isNaN.js","../node_modules/math-intrinsics/sign.js","../node_modules/has-symbols/shams.js","../node_modules/has-symbols/index.js","../node_modules/get-proto/Reflect.getPrototypeOf.js","../node_modules/get-proto/Object.getPrototypeOf.js","../node_modules/function-bind/implementation.js","../node_modules/function-bind/index.js","../node_modules/call-bind-apply-helpers/functionCall.js","../node_modules/call-bind-apply-helpers/functionApply.js","../node_modules/call-bind-apply-helpers/actualApply.js","../node_modules/call-bind-apply-helpers/reflectApply.js","../node_modules/call-bind-apply-helpers/index.js","../node_modules/get-intrinsic/index.js","../node_modules/get-proto/index.js","../node_modules/hasown/index.js","../node_modules/set-function-length/index.js","../node_modules/call-bind-apply-helpers/applyBind.js","../node_modules/call-bind/index.js","../node_modules/call-bound/index.js","../node_modules/object.assign/implementation.js","../node_modules/object.assign/polyfill.js","../node_modules/object.assign/shim.js","../node_modules/object.assign/index.js","../node_modules/call-bind/callBound.js","../node_modules/functions-have-names/index.js","../node_modules/set-function-name/index.js","../node_modules/regexp.prototype.flags/implementation.js","../node_modules/regexp.prototype.flags/polyfill.js","../node_modules/regexp.prototype.flags/shim.js","../node_modules/regexp.prototype.flags/index.js","../node_modules/es-get-iterator/node.js","../node_modules/object-inspect/index.js","../node_modules/side-channel-list/index.js","../node_modules/side-channel-map/index.js","../node_modules/side-channel-weakmap/index.js","../node_modules/side-channel/index.js","../node_modules/object-is/implementation.js","../node_modules/object-is/polyfill.js","../node_modules/object-is/shim.js","../node_modules/object-is/index.js","../node_modules/has-tostringtag/shams.js","../node_modules/is-arguments/index.js","../node_modules/is-regex/index.js","../node_modules/deep-equal/node_modules/isarray/index.js","../node_modules/is-array-buffer/index.js","../node_modules/is-date-object/index.js","../node_modules/is-shared-array-buffer/index.js","../node_modules/is-string/index.js","../node_modules/is-number-object/index.js","../node_modules/is-boolean-object/index.js","../node_modules/safe-regex-test/index.js","../node_modules/is-symbol/index.js","../node_modules/has-bigints/index.js","../node_modules/is-bigint/index.js","../node_modules/which-boxed-primitive/index.js","../node_modules/is-map/index.js","../node_modules/is-set/index.js","../node_modules/is-weakmap/index.js","../node_modules/is-weakset/index.js","../node_modules/which-collection/index.js","../node_modules/is-callable/index.js","../node_modules/for-each/index.js","../node_modules/available-typed-arrays/index.js","../node_modules/possible-typed-array-names/index.js","../node_modules/which-typed-array/index.js","../node_modules/array-buffer-byte-length/index.js","../node_modules/deep-equal/index.js","../node_modules/@googlemaps/js-api-loader/dist/index.mjs","../src/components/GoogleMap.svelte","../src/transform-urls.js","../src/fetch-url.js","../src/branch-utils.js","../src/constants.js","../node_modules/@loaders.gl/loader-utils/dist/loader-types.js","../node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js","../node_modules/@probe.gl/env/dist/lib/globals.js","../node_modules/@probe.gl/env/dist/lib/is-electron.js","../node_modules/@probe.gl/env/dist/lib/is-browser.js","../node_modules/@probe.gl/env/dist/index.js","../node_modules/@probe.gl/log/dist/utils/local-storage.js","../node_modules/@probe.gl/log/dist/utils/color.js","../node_modules/@probe.gl/log/dist/utils/assert.js","../node_modules/@probe.gl/log/dist/utils/hi-res-timestamp.js","../node_modules/@probe.gl/log/dist/log.js","../node_modules/@probe.gl/log/dist/utils/autobind.js","../node_modules/@probe.gl/log/dist/utils/formatters.js","../node_modules/@probe.gl/log/dist/init.js","../node_modules/@probe.gl/log/dist/index.js","../node_modules/@loaders.gl/loader-utils/dist/lib/log-utils/log.js","../node_modules/@loaders.gl/loader-utils/dist/lib/option-utils/merge-loader-options.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-job.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/node/worker_threads-browser.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-utils/get-loadable-worker-url.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-utils/get-transfer-list.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-thread.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-pool.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-farm.js","../node_modules/@loaders.gl/loader-utils/dist/lib/worker-loader-utils/parse-with-worker.js","../node_modules/@loaders.gl/loader-utils/node_modules/@loaders.gl/worker-utils/dist/lib/worker-api/get-worker-url.js","../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/get-first-characters.js","../node_modules/@loaders.gl/loader-utils/dist/lib/parser-utils/parse-json.js","../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/array-buffer-utils.js","../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/memory-copy-utils.js","../node_modules/@probe.gl/stats/dist/utils/hi-res-timestamp.js","../node_modules/@probe.gl/stats/dist/lib/stat.js","../node_modules/@probe.gl/stats/dist/lib/stats.js","../node_modules/@loaders.gl/loader-utils/dist/lib/request-utils/request-scheduler.js","../node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/file-aliases.js","../node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/memory-conversion-utils.js","../node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/get-cwd.js","../node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/path.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/javascript-utils/is-type.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/fetch/fetch-error.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/utils/mime-type-utils.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/utils/url-utils.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/utils/resource-utils.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/utils/response-utils.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/fetch/fetch-file.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/loggers.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/option-defaults.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/option-utils.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/normalize-loader.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/api/register-loaders.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/api/select-loader.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-array-buffer-iterator.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-stream-iterator.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-iterator.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-string-iterator.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-blob-iterator.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/get-data.js","../node_modules/@loaders.gl/loader-utils/dist/lib/iterators/async-iteration.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/get-fetch-function.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/loader-utils/loader-context.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/api/parse.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/worker-utils/dist/lib/worker-api/validate-worker-version.js","../node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js","../node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js","../node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js","../node_modules/@deck.gl/core/node_modules/@loaders.gl/core/dist/lib/api/load.js","../node_modules/@loaders.gl/images/dist/lib/utils/version.js","../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js","../node_modules/@loaders.gl/images/dist/lib/category-api/parsed-image-api.js","../node_modules/@loaders.gl/images/dist/lib/parsers/svg-utils.js","../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image.js","../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image-bitmap.js","../node_modules/@loaders.gl/images/dist/lib/category-api/parse-isobmff-binary.js","../node_modules/@loaders.gl/images/dist/lib/category-api/binary-image-api.js","../node_modules/@loaders.gl/images/dist/image-loader.js","../node_modules/@loaders.gl/images/dist/lib/parsers/parse-image.js","../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js","../node_modules/@loaders.gl/images/dist/lib/category-api/image-format.js","../node_modules/@deck.gl/core/dist/utils/log.js","../node_modules/@deck.gl/core/dist/debug/loggers.js","../node_modules/@deck.gl/core/dist/debug/index.js","../node_modules/@deck.gl/core/dist/utils/json-loader.js","../node_modules/@deck.gl/core/dist/lib/init.js","../node_modules/@luma.gl/shadertools/dist/lib/utils/assert.js","../node_modules/@luma.gl/shadertools/dist/lib/filters/prop-types.js","../node_modules/@luma.gl/shadertools/dist/module-injectors.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/shader-injections.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-module/shader-module-instance.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/select-shaders.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/resolve-modules.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-transpiler/transpile-glsl-shader.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/shader-hooks.js","../node_modules/@luma.gl/shadertools/dist/lib/glsl-utils/get-shader-info.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/assemble-shaders.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembly/platform-defines.js","../node_modules/@luma.gl/shadertools/dist/lib/shader-assembler.js","../node_modules/@luma.gl/shadertools/dist/lib/glsl-utils/shader-utils.js","../node_modules/@luma.gl/core/dist/utils/log.js","../node_modules/@luma.gl/core/dist/utils/stats-manager.js","../node_modules/@luma.gl/core/dist/init.js","../node_modules/@luma.gl/core/dist/utils/is-array.js","../node_modules/@luma.gl/core/dist/utils/utils.js","../node_modules/@luma.gl/core/dist/adapter/resources/resource.js","../node_modules/@luma.gl/core/dist/adapter/resources/buffer.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/decode-data-type.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/decode-texture-format.js","../node_modules/@luma.gl/core/dist/adapter/device.js","../node_modules/@luma.gl/core/dist/utils/assert.js","../node_modules/@luma.gl/core/dist/lib/luma.js","../node_modules/@luma.gl/core/dist/adapter/canvas-context.js","../node_modules/@luma.gl/core/dist/adapter/resources/texture.js","../node_modules/@luma.gl/core/dist/adapter/resources/texture-view.js","../node_modules/@luma.gl/core/dist/lib/compiler-log/format-compiler-log.js","../node_modules/@luma.gl/core/dist/lib/compiler-log/get-shader-info.js","../node_modules/@luma.gl/core/dist/adapter/resources/shader.js","../node_modules/@luma.gl/core/dist/adapter/resources/sampler.js","../node_modules/@luma.gl/core/dist/adapter/resources/framebuffer.js","../node_modules/@luma.gl/core/dist/adapter/resources/render-pipeline.js","../node_modules/@luma.gl/core/dist/adapter/resources/render-pass.js","../node_modules/@luma.gl/core/dist/adapter/resources/compute-pipeline.js","../node_modules/@luma.gl/core/dist/adapter/resources/command-encoder.js","../node_modules/@luma.gl/core/dist/adapter/resources/command-buffer.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/decode-attribute-type.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/decode-vertex-format.js","../node_modules/@luma.gl/core/dist/adapter/attribute-utils/get-attribute-from-layouts.js","../node_modules/@luma.gl/core/dist/adapter/resources/vertex-array.js","../node_modules/@luma.gl/core/dist/adapter/resources/transform-feedback.js","../node_modules/@luma.gl/core/dist/adapter/resources/query-set.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/decode-shader-types.js","../node_modules/@luma.gl/core/dist/utils/array-utils-flat.js","../node_modules/@luma.gl/core/dist/lib/uniforms/uniform-buffer-layout.js","../node_modules/@luma.gl/core/dist/lib/uniforms/uniform-block.js","../node_modules/@luma.gl/core/dist/utils/array-equal.js","../node_modules/@luma.gl/core/dist/lib/uniforms/uniform-store.js","../node_modules/@luma.gl/core/dist/adapter/type-utils/vertex-format-from-attribute.js","../node_modules/@luma.gl/core/dist/lib/uniforms/uniform.js","../node_modules/@luma.gl/core/dist/utils/load-file.js","../node_modules/@luma.gl/core/dist/utils/deep-equal.js","../node_modules/wgsl_reflect/wgsl_reflect.module.js","../node_modules/@luma.gl/shadertools/dist/lib/wgsl/get-shader-layout-wgsl.js","../node_modules/@luma.gl/shadertools/dist/modules/math/fp32/fp32.js","../node_modules/@luma.gl/shadertools/dist/modules/engine/picking/picking.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-utils.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64-arithmetic-glsl.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/math/fp64/fp64.js","../node_modules/@math.gl/core/dist/lib/common.js","../node_modules/@math.gl/core/dist/classes/base/math-array.js","../node_modules/@math.gl/core/dist/lib/validators.js","../node_modules/@math.gl/core/dist/lib/assert.js","../node_modules/@math.gl/core/dist/classes/base/vector.js","../node_modules/@math.gl/core/dist/gl-matrix/common.js","../node_modules/@math.gl/core/dist/gl-matrix/vec2.js","../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js","../node_modules/@math.gl/core/dist/classes/vector2.js","../node_modules/@math.gl/core/dist/gl-matrix/vec3.js","../node_modules/@math.gl/core/dist/classes/vector3.js","../node_modules/@math.gl/core/dist/classes/vector4.js","../node_modules/@math.gl/core/dist/classes/base/matrix.js","../node_modules/@math.gl/core/dist/gl-matrix/mat3.js","../node_modules/@math.gl/core/dist/classes/matrix3.js","../node_modules/@math.gl/core/dist/gl-matrix/mat4.js","../node_modules/@math.gl/core/dist/gl-matrix/vec4.js","../node_modules/@math.gl/core/dist/classes/matrix4.js","../node_modules/@math.gl/core/dist/gl-matrix/quat.js","../node_modules/@math.gl/core/dist/classes/quaternion.js","../node_modules/@math.gl/core/dist/lib/math-utils.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights-glsl.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/lights/lights.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/phong-lighting/phong-lighting-glsl.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/phong-lighting/phong-lighting.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-vertex-glsl.js","../node_modules/@luma.gl/shadertools/dist/modules-webgl1/lighting/pbr/pbr-fragment-glsl.js","../node_modules/@deck.gl/core/dist/shaderlib/misc/geometry.js","../node_modules/@deck.gl/core/dist/lib/constants.js","../node_modules/@deck.gl/core/dist/shaderlib/project/project.glsl.js","../node_modules/@deck.gl/core/dist/utils/memoize.js","../node_modules/@deck.gl/core/dist/shaderlib/project/viewport-uniforms.js","../node_modules/@deck.gl/core/dist/shaderlib/project/project.js","../node_modules/@deck.gl/core/dist/shaderlib/project32/project32.js","../node_modules/@math.gl/web-mercator/dist/math-utils.js","../node_modules/@math.gl/web-mercator/dist/assert.js","../node_modules/@math.gl/web-mercator/dist/web-mercator-utils.js","../node_modules/@math.gl/web-mercator/dist/fit-bounds.js","../node_modules/@math.gl/web-mercator/dist/get-bounds.js","../node_modules/@deck.gl/core/dist/shaderlib/shadow/shadow.js","../node_modules/@deck.gl/core/dist/shaderlib/picking/picking.js","../node_modules/@deck.gl/core/dist/shaderlib/index.js","../node_modules/@deck.gl/core/dist/effects/lighting/ambient-light.js","../node_modules/@deck.gl/core/dist/effects/lighting/directional-light.js","../node_modules/@deck.gl/core/dist/passes/pass.js","../node_modules/@deck.gl/core/dist/passes/layers-pass.js","../node_modules/@deck.gl/core/dist/passes/shadow-pass.js","../node_modules/@deck.gl/core/dist/effects/lighting/lighting-effect.js","../node_modules/@deck.gl/core/dist/utils/typed-array-manager.js","../node_modules/@deck.gl/core/dist/utils/math-utils.js","../node_modules/@deck.gl/core/dist/viewports/viewport.js","../node_modules/@deck.gl/core/dist/viewports/web-mercator-viewport.js","../node_modules/@deck.gl/core/dist/shaderlib/project/project-functions.js","../node_modules/@deck.gl/core/dist/effects/lighting/point-light.js","../node_modules/@deck.gl/core/dist/effects/lighting/camera-light.js","../node_modules/@luma.gl/engine/dist/animation/timeline.js","../node_modules/@luma.gl/engine/dist/animation-loop/animation-loop.js","../node_modules/@luma.gl/core/dist/utils/request-animation-frame.js","../node_modules/@luma.gl/engine/dist/geometry/gpu-geometry.js","../node_modules/@luma.gl/engine/dist/shader-inputs.js","../node_modules/@luma.gl/engine/dist/lib/pipeline-factory.js","../node_modules/@luma.gl/engine/dist/lib/shader-factory.js","../node_modules/@luma.gl/engine/dist/debug/debug-framebuffer.js","../node_modules/@luma.gl/engine/dist/model/model.js","../node_modules/@luma.gl/engine/dist/debug/debug-shader-layout.js","../node_modules/@luma.gl/engine/dist/transform/buffer-transform.js","../node_modules/@luma.gl/engine/dist/geometry/geometry.js","../node_modules/@luma.gl/engine/dist/scenegraph/scenegraph-node.js","../node_modules/@luma.gl/engine/dist/scenegraph/group-node.js","../node_modules/@luma.gl/engine/dist/scenegraph/model-node.js","../node_modules/@deck.gl/core/dist/passes/pick-layers-pass.js","../node_modules/@deck.gl/core/dist/lifecycle/constants.js","../node_modules/@deck.gl/core/dist/utils/flatten.js","../node_modules/@deck.gl/core/dist/lib/resource/resource.js","../node_modules/@deck.gl/core/dist/lib/resource/resource-manager.js","../node_modules/@deck.gl/core/dist/lib/layer-manager.js","../node_modules/@deck.gl/core/dist/utils/deep-equal.js","../node_modules/@deck.gl/core/dist/lib/view-manager.js","../node_modules/@deck.gl/core/dist/utils/positions.js","../node_modules/@deck.gl/core/dist/views/view.js","../node_modules/@deck.gl/core/dist/transitions/transition.js","../node_modules/@deck.gl/core/dist/controllers/transition-manager.js","../node_modules/@deck.gl/core/dist/utils/assert.js","../node_modules/@deck.gl/core/dist/transitions/transition-interpolator.js","../node_modules/@deck.gl/core/dist/transitions/linear-interpolator.js","../node_modules/@deck.gl/core/dist/controllers/controller.js","../node_modules/@deck.gl/core/dist/controllers/view-state.js","../node_modules/@deck.gl/core/dist/controllers/map-controller.js","../node_modules/@math.gl/web-mercator/dist/normalize-viewport-props.js","../node_modules/@deck.gl/core/dist/views/map-view.js","../node_modules/@deck.gl/core/dist/lib/effect-manager.js","../node_modules/@deck.gl/core/dist/passes/draw-layers-pass.js","../node_modules/@deck.gl/core/dist/lib/deck-renderer.js","../node_modules/@deck.gl/core/dist/lib/picking/query-object.js","../node_modules/@deck.gl/core/dist/lib/picking/pick-info.js","../node_modules/@deck.gl/core/dist/lib/deck-picker.js","../node_modules/@deck.gl/core/dist/lib/widget-manager.js","../node_modules/@deck.gl/core/dist/lib/tooltip.js","../node_modules/@luma.gl/constants/dist/webgl-constants.js","../node_modules/@luma.gl/webgl/dist/context/parameters/webgl-parameter-tables.js","../node_modules/@luma.gl/webgl/dist/context/parameters/unified-parameter-api.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/deep-array-equal.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/track-context-state.js","../node_modules/@luma.gl/webgl/dist/context/helpers/create-browser-context.js","../node_modules/@luma.gl/webgl/dist/context/helpers/webgl-extensions.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-info.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/vertex-formats.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/texture-formats.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-features.js","../node_modules/@luma.gl/webgl/dist/adapter/device-helpers/webgl-device-limits.js","../node_modules/@luma.gl/webgl/dist/context/state-tracker/with-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/device-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/converters/sampler-parameters.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-buffer.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-sampler.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture-view.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-texture.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-framebuffer.js","../node_modules/@luma.gl/webgl/dist/adapter/webgl-canvas-context.js","../node_modules/@luma.gl/webgl/dist/context/debug/spector.js","../node_modules/@luma.gl/webgl/dist/context/debug/webgl-developer-tools.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/parse-shader-compiler-log.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-shader.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pass.js","../node_modules/@luma.gl/webgl/dist/classic/typed-array-utils.js","../node_modules/@luma.gl/webgl/dist/classic/accessor.js","../node_modules/@luma.gl/core/dist/utils/check-props.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/decode-webgl-types.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/get-shader-layout.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/set-uniform.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-render-pipeline.js","../node_modules/@luma.gl/webgl/dist/adapter/helpers/webgl-topology-utils.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-buffer.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-command-encoder.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-vertex-array.js","../node_modules/@probe.gl/env/dist/lib/get-browser.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-transform-feedback.js","../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-query-set.js","../node_modules/@luma.gl/webgl/dist/classic/format-utils.js","../node_modules/@luma.gl/webgl/dist/classic/copy-and-blit.js","../node_modules/@luma.gl/webgl/dist/adapter/webgl-device.js","../node_modules/@luma.gl/webgl/dist/classic/clear.js","../node_modules/hammerjs/hammer.js","../node_modules/mjolnir.js/dist/esm/utils/hammer-overrides.js","../node_modules/mjolnir.js/dist/esm/utils/hammer.browser.js","../node_modules/mjolnir.js/dist/esm/inputs/input.js","../node_modules/mjolnir.js/dist/esm/constants.js","../node_modules/mjolnir.js/dist/esm/utils/globals.js","../node_modules/mjolnir.js/dist/esm/inputs/wheel-input.js","../node_modules/mjolnir.js/dist/esm/inputs/move-input.js","../node_modules/mjolnir.js/dist/esm/inputs/key-input.js","../node_modules/mjolnir.js/dist/esm/inputs/contextmenu-input.js","../node_modules/mjolnir.js/dist/esm/utils/event-utils.js","../node_modules/mjolnir.js/dist/esm/utils/event-registrar.js","../node_modules/mjolnir.js/dist/esm/event-manager.js","../node_modules/@deck.gl/core/dist/lib/deck.js","../node_modules/@deck.gl/core/dist/lib/attribute/gl-utils.js","../node_modules/@deck.gl/core/dist/lib/attribute/data-column.js","../node_modules/@deck.gl/core/dist/utils/iterable-utils.js","../node_modules/@deck.gl/core/dist/utils/range.js","../node_modules/@deck.gl/core/dist/lib/attribute/transition-settings.js","../node_modules/@deck.gl/core/dist/lib/attribute/attribute.js","../node_modules/@deck.gl/core/dist/utils/array-utils.js","../node_modules/@deck.gl/core/dist/transitions/gpu-transition-utils.js","../node_modules/@deck.gl/core/dist/transitions/gpu-transition.js","../node_modules/@deck.gl/core/dist/transitions/gpu-interpolation-transition.js","../node_modules/@deck.gl/core/dist/transitions/gpu-spring-transition.js","../node_modules/@deck.gl/core/dist/lib/attribute/attribute-transition-manager.js","../node_modules/@deck.gl/core/dist/lib/attribute/attribute-manager.js","../node_modules/@deck.gl/core/dist/transitions/cpu-spring-transition.js","../node_modules/@deck.gl/core/dist/lib/uniform-transition-manager.js","../node_modules/@deck.gl/core/dist/transitions/cpu-interpolation-transition.js","../node_modules/@deck.gl/core/dist/lifecycle/props.js","../node_modules/@deck.gl/core/dist/utils/count.js","../node_modules/@deck.gl/core/dist/utils/shader.js","../node_modules/@deck.gl/core/dist/utils/texture.js","../node_modules/@deck.gl/core/dist/lifecycle/prop-types.js","../node_modules/@deck.gl/core/dist/lifecycle/create-props.js","../node_modules/@deck.gl/core/dist/lifecycle/component.js","../node_modules/@deck.gl/core/dist/lifecycle/component-state.js","../node_modules/@deck.gl/core/dist/lib/layer-state.js","../node_modules/@deck.gl/core/dist/lib/layer.js","../node_modules/@deck.gl/core/dist/lib/composite-layer.js","../node_modules/@deck.gl/core/dist/viewports/globe-viewport.js","../node_modules/@deck.gl/core/dist/viewports/orthographic-viewport.js","../node_modules/@deck.gl/core/dist/lib/layer-extension.js","../node_modules/@deck.gl/core/dist/utils/tesselator.js","../node_modules/@deck.gl/mapbox/dist/deck-utils.js","../node_modules/@deck.gl/mapbox/dist/mapbox-layer.js","../node_modules/@deck.gl/mapbox/dist/resolve-layers.js","../node_modules/@deck.gl/mapbox/dist/mapbox-overlay.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/option-utils/merge-loader-options.js","../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-job.js","../node_modules/@loaders.gl/worker-utils/dist/lib/node/worker_threads-browser.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-utils/get-loadable-worker-url.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-utils/get-transfer-list.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-thread.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-pool.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-farm/worker-farm.js","../node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/worker-loader-utils/parse-with-worker.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-api/get-worker-url.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/array-buffer-utils.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/file-aliases.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/memory-conversion-utils.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/path.js","../node_modules/@loaders.gl/core/dist/javascript-utils/is-type.js","../node_modules/@loaders.gl/core/dist/lib/fetch/fetch-error.js","../node_modules/@loaders.gl/core/dist/lib/utils/mime-type-utils.js","../node_modules/@loaders.gl/core/dist/lib/utils/url-utils.js","../node_modules/@loaders.gl/core/dist/lib/utils/resource-utils.js","../node_modules/@loaders.gl/core/dist/lib/utils/response-utils.js","../node_modules/@loaders.gl/core/dist/lib/fetch/fetch-file.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/loggers.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/option-defaults.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/option-utils.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/normalize-loader.js","../node_modules/@loaders.gl/core/dist/lib/api/register-loaders.js","../node_modules/@loaders.gl/core/dist/lib/utils/log.js","../node_modules/@loaders.gl/core/dist/lib/api/select-loader.js","../node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-array-buffer-iterator.js","../node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-stream-iterator.js","../node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-iterator.js","../node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-string-iterator.js","../node_modules/@loaders.gl/core/dist/iterators/make-iterator/make-blob-iterator.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/get-data.js","../node_modules/@loaders.gl/core/node_modules/@loaders.gl/loader-utils/dist/lib/iterators/async-iteration.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/get-fetch-function.js","../node_modules/@loaders.gl/core/dist/lib/loader-utils/loader-context.js","../node_modules/@loaders.gl/core/dist/lib/api/parse.js","../node_modules/@loaders.gl/worker-utils/dist/lib/worker-api/validate-worker-version.js","../node_modules/@loaders.gl/core/dist/lib/api/load.js","../node_modules/@deck.gl/layers/dist/icon-layer/icon-manager.js","../node_modules/@deck.gl/layers/dist/icon-layer/icon-layer.js","../node_modules/@deck.gl/layers/dist/icon-layer/icon-layer-vertex.glsl.js","../node_modules/@deck.gl/layers/dist/icon-layer/icon-layer-fragment.glsl.js","../node_modules/@deck.gl/layers/dist/point-cloud-layer/point-cloud-layer.js","../node_modules/@deck.gl/layers/dist/point-cloud-layer/point-cloud-layer-vertex.glsl.js","../node_modules/@deck.gl/layers/dist/point-cloud-layer/point-cloud-layer-fragment.glsl.js","../node_modules/@deck.gl/layers/dist/scatterplot-layer/scatterplot-layer.js","../node_modules/@deck.gl/layers/dist/scatterplot-layer/scatterplot-layer-vertex.glsl.js","../node_modules/@deck.gl/layers/dist/scatterplot-layer/scatterplot-layer-fragment.glsl.js","../node_modules/@math.gl/polygon/dist/polygon-utils.js","../node_modules/@math.gl/polygon/dist/utils.js","../node_modules/@math.gl/polygon/dist/lineclip.js","../node_modules/@math.gl/polygon/dist/cut-by-grid.js","../node_modules/@math.gl/polygon/dist/cut-by-mercator-bounds.js","../node_modules/@deck.gl/layers/dist/path-layer/path.js","../node_modules/@deck.gl/layers/dist/path-layer/path-tesselator.js","../node_modules/@deck.gl/layers/dist/path-layer/path-layer.js","../node_modules/@deck.gl/layers/dist/path-layer/path-layer-vertex.glsl.js","../node_modules/@deck.gl/layers/dist/path-layer/path-layer-fragment.glsl.js","../node_modules/@deck.gl/layers/node_modules/earcut/src/earcut.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/polygon.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/polygon-tesselator.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/solid-polygon-layer-vertex-main.glsl.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/solid-polygon-layer-vertex-top.glsl.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/solid-polygon-layer-vertex-side.glsl.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/solid-polygon-layer.js","../node_modules/@deck.gl/layers/dist/solid-polygon-layer/solid-polygon-layer-fragment.glsl.js","../node_modules/@deck.gl/layers/dist/utils.js","../node_modules/@deck.gl/layers/dist/text-layer/multi-icon-layer/multi-icon-layer.js","../node_modules/@deck.gl/layers/dist/text-layer/multi-icon-layer/multi-icon-layer-fragment.glsl.js","../node_modules/@mapbox/tiny-sdf/index.js","../node_modules/@deck.gl/layers/dist/text-layer/utils.js","../node_modules/@deck.gl/layers/dist/text-layer/lru-cache.js","../node_modules/@deck.gl/layers/dist/text-layer/font-atlas-manager.js","../node_modules/@deck.gl/layers/dist/text-layer/text-background-layer/text-background-layer.js","../node_modules/@deck.gl/layers/dist/text-layer/text-background-layer/text-background-layer-vertex.glsl.js","../node_modules/@deck.gl/layers/dist/text-layer/text-background-layer/text-background-layer-fragment.glsl.js","../node_modules/@deck.gl/layers/dist/text-layer/text-layer.js","../node_modules/@deck.gl/layers/dist/geojson-layer/sub-layer-map.js","../node_modules/@deck.gl/layers/dist/geojson-layer/geojson.js","../node_modules/@deck.gl/layers/dist/geojson-layer/geojson-layer-props.js","../node_modules/@deck.gl/layers/dist/geojson-layer/geojson-binary.js","../node_modules/@deck.gl/layers/dist/geojson-layer/geojson-layer.js","../node_modules/@deck.gl/geo-layers/dist/tileset-2d/tile-2d-header.js","../node_modules/@math.gl/culling/dist/constants.js","../node_modules/@math.gl/culling/dist/lib/bounding-volumes/axis-aligned-bounding-box.js","../node_modules/@math.gl/culling/dist/lib/bounding-volumes/bounding-sphere.js","../node_modules/@math.gl/culling/dist/lib/bounding-volumes/oriented-bounding-box.js","../node_modules/@math.gl/culling/dist/lib/plane.js","../node_modules/@math.gl/culling/dist/lib/culling-volume.js","../node_modules/@math.gl/culling/dist/lib/perspective-off-center-frustum.js","../node_modules/@math.gl/culling/dist/lib/algorithms/bounding-sphere-from-points.js","../node_modules/@math.gl/culling/dist/lib/algorithms/compute-eigen-decomposition.js","../node_modules/@math.gl/culling/dist/lib/algorithms/bounding-box-from-points.js","../node_modules/@deck.gl/geo-layers/dist/tileset-2d/tile-2d-traversal.js","../node_modules/@deck.gl/geo-layers/dist/tileset-2d/utils.js","../node_modules/@deck.gl/geo-layers/dist/tileset-2d/memoize.js","../node_modules/@deck.gl/geo-layers/dist/tileset-2d/tileset-2d.js","../node_modules/@deck.gl/geo-layers/dist/tile-layer/tile-layer.js","../node_modules/@deck.gl/mesh-layers/dist/utils/matrix.js","../node_modules/@deck.gl/mesh-layers/dist/simple-mesh-layer/simple-mesh-layer.js","../node_modules/@deck.gl/mesh-layers/dist/simple-mesh-layer/simple-mesh-layer-vertex.glsl.js","../node_modules/@deck.gl/mesh-layers/dist/simple-mesh-layer/simple-mesh-layer-fragment.glsl.js","../node_modules/@luma.gl/gltf/dist/pbr/parse-pbr-material.js","../node_modules/@loaders.gl/textures/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@loaders.gl/textures/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/textures/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js","../node_modules/@loaders.gl/textures/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js","../node_modules/@loaders.gl/loader-utils/dist/lib/module-utils/js-module-utils.js","../node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js","../node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js","../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js","../node_modules/@loaders.gl/textures/dist/lib/parsers/parse-basis.js","../node_modules/@loaders.gl/textures/dist/basis-loader.js","../node_modules/@loaders.gl/textures/dist/lib/utils/version.js","../node_modules/@luma.gl/gltf/dist/gltf/gltf-animator.js","../node_modules/@luma.gl/gltf/dist/gltf/create-gltf-model.js","../node_modules/@luma.gl/gltf/dist/gltf/gltf-instantiator.js","../node_modules/@loaders.gl/gltf/dist/lib/utils/assert.js","../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-constants.js","../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-utils.js","../node_modules/@loaders.gl/gltf/dist/lib/api/gltf-scenegraph.js","../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/get-typed-array.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/utils/3d-tiles-utils.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_mesh_features.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_structural_metadata.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/EXT_feature_metadata.js","../node_modules/@loaders.gl/gltf/dist/lib/utils/version.js","../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-glb.js","../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/resolve-url.js","../node_modules/@loaders.gl/gltf/dist/meshopt/meshopt-decoder.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_meshopt_compression.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_texture_webp.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_basisu.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/lib/utils/version.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/draco-loader.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/lib/draco-parser.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js","../node_modules/@loaders.gl/gltf/node_modules/@loaders.gl/draco/dist/index.js","../node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-attribute-utils.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_draco_mesh_compression.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_transform.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_lights_punctual.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_materials_unlit.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_techniques_webgl.js","../node_modules/@loaders.gl/gltf/dist/lib/api/gltf-extensions.js","../node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_binary_gltf.js","../node_modules/@loaders.gl/gltf/dist/lib/api/normalize-gltf-v1.js","../node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-gltf.js","../node_modules/@loaders.gl/gltf/dist/gltf-loader.js","../node_modules/@loaders.gl/gltf/dist/lib/api/post-process-gltf.js","../node_modules/@deck.gl/mesh-layers/dist/scenegraph-layer/gltf-utils.js","../node_modules/@deck.gl/mesh-layers/dist/scenegraph-layer/scenegraph-layer.js","../node_modules/@deck.gl/mesh-layers/dist/scenegraph-layer/scenegraph-layer-vertex.glsl.js","../node_modules/@deck.gl/mesh-layers/dist/scenegraph-layer/scenegraph-layer-fragment.glsl.js","../node_modules/@luma.gl/gltf/dist/gltf/create-gltf-objects.js","../node_modules/@deck.gl/geo-layers/dist/mesh-layer/mesh-layer.js","../node_modules/@deck.gl/geo-layers/dist/mesh-layer/mesh-layer-vertex.glsl.js","../node_modules/@deck.gl/geo-layers/dist/mesh-layer/mesh-layer-fragment.glsl.js","../node_modules/@math.gl/geospatial/dist/type-utils.js","../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/ellipsoid-transform.js","../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/scale-to-geodetic-surface.js","../node_modules/@math.gl/geospatial/dist/ellipsoid/ellipsoid.js","../node_modules/@math.gl/geospatial/dist/constants.js","../node_modules/@loaders.gl/tiles/dist/utils/doubly-linked-list-node.js","../node_modules/@loaders.gl/tiles/dist/utils/doubly-linked-list.js","../node_modules/@loaders.gl/tiles/dist/tileset/tileset-cache.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/frame-state.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/zoom.js","../node_modules/@loaders.gl/tiles/dist/constants.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/bounding-volume.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/tiles-3d-lod.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/i3s-lod.js","../node_modules/@loaders.gl/tiles/dist/utils/managed-array.js","../node_modules/@loaders.gl/tiles/dist/tileset/tileset-traverser.js","../node_modules/@loaders.gl/tiles/dist/tileset/tile-3d.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/3d-tiles-options.js","../node_modules/@loaders.gl/tiles/dist/tileset/format-3d-tiles/tileset-3d-traverser.js","../node_modules/@loaders.gl/tiles/dist/tileset/format-i3s/i3s-pending-tiles-register.js","../node_modules/@loaders.gl/tiles/dist/tileset/format-i3s/i3s-tile-manager.js","../node_modules/@loaders.gl/tiles/dist/tileset/format-i3s/i3s-tileset-traverser.js","../node_modules/@loaders.gl/tiles/dist/tileset/tileset-3d.js","../node_modules/@loaders.gl/tiles/dist/tileset/helpers/transform-utils.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/version.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/constants.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-utils.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/lib/utils/version.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/draco-loader.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/lib/draco-parser.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/draco/dist/index.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/math/dist/geometry/constants.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/math/dist/geometry/gl/gl-type.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/math/dist/geometry/colors/rgb565.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/math/dist/geometry/compression/attribute-compression.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/math/dist/geometry/utils/assert.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-feature-table.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/classes/helpers/tile-3d-accessor-utils.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-batch-table-hierarchy.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-batch-table.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-header.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-tables.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-colors.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-normals.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-positions.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-point-cloud.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-batched-model.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-instanced-model.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-composite.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-gltf.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-subtree.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/tile-3d-subtree-loader.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/node_modules/long/index.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2-token-functions.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2geometry/s2-geometry.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-boundary.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2geometry/s2-cell-utils.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2-geometry-functions.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-region.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-obb-points.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/utils/obb/s2-corners-to-obb.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-header.js","../node_modules/@deck.gl/geo-layers/node_modules/@loaders.gl/3d-tiles/dist/tiles-3d-loader.js","../node_modules/@deck.gl/geo-layers/dist/tile-3d-layer/tile-3d-layer.js","../node_modules/@loaders.gl/terrain/dist/lib/decode-quantized-mesh.js","../node_modules/@loaders.gl/terrain/dist/lib/helpers/skirt.js","../node_modules/@mapbox/martini/index.js","../node_modules/@loaders.gl/terrain/dist/lib/delatin/index.js","../node_modules/@loaders.gl/terrain/dist/lib/parse-terrain.js","../node_modules/@loaders.gl/terrain/dist/lib/utils/version.js","../node_modules/@loaders.gl/terrain/dist/terrain-loader.js","../node_modules/@loaders.gl/terrain/dist/index.js","../node_modules/@deck.gl/geo-layers/dist/terrain-layer/terrain-layer.js","../node_modules/@deck.gl/extensions/dist/utils/projection-utils.js","../node_modules/@deck.gl/extensions/dist/terrain/shader-module.js","../node_modules/@deck.gl/extensions/dist/terrain/utils.js","../node_modules/@deck.gl/extensions/dist/terrain/terrain-cover.js","../node_modules/@deck.gl/extensions/dist/terrain/terrain-pass.js","../node_modules/@deck.gl/extensions/dist/terrain/terrain-picking-pass.js","../node_modules/@deck.gl/extensions/dist/terrain/height-map-builder.js","../node_modules/@deck.gl/extensions/dist/terrain/terrain-effect.js","../node_modules/@deck.gl/extensions/dist/terrain/terrain-extension.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/loader-types.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/assert.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/env-utils/globals.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/get-first-characters.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/parser-utils/parse-json.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/array-buffer-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/binary-utils/memory-copy-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/get-cwd.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/path-utils/path.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/tiles/dist/constants.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/version.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/constants.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-utils.js","../node_modules/@loaders.gl/draco/dist/lib/utils/version.js","../node_modules/@loaders.gl/draco/dist/draco-loader.js","../node_modules/@loaders.gl/draco/node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js","../node_modules/@loaders.gl/draco/node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js","../node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js","../node_modules/@loaders.gl/draco/dist/lib/draco-parser.js","../node_modules/@loaders.gl/draco/node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js","../node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js","../node_modules/@loaders.gl/draco/dist/index.js","../node_modules/@loaders.gl/math/dist/geometry/constants.js","../node_modules/@loaders.gl/math/dist/geometry/gl/gl-type.js","../node_modules/@loaders.gl/math/dist/geometry/colors/rgb565.js","../node_modules/@loaders.gl/math/dist/geometry/compression/attribute-compression.js","../node_modules/@loaders.gl/math/dist/geometry/utils/assert.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-feature-table.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/classes/helpers/tile-3d-accessor-utils.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-batch-table-hierarchy.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/classes/tile-3d-batch-table.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-header.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-tables.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-colors.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-normals.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/normalize-3d-tile-positions.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-point-cloud.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/utils/version.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/category-api/parsed-image-api.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/parsers/svg-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-image-bitmap.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/category-api/parse-isobmff-binary.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/category-api/binary-image-api.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/image-loader.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/parsers/parse-image.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/images/dist/lib/category-api/image-format.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/utils/assert.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-constants.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/api/gltf-scenegraph.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/get-typed-array.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/utils/3d-tiles-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_mesh_features.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_structural_metadata.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/EXT_feature_metadata.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/utils/version.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/parsers/basis-module-loader.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/loader-utils/dist/lib/module-utils/js-module-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/gl-extensions.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/utils/texture-formats.js","../node_modules/@loaders.gl/3d-tiles/node_modules/ktx-parse/dist/ktx-parse.modern.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/parsers/parse-ktx.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/parsers/parse-basis.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/basis-loader.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/textures/dist/lib/utils/version.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-glb.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/resolve-url.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/meshopt/meshopt-decoder.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_meshopt_compression.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/EXT_texture_webp.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_basisu.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/gltf-utils/gltf-attribute-utils.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_draco_mesh_compression.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_texture_transform.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_lights_punctual.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_materials_unlit.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/deprecated/KHR_techniques_webgl.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/api/gltf-extensions.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/extensions/KHR_binary_gltf.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/api/normalize-gltf-v1.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/parsers/parse-gltf.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/gltf-loader.js","../node_modules/@loaders.gl/3d-tiles/node_modules/@loaders.gl/gltf/dist/lib/api/post-process-gltf.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-batched-model.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-instanced-model.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-composite.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-gltf.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-tile-subtree.js","../node_modules/@loaders.gl/3d-tiles/dist/tile-3d-subtree-loader.js","../node_modules/long/index.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2-token-functions.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2geometry/s2-geometry.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-boundary.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2geometry/s2-cell-utils.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/s2-geometry-functions.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-region.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/s2/converters/s2-to-obb-points.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/utils/obb/s2-corners-to-obb.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js","../node_modules/@loaders.gl/3d-tiles/dist/lib/parsers/parse-3d-tile-header.js","../node_modules/@loaders.gl/3d-tiles/dist/tiles-3d-loader.js","../node_modules/color-name/index.js","../node_modules/color-string/index.js","../node_modules/color-convert/conversions.js","../node_modules/color-convert/route.js","../node_modules/color-convert/index.js","../node_modules/color/index.js","../src/components/GlMap.svelte","../src/components/LeafletMap.svelte","../node_modules/leaflet/dist/leaflet-src.js","../src/components/TangramMap.svelte","../node_modules/tangram/dist/tangram.min.js","../node_modules/@fortawesome/free-solid-svg-icons/index.mjs","../node_modules/svelte-fa/src/utils.js","../node_modules/svelte-fa/src/fa.svelte","../node_modules/hat/index.js","../src/mapbox-urls.js","../src/renderers.js","../src/shortcut.js","../src/components/inputs/Dropdown/DropdownToggle.svelte","../src/components/inputs/Dropdown/Dropdown.svelte","../src/components/inputs/StylesDropdown.svelte","../src/components/MapStyleInput.svelte","../src/components/CustomJsUi.svelte","../src/components/MapStyleInputWrapper.svelte","../src/components/inputs/Button.svelte","../src/components/MapLocationControl.svelte","../src/components/MapLabel.svelte","../src/map-state-utils.js","../node_modules/lodash.isequal/index.js","../src/components/Map.svelte","../src/components/MapsMirrorLayout.svelte","../src/components/MapsPhoneLayout.svelte","../src/components/MapsSwipeLayout.svelte","../src/components/MapsResponsiveLayout.svelte","../src/components/Maps.svelte","../node_modules/html2canvas/dist/html2canvas.js","../node_modules/@beyonk/svelte-mapbox/src/lib/geocoder/geocoder-action.js","../node_modules/@beyonk/svelte-mapbox/src/lib/asset-loader.js","../node_modules/@beyonk/svelte-mapbox/src/lib/event-bindings.js","../node_modules/@beyonk/svelte-mapbox/src/lib/geocoder/Geocoder.svelte","../src/components/ViewModeControl.svelte","../src/components/MapLocationDropdown.svelte","../src/components/Tooltip.svelte","../src/components/MapControls.svelte","../src/query.js","../src/settings.js","../node_modules/stamen-attribution/dist/main.js","../src/App.svelte","../src/make-config.js","../src/main.js","../node_modules/@maptiler/sdk/node_modules/maplibre-gl/dist/maplibre-gl.js","../node_modules/js-base64/base64.mjs","../node_modules/events/events.js","../node_modules/quick-lru/index.js","../node_modules/@maptiler/client/dist/maptiler-client.mjs","../node_modules/uuid/dist/esm-browser/stringify.js","../node_modules/uuid/dist/esm-browser/rng.js","../node_modules/uuid/dist/esm-browser/native.js","../node_modules/@maptiler/sdk/dist/maptiler-sdk.mjs","../node_modules/uuid/dist/esm-browser/v4.js"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for