{"version":3,"file":"application.js","sources":["../../../node_modules/mapbox-gl/dist/mapbox-gl.js","../javascripts/copyable.js","../../../node_modules/svelte/src/runtime/internal/utils.js","../../../node_modules/svelte/src/runtime/internal/environment.js","../../../node_modules/svelte/src/runtime/internal/loop.js","../../../node_modules/svelte/src/runtime/internal/globals.js","../../../node_modules/svelte/src/runtime/internal/dom.js","../../../node_modules/svelte/src/runtime/internal/style_manager.js","../../../node_modules/svelte/src/runtime/internal/lifecycle.js","../../../node_modules/svelte/src/runtime/internal/scheduler.js","../../../node_modules/svelte/src/runtime/internal/transitions.js","../../../node_modules/svelte/src/runtime/internal/each.js","../../../node_modules/svelte/src/runtime/internal/spread.js","../../../node_modules/svelte/src/runtime/internal/Component.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/style.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/attr.js","../../../node_modules/svelte/src/runtime/internal/disclose-version/index.js","../../../node_modules/svelte/src/shared/version.js","../../../node_modules/svelte/src/runtime/store/index.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/store/lightable.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/makeElement.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/is.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/callbacks.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/event.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/lifecycle.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/object.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/withGet.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/overridable.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/sleep.js","../../../node_modules/@melt-ui/svelte/node_modules/nanoid/non-secure/index.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/id.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/keyboard.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/platform.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/scroll.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/store/effect.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/store/toWritableStores.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/elements.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/focus.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/click-outside/action.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/escape-keydown/action.js","../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs","../../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs","../../../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs","../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs","../../../node_modules/@melt-ui/svelte/dist/internal/actions/floating/action.js","../../../node_modules/tabbable/dist/index.esm.js","../../../node_modules/focus-trap/dist/focus-trap.esm.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/modal/action.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/array.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/popper/action.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/focus-trap/action.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/portal.js","../../../node_modules/@melt-ui/svelte/dist/internal/actions/interact-outside/action.js","../../../node_modules/@melt-ui/svelte/dist/builders/hidden-input/create.js","../../../node_modules/@melt-ui/svelte/dist/builders/date-picker/create.js","../../../node_modules/@melt-ui/svelte/dist/builders/calendar/create.js","../../../node_modules/@melt-ui/svelte/dist/builders/popover/create.js","../../../node_modules/@melt-ui/svelte/dist/internal/helpers/store/derivedVisible.js","../../../node_modules/bits-ui/dist/internal/object.js","../../../node_modules/bits-ui/dist/helpers/builders.js","../../../node_modules/bits-ui/dist/bits/floating/helpers.js","../../../node_modules/bits-ui/dist/bits/popover/ctx.js","../../../node_modules/bits-ui/dist/internal/attrs.js","../../../node_modules/bits-ui/dist/internal/updater.js","../../../node_modules/bits-ui/dist/bits/popover/components/popover.svelte","../../../node_modules/bits-ui/dist/bits/popover/components/popover-content.svelte","../../../node_modules/bits-ui/dist/bits/popover/components/popover-trigger.svelte","../../../node_modules/bits-ui/dist/internal/events.js","../../../node_modules/@propublica/pp-svelte/dist/Button/Button.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/link.svg","../../../node_modules/@propublica/pp-svelte/dist/CopyButton/CopyButton.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/contrast--filled.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/sun--filled.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/moon--filled.svg","../../../node_modules/@propublica/pp-svelte/dist/DarkModeToggle/DarkModeToggle.svelte","../../../node_modules/@propublica/pp-svelte/dist/FeltronNumber/FeltronNumber.svelte","../../../node_modules/@propublica/pp-svelte/dist/NewsletterInit.svelte","../../../node_modules/@propublica/pp-svelte/dist/RecaptchaInit.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/mail.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/arrow-right--filled.svg","../../../node_modules/@propublica/pp-svelte/dist/NewsletterSignup/NewsletterSignup.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/share.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/social-x.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/social-facebook.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/social-whatsapp.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/social-threads.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/close.svg","../../../node_modules/@propublica/pp-svelte/dist/ShareTools/ShareTools.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/propublica-logo.svg","../../../node_modules/@propublica/pp-svelte/dist/SiteFooter/SiteFooter.svelte","../../../node_modules/@propublica/pp-v5-shared/src/icons/menu.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/search.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/social-instagram.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/topic-racial-justice.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/topic-healthcare.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/topic-politics.svg","../../../node_modules/@propublica/pp-v5-shared/src/icons/topic-criminal-justice.svg","../../../node_modules/@propublica/pp-svelte/dist/SiteHeader/SiteHeader.svelte","../../../node_modules/lucide-svelte/dist/defaultAttributes.js","../../../node_modules/lucide-svelte/dist/Icon.svelte","../../../node_modules/lucide-svelte/dist/icons/chevron-down.svelte","../../../node_modules/lucide-svelte/dist/icons/chevron-up.svelte","../javascripts/components/About.svelte","../javascripts/components/Contributors.svelte","../javascripts/components/ErrorForm.svelte","../../../node_modules/lucide-svelte/dist/icons/chevron-right.svelte","../javascripts/components/RelatedStories.svelte","../javascripts/components/breadcrumbs.svelte","../../../node_modules/d3-array/src/ascending.js","../../../node_modules/d3-array/src/descending.js","../../../node_modules/d3-array/src/bisector.js","../../../node_modules/d3-array/src/bisect.js","../../../node_modules/d3-array/src/number.js","../../../node_modules/d3-array/src/ticks.js","../../../node_modules/d3-array/src/min.js","../../../node_modules/d3-axis/src/identity.js","../../../node_modules/d3-axis/src/axis.js","../../../node_modules/d3-dispatch/src/dispatch.js","../../../node_modules/d3-selection/src/namespaces.js","../../../node_modules/d3-selection/src/namespace.js","../../../node_modules/d3-selection/src/creator.js","../../../node_modules/d3-selection/src/selector.js","../../../node_modules/d3-selection/src/selectorAll.js","../../../node_modules/d3-selection/src/selection/selectAll.js","../../../node_modules/d3-selection/src/array.js","../../../node_modules/d3-selection/src/matcher.js","../../../node_modules/d3-selection/src/selection/selectChild.js","../../../node_modules/d3-selection/src/selection/selectChildren.js","../../../node_modules/d3-selection/src/selection/sparse.js","../../../node_modules/d3-selection/src/selection/enter.js","../../../node_modules/d3-selection/src/selection/data.js","../../../node_modules/d3-selection/src/selection/sort.js","../../../node_modules/d3-selection/src/selection/attr.js","../../../node_modules/d3-selection/src/window.js","../../../node_modules/d3-selection/src/selection/style.js","../../../node_modules/d3-selection/src/selection/property.js","../../../node_modules/d3-selection/src/selection/classed.js","../../../node_modules/d3-selection/src/selection/text.js","../../../node_modules/d3-selection/src/selection/html.js","../../../node_modules/d3-selection/src/selection/raise.js","../../../node_modules/d3-selection/src/selection/lower.js","../../../node_modules/d3-selection/src/selection/insert.js","../../../node_modules/d3-selection/src/selection/remove.js","../../../node_modules/d3-selection/src/selection/clone.js","../../../node_modules/d3-selection/src/selection/on.js","../../../node_modules/d3-selection/src/selection/dispatch.js","../../../node_modules/d3-selection/src/selection/index.js","../../../node_modules/d3-selection/src/select.js","../../../node_modules/d3-color/src/define.js","../../../node_modules/d3-color/src/color.js","../../../node_modules/d3-selection/src/selection/select.js","../../../node_modules/d3-selection/src/selection/filter.js","../../../node_modules/d3-selection/src/constant.js","../../../node_modules/d3-selection/src/selection/exit.js","../../../node_modules/d3-selection/src/selection/join.js","../../../node_modules/d3-selection/src/selection/merge.js","../../../node_modules/d3-selection/src/selection/order.js","../../../node_modules/d3-selection/src/selection/call.js","../../../node_modules/d3-selection/src/selection/nodes.js","../../../node_modules/d3-selection/src/selection/node.js","../../../node_modules/d3-selection/src/selection/size.js","../../../node_modules/d3-selection/src/selection/empty.js","../../../node_modules/d3-selection/src/selection/each.js","../../../node_modules/d3-selection/src/selection/append.js","../../../node_modules/d3-selection/src/selection/datum.js","../../../node_modules/d3-selection/src/selection/iterator.js","../../../node_modules/d3-interpolate/src/constant.js","../../../node_modules/d3-interpolate/src/color.js","../../../node_modules/d3-interpolate/src/rgb.js","../../../node_modules/d3-interpolate/src/numberArray.js","../../../node_modules/d3-interpolate/src/array.js","../../../node_modules/d3-interpolate/src/date.js","../../../node_modules/d3-interpolate/src/number.js","../../../node_modules/d3-interpolate/src/object.js","../../../node_modules/d3-interpolate/src/string.js","../../../node_modules/d3-interpolate/src/value.js","../../../node_modules/d3-interpolate/src/round.js","../../../node_modules/d3-interpolate/src/transform/decompose.js","../../../node_modules/d3-interpolate/src/transform/parse.js","../../../node_modules/d3-interpolate/src/transform/index.js","../../../node_modules/d3-timer/src/timer.js","../../../node_modules/d3-timer/src/timeout.js","../../../node_modules/d3-transition/src/transition/schedule.js","../../../node_modules/d3-transition/src/transition/tween.js","../../../node_modules/d3-transition/src/transition/interpolate.js","../../../node_modules/d3-transition/src/transition/attr.js","../../../node_modules/d3-transition/src/transition/attrTween.js","../../../node_modules/d3-transition/src/transition/delay.js","../../../node_modules/d3-transition/src/transition/duration.js","../../../node_modules/d3-transition/src/transition/selection.js","../../../node_modules/d3-transition/src/transition/style.js","../../../node_modules/d3-transition/src/transition/index.js","../../../node_modules/d3-ease/src/cubic.js","../../../node_modules/d3-transition/src/transition/select.js","../../../node_modules/d3-transition/src/transition/selectAll.js","../../../node_modules/d3-transition/src/transition/filter.js","../../../node_modules/d3-transition/src/transition/merge.js","../../../node_modules/d3-transition/src/transition/transition.js","../../../node_modules/d3-transition/src/transition/on.js","../../../node_modules/d3-transition/src/transition/styleTween.js","../../../node_modules/d3-transition/src/transition/text.js","../../../node_modules/d3-transition/src/transition/textTween.js","../../../node_modules/d3-transition/src/transition/remove.js","../../../node_modules/d3-transition/src/transition/ease.js","../../../node_modules/d3-transition/src/transition/easeVarying.js","../../../node_modules/d3-transition/src/transition/end.js","../../../node_modules/d3-transition/src/selection/transition.js","../../../node_modules/d3-transition/src/selection/index.js","../../../node_modules/d3-transition/src/selection/interrupt.js","../../../node_modules/d3-transition/src/interrupt.js","../../../node_modules/d3-path/src/path.js","../../../node_modules/d3-format/src/formatDecimal.js","../../../node_modules/d3-format/src/exponent.js","../../../node_modules/d3-format/src/formatSpecifier.js","../../../node_modules/d3-format/src/formatPrefixAuto.js","../../../node_modules/d3-format/src/formatRounded.js","../../../node_modules/d3-format/src/formatTypes.js","../../../node_modules/d3-format/src/identity.js","../../../node_modules/d3-format/src/locale.js","../../../node_modules/d3-format/src/defaultLocale.js","../../../node_modules/d3-format/src/formatGroup.js","../../../node_modules/d3-format/src/formatNumerals.js","../../../node_modules/d3-format/src/formatTrim.js","../../../node_modules/d3-scale/src/init.js","../../../node_modules/d3-scale/src/number.js","../../../node_modules/d3-scale/src/continuous.js","../../../node_modules/d3-scale/src/constant.js","../../../node_modules/d3-scale/src/tickFormat.js","../../../node_modules/d3-format/src/precisionPrefix.js","../../../node_modules/d3-format/src/precisionRound.js","../../../node_modules/d3-format/src/precisionFixed.js","../../../node_modules/d3-scale/src/linear.js","../../../node_modules/d3-time/src/interval.js","../../../node_modules/d3-time/src/millisecond.js","../../../node_modules/d3-time/src/duration.js","../../../node_modules/d3-time/src/second.js","../../../node_modules/d3-time/src/minute.js","../../../node_modules/d3-time/src/hour.js","../../../node_modules/d3-time/src/day.js","../../../node_modules/d3-time/src/week.js","../../../node_modules/d3-time/src/month.js","../../../node_modules/d3-time/src/year.js","../../../node_modules/d3-time/src/ticks.js","../../../node_modules/d3-time-format/src/locale.js","../../../node_modules/d3-time-format/src/defaultLocale.js","../../../node_modules/d3-scale/src/time.js","../../../node_modules/d3-scale/src/nice.js","../../../node_modules/d3-shape/src/constant.js","../../../node_modules/d3-shape/src/curve/linear.js","../../../node_modules/d3-shape/src/point.js","../../../node_modules/d3-shape/src/line.js","../../../node_modules/d3-shape/src/path.js","../../../node_modules/d3-shape/src/array.js","../../../node_modules/d3-zoom/src/transform.js","../../../node_modules/journalize/dist/journalize.mjs","../../../node_modules/popper.js/dist/esm/popper.js","../../../node_modules/tippy.js/esm/index.all.js","../javascripts/components/charts/utils.js","../javascripts/components/charts/demographics.svelte","../../../node_modules/d3-array/src/max.js","../../../node_modules/lucide-svelte/dist/icons/download.svelte","../../../node_modules/lucide-svelte/dist/icons/file-json.svelte","../../../node_modules/lucide-svelte/dist/icons/file-spreadsheet.svelte","../javascripts/components/data_download_menu.svelte","../../../node_modules/@turf/helpers/dist/esm/index.js","../../../node_modules/@turf/meta/dist/esm/index.js","../../../node_modules/@turf/bbox/dist/esm/index.js","../../../node_modules/@turf/invariant/dist/esm/index.js","../../../node_modules/@turf/distance/dist/esm/index.js","../../../node_modules/lucide-svelte/dist/icons/arrow-right.svelte","../../../node_modules/lucide-svelte/dist/icons/locate-fixed.svelte","../../../node_modules/lucide-svelte/dist/icons/map-pin.svelte","../javascripts/components/table/utils.js","../javascripts/components/district_school_search.svelte","../javascripts/components/mapbox.svelte","../../../node_modules/lucide-svelte/dist/icons/info.svelte","../../../node_modules/lucide-svelte/dist/icons/x.svelte","../javascripts/components/more_info.svelte","../../../node_modules/lucide-svelte/dist/icons/search.svelte","../javascripts/components/school_search.svelte","../javascripts/components/search_summary.svelte","../javascripts/components/state_filter.svelte","../../../node_modules/lucide-svelte/dist/icons/arrow-down-to-line.svelte","../../../node_modules/lucide-svelte/dist/icons/arrow-up-from-line.svelte","../../../node_modules/lucide-svelte/dist/icons/filter-x.svelte","../../../node_modules/lucide-svelte/dist/icons/list-filter.svelte","../../../node_modules/lucide-svelte/dist/icons/arrow-down-a-z.svelte","../../../node_modules/lucide-svelte/dist/icons/arrow-down-up.svelte","../../../node_modules/lucide-svelte/dist/icons/arrow-up-z-a.svelte","../../../node_modules/lucide-svelte/dist/icons/check.svelte","../javascripts/components/table/FilterDropdown.svelte","../javascripts/components/table/MobileFilterMenu.svelte","../javascripts/components/table/TableHeader.svelte","../javascripts/components/table/TableCell.svelte","../javascripts/components/table/TableRow.svelte","../javascripts/components/table/Table.svelte","../javascripts/components/table/TableWithAPI.svelte","../javascripts/hydrate-svelte-components.js","../../../node_modules/@propublica/pp-svelte/util/hydrate-rails.mjs","../javascripts/tooltips.js","../javascripts/search-form.js"],"sourcesContent":["/* Mapbox GL JS is Copyright © 2020 Mapbox and subject to the Mapbox Terms of Service ((https://www.mapbox.com/legal/tos/). */\n(function (global, factory) {\ntypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\ntypeof define === 'function' && define.amd ? define(factory) :\n(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.mapboxgl = factory());\n})(this, (function () { 'use strict';\n\n/* eslint-disable */\n\nvar shared, worker, mapboxgl;\n// define gets called three times: one for each chunk. we rely on the order\n// they're imported to know which is which\nfunction define(_, chunk) {\nif (!shared) {\n shared = chunk;\n} else if (!worker) {\n worker = chunk;\n} else {\n var workerBundleString = \"self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; (\" + shared + \")(sharedChunk); (\" + worker + \")(sharedChunk); self.onerror = null;\"\n\n var sharedChunk = {};\n shared(sharedChunk);\n mapboxgl = chunk(sharedChunk);\n if (typeof window !== 'undefined' && window && window.URL && window.URL.createObjectURL) {\n mapboxgl.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));\n }\n}\n}\n\n\ndefine([\"exports\"],(function(t){var e=\"3.5.2\";let r;const n={API_URL:\"https://api.mapbox.com\",get API_URL_REGEX(){if(null==r){const t=/^((https?:)?\\/\\/)?([^\\/]+\\.)?mapbox\\.c(n|om)(\\/|\\?|$)/i;try{r=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t;}catch(e){r=t;}}return r},get API_TILEJSON_REGEX(){return /^((https?:)?\\/\\/)?([^\\/]+\\.)?mapbox\\.c(n|om)(\\/v[0-9]*\\/.*\\.json.*$)/i},get API_SPRITE_REGEX(){return /^((https?:)?\\/\\/)?([^\\/]+\\.)?mapbox\\.c(n|om)(\\/styles\\/v[0-9]*\\/)(.*\\/sprite.*\\..*$)/i},get API_FONTS_REGEX(){return /^((https?:)?\\/\\/)?([^\\/]+\\.)?mapbox\\.c(n|om)(\\/fonts\\/v[0-9]*\\/)(.*\\.pbf.*$)/i},get API_STYLE_REGEX(){return /^((https?:)?\\/\\/)?([^\\/]+\\.)?mapbox\\.c(n|om)(\\/styles\\/v[0-9]*\\/)(.*$)/i},get API_CDN_URL_REGEX(){return /^((https?:)?\\/\\/)?api\\.mapbox\\.c(n|om)(\\/mapbox-gl-js\\/)(.*$)/i},get EVENTS_URL(){if(!n.API_URL)return null;try{const t=new URL(n.API_URL);return \"api.mapbox.cn\"===t.hostname?\"https://events.mapbox.cn/events/v2\":\"api.mapbox.com\"===t.hostname?\"https://events.mapbox.com/events/v2\":null}catch(t){return null}},SESSION_PATH:\"/map-sessions/v1\",FEEDBACK_URL:\"https://apps.mapbox.com/feedback\",TILE_URL_VERSION:\"v4\",RASTER_URL_PREFIX:\"raster/v1\",RASTERARRAYS_URL_PREFIX:\"rasterarrays/v1\",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,DEFAULT_STYLE:\"mapbox://styles/mapbox/standard\",MAX_PARALLEL_IMAGE_REQUESTS:16,DRACO_URL:\"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm\",MESHOPT_URL:\"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm\",MESHOPT_SIMD_URL:\"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm\",GLYPHS_URL:\"mapbox://fonts/mapbox/{fontstack}/{range}.pbf\",TILES3D_URL_PREFIX:\"3dtiles/v1\"};function i(t){return n.API_URL_REGEX.test(t)}function s(t){return 0===t.indexOf(\"mapbox:\")}function a(t){return n.API_CDN_URL_REGEX.test(t)}function o(t){return n.API_SPRITE_REGEX.test(t)}function l(t){return n.API_STYLE_REGEX.test(t)&&!o(t)}const u={create:\"create\",load:\"load\",fullLoad:\"fullLoad\"},c={mark(t){performance.mark(t);},measure(t,e,r){performance.measure(t,e,r);}};function h(t){const e=t.name.split(\"?\")[0];return a(e)&&e.includes(\"mapbox-gl.js\")?\"javascript\":a(e)&&e.includes(\"mapbox-gl.css\")?\"css\":function(t){return n.API_FONTS_REGEX.test(t)}(e)?\"fontRange\":o(e)?\"sprite\":l(e)?\"style\":function(t){return n.API_TILEJSON_REGEX.test(t)}(e)?\"tilejson\":\"other\"}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,\"default\")?t.default:t}var f={},d={};Object.defineProperty(d,\"__esModule\",{value:!0}),d.setMatrixArrayType=function(t){d.ARRAY_TYPE=y=t;},d.toRadian=function(t){return t*x},d.equals=function(t,e){return Math.abs(t-e)<=m*Math.max(1,Math.abs(t),Math.abs(e))},d.RANDOM=d.ARRAY_TYPE=d.EPSILON=void 0;var m=1e-6;d.EPSILON=m;var y=\"undefined\"!=typeof Float32Array?Float32Array:Array;d.ARRAY_TYPE=y;var g=Math.random;d.RANDOM=g;var x=Math.PI/180;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var b={};function v(t){return v=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},v(t)}Object.defineProperty(b,\"__esModule\",{value:!0}),b.create=function(){var t=new _.ARRAY_TYPE(4);return _.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t},b.clone=function(t){var e=new _.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},b.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},b.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},b.fromValues=function(t,e,r,n){var i=new _.ARRAY_TYPE(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i},b.set=function(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t},b.transpose=function(t,e){if(t===e){var r=e[1];t[1]=e[2],t[2]=r;}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},b.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r*s-i*n;return a?(t[0]=s*(a=1/a),t[1]=-n*a,t[2]=-i*a,t[3]=r*a,t):null},b.adjoint=function(t,e){var r=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=r,t},b.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},b.multiply=M,b.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+s*o,t[1]=i*l+a*o,t[2]=n*-o+s*l,t[3]=i*-o+a*l,t},b.scale=function(t,e,r){var n=e[1],i=e[2],s=e[3],a=r[0],o=r[1];return t[0]=e[0]*a,t[1]=n*a,t[2]=i*o,t[3]=s*o,t},b.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t},b.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},b.str=function(t){return \"mat2(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\")\"},b.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},b.LDU=function(t,e,r,n){return t[2]=n[2]/n[0],r[0]=n[0],r[1]=n[1],r[3]=n[3]-t[2]*r[1],[t,e,r]},b.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t},b.subtract=A,b.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},b.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=e[0],o=e[1],l=e[2],u=e[3];return Math.abs(r-a)<=_.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-o)<=_.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=_.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-u)<=_.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))},b.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t},b.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t},b.sub=b.mul=void 0;var _=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==v(t)&&\"function\"!=typeof t)return {default:t};var r=w(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function w(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (w=function(t){return t?r:e})(t)}function M(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*o+s*l,t[1]=i*o+a*l,t[2]=n*u+s*c,t[3]=i*u+a*c,t}function A(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}b.mul=M,b.sub=A;var S={};function I(t){return I=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},I(t)}Object.defineProperty(S,\"__esModule\",{value:!0}),S.create=function(){var t=new T.ARRAY_TYPE(6);return T.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[4]=0,t[5]=0),t[0]=1,t[3]=1,t},S.clone=function(t){var e=new T.ARRAY_TYPE(6);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},S.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},S.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},S.fromValues=function(t,e,r,n,i,s){var a=new T.ARRAY_TYPE(6);return a[0]=t,a[1]=e,a[2]=r,a[3]=n,a[4]=i,a[5]=s,a},S.set=function(t,e,r,n,i,s,a){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t},S.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=r*s-n*i;return l?(t[0]=s*(l=1/l),t[1]=-n*l,t[2]=-i*l,t[3]=r*l,t[4]=(i*o-s*a)*l,t[5]=(n*a-r*o)*l,t):null},S.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},S.multiply=P,S.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*u,t[1]=i*c+a*u,t[2]=n*-u+s*c,t[3]=i*-u+a*c,t[4]=o,t[5]=l,t},S.scale=function(t,e,r){var n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=r[0],u=r[1];return t[0]=e[0]*l,t[1]=n*l,t[2]=i*u,t[3]=s*u,t[4]=a,t[5]=o,t},S.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=r[0],c=r[1];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=n*u+s*c+o,t[5]=i*u+a*c+l,t},S.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=-r,t[3]=n,t[4]=0,t[5]=0,t},S.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},S.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},S.str=function(t){return \"mat2d(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\", \"+t[4]+\", \"+t[5]+\")\"},S.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],1)},S.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t},S.subtract=z,S.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t},S.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t},S.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},S.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=e[0],u=e[1],c=e[2],h=e[3],p=e[4],f=e[5];return Math.abs(r-l)<=T.EPSILON*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=T.EPSILON*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(i-c)<=T.EPSILON*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(s-h)<=T.EPSILON*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(a-p)<=T.EPSILON*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(o-f)<=T.EPSILON*Math.max(1,Math.abs(o),Math.abs(f))},S.sub=S.mul=void 0;var T=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==I(t)&&\"function\"!=typeof t)return {default:t};var r=k(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function k(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (k=function(t){return t?r:e})(t)}function P(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=r[0],c=r[1],h=r[2],p=r[3],f=r[4],d=r[5];return t[0]=n*u+s*c,t[1]=i*u+a*c,t[2]=n*h+s*p,t[3]=i*h+a*p,t[4]=n*f+s*d+o,t[5]=i*f+a*d+l,t}function z(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t}S.mul=P,S.sub=z;var E={};function B(t){return B=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},B(t)}Object.defineProperty(E,\"__esModule\",{value:!0}),E.create=function(){var t=new D.ARRAY_TYPE(9);return D.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t},E.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},E.clone=function(t){var e=new D.ARRAY_TYPE(9);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},E.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},E.fromValues=function(t,e,r,n,i,s,a,o,l){var u=new D.ARRAY_TYPE(9);return u[0]=t,u[1]=e,u[2]=r,u[3]=n,u[4]=i,u[5]=s,u[6]=a,u[7]=o,u[8]=l,u},E.set=function(t,e,r,n,i,s,a,o,l,u){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t[8]=u,t},E.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},E.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i;}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},E.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=c*a-o*u,p=-c*s+o*l,f=u*s-a*l,d=r*h+n*p+i*f;return d?(t[0]=h*(d=1/d),t[1]=(-c*n+i*u)*d,t[2]=(o*n-i*a)*d,t[3]=p*d,t[4]=(c*r-i*l)*d,t[5]=(-o*r+i*s)*d,t[6]=f*d,t[7]=(-u*r+n*l)*d,t[8]=(a*r-n*s)*d,t):null},E.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return t[0]=a*c-o*u,t[1]=i*u-n*c,t[2]=n*o-i*a,t[3]=o*l-s*c,t[4]=r*c-i*l,t[5]=i*s-r*o,t[6]=s*u-a*l,t[7]=n*l-r*u,t[8]=r*a-n*s,t},E.determinant=function(t){var e=t[3],r=t[4],n=t[5],i=t[6],s=t[7],a=t[8];return t[0]*(a*r-n*s)+t[1]*(-a*e+n*i)+t[2]*(s*e-r*i)},E.multiply=R,E.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=p*n+f*a+u,t[7]=p*i+f*o+c,t[8]=p*s+f*l+h,t},E.rotate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=Math.sin(r),f=Math.cos(r);return t[0]=f*n+p*a,t[1]=f*i+p*o,t[2]=f*s+p*l,t[3]=f*a-p*n,t[4]=f*o-p*i,t[5]=f*l-p*s,t[6]=u,t[7]=c,t[8]=h,t},E.scale=function(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},E.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},E.fromRotation=function(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},E.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},E.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},E.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,u=r*a,c=n*a,h=n*o,p=i*a,f=i*o,d=i*l,m=s*a,y=s*o,g=s*l;return t[0]=1-h-d,t[3]=c-g,t[6]=p+y,t[1]=c+g,t[4]=1-u-d,t[7]=f-m,t[2]=p-y,t[5]=f+m,t[8]=1-u-h,t},E.normalFromMat4=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*a,b=r*l-i*a,v=r*u-s*a,_=n*l-i*o,w=n*u-s*o,M=i*u-s*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,T=h*y-p*m,k=h*g-f*m,P=p*g-f*y,z=x*P-b*k+v*T+_*I-w*S+M*A;return z?(t[0]=(o*P-l*k+u*T)*(z=1/z),t[1]=(l*I-a*P-u*S)*z,t[2]=(a*k-o*I+u*A)*z,t[3]=(i*k-n*P-s*T)*z,t[4]=(r*P-i*I+s*S)*z,t[5]=(n*I-r*k-s*A)*z,t[6]=(m*M-y*w+g*_)*z,t[7]=(y*v-d*M-g*b)*z,t[8]=(d*w-m*v+g*x)*z,t):null},E.projection=function(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},E.str=function(t){return \"mat3(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\", \"+t[4]+\", \"+t[5]+\", \"+t[6]+\", \"+t[7]+\", \"+t[8]+\")\"},E.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},E.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t},E.subtract=V,E.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t},E.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t},E.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]},E.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=e[0],p=e[1],f=e[2],d=e[3],m=e[4],y=e[5],g=e[6],x=e[7],b=e[8];return Math.abs(r-h)<=D.EPSILON*Math.max(1,Math.abs(r),Math.abs(h))&&Math.abs(n-p)<=D.EPSILON*Math.max(1,Math.abs(n),Math.abs(p))&&Math.abs(i-f)<=D.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(s-d)<=D.EPSILON*Math.max(1,Math.abs(s),Math.abs(d))&&Math.abs(a-m)<=D.EPSILON*Math.max(1,Math.abs(a),Math.abs(m))&&Math.abs(o-y)<=D.EPSILON*Math.max(1,Math.abs(o),Math.abs(y))&&Math.abs(l-g)<=D.EPSILON*Math.max(1,Math.abs(l),Math.abs(g))&&Math.abs(u-x)<=D.EPSILON*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(c-b)<=D.EPSILON*Math.max(1,Math.abs(c),Math.abs(b))},E.sub=E.mul=void 0;var D=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==B(t)&&\"function\"!=typeof t)return {default:t};var r=C(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function C(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (C=function(t){return t?r:e})(t)}function R(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1],d=r[2],m=r[3],y=r[4],g=r[5],x=r[6],b=r[7],v=r[8];return t[0]=p*n+f*a+d*u,t[1]=p*i+f*o+d*c,t[2]=p*s+f*l+d*h,t[3]=m*n+y*a+g*u,t[4]=m*i+y*o+g*c,t[5]=m*s+y*l+g*h,t[6]=x*n+b*a+v*u,t[7]=x*i+b*o+v*c,t[8]=x*s+b*l+v*h,t}function V(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}E.mul=R,E.sub=V;var L={};function O(t){return O=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},O(t)}Object.defineProperty(L,\"__esModule\",{value:!0}),L.create=function(){var t=new F.ARRAY_TYPE(16);return F.ARRAY_TYPE!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},L.clone=function(t){var e=new F.ARRAY_TYPE(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},L.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},L.fromValues=function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){var y=new F.ARRAY_TYPE(16);return y[0]=t,y[1]=e,y[2]=r,y[3]=n,y[4]=i,y[5]=s,y[6]=a,y[7]=o,y[8]=l,y[9]=u,y[10]=c,y[11]=h,y[12]=p,y[13]=f,y[14]=d,y[15]=m,y},L.set=function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t[8]=u,t[9]=c,t[10]=h,t[11]=p,t[12]=f,t[13]=d,t[14]=m,t[15]=y,t},L.identity=N,L.transpose=function(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],s=e[6],a=e[7],o=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=s,t[11]=e[14],t[12]=i,t[13]=a,t[14]=o;}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},L.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15],x=r*o-n*a,b=r*l-i*a,v=r*u-s*a,_=n*l-i*o,w=n*u-s*o,M=i*u-s*l,A=c*m-h*d,S=c*y-p*d,I=c*g-f*d,T=h*y-p*m,k=h*g-f*m,P=p*g-f*y,z=x*P-b*k+v*T+_*I-w*S+M*A;return z?(t[0]=(o*P-l*k+u*T)*(z=1/z),t[1]=(i*k-n*P-s*T)*z,t[2]=(m*M-y*w+g*_)*z,t[3]=(p*w-h*M-f*_)*z,t[4]=(l*I-a*P-u*S)*z,t[5]=(r*P-i*I+s*S)*z,t[6]=(y*v-d*M-g*b)*z,t[7]=(c*M-p*v+f*b)*z,t[8]=(a*k-o*I+u*A)*z,t[9]=(n*I-r*k-s*A)*z,t[10]=(d*w-m*v+g*x)*z,t[11]=(h*v-c*w-f*x)*z,t[12]=(o*S-a*T-l*A)*z,t[13]=(r*T-n*S+i*A)*z,t[14]=(m*b-d*_-y*x)*z,t[15]=(c*_-h*b+p*x)*z,t):null},L.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8],h=e[9],p=e[10],f=e[11],d=e[12],m=e[13],y=e[14],g=e[15];return t[0]=o*(p*g-f*y)-h*(l*g-u*y)+m*(l*f-u*p),t[1]=-(n*(p*g-f*y)-h*(i*g-s*y)+m*(i*f-s*p)),t[2]=n*(l*g-u*y)-o*(i*g-s*y)+m*(i*u-s*l),t[3]=-(n*(l*f-u*p)-o*(i*f-s*p)+h*(i*u-s*l)),t[4]=-(a*(p*g-f*y)-c*(l*g-u*y)+d*(l*f-u*p)),t[5]=r*(p*g-f*y)-c*(i*g-s*y)+d*(i*f-s*p),t[6]=-(r*(l*g-u*y)-a*(i*g-s*y)+d*(i*u-s*l)),t[7]=r*(l*f-u*p)-a*(i*f-s*p)+c*(i*u-s*l),t[8]=a*(h*g-f*m)-c*(o*g-u*m)+d*(o*f-u*h),t[9]=-(r*(h*g-f*m)-c*(n*g-s*m)+d*(n*f-s*h)),t[10]=r*(o*g-u*m)-a*(n*g-s*m)+d*(n*u-s*o),t[11]=-(r*(o*f-u*h)-a*(n*f-s*h)+c*(n*u-s*o)),t[12]=-(a*(h*y-p*m)-c*(o*y-l*m)+d*(o*p-l*h)),t[13]=r*(h*y-p*m)-c*(n*y-i*m)+d*(n*p-i*h),t[14]=-(r*(o*y-l*m)-a*(n*y-i*m)+d*(n*l-i*o)),t[15]=r*(o*p-l*h)-a*(n*p-i*h)+c*(n*l-i*o),t},L.determinant=function(t){var e=t[0],r=t[1],n=t[2],i=t[3],s=t[4],a=t[5],o=t[6],l=t[7],u=t[8],c=t[9],h=t[10],p=t[11],f=t[12],d=t[13],m=t[14],y=t[15];return (e*a-r*s)*(h*y-p*m)-(e*o-n*s)*(c*y-p*d)+(e*l-i*s)*(c*m-h*d)+(r*o-n*a)*(u*y-p*f)-(r*l-i*a)*(u*m-h*f)+(n*l-i*o)*(u*d-c*f)},L.multiply=j,L.translate=function(t,e,r){var n,i,s,a,o,l,u,c,h,p,f,d,m=r[0],y=r[1],g=r[2];return e===t?(t[12]=e[0]*m+e[4]*y+e[8]*g+e[12],t[13]=e[1]*m+e[5]*y+e[9]*g+e[13],t[14]=e[2]*m+e[6]*y+e[10]*g+e[14],t[15]=e[3]*m+e[7]*y+e[11]*g+e[15]):(i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],t[0]=n=e[0],t[1]=i,t[2]=s,t[3]=a,t[4]=o,t[5]=l,t[6]=u,t[7]=c,t[8]=h,t[9]=p,t[10]=f,t[11]=d,t[12]=n*m+o*y+h*g+e[12],t[13]=i*m+l*y+p*g+e[13],t[14]=s*m+u*y+f*g+e[14],t[15]=a*m+c*y+d*g+e[15]),t},L.scale=function(t,e,r){var n=r[0],i=r[1],s=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},L.rotate=function(t,e,r,n){var i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I,T,k=n[0],P=n[1],z=n[2],E=Math.hypot(k,P,z);return E0?(r[0]=2*(o*a+c*n+l*s-u*i)/h,r[1]=2*(l*a+c*i+u*n-o*s)/h,r[2]=2*(u*a+c*s+o*i-l*n)/h):(r[0]=2*(o*a+c*n+l*s-u*i),r[1]=2*(l*a+c*i+u*n-o*s),r[2]=2*(u*a+c*s+o*i-l*n)),q(t,e,r),t},L.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},L.getScaling=$,L.getRotation=function(t,e){var r=new F.ARRAY_TYPE(3);$(r,e);var n=1/r[0],i=1/r[1],s=1/r[2],a=e[0]*n,o=e[1]*i,l=e[2]*s,u=e[4]*n,c=e[5]*i,h=e[6]*s,p=e[8]*n,f=e[9]*i,d=e[10]*s,m=a+c+d,y=0;return m>0?(y=2*Math.sqrt(m+1),t[3]=.25*y,t[0]=(h-f)/y,t[1]=(p-l)/y,t[2]=(o-u)/y):a>c&&a>d?(y=2*Math.sqrt(1+a-c-d),t[3]=(h-f)/y,t[0]=.25*y,t[1]=(o+u)/y,t[2]=(p+l)/y):c>d?(y=2*Math.sqrt(1+c-a-d),t[3]=(p-l)/y,t[0]=(o+u)/y,t[1]=.25*y,t[2]=(h+f)/y):(y=2*Math.sqrt(1+d-a-c),t[3]=(o-u)/y,t[0]=(p+l)/y,t[1]=(h+f)/y,t[2]=.25*y),t},L.fromRotationTranslationScale=function(t,e,r,n){var i=e[0],s=e[1],a=e[2],o=e[3],l=i+i,u=s+s,c=a+a,h=i*l,p=i*u,f=i*c,d=s*u,m=s*c,y=a*c,g=o*l,x=o*u,b=o*c,v=n[0],_=n[1],w=n[2];return t[0]=(1-(d+y))*v,t[1]=(p+b)*v,t[2]=(f-x)*v,t[3]=0,t[4]=(p-b)*_,t[5]=(1-(h+y))*_,t[6]=(m+g)*_,t[7]=0,t[8]=(f+x)*w,t[9]=(m-g)*w,t[10]=(1-(h+d))*w,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t},L.fromRotationTranslationScaleOrigin=function(t,e,r,n,i){var s=e[0],a=e[1],o=e[2],l=e[3],u=s+s,c=a+a,h=o+o,p=s*u,f=s*c,d=s*h,m=a*c,y=a*h,g=o*h,x=l*u,b=l*c,v=l*h,_=n[0],w=n[1],M=n[2],A=i[0],S=i[1],I=i[2],T=(1-(m+g))*_,k=(f+v)*_,P=(d-b)*_,z=(f-v)*w,E=(1-(p+g))*w,B=(y+x)*w,D=(d+b)*M,C=(y-x)*M,R=(1-(p+m))*M;return t[0]=T,t[1]=k,t[2]=P,t[3]=0,t[4]=z,t[5]=E,t[6]=B,t[7]=0,t[8]=D,t[9]=C,t[10]=R,t[11]=0,t[12]=r[0]+A-(T*A+z*S+D*I),t[13]=r[1]+S-(k*A+E*S+C*I),t[14]=r[2]+I-(P*A+B*S+R*I),t[15]=1,t},L.fromQuat=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,u=r*a,c=n*a,h=n*o,p=i*a,f=i*o,d=i*l,m=s*a,y=s*o,g=s*l;return t[0]=1-h-d,t[1]=c+g,t[2]=p-y,t[3]=0,t[4]=c-g,t[5]=1-u-d,t[6]=f+m,t[7]=0,t[8]=p+y,t[9]=f-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},L.frustum=function(t,e,r,n,i,s,a){var o=1/(r-e),l=1/(i-n),u=1/(s-a);return t[0]=2*s*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*s*l,t[6]=0,t[7]=0,t[8]=(r+e)*o,t[9]=(i+n)*l,t[10]=(a+s)*u,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*s*2*u,t[15]=0,t},L.perspectiveNO=G,L.perspectiveZO=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=i*(s=1/(n-i)),t[14]=i*n*s):(t[10]=-1,t[14]=-n),t},L.perspectiveFromFieldOfView=function(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),o=Math.tan(e.rightDegrees*Math.PI/180),l=2/(a+o),u=2/(i+s);return t[0]=l,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=-(a-o)*l*.5,t[9]=(i-s)*u*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t},L.orthoNO=Y,L.orthoZO=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=s*u,t[15]=1,t},L.lookAt=function(t,e,r,n){var i,s,a,o,l,u,c,h,p,f,d=e[0],m=e[1],y=e[2],g=n[0],x=n[1],b=n[2],v=r[0],_=r[1],w=r[2];return Math.abs(d-v)0&&(c*=f=1/Math.sqrt(f),h*=f,p*=f);var d=l*p-u*h,m=u*c-o*p,y=o*h-l*c;return (f=d*d+m*m+y*y)>0&&(d*=f=1/Math.sqrt(f),m*=f,y*=f),t[0]=d,t[1]=m,t[2]=y,t[3]=0,t[4]=h*y-p*m,t[5]=p*d-c*y,t[6]=c*m-h*d,t[7]=0,t[8]=c,t[9]=h,t[10]=p,t[11]=0,t[12]=i,t[13]=s,t[14]=a,t[15]=1,t},L.str=function(t){return \"mat4(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\", \"+t[4]+\", \"+t[5]+\", \"+t[6]+\", \"+t[7]+\", \"+t[8]+\", \"+t[9]+\", \"+t[10]+\", \"+t[11]+\", \"+t[12]+\", \"+t[13]+\", \"+t[14]+\", \"+t[15]+\")\"},L.frob=function(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},L.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t},L.subtract=X,L.multiplyScalar=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t},L.multiplyScalarAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t},L.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},L.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=t[8],h=t[9],p=t[10],f=t[11],d=t[12],m=t[13],y=t[14],g=t[15],x=e[0],b=e[1],v=e[2],_=e[3],w=e[4],M=e[5],A=e[6],S=e[7],I=e[8],T=e[9],k=e[10],P=e[11],z=e[12],E=e[13],B=e[14],D=e[15];return Math.abs(r-x)<=F.EPSILON*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(n-b)<=F.EPSILON*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-v)<=F.EPSILON*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(s-_)<=F.EPSILON*Math.max(1,Math.abs(s),Math.abs(_))&&Math.abs(a-w)<=F.EPSILON*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(o-M)<=F.EPSILON*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(l-A)<=F.EPSILON*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-S)<=F.EPSILON*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(c-I)<=F.EPSILON*Math.max(1,Math.abs(c),Math.abs(I))&&Math.abs(h-T)<=F.EPSILON*Math.max(1,Math.abs(h),Math.abs(T))&&Math.abs(p-k)<=F.EPSILON*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(f-P)<=F.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))&&Math.abs(d-z)<=F.EPSILON*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(m-E)<=F.EPSILON*Math.max(1,Math.abs(m),Math.abs(E))&&Math.abs(y-B)<=F.EPSILON*Math.max(1,Math.abs(y),Math.abs(B))&&Math.abs(g-D)<=F.EPSILON*Math.max(1,Math.abs(g),Math.abs(D))},L.sub=L.mul=L.ortho=L.perspective=void 0;var F=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==O(t)&&\"function\"!=typeof t)return {default:t};var r=U(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function U(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (U=function(t){return t?r:e})(t)}function N(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function j(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=e[9],f=e[10],d=e[11],m=e[12],y=e[13],g=e[14],x=e[15],b=r[0],v=r[1],_=r[2],w=r[3];return t[0]=b*n+v*o+_*h+w*m,t[1]=b*i+v*l+_*p+w*y,t[2]=b*s+v*u+_*f+w*g,t[3]=b*a+v*c+_*d+w*x,t[4]=(b=r[4])*n+(v=r[5])*o+(_=r[6])*h+(w=r[7])*m,t[5]=b*i+v*l+_*p+w*y,t[6]=b*s+v*u+_*f+w*g,t[7]=b*a+v*c+_*d+w*x,t[8]=(b=r[8])*n+(v=r[9])*o+(_=r[10])*h+(w=r[11])*m,t[9]=b*i+v*l+_*p+w*y,t[10]=b*s+v*u+_*f+w*g,t[11]=b*a+v*c+_*d+w*x,t[12]=(b=r[12])*n+(v=r[13])*o+(_=r[14])*h+(w=r[15])*m,t[13]=b*i+v*l+_*p+w*y,t[14]=b*s+v*u+_*f+w*g,t[15]=b*a+v*c+_*d+w*x,t}function q(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=n+n,l=i+i,u=s+s,c=n*o,h=n*l,p=n*u,f=i*l,d=i*u,m=s*u,y=a*o,g=a*l,x=a*u;return t[0]=1-(f+m),t[1]=h+x,t[2]=p-g,t[3]=0,t[4]=h-x,t[5]=1-(c+m),t[6]=d+y,t[7]=0,t[8]=p+g,t[9]=d-y,t[10]=1-(c+f),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function $(t,e){var r=e[4],n=e[5],i=e[6],s=e[8],a=e[9],o=e[10];return t[0]=Math.hypot(e[0],e[1],e[2]),t[1]=Math.hypot(r,n,i),t[2]=Math.hypot(s,a,o),t}function G(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t}function Y(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t}function X(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}L.perspective=G,L.ortho=Y,L.mul=j,L.sub=X;var Z={},H={};function K(t){return K=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},K(t)}Object.defineProperty(H,\"__esModule\",{value:!0}),H.create=Q,H.clone=function(t){var e=new W.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},H.length=tt,H.fromValues=function(t,e,r){var n=new W.ARRAY_TYPE(3);return n[0]=t,n[1]=e,n[2]=r,n},H.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},H.set=function(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t},H.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t},H.subtract=et,H.multiply=rt,H.divide=nt,H.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},H.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},H.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t},H.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t},H.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},H.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},H.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t},H.distance=it,H.squaredDistance=st,H.squaredLength=at,H.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},H.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},H.normalize=function(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t},H.dot=ot,H.cross=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t},H.lerp=function(t,e,r,n){var i=e[0],s=e[1],a=e[2];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=a+n*(r[2]-a),t},H.hermite=function(t,e,r,n,i,s){var a=s*s,o=a*(2*s-3)+1,l=a*(s-2)+s,u=a*(s-1),c=a*(3-2*s);return t[0]=e[0]*o+r[0]*l+n[0]*u+i[0]*c,t[1]=e[1]*o+r[1]*l+n[1]*u+i[1]*c,t[2]=e[2]*o+r[2]*l+n[2]*u+i[2]*c,t},H.bezier=function(t,e,r,n,i,s){var a=1-s,o=a*a,l=s*s,u=o*a,c=3*s*o,h=3*l*a,p=l*s;return t[0]=e[0]*u+r[0]*c+n[0]*h+i[0]*p,t[1]=e[1]*u+r[1]*c+n[1]*h+i[1]*p,t[2]=e[2]*u+r[2]*c+n[2]*h+i[2]*p,t},H.random=function(t,e){e=e||1;var r=2*W.RANDOM()*Math.PI,n=2*W.RANDOM()-1,i=Math.sqrt(1-n*n)*e;return t[0]=Math.cos(r)*i,t[1]=Math.sin(r)*i,t[2]=n*e,t},H.transformMat4=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[3]*n+r[7]*i+r[11]*s+r[15];return t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/(a=a||1),t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/a,t},H.transformMat3=function(t,e,r){var n=e[0],i=e[1],s=e[2];return t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8],t},H.transformQuat=function(t,e,r){var n=r[0],i=r[1],s=r[2],a=e[0],o=e[1],l=e[2],u=i*l-s*o,c=s*a-n*l,h=n*o-i*a,p=i*h-s*c,f=s*u-n*h,d=n*c-i*u,m=2*r[3];return c*=m,h*=m,f*=2,d*=2,t[0]=a+(u*=m)+(p*=2),t[1]=o+c+f,t[2]=l+h+d,t},H.rotateX=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},H.rotateY=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},H.rotateZ=function(t,e,r,n){var i=[],s=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],t[0]=s[0]+r[0],t[1]=s[1]+r[1],t[2]=s[2]+r[2],t},H.angle=function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],a=e[1],o=e[2],l=Math.sqrt(r*r+n*n+i*i)*Math.sqrt(s*s+a*a+o*o),u=l&&ot(t,e)/l;return Math.acos(Math.min(Math.max(u,-1),1))},H.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t},H.str=function(t){return \"vec3(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\")\"},H.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},H.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],a=e[1],o=e[2];return Math.abs(r-s)<=W.EPSILON*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-a)<=W.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-o)<=W.EPSILON*Math.max(1,Math.abs(i),Math.abs(o))},H.forEach=H.sqrLen=H.len=H.sqrDist=H.dist=H.div=H.mul=H.sub=void 0;var W=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==K(t)&&\"function\"!=typeof t)return {default:t};var r=J(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function J(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (J=function(t){return t?r:e})(t)}function Q(){var t=new W.ARRAY_TYPE(3);return W.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function tt(t){return Math.hypot(t[0],t[1],t[2])}function et(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function rt(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function nt(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function it(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])}function st(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function at(t){var e=t[0],r=t[1],n=t[2];return e*e+r*r+n*n}function ot(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}H.sub=et,H.mul=rt,H.div=nt,H.dist=it,H.sqrDist=st,H.len=tt,H.sqrLen=at;var lt,ut=(lt=Q(),function(t,e,r,n,i,s){var a,o;for(e||(e=3),r||(r=0),o=n?Math.min(n*e+r,t.length):t.length,a=r;a0&&(a=1/Math.sqrt(a)),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=s*a,t},ct.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},ct.cross=function(t,e,r,n){var i=r[0]*n[1]-r[1]*n[0],s=r[0]*n[2]-r[2]*n[0],a=r[0]*n[3]-r[3]*n[0],o=r[1]*n[2]-r[2]*n[1],l=r[1]*n[3]-r[3]*n[1],u=r[2]*n[3]-r[3]*n[2],c=e[0],h=e[1],p=e[2],f=e[3];return t[0]=h*u-p*l+f*o,t[1]=-c*u+p*a-f*s,t[2]=c*l-h*a+f*i,t[3]=-c*o+h*s-p*i,t},ct.lerp=function(t,e,r,n){var i=e[0],s=e[1],a=e[2],o=e[3];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t[2]=a+n*(r[2]-a),t[3]=o+n*(r[3]-o),t},ct.random=function(t,e){var r,n,i,s,a,o;e=e||1;do{a=(r=2*pt.RANDOM()-1)*r+(n=2*pt.RANDOM()-1)*n;}while(a>=1);do{o=(i=2*pt.RANDOM()-1)*i+(s=2*pt.RANDOM()-1)*s;}while(o>=1);var l=Math.sqrt((1-a)/o);return t[0]=e*r,t[1]=e*n,t[2]=e*i*l,t[3]=e*s*l,t},ct.transformMat4=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*a,t[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*a,t[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*a,t[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*a,t},ct.transformQuat=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2],u=r[3],c=u*n+o*s-l*i,h=u*i+l*n-a*s,p=u*s+a*i-o*n,f=-a*n-o*i-l*s;return t[0]=c*u+f*-a+h*-l-p*-o,t[1]=h*u+f*-o+p*-a-c*-l,t[2]=p*u+f*-l+c*-o-h*-a,t[3]=e[3],t},ct.zero=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t},ct.str=function(t){return \"vec4(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\")\"},ct.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},ct.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=e[0],o=e[1],l=e[2],u=e[3];return Math.abs(r-a)<=pt.EPSILON*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(n-o)<=pt.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-l)<=pt.EPSILON*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(s-u)<=pt.EPSILON*Math.max(1,Math.abs(s),Math.abs(u))},ct.forEach=ct.sqrLen=ct.len=ct.sqrDist=ct.dist=ct.div=ct.mul=ct.sub=void 0;var pt=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==ht(t)&&\"function\"!=typeof t)return {default:t};var r=ft(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function ft(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (ft=function(t){return t?r:e})(t)}function dt(){var t=new pt.ARRAY_TYPE(4);return pt.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function mt(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function yt(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function gt(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function xt(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2],e[3]-t[3])}function bt(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2],s=e[3]-t[3];return r*r+n*n+i*i+s*s}function vt(t){return Math.hypot(t[0],t[1],t[2],t[3])}function _t(t){var e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}ct.sub=mt,ct.mul=yt,ct.div=gt,ct.dist=xt,ct.sqrDist=bt,ct.len=vt,ct.sqrLen=_t;var wt=function(){var t=dt();return function(e,r,n,i,s,a){var o,l;for(r||(r=4),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,o=n;oAt.EPSILON?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r},Z.getAngle=function(t,e){var r=Ot(t,e);return Math.acos(2*r*r-1)},Z.multiply=Bt,Z.rotateX=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+a*o,t[1]=i*l+s*o,t[2]=s*l-i*o,t[3]=a*l-n*o,t},Z.rotateY=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l-s*o,t[1]=i*l+a*o,t[2]=s*l+n*o,t[3]=a*l-i*o,t},Z.rotateZ=function(t,e,r){r*=.5;var n=e[0],i=e[1],s=e[2],a=e[3],o=Math.sin(r),l=Math.cos(r);return t[0]=n*l+i*o,t[1]=i*l-n*o,t[2]=s*l+a*o,t[3]=a*l-s*o,t},Z.calculateW=function(t,e){var r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t},Z.exp=Dt,Z.ln=Ct,Z.pow=function(t,e,r){return Ct(t,e),Lt(t,t,r),Dt(t,t),t},Z.slerp=Rt,Z.random=function(t){var e=At.RANDOM(),r=At.RANDOM(),n=At.RANDOM(),i=Math.sqrt(1-e),s=Math.sqrt(e);return t[0]=i*Math.sin(2*Math.PI*r),t[1]=i*Math.cos(2*Math.PI*r),t[2]=s*Math.sin(2*Math.PI*n),t[3]=s*Math.cos(2*Math.PI*n),t},Z.invert=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r*r+n*n+i*i+s*s,o=a?1/a:0;return t[0]=-r*o,t[1]=-n*o,t[2]=-i*o,t[3]=s*o,t},Z.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},Z.fromMat3=Vt,Z.fromEuler=function(t,e,r,n){var i=.5*Math.PI/180;e*=i,r*=i,n*=i;var s=Math.sin(e),a=Math.cos(e),o=Math.sin(r),l=Math.cos(r),u=Math.sin(n),c=Math.cos(n);return t[0]=s*l*c-a*o*u,t[1]=a*o*c+s*l*u,t[2]=a*l*u-s*o*c,t[3]=a*l*c+s*o*u,t},Z.str=function(t){return \"quat(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\")\"},Z.setAxes=Z.sqlerp=Z.rotationTo=Z.equals=Z.exactEquals=Z.normalize=Z.sqrLen=Z.squaredLength=Z.len=Z.length=Z.lerp=Z.dot=Z.scale=Z.mul=Z.add=Z.set=Z.copy=Z.fromValues=Z.clone=void 0;var At=Pt(d),St=Pt(E),It=Pt(H),Tt=Pt(ct);function kt(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (kt=function(t){return t?r:e})(t)}function Pt(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==Mt(t)&&\"function\"!=typeof t)return {default:t};var r=kt(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}function zt(){var t=new At.ARRAY_TYPE(4);return At.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Et(t,e,r){r*=.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function Bt(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*o+i*u-s*l,t[1]=i*c+a*l+s*o-n*u,t[2]=s*c+a*u+n*l-i*o,t[3]=a*c-n*o-i*l-s*u,t}function Dt(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=Math.sqrt(r*r+n*n+i*i),o=Math.exp(s),l=a>0?o*Math.sin(a)/a:0;return t[0]=r*l,t[1]=n*l,t[2]=i*l,t[3]=o*Math.cos(a),t}function Ct(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=Math.sqrt(r*r+n*n+i*i),o=a>0?Math.atan2(a,s)/a:0;return t[0]=r*o,t[1]=n*o,t[2]=i*o,t[3]=.5*Math.log(r*r+n*n+i*i+s*s),t}function Rt(t,e,r,n){var i,s,a,o,l,u=e[0],c=e[1],h=e[2],p=e[3],f=r[0],d=r[1],m=r[2],y=r[3];return (s=u*f+c*d+h*m+p*y)<0&&(s=-s,f=-f,d=-d,m=-m,y=-y),1-s>At.EPSILON?(i=Math.acos(s),a=Math.sin(i),o=Math.sin((1-n)*i)/a,l=Math.sin(n*i)/a):(o=1-n,l=n),t[0]=o*u+l*f,t[1]=o*c+l*d,t[2]=o*h+l*m,t[3]=o*p+l*y,t}function Vt(t,e){var r,n=e[0]+e[4]+e[8];if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,t[0]=(e[5]-e[7])*(r=.5/r),t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else {var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var s=(i+1)%3,a=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*s+s]-e[3*a+a]+1),t[i]=.5*r,t[3]=(e[3*s+a]-e[3*a+s])*(r=.5/r),t[s]=(e[3*s+i]+e[3*i+s])*r,t[a]=(e[3*a+i]+e[3*i+a])*r;}return t}Z.clone=Tt.clone,Z.fromValues=Tt.fromValues,Z.copy=Tt.copy,Z.set=Tt.set,Z.add=Tt.add,Z.mul=Bt;var Lt=Tt.scale;Z.scale=Lt;var Ot=Tt.dot;Z.dot=Ot,Z.lerp=Tt.lerp;var Ft=Tt.length;Z.length=Ft,Z.len=Ft;var Ut=Tt.squaredLength;Z.squaredLength=Ut,Z.sqrLen=Ut;var Nt=Tt.normalize;Z.normalize=Nt,Z.exactEquals=Tt.exactEquals,Z.equals=Tt.equals;var jt,qt,$t,Gt=(jt=It.create(),qt=It.fromValues(1,0,0),$t=It.fromValues(0,1,0),function(t,e,r){var n=It.dot(e,r);return n<-.999999?(It.cross(jt,qt,e),It.len(jt)<1e-6&&It.cross(jt,$t,e),It.normalize(jt,jt),Et(t,jt,Math.PI),t):n>.999999?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(It.cross(jt,e,r),t[0]=jt[0],t[1]=jt[1],t[2]=jt[2],t[3]=1+n,Nt(t,t))});Z.rotationTo=Gt;var Yt,Xt,Zt=(Yt=zt(),Xt=zt(),function(t,e,r,n,i,s){return Rt(Yt,e,i,s),Rt(Xt,r,n,s),Rt(t,Yt,Xt,2*s*(1-s)),t});Z.sqlerp=Zt;var Ht,Kt=(Ht=St.create(),function(t,e,r,n){return Ht[0]=r[0],Ht[3]=r[1],Ht[6]=r[2],Ht[1]=n[0],Ht[4]=n[1],Ht[7]=n[2],Ht[2]=-e[0],Ht[5]=-e[1],Ht[8]=-e[2],Nt(t,Vt(t,Ht))});Z.setAxes=Kt;var Wt={};function Jt(t){return Jt=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},Jt(t)}Object.defineProperty(Wt,\"__esModule\",{value:!0}),Wt.create=function(){var t=new Qt.ARRAY_TYPE(8);return Qt.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[4]=0,t[5]=0,t[6]=0,t[7]=0),t[3]=1,t},Wt.clone=function(t){var e=new Qt.ARRAY_TYPE(8);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},Wt.fromValues=function(t,e,r,n,i,s,a,o){var l=new Qt.ARRAY_TYPE(8);return l[0]=t,l[1]=e,l[2]=r,l[3]=n,l[4]=i,l[5]=s,l[6]=a,l[7]=o,l},Wt.fromRotationTranslationValues=function(t,e,r,n,i,s,a){var o=new Qt.ARRAY_TYPE(8);o[0]=t,o[1]=e,o[2]=r,o[3]=n;var l=.5*i,u=.5*s,c=.5*a;return o[4]=l*n+u*r-c*e,o[5]=u*n+c*t-l*r,o[6]=c*n+l*e-u*t,o[7]=-l*t-u*e-c*r,o},Wt.fromRotationTranslation=ie,Wt.fromTranslation=function(t,e){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=.5*e[0],t[5]=.5*e[1],t[6]=.5*e[2],t[7]=0,t},Wt.fromRotation=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Wt.fromMat4=function(t,e){var r=te.create();ee.getRotation(r,e);var n=new Qt.ARRAY_TYPE(3);return ee.getTranslation(n,e),ie(t,r,n),t},Wt.copy=se,Wt.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t[6]=0,t[7]=0,t},Wt.set=function(t,e,r,n,i,s,a,o,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=s,t[5]=a,t[6]=o,t[7]=l,t},Wt.getDual=function(t,e){return t[0]=e[4],t[1]=e[5],t[2]=e[6],t[3]=e[7],t},Wt.setDual=function(t,e){return t[4]=e[0],t[5]=e[1],t[6]=e[2],t[7]=e[3],t},Wt.getTranslation=function(t,e){var r=e[4],n=e[5],i=e[6],s=e[7],a=-e[0],o=-e[1],l=-e[2],u=e[3];return t[0]=2*(r*u+s*a+n*l-i*o),t[1]=2*(n*u+s*o+i*a-r*l),t[2]=2*(i*u+s*l+r*o-n*a),t},Wt.translate=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=.5*r[0],l=.5*r[1],u=.5*r[2],c=e[4],h=e[5],p=e[6],f=e[7];return t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=a*o+i*u-s*l+c,t[5]=a*l+s*o-n*u+h,t[6]=a*u+n*l-i*o+p,t[7]=-n*o-i*l-s*u+f,t},Wt.rotateX=function(t,e,r){var n=-e[0],i=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*a+c*n+l*s-u*i,p=l*a+c*i+u*n-o*s,f=u*a+c*s+o*i-l*n,d=c*a-o*n-l*i-u*s;return te.rotateX(t,e,r),t[4]=h*(a=t[3])+d*(n=t[0])+p*(s=t[2])-f*(i=t[1]),t[5]=p*a+d*i+f*n-h*s,t[6]=f*a+d*s+h*i-p*n,t[7]=d*a-h*n-p*i-f*s,t},Wt.rotateY=function(t,e,r){var n=-e[0],i=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*a+c*n+l*s-u*i,p=l*a+c*i+u*n-o*s,f=u*a+c*s+o*i-l*n,d=c*a-o*n-l*i-u*s;return te.rotateY(t,e,r),t[4]=h*(a=t[3])+d*(n=t[0])+p*(s=t[2])-f*(i=t[1]),t[5]=p*a+d*i+f*n-h*s,t[6]=f*a+d*s+h*i-p*n,t[7]=d*a-h*n-p*i-f*s,t},Wt.rotateZ=function(t,e,r){var n=-e[0],i=-e[1],s=-e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=o*a+c*n+l*s-u*i,p=l*a+c*i+u*n-o*s,f=u*a+c*s+o*i-l*n,d=c*a-o*n-l*i-u*s;return te.rotateZ(t,e,r),t[4]=h*(a=t[3])+d*(n=t[0])+p*(s=t[2])-f*(i=t[1]),t[5]=p*a+d*i+f*n-h*s,t[6]=f*a+d*s+h*i-p*n,t[7]=d*a-h*n-p*i-f*s,t},Wt.rotateByQuatAppend=function(t,e,r){var n=r[0],i=r[1],s=r[2],a=r[3],o=e[0],l=e[1],u=e[2],c=e[3];return t[0]=o*a+c*n+l*s-u*i,t[1]=l*a+c*i+u*n-o*s,t[2]=u*a+c*s+o*i-l*n,t[3]=c*a-o*n-l*i-u*s,t[4]=(o=e[4])*a+(c=e[7])*n+(l=e[5])*s-(u=e[6])*i,t[5]=l*a+c*i+u*n-o*s,t[6]=u*a+c*s+o*i-l*n,t[7]=c*a-o*n-l*i-u*s,t},Wt.rotateByQuatPrepend=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[0],l=r[1],u=r[2],c=r[3];return t[0]=n*c+a*o+i*u-s*l,t[1]=i*c+a*l+s*o-n*u,t[2]=s*c+a*u+n*l-i*o,t[3]=a*c-n*o-i*l-s*u,t[4]=n*(c=r[7])+a*(o=r[4])+i*(u=r[6])-s*(l=r[5]),t[5]=i*c+a*l+s*o-n*u,t[6]=s*c+a*u+n*l-i*o,t[7]=a*c-n*o-i*l-s*u,t},Wt.rotateAroundAxis=function(t,e,r,n){if(Math.abs(n)0){r=Math.sqrt(r);var n=e[0]/r,i=e[1]/r,s=e[2]/r,a=e[3]/r,o=e[4],l=e[5],u=e[6],c=e[7],h=n*o+i*l+s*u+a*c;t[0]=n,t[1]=i,t[2]=s,t[3]=a,t[4]=(o-n*h)/r,t[5]=(l-i*h)/r,t[6]=(u-s*h)/r,t[7]=(c-a*h)/r;}return t},Wt.str=function(t){return \"quat2(\"+t[0]+\", \"+t[1]+\", \"+t[2]+\", \"+t[3]+\", \"+t[4]+\", \"+t[5]+\", \"+t[6]+\", \"+t[7]+\")\"},Wt.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]},Wt.equals=function(t,e){var r=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],u=t[7],c=e[0],h=e[1],p=e[2],f=e[3],d=e[4],m=e[5],y=e[6],g=e[7];return Math.abs(r-c)<=Qt.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(n-h)<=Qt.EPSILON*Math.max(1,Math.abs(n),Math.abs(h))&&Math.abs(i-p)<=Qt.EPSILON*Math.max(1,Math.abs(i),Math.abs(p))&&Math.abs(s-f)<=Qt.EPSILON*Math.max(1,Math.abs(s),Math.abs(f))&&Math.abs(a-d)<=Qt.EPSILON*Math.max(1,Math.abs(a),Math.abs(d))&&Math.abs(o-m)<=Qt.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(l-y)<=Qt.EPSILON*Math.max(1,Math.abs(l),Math.abs(y))&&Math.abs(u-g)<=Qt.EPSILON*Math.max(1,Math.abs(u),Math.abs(g))},Wt.sqrLen=Wt.squaredLength=Wt.len=Wt.length=Wt.dot=Wt.mul=Wt.setReal=Wt.getReal=void 0;var Qt=ne(d),te=ne(Z),ee=ne(L);function re(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (re=function(t){return t?r:e})(t)}function ne(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==Jt(t)&&\"function\"!=typeof t)return {default:t};var r=re(e);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}function ie(t,e,r){var n=.5*r[0],i=.5*r[1],s=.5*r[2],a=e[0],o=e[1],l=e[2],u=e[3];return t[0]=a,t[1]=o,t[2]=l,t[3]=u,t[4]=n*u+i*l-s*o,t[5]=i*u+s*a-n*l,t[6]=s*u+n*o-i*a,t[7]=-n*a-i*o-s*l,t}function se(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t}function ae(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=r[4],l=r[5],u=r[6],c=r[7],h=e[4],p=e[5],f=e[6],d=e[7],m=r[0],y=r[1],g=r[2],x=r[3];return t[0]=n*x+a*m+i*g-s*y,t[1]=i*x+a*y+s*m-n*g,t[2]=s*x+a*g+n*y-i*m,t[3]=a*x-n*m-i*y-s*g,t[4]=n*c+a*o+i*u-s*l+h*x+d*m+p*g-f*y,t[5]=i*c+a*l+s*o-n*u+p*x+d*y+f*m-h*g,t[6]=s*c+a*u+n*l-i*o+f*x+d*g+h*y-p*m,t[7]=a*c-n*o-i*l-s*u+d*x-h*m-p*y-f*g,t}Wt.getReal=te.copy,Wt.setReal=te.copy,Wt.mul=ae;var oe=te.dot;Wt.dot=oe;var le=te.length;Wt.length=le,Wt.len=le;var ue=te.squaredLength;Wt.squaredLength=ue,Wt.sqrLen=ue;var ce={};function he(t){return he=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},he(t)}Object.defineProperty(ce,\"__esModule\",{value:!0}),ce.create=de,ce.clone=function(t){var e=new pe.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},ce.fromValues=function(t,e){var r=new pe.ARRAY_TYPE(2);return r[0]=t,r[1]=e,r},ce.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},ce.set=function(t,e,r){return t[0]=e,t[1]=r,t},ce.add=function(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t},ce.subtract=me,ce.multiply=ye,ce.divide=ge,ce.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},ce.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},ce.min=function(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t},ce.max=function(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t},ce.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},ce.scale=function(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t},ce.scaleAndAdd=function(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t},ce.distance=xe,ce.squaredDistance=be,ce.length=ve,ce.squaredLength=_e,ce.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},ce.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},ce.normalize=function(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t},ce.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},ce.cross=function(t,e,r){var n=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=n,t},ce.lerp=function(t,e,r,n){var i=e[0],s=e[1];return t[0]=i+n*(r[0]-i),t[1]=s+n*(r[1]-s),t},ce.random=function(t,e){e=e||1;var r=2*pe.RANDOM()*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t},ce.transformMat2=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t},ce.transformMat2d=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t},ce.transformMat3=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t},ce.transformMat4=function(t,e,r){var n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t},ce.rotate=function(t,e,r,n){var i=e[0]-r[0],s=e[1]-r[1],a=Math.sin(n),o=Math.cos(n);return t[0]=i*o-s*a+r[0],t[1]=i*a+s*o+r[1],t},ce.angle=function(t,e){var r=t[0],n=t[1],i=e[0],s=e[1],a=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+s*s);return Math.acos(Math.min(Math.max(a&&(r*i+n*s)/a,-1),1))},ce.zero=function(t){return t[0]=0,t[1]=0,t},ce.str=function(t){return \"vec2(\"+t[0]+\", \"+t[1]+\")\"},ce.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},ce.equals=function(t,e){var r=t[0],n=t[1],i=e[0],s=e[1];return Math.abs(r-i)<=pe.EPSILON*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-s)<=pe.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))},ce.forEach=ce.sqrLen=ce.sqrDist=ce.dist=ce.div=ce.mul=ce.sub=ce.len=void 0;var pe=function(t,e){if(t&&t.__esModule)return t;if(null===t||\"object\"!==he(t)&&\"function\"!=typeof t)return {default:t};var r=fe(void 0);if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in t)if(\"default\"!==s&&Object.prototype.hasOwnProperty.call(t,s)){var a=i?Object.getOwnPropertyDescriptor(t,s):null;a&&(a.get||a.set)?Object.defineProperty(n,s,a):n[s]=t[s];}return n.default=t,r&&r.set(t,n),n}(d);function fe(t){if(\"function\"!=typeof WeakMap)return null;var e=new WeakMap,r=new WeakMap;return (fe=function(t){return t?r:e})(t)}function de(){var t=new pe.ARRAY_TYPE(2);return pe.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0),t}function me(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function ye(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function ge(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function xe(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1])}function be(t,e){var r=e[0]-t[0],n=e[1]-t[1];return r*r+n*n}function ve(t){return Math.hypot(t[0],t[1])}function _e(t){var e=t[0],r=t[1];return e*e+r*r}ce.len=ve,ce.sub=me,ce.mul=ye,ce.div=ge,ce.dist=xe,ce.sqrDist=be,ce.sqrLen=_e;var we=function(){var t=de();return function(e,r,n,i,s,a){var o,l;for(r||(r=2),n||(n=0),l=i?Math.min(i*r+n,e.length):e.length,o=n;o1)return 1;for(var r=t,n=0;n<8;n++){var i=this.sampleCurveX(r)-t;if(Math.abs(i)i?a=r:o=r,r=.5*(o-a)+a;return r},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Oe=p(Ve),Fe=Ue;function Ue(t,e){this.x=t,this.y=e;}Ue.prototype={clone:function(){return new Ue(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),n=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=n,this},_rotateAround:function(t,e){var r=Math.cos(t),n=Math.sin(t),i=e.y+n*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-n*(this.y-e.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ue.convert=function(t){return t instanceof Ue?t:Array.isArray(t)?new Ue(t[0],t[1]):t};var Ne=p(Fe);const je=Math.PI/180,qe=180/Math.PI;function $e(t){return t*je}function Ge(t){return t*qe}const Ye=[[0,0],[1,0],[1,1],[0,1]];function Xe(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,r=e*t;return 4*(t<.5?r:3*(t-e)+r-.75)}function Ze(t,e,r,n){const i=new Oe(t,e,r,n);return function(t){return i.solve(t)}}const He=Ze(.25,.1,.25,1);function Ke(t,e,r){return Math.min(r,Math.max(e,t))}function We(t,e,r){return (r=Ke((r-t)/(e-t),0,1))*r*(3-2*r)}function Je(t,e,r){const n=r-e,i=((t-e)%n+n)%n+e;return i===e?r:i}function Qe(t,e,r){if(!t.length)return r(null,[]);let n=t.length;const i=new Array(t.length);let s=null;t.forEach(((t,a)=>{e(t,((t,e)=>{t&&(s=t),i[a]=e,0==--n&&r(s,i);}));}));}function tr(t){const e=[];for(const r in t)e.push(t[r]);return e}function er(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}let rr=1;function nr(){return rr++}function ir(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function sr(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ar(t){return !!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function or(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e));}));}function lr(t,e){return -1!==t.indexOf(e,t.length-e.length)}function ur(t,e,r){const n={};for(const r in t)n[r]=e.call(this,t[r],r,t);return n}function cr(t,e,r){const n={};for(const r in t)e.call(this,t[r],r,t)&&(n[r]=t[r]);return n}function hr(t){return Array.isArray(t)?t.map(hr):\"object\"==typeof t&&t?ur(t,hr):t}const pr={};function fr(t){pr[t]||(\"undefined\"!=typeof console&&console.warn(t),pr[t]=!0);}function dr(t,e,r){return (r.y-t.y)*(e.x-t.x)>(e.y-t.y)*(r.x-t.x)}function mr(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)(?:\\=(?:([^\\x00-\\x20\\(\\)<>@\\,;\\:\\\\\"\\/\\[\\]\\?\\=\\{\\}\\x7F]+)|(?:\\\"((?:[^\"\\\\]|\\\\.)*)\\\")))?/g,((t,r,n,i)=>{const s=n||i;return e[r]=!s||s.toLowerCase(),\"\"})),e[\"max-age\"]){const t=parseInt(e[\"max-age\"],10);isNaN(t)?delete e[\"max-age\"]:e[\"max-age\"]=t;}return e}let br,vr,_r,wr,Mr,Ar,Sr=null;function Ir(t){try{const e=self[t];return e.setItem(\"_mapbox_test_\",1),e.removeItem(\"_mapbox_test_\"),!0}catch(t){return !1}}function Tr(t,e){return [t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}function kr(t,e,r,n){for(;e>1;t[i]>1;t[i]<=n?e=i+1:r=i;}return e}function zr(t){return t>0?1/(1.001-t):1+t}function Er(t){return t>0?1-1/(1.001-t):-t}function Br(){return null==br&&(br=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext(\"2d\")&&\"function\"==typeof self.createImageBitmap),br}const Dr={now:()=>void 0!==wr?wr:performance.now(),setNow(t){wr=t;},restoreNow(){wr=void 0;},frame(t){const e=requestAnimationFrame(t);return {cancel:()=>cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:r,height:n}=t;Mr||(Mr=document.createElement(\"canvas\"));const i=Mr.getContext(\"2d\",{willReadFrequently:!0});if(!i)throw new Error(\"failed to create canvas 2d context\");return (r>Mr.width||n>Mr.height)&&(Mr.width=r,Mr.height=n),i.clearRect(-e,-e,r+2*e,n+2*e),i.drawImage(t,0,0,r,n),i.getImageData(-e,-e,r+2*e,n+2*e)},resolveURL:t=>(vr||(vr=document.createElement(\"a\")),vr.href=t,vr.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return !!window.matchMedia&&(null==_r&&(_r=window.matchMedia(\"(prefers-reduced-motion: reduce)\")),_r.matches)},hasCanvasFingerprintNoise(){if(void 0!==Ar)return Ar;if(!Br())return Ar=!1,!1;const t=new OffscreenCanvas(85,1),e=t.getContext(\"2d\",{willReadFrequently:!0});let r=0;for(let n=0;n0?`?${s}`:\"\"}`}const Vr=\"mapbox-tiles\";let Lr=500,Or=50;let Fr,Ur;function Nr(){try{return caches}catch(t){}}function jr(){const t=Nr();t&&!Fr&&(Fr=t.open(Vr));}let qr=1/0;const $r={supported:!1,testSupport:function(t){!Xr&&Yr&&(Zr?Kr(t):Gr=t);}};let Gr,Yr,Xr=!1,Zr=!1;const Hr=\"undefined\"!=typeof self?self:{};function Kr(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Yr),t.isContextLost())return;$r.supported=!0;}catch(t){}t.deleteTexture(e),Xr=!0;}Hr.document&&(Yr=Hr.document.createElement(\"img\"),Yr.onload=function(){Gr&&Kr(Gr),Gr=null,Zr=!0;},Yr.onerror=function(){Xr=!0,Gr=null;},Yr.src=\"data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=\");const Wr={Unknown:\"Unknown\",Style:\"Style\",Source:\"Source\",Tile:\"Tile\",Glyphs:\"Glyphs\",SpriteImage:\"SpriteImage\",SpriteJSON:\"SpriteJSON\",Image:\"Image\",Model:\"Model\"};\"function\"==typeof Object.freeze&&Object.freeze(Wr);class Jr extends Error{constructor(t,e,r){401===e&&i(r)&&(t+=\": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes\"),super(t),this.status=e,this.url=r;}toString(){return `${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Qr=gr()?()=>self.worker&&self.worker.referrer:()=>(\"blob:\"===location.protocol?parent:self).location.href;const tn=function(t,e){if(!(/^file:/.test(r=t.url)||/^file:/.test(Qr())&&!/^\\w+:/.test(r))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty(\"signal\"))return function(t,e){const r=new AbortController,n=new Request(t.url,{method:t.method||\"GET\",body:t.body,credentials:t.credentials,headers:t.headers,referrer:Qr(),referrerPolicy:t.referrerPolicy,signal:r.signal});let s=!1,a=!1;const o=(l=n.url).indexOf(\"sku=\")>0&&i(l);var l;\"json\"===t.type&&n.headers.set(\"Accept\",\"application/json\");const u=(r,i,s)=>{if(a)return;if(r&&\"SecurityError\"!==r.message&&fr(r.toString()),i&&s)return c(i);const l=Date.now();fetch(n).then((r=>{if(r.ok){const t=o?r.clone():null;return c(r,t,l)}return e(new Jr(r.statusText,r.status,t.url))})).catch((r=>{\"AbortError\"!==r.name&&e(new Error(`${r.message} ${t.url}`));}));},c=(r,i,o)=>{(\"arrayBuffer\"===t.type?r.arrayBuffer():\"json\"===t.type?r.json():r.text()).then((t=>{a||(i&&o&&function(t,e,r){if(jr(),!Fr)return;const n=xr(e.headers.get(\"Cache-Control\")||\"\");if(n[\"no-store\"])return;const i={status:e.status,statusText:e.statusText,headers:new Headers};e.headers.forEach(((t,e)=>i.headers.set(e,t))),n[\"max-age\"]&&i.headers.set(\"Expires\",new Date(r+1e3*n[\"max-age\"]).toUTCString());const s=i.headers.get(\"Expires\");if(!s)return;if(new Date(s).getTime()-r<42e4)return;let a=Rr(t.url,{persistentParams:[\"language\",\"worldview\"]});if(206===e.status){const e=t.headers.get(\"Range\");if(!e)return;i.status=200,a=Cr(a,{range:e});}!function(t,e){if(void 0===Ur)try{new Response(new ReadableStream),Ur=!0;}catch(t){Ur=!1;}Ur?e(t.body):t.blob().then(e);}(e,(t=>{const r=new Response(200!==(n=e.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:t,i);var n;jr(),Fr&&Fr.then((t=>t.put(a,r))).catch((t=>fr(t.message)));}));}(n,i,o),s=!0,e(null,t,r.headers.get(\"Cache-Control\"),r.headers.get(\"Expires\")));})).catch((t=>{a||e(new Error(t.message));}));};return o?function(t,e){if(jr(),!Fr)return e(null);Fr.then((r=>{let n=Rr(t.url,{persistentParams:[\"language\",\"worldview\"]});const i=t.headers.get(\"Range\");i&&(n=Cr(n,{range:i})),r.match(n).then((t=>{const i=function(t){if(!t)return !1;const e=new Date(t.headers.get(\"Expires\")||0),r=xr(t.headers.get(\"Cache-Control\")||\"\");return e>Date.now()&&!r[\"no-cache\"]}(t);r.delete(n),i&&r.put(n,t.clone()),e(null,t,i);})).catch(e);})).catch(e);}(n,u):u(null,null),{cancel:()=>{a=!0,s||r.abort();}}}(t,e);if(gr()&&self.worker&&self.worker.actor)return self.worker.actor.send(\"getResource\",t,e,void 0,!0)}var r;return function(t,e){const r=new XMLHttpRequest;r.open(t.method||\"GET\",t.url,!0),\"arrayBuffer\"===t.type&&(r.responseType=\"arraybuffer\");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);return \"json\"===t.type&&(r.responseType=\"text\",r.setRequestHeader(\"Accept\",\"application/json\")),r.withCredentials=\"include\"===t.credentials,r.onerror=()=>{e(new Error(r.statusText));},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if(\"json\"===t.type)try{n=JSON.parse(r.response);}catch(t){return e(t)}e(null,n,r.getResponseHeader(\"Cache-Control\"),r.getResponseHeader(\"Expires\"));}else e(new Jr(r.statusText,r.status,t.url));},r.send(t.body),{cancel:()=>r.abort()}}(t,e)},en=function(t,e){return tn(er(t,{type:\"arrayBuffer\"}),e)};function rn(t){const e=document.createElement(\"a\");return e.href=t,e.protocol===location.protocol&&e.host===location.host}const nn=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=\";let sn,an;sn=[],an=0;const on=function(t,e){if($r.supported&&(t.headers||(t.headers={}),t.headers.accept=\"image/webp,*/*\"),an>=n.MAX_PARALLEL_IMAGE_REQUESTS){const r={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0;}};return sn.push(r),r}an++;let r=!1;const i=()=>{if(!r)for(r=!0,an--;sn.length&&an{i(),t?e(t):r&&(self.createImageBitmap?function(t,e){const r=new Blob([new Uint8Array(t)],{type:\"image/png\"});createImageBitmap(r).then((t=>{e(null,t);})).catch((t=>{e(new Error(`Could not load image because of ${t.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`));}));}(r,((t,r)=>e(t,r,n,s))):function(t,e){const r=new Image;r.onload=()=>{e(null,r),URL.revokeObjectURL(r.src),r.onload=null,requestAnimationFrame((()=>{r.src=nn;}));},r.onerror=()=>e(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 n=new Blob([new Uint8Array(t)],{type:\"image/png\"});r.src=t.byteLength?URL.createObjectURL(n):nn;}(r,((t,r)=>e(t,r,n,s))));}));return {cancel:()=>{s.cancel(),i();}}},ln=\"01\",un=\"NO_ACCESS_TOKEN\",cn=/^(\\w+):\\/\\/([^/?]*)(\\/[^?]+)?\\??(.+)?/;function hn(t){const e=t.match(cn);if(!e)throw new Error(\"Unable to parse URL object\");return {protocol:e[1],authority:e[2],path:e[3]||\"/\",params:e[4]?e[4].split(\"&\"):[]}}function pn(t){const e=t.params.length?`?${t.params.join(\"&\")}`:\"\";return `${t.protocol}://${t.authority}${t.path}${e}`}const fn=\"mapbox.eventData\";function dn(t){if(!t)return null;const e=t.split(\".\");if(!e||3!==e.length)return null;try{return JSON.parse(decodeURIComponent(atob(e[1]).split(\"\").map((t=>\"%\"+(\"00\"+t.charCodeAt(0).toString(16)).slice(-2))).join(\"\")))}catch(t){return null}}class mn{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null;}getStorageKey(t){const e=dn(n.ACCESS_TOKEN);let r=\"\";return r=e&&e.u?btoa(encodeURIComponent(e.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number(\"0x\"+e))))):n.ACCESS_TOKEN||\"\",t?`${fn}.${t}:${r}`:`${fn}:${r}`}fetchEventData(){const t=Ir(\"localStorage\"),e=this.getStorageKey(),r=this.getStorageKey(\"uuid\");if(t)try{const t=localStorage.getItem(e);t&&(this.eventData=JSON.parse(t));const n=localStorage.getItem(r);n&&(this.anonId=n);}catch(t){fr(\"Unable to read from LocalStorage\");}}saveEventData(){const t=Ir(\"localStorage\"),e=this.getStorageKey(),r=this.getStorageKey(\"uuid\"),n=this.anonId;if(t&&n)try{localStorage.setItem(r,n),Object.keys(this.eventData).length>=1&&localStorage.setItem(e,JSON.stringify(this.eventData));}catch(t){fr(\"Unable to write to LocalStorage\");}}processRequests(t){}postEvent(t,e,r,i){if(!n.EVENTS_URL)return;const s=hn(n.EVENTS_URL);s.params.push(`access_token=${i||n.ACCESS_TOKEN||\"\"}`);const a={event:this.type,created:new Date(t).toISOString()},o=e?er(a,e):a,l={url:pn(s),headers:{\"Content-Type\":\"text/plain\"},body:JSON.stringify([o])};this.pendingRequest=function(t,e){return tn(er(t,{method:\"POST\"}),e)}(l,(t=>{this.pendingRequest=null,r(t),this.saveEventData(),this.processRequests(i);}));}queueRequest(t,e){this.queue.push(t),this.processRequests(e);}}const yn=new class extends mn{constructor(t){super(\"appUserTurnstile\"),this._customAccessToken=t;}postTurnstileEvent(t,e){n.EVENTS_URL&&n.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>s(t)||i(t)))&&this.queueRequest(Date.now(),e);}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const r=dn(n.ACCESS_TOKEN),i=r?r.u:n.ACCESS_TOKEN;let s=i!==this.eventData.tokenU;ar(this.anonId)||(this.anonId=ir(),s=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(a),r=(a-this.eventData.lastSuccess)/864e5;s=s||r>=1||r<-1||t.getDate()!==e.getDate();}else s=!0;s?this.postEvent(a,{sdkIdentifier:\"mapbox-gl-js\",sdkVersion:e,skuId:ln,\"enabled.telemetry\":!1,userId:this.anonId},(t=>{t||(this.eventData.lastSuccess=a,this.eventData.tokenU=i);}),t):this.processRequests();}},gn=yn.postTurnstileEvent.bind(yn),xn=new class extends mn{constructor(){super(\"map.load\"),this.success={},this.skuToken=\"\";}postMapLoadEvent(t,e,r,i){this.skuToken=e,this.errorCb=i,n.EVENTS_URL&&(r||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(un)));}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId||this.fetchEventData(),ar(this.anonId)||(this.anonId=ir()),this.postEvent(n,{sdkIdentifier:\"mapbox-gl-js\",sdkVersion:e,skuId:ln,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):r&&(this.success[r]=!0);}),t));}remove(){this.errorCb=null;}},bn=xn.postMapLoadEvent.bind(xn),vn=new class extends mn{constructor(){super(\"style.load\"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap;}getMapInstanceId(t){let e=this.mapInstanceIdMap.get(t);return e||(e=ir(),this.mapInstanceIdMap.set(t,e)),e}getEventId(t){const e=this.eventIdPerMapInstanceMap.get(t)||0;return this.eventIdPerMapInstanceMap.set(t,e+1),e}postStyleLoadEvent(t,e){const{map:r,style:i,importedStyles:s}=e;if(!n.EVENTS_URL||!t&&!n.ACCESS_TOKEN)return;const a=this.getMapInstanceId(r),o={mapInstanceId:a,eventId:this.getEventId(a),style:i};s.length&&(o.importedStyles=s),this.queueRequest({timestamp:Date.now(),payload:o},t);}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:e,payload:r}=this.queue.shift();this.postEvent(e,r,(()=>{}),t);}},_n=vn.postStyleLoadEvent.bind(vn),wn=new class extends mn{constructor(){super(\"gljs.performance\");}postPerformanceEvent(t,e){n.EVENTS_URL&&(t||n.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t);}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:r,performanceData:n}=this.queue.shift(),i=function(t){const r=performance.getEntriesByType(\"resource\"),n=performance.getEntriesByType(\"mark\"),i=function(t){const e={};if(t)for(const r in t)if(\"other\"!==r)for(const n of t[r]){const t=`${r}ResolveRangeMin`,i=`${r}ResolveRangeMax`,s=`${r}RequestCount`,a=`${r}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,n.startTime),e[i]=Math.max(e[i]||-1/0,n.responseEnd);const o=t=>{void 0===e[t]&&(e[t]=0),++e[t];};void 0!==n.transferSize&&0===n.transferSize&&o(a),o(s);}return e}(function(t,e){const r={};if(t)for(const n of t){const t=e(n);void 0===r[t]&&(r[t]=[]),r[t].push(n);}return r}(r,h)),s=window.devicePixelRatio,a=navigator.connection||navigator.mozConnection||navigator.webkitConnection,o=a?a.effectiveType:void 0,c={counters:[],metadata:[],attributes:[]},p=(t,e,r)=>{null!=r&&t.push({name:e,value:r.toString()});};for(const t in i)p(c.counters,t,i[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(p(c.counters,\"interactionRangeMin\",t.interactionRange[0]),p(c.counters,\"interactionRangeMax\",t.interactionRange[1])),n)for(const t of Object.keys(u)){const e=u[t],r=n.find((t=>t.name===e));r&&p(c.counters,e,r.startTime);}return p(c.counters,\"visibilityHidden\",t.visibilityHidden),p(c.attributes,\"style\",function(t){if(t)for(const e of t){const t=e.name.split(\"?\")[0];if(l(t)){const e=t.split(\"/\").slice(-2);if(2===e.length)return `mapbox://styles/${e[0]}/${e[1]}`}}}(r)),p(c.attributes,\"terrainEnabled\",t.terrainEnabled?\"true\":\"false\"),p(c.attributes,\"fogEnabled\",t.fogEnabled?\"true\":\"false\"),p(c.attributes,\"projection\",t.projection),p(c.attributes,\"zoom\",t.zoom),p(c.metadata,\"devicePixelRatio\",s),p(c.metadata,\"connectionEffectiveType\",o),p(c.metadata,\"navigatorUserAgent\",navigator.userAgent),p(c.metadata,\"screenWidth\",window.screen.width),p(c.metadata,\"screenHeight\",window.screen.height),p(c.metadata,\"windowWidth\",window.innerWidth),p(c.metadata,\"windowHeight\",window.innerHeight),p(c.metadata,\"mapWidth\",t.width/s),p(c.metadata,\"mapHeight\",t.height/s),p(c.metadata,\"webglRenderer\",t.renderer),p(c.metadata,\"webglVendor\",t.vendor),p(c.metadata,\"sdkVersion\",e),p(c.metadata,\"sdkIdentifier\",\"mapbox-gl-js\"),c}(n);for(const t of i.metadata);for(const t of i.counters);for(const t of i.attributes);this.postEvent(r,i,(()=>{}),t);}},Mn=wn.postPerformanceEvent.bind(wn),An=new class extends mn{constructor(){super(\"map.auth\"),this.success={},this.skuToken=\"\";}getSession(t,e,r,i){if(!n.API_URL||!n.SESSION_PATH)return;const s=hn(n.API_URL+n.SESSION_PATH);s.params.push(`sku=${e||\"\"}`),s.params.push(`access_token=${i||n.ACCESS_TOKEN||\"\"}`);const a={url:pn(s),headers:{\"Content-Type\":\"text/plain\"}};this.pendingRequest=function(t,e){return tn(er(t,{method:\"GET\"}),e)}(a,(t=>{this.pendingRequest=null,r(t),this.saveEventData(),this.processRequests(i);}));}getSessionAPI(t,e,r,i){this.skuToken=e,this.errorCb=i,n.SESSION_PATH&&n.API_URL&&(r||n.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(un)));}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:r}=this.queue.shift();e&&this.success[e]||this.getSession(r,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0);}),t);}remove(){this.errorCb=null;}},Sn=An.getSessionAPI.bind(An),In=new Set;var Tn={exports:{}},kn={exports:function(t,e){var r,n,i,s,a,o,l,u;for(n=t.length-(r=3&t.length),i=e,a=3432918353,o=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(s>>>16)&65535)<<16);switch(l=0,r){case 3:l^=(255&t.charCodeAt(u+2))<<16;case 2:l^=(255&t.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295;}return i^=t.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0}},Pn={exports:({},function(t,e){for(var r,n=t.length,i=e^n,s=0;n>=4;)r=1540483477*(65535&(r=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(r>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),n-=4,++s;switch(n){case 3:i^=(255&t.charCodeAt(s+2))<<16;case 2:i^=(255&t.charCodeAt(s+1))<<8;case 1:i=1540483477*(65535&(i^=255&t.charCodeAt(s)))+((1540483477*(i>>>16)&65535)<<16);}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0})},zn=kn.exports,En=Pn.exports;Tn.exports=zn,Tn.exports.murmur3=zn,Tn.exports.murmur2=En;var Bn=p(Tn.exports);class Dn{constructor(t,...e){er(this,e[0]||{}),this.type=t;}}class Cn extends Dn{constructor(t,e={}){super(\"error\",er({error:t},e));}}function Rn(t,e,r){r[t]&&-1!==r[t].indexOf(e)||(r[t]=r[t]||[],r[t].push(e));}function Vn(t,e,r){if(r&&r[t]){const n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1);}}class Ln{on(t,e){return this._listeners=this._listeners||{},Rn(t,e,this._listeners),this}off(t,e){return Vn(t,e,this._listeners),Vn(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Rn(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){const r=\"string\"==typeof t?new Dn(t,e):t,n=r.type;if(this.listens(n)){r.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const e of t)e.call(this,r);const e=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of e)Vn(n,t,this._oneTimeListeners),t.call(this,r);const i=this._eventedParent;i&&(er(r,\"function\"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(r));}else r instanceof Cn&&console.error(r.error);return this}listens(t){return !!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}t.F=void 0;var On={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Fn(t){return (t=Math.round(t))<0?0:t>255?255:t}function Un(t){return Fn(\"%\"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function Nn(t){return (e=\"%\"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e;}function jn(t,e,r){return r<0?r+=1:r>1&&(r-=1),6*r<1?t+(e-t)*r*6:2*r<1?e:3*r<2?t+(e-t)*(2/3-r)*6:t}try{t.F={}.parseCSSColor=function(t){var e,r=t.replace(/ /g,\"\").toLowerCase();if(r in On)return On[r].slice();if(\"#\"===r[0])return 4===r.length?(e=parseInt(r.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===r.length&&(e=parseInt(r.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=r.indexOf(\"(\"),i=r.indexOf(\")\");if(-1!==n&&i+1===r.length){var s=r.substr(0,n),a=r.substr(n+1,i-(n+1)).split(\",\"),o=1;switch(s){case\"rgba\":if(4!==a.length)return null;o=Nn(a.pop());case\"rgb\":return 3!==a.length?null:[Un(a[0]),Un(a[1]),Un(a[2]),o];case\"hsla\":if(4!==a.length)return null;o=Nn(a.pop());case\"hsl\":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=Nn(a[1]),c=Nn(a[2]),h=c<=.5?c*(u+1):c+u-c*u,p=2*c-h;return [Fn(255*jn(p,h,l+1/3)),Fn(255*jn(p,h,l)),Fn(255*jn(p,h,l-1/3)),o];default:return null}}return null};}catch(t){}class qn{constructor(t,e,r,n=1){this.r=t,this.g=e,this.b=r,this.a=n;}static parse(e){if(!e)return;if(e instanceof qn)return e;if(\"string\"!=typeof e)return;const r=t.F(e);return r?new qn(r[0]/255*r[3],r[1]/255*r[3],r[2]/255*r[3],r[3]):void 0}toString(){const[t,e,r,n]=0===this.a?[0,0,0,0]:[255*this.r/this.a,255*this.g/this.a,255*this.b/this.a,this.a];return `rgba(${Math.round(t)},${Math.round(e)},${Math.round(r)},${n})`}toRenderColor(t){const{r:e,g:r,b:n,a:i}=this;return new $n(t,e,r,n,i)}}class $n{constructor(t,e,r,n,i){if(t){const s=t.image.height,a=s*s;e=0===i?0:e/i*(s-1),r=0===i?0:r/i*(s-1),n=0===i?0:n/i*(s-1);const o=Math.floor(e),l=Math.floor(r),u=Math.floor(n),c=Math.ceil(e),h=Math.ceil(r),p=Math.ceil(n),f=e-o,d=r-l,m=n-u,y=t.image.data,g=4*(o+l*a+u*s),x=4*(o+l*a+p*s),b=4*(o+h*a+u*s),v=4*(o+h*a+p*s),_=4*(c+l*a+u*s),w=4*(c+l*a+p*s),M=4*(c+h*a+u*s),A=4*(c+h*a+p*s);if(g<0||A>=y.length)throw new Error(\"out of range\");this.r=Gn(Gn(Gn(y[g],y[x],m),Gn(y[b],y[v],m),d),Gn(Gn(y[_],y[w],m),Gn(y[M],y[A],m),d),f)/255*i,this.g=Gn(Gn(Gn(y[g+1],y[x+1],m),Gn(y[b+1],y[v+1],m),d),Gn(Gn(y[_+1],y[w+1],m),Gn(y[M+1],y[A+1],m),d),f)/255*i,this.b=Gn(Gn(Gn(y[g+2],y[x+2],m),Gn(y[b+2],y[v+2],m),d),Gn(Gn(y[_+2],y[w+2],m),Gn(y[M+2],y[A+2],m),d),f)/255*i,this.a=i;}else this.r=e,this.g=r,this.b=n,this.a=i;}toArray(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*r/n,n]}toArray01(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,r/n,n]}toArray01Scaled(t){const{r:e,g:r,b:n,a:i}=this;return 0===i?[0,0,0]:[e/i*t,r/i*t,n/i*t]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:r,a:n}=this;return [t,e,r,n]}toArray01Linear(){const{r:t,g:e,b:r,a:n}=this;return 0===n?[0,0,0,0]:[Math.pow(t/n,2.2),Math.pow(e/n,2.2),Math.pow(r/n,2.2),n]}}function Gn(t,e,r){return t*(1-r)+e*r}function Yn(t,e,r){return t.map(((t,n)=>Gn(t,e[n],r)))}qn.black=new qn(0,0,0,1),qn.white=new qn(1,1,1,1),qn.transparent=new qn(0,0,0,0),qn.red=new qn(1,0,0,1),qn.blue=new qn(0,0,1,1);var Xn=Object.freeze({__proto__:null,array:Yn,color:function(t,e,r){return new qn(Gn(t.r,e.r,r),Gn(t.g,e.g,r),Gn(t.b,e.b,r),Gn(t.a,e.a,r))},number:Gn});function Zn(t,...e){for(const r of e)for(const e in r)t[e]=r[e];return t}class Hn extends Error{constructor(t,e){super(e),this.message=e,this.key=t;}}class Kn{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,r]of e)this.bindings[t]=r;}concat(t){return new Kn(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return !!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const Wn={kind:\"null\"},Jn={kind:\"number\"},Qn={kind:\"string\"},ti={kind:\"boolean\"},ei={kind:\"color\"},ri={kind:\"object\"},ni={kind:\"value\"},ii={kind:\"collator\"},si={kind:\"formatted\"},ai={kind:\"resolvedImage\"};function oi(t,e){return {kind:\"array\",itemType:t,N:e}}function li(t){if(\"array\"===t.kind){const e=li(t.itemType);return \"number\"==typeof t.N?`array<${e}, ${t.N}>`:\"value\"===t.itemType.kind?\"array\":`array<${e}>`}return t.kind}const ui=[Wn,Jn,Qn,ti,ei,si,ri,oi(ni),ai];function ci(t,e){if(\"error\"===e.kind)return null;if(\"array\"===t.kind){if(\"array\"===e.kind&&(0===e.N&&\"value\"===e.itemType.kind||!ci(t.itemType,e.itemType))&&(\"number\"!=typeof t.N||t.N===e.N))return null}else {if(t.kind===e.kind)return null;if(\"value\"===t.kind)for(const t of ui)if(!ci(t,e))return null}return `Expected ${li(t)} but found ${li(e)} instead.`}function hi(t,e){return e.some((e=>e.kind===t.kind))}function pi(t,e){return e.some((e=>\"null\"===e?null===t:\"array\"===e?Array.isArray(t):\"object\"===e?t&&!Array.isArray(t)&&\"object\"==typeof t:e===typeof t))}class fi{constructor(t,e,r){this.sensitivity=t?e?\"variant\":\"case\":e?\"accent\":\"base\",this.locale=r,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:\"search\"});}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class di{constructor(t,e,r,n,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=r,this.fontStack=n,this.textColor=i;}}class mi{constructor(t){this.sections=t;}static fromString(t){return new mi([new di(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.namePrimary.length))}static factory(t){return t instanceof mi?t:mi.fromString(t)}toString(){return 0===this.sections.length?\"\":this.sections.map((t=>t.text)).join(\"\")}serialize(){const t=[\"format\"];for(const e of this.sections){if(e.image){t.push([\"image\",e.image.namePrimary]);continue}t.push(e.text);const r={};e.fontStack&&(r[\"text-font\"]=[\"literal\",e.fontStack.split(\",\")]),e.scale&&(r[\"font-scale\"]=e.scale),e.textColor&&(r[\"text-color\"]=[\"rgba\"].concat(e.textColor.toRenderColor(null).toArray())),t.push(r);}return t}}class yi{constructor(t){this.namePrimary=t.namePrimary,t.nameSecondary&&(this.nameSecondary=t.nameSecondary),this.available=t.available;}toString(){return this.nameSecondary?`[${this.namePrimary},${this.nameSecondary}]`:this.namePrimary}static fromString(t,e){return t?new yi({namePrimary:t,nameSecondary:e,available:!1}):null}serialize(){return this.nameSecondary?[\"image\",this.namePrimary,this.nameSecondary]:[\"image\",this.namePrimary]}}function gi(t,e,r,n){return \"number\"==typeof t&&t>=0&&t<=255&&\"number\"==typeof e&&e>=0&&e<=255&&\"number\"==typeof r&&r>=0&&r<=255?void 0===n||\"number\"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,r,n].join(\", \")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(\"number\"==typeof n?[t,e,r,n]:[t,e,r]).join(\", \")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function xi(t){if(null===t)return !0;if(\"string\"==typeof t)return !0;if(\"boolean\"==typeof t)return !0;if(\"number\"==typeof t)return !0;if(t instanceof qn)return !0;if(t instanceof fi)return !0;if(t instanceof mi)return !0;if(t instanceof yi)return !0;if(Array.isArray(t)){for(const e of t)if(!xi(e))return !1;return !0}if(\"object\"==typeof t){for(const e in t)if(!xi(t[e]))return !1;return !0}return !1}function bi(t){if(null===t)return Wn;if(\"string\"==typeof t)return Qn;if(\"boolean\"==typeof t)return ti;if(\"number\"==typeof t)return Jn;if(t instanceof qn)return ei;if(t instanceof fi)return ii;if(t instanceof mi)return si;if(t instanceof yi)return ai;if(Array.isArray(t)){const e=t.length;let r;for(const e of t){const t=bi(e);if(r){if(r===t)continue;r=ni;break}r=t;}return oi(r||ni,e)}return ri}function vi(t){const e=typeof t;return null===t?\"\":\"string\"===e||\"number\"===e||\"boolean\"===e?String(t):t instanceof qn||t instanceof mi||t instanceof yi?t.toString():JSON.stringify(t)}class _i{constructor(t,e){this.type=t,this.value=e;}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!xi(t[1]))return e.error(\"invalid value\");const r=t[1];let n=bi(r);const i=e.expectedType;return \"array\"!==n.kind||0!==n.N||!i||\"array\"!==i.kind||\"number\"==typeof i.N&&0!==i.N||(n=i),new _i(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return !0}serialize(){return \"array\"===this.type.kind||\"object\"===this.type.kind?[\"literal\",this.value]:this.value instanceof qn?[\"rgba\"].concat(this.value.toRenderColor(null).toArray()):this.value instanceof mi?this.value.serialize():this.value}}class wi{constructor(t){this.name=\"ExpressionEvaluationError\",this.message=t;}toJSON(){return this.message}}const Mi={string:Qn,number:Jn,boolean:ti,object:ri};class Ai{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error(\"Expected at least one argument.\");let r,n=1;const i=t[0];if(\"array\"===i){let i,s;if(t.length>2){const r=t[1];if(\"string\"!=typeof r||!(r in Mi)||\"object\"===r)return e.error('The item type argument of \"array\" must be one of string, number, boolean',1);i=Mi[r],n++;}else i=ni;if(t.length>3){if(null!==t[2]&&(\"number\"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to \"array\" must be a positive integer literal',2);s=t[2],n++;}r=oi(i,s);}else r=Mi[i];const s=[];for(;nt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if(\"array\"===t.kind){const r=t.itemType;if(\"string\"===r.kind||\"number\"===r.kind||\"boolean\"===r.kind){e.push(r.kind);const n=t.N;(\"number\"==typeof n||this.args.length>1)&&e.push(n);}}return e.concat(this.args.map((t=>t.serialize())))}}class Si{constructor(t){this.type=si,this.sections=t;}static parse(t,e){if(t.length<2)return e.error(\"Expected at least one argument.\");const r=t[1];if(!Array.isArray(r)&&\"object\"==typeof r)return e.error(\"First argument must be an image or text section.\");const n=[];let i=!1;for(let r=1;r<=t.length-1;++r){const s=t[r];if(i&&\"object\"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s[\"font-scale\"]&&(t=e.parse(s[\"font-scale\"],1,Jn),!t))return null;let r=null;if(s[\"text-font\"]&&(r=e.parse(s[\"text-font\"],1,oi(Qn)),!r))return null;let a=null;if(s[\"text-color\"]&&(a=e.parse(s[\"text-color\"],1,ei),!a))return null;const o=n[n.length-1];o.scale=t,o.font=r,o.textColor=a;}else {const s=e.parse(t[r],1,ni);if(!s)return null;const a=s.type.kind;if(\"string\"!==a&&\"value\"!==a&&\"null\"!==a&&\"resolvedImage\"!==a)return e.error(\"Formatted text type must be 'string', 'value', 'image' or 'null'.\");i=!0,n.push({content:s,scale:null,font:null,textColor:null});}}return new Si(n)}evaluate(t){return new mi(this.sections.map((e=>{const r=e.content.evaluate(t);return bi(r)===ai?new di(\"\",r,null,null,null):new di(vi(r),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(\",\"):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor);}outputDefined(){return !1}serialize(){const t=[\"format\"];for(const e of this.sections){t.push(e.content.serialize());const r={};e.scale&&(r[\"font-scale\"]=e.scale.serialize()),e.font&&(r[\"text-font\"]=e.font.serialize()),e.textColor&&(r[\"text-color\"]=e.textColor.serialize()),t.push(r);}return t}}class Ii{constructor(t,e){this.type=ai,this.inputPrimary=t,this.inputSecondary=e;}static parse(t,e){if(t.length<2)return e.error(\"Expected two or more arguments.\");const r=e.parse(t[1],1,Qn);if(!r)return e.error(\"No image name provided.\");if(2===t.length)return new Ii(r);const n=e.parse(t[2],1,Qn);return n?new Ii(r,n):e.error(\"Secondary image variant is not a string.\")}evaluate(t){const e=yi.fromString(this.inputPrimary.evaluate(t),this.inputSecondary?this.inputSecondary.evaluate(t):void 0);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(e.namePrimary)>-1,e.nameSecondary&&e.available&&t.availableImages&&(e.available=t.availableImages.indexOf(e.nameSecondary)>-1)),e}eachChild(t){t(this.inputPrimary),this.inputSecondary&&t(this.inputSecondary);}outputDefined(){return !1}serialize(){return this.inputSecondary?[\"image\",this.inputPrimary.serialize(),this.inputSecondary.serialize()]:[\"image\",this.inputPrimary.serialize()]}}function Ti(t){return t instanceof Number?\"number\":t instanceof String?\"string\":t instanceof Boolean?\"boolean\":Array.isArray(t)?\"array\":null===t?\"null\":typeof t}const ki={\"to-boolean\":ti,\"to-color\":ei,\"to-number\":Jn,\"to-string\":Qn};class Pi{constructor(t,e){this.type=t,this.args=e;}static parse(t,e){if(t.length<2)return e.error(\"Expected at least one argument.\");const r=t[0],n=[];let i=Wn;if(\"to-array\"===r){if(!Array.isArray(t[1]))return null;const r=t[1].length;if(e.expectedType){if(\"array\"!==e.expectedType.kind)return e.error(`Expected ${e.expectedType.kind} but found array.`);i=oi(e.expectedType.itemType,r);}else {if(!(r>0&&xi(t[1][0])))return null;i=oi(bi(t[1][0]),r);}for(let s=0;s4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:gi(e[0],e[1],e[2],e[3]),!r))return new qn(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new wi(r||`Could not parse color from value '${\"string\"==typeof e?e:String(JSON.stringify(e))}'`)}if(\"number\"===this.type.kind){let e=null;for(const r of this.args){if(e=r.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new wi(`Could not convert ${JSON.stringify(e)} to number.`)}return \"formatted\"===this.type.kind?mi.fromString(vi(this.args[0].evaluate(t))):\"resolvedImage\"===this.type.kind?yi.fromString(vi(this.args[0].evaluate(t))):\"array\"===this.type.kind?this.args.map((e=>e.evaluate(t))):vi(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if(\"formatted\"===this.type.kind)return new Si([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(\"resolvedImage\"===this.type.kind)return new Ii(this.args[0]).serialize();const t=\"array\"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize());})),t}}const zi=[\"Unknown\",\"Point\",\"LineString\",\"Polygon\"];class Ei{constructor(t,e){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null,this.scope=t,this.options=e;}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?\"number\"==typeof this.feature.type?zi[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&\"geometry\"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}measureLight(t){return this.globals.brightness||0}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:r,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(r*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=qn.parse(t)),e}getConfig(t){return this.options?this.options.get(t):null}}class Bi{constructor(t,e,r,n,i){this.name=t,this.type=e,this._evaluate=r,this.args=n,this._overloadIndex=i;}evaluate(t){if(!this._evaluate){const t=Bi.definitions[this.name];this._evaluate=Array.isArray(t)?t[2]:t.overloads[this._overloadIndex][1];}return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t);}outputDefined(){return !1}serialize(){return [this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const r=t[0],n=Bi.definitions[r];if(!n)return e.error(`Unknown expression \"${r}\". If you wanted a literal array, use [\"literal\", [...]].`,0);const i=Array.isArray(n)?n[0]:n.type,s=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=[];let o=null,l=-1;for(const[n,u]of s){if(Array.isArray(n)&&n.length!==t.length-1)continue;a.push(n),l++,o=new Js(e.registry,e.path,null,e.scope,void 0,e._scope,e.options);const s=[];let c=!1;for(let e=1;et))).map(Di).join(\" | \"),n=[];for(let r=1;rr;){if(n-r>600){const s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Ri(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}const s=t[e];let a=r,o=n;for(Vi(t,r,e),i(t[n],s)>0&&Vi(t,r,n);a0;)o--;}0===i(t[r],s)?Vi(t,r,o):(o++,Vi(t,o,n)),o<=e&&(r=o+1),e<=o&&(n=o-1);}}function Vi(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function Li(t,e){return te?1:0}function Oi(t){let e=0;for(let r,n,i=0,s=t.length,a=s-1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Ni(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],s=t[0]-r[0],a=t[1]-r[1];return n*a-s*i==0&&n*s<=0&&i*a<=0}function ji(t,e,r=!1){let n=!1;for(let o=0,l=e.length;o(i=t)[1]!=(a=c)[1]>i[1]&&i[0]<(a[0]-s[0])*(i[1]-s[1])/(a[1]-s[1])+s[0]&&(n=!n);}}var i,s,a;return n}function qi(t,e,r,n){const i=n[0]-r[0],s=n[1]-r[1],a=(t[0]-r[0])*s-i*(t[1]-r[1]),o=(e[0]-r[0])*s-i*(e[1]-r[1]);return a>0&&o<0||a<0&&o>0}function $i(t,e,r,n){return 0!=(i=[n[0]-r[0],n[1]-r[1]])[0]*(s=[e[0]-t[0],e[1]-t[1]])[1]-i[1]*s[0]&&!(!qi(t,e,r,n)||!qi(r,n,t,e));var i,s;}const Gi=8192;function Yi(t,e){const r=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return [Math.round(r*i*Gi),Math.round(n*i*Gi)]}function Xi(t,e){for(let r=0;rr[2]){const e=.5*n;let i=t[0]-r[0]>e?-n:r[0]-t[0]>e?n:0;0===i&&(i=t[0]-r[2]>e?-n:r[2]-t[0]>e?n:0),t[0]+=i;}Fi(e,t);}function ts(t,e,r,n){const i=Math.pow(2,n.z)*Gi,s=[n.x*Gi,n.y*Gi],a=[];if(!t)return a;for(const n of t)for(const t of n){const n=[t.x+s[0],t.y+s[1]];Qi(n,e,r,i),a.push(n);}return a}function es(t,e,r,n){const i=Math.pow(2,n.z)*Gi,s=[n.x*Gi,n.y*Gi],a=[];if(!t)return a;for(const r of t){const t=[];for(const n of r){const r=[n.x+s[0],n.y+s[1]];Fi(e,r),t.push(r);}a.push(t);}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const n of t)Qi(n,e,r,i);}var o;return a}class rs{constructor(t,e){this.type=ti,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(xi(t[1])){const e=t[1];if(\"FeatureCollection\"===e.type)for(let t=0;te)return us(i,s,(e-(r-a))/a)}return t[t.length-1]}pointToSegmentDistance(t,e,r){let[n,i]=e,s=cs(r[0]-n)*this.kx,a=(r[1]-i)*this.ky;if(0!==s||0!==a){const e=(cs(t[0]-n)*this.kx*s+(t[1]-i)*this.ky*a)/(s*s+a*a);e>1?(n=r[0],i=r[1]):e>0&&(n+=s/this.kx*e,i+=a/this.ky*e);}return s=cs(t[0]-n)*this.kx,a=(t[1]-i)*this.ky,Math.sqrt(s*s+a*a)}pointOnLine(t,e){let r=1/0,n=t[0][0],i=t[0][1],s=0,a=0;for(let o=0;o1?(l=t[o+1][0],u=t[o+1][1]):p>0&&(l+=c/this.kx*p,u+=h/this.ky*p)),c=cs(e[0]-l)*this.kx,h=(e[1]-u)*this.ky;const f=c*c+h*h;fi.index||n.index===i.index&&n.t>i.t){const t=n;n=i,i=t;}const s=[n.point],a=n.index+1,o=i.index;!ls(r[a],s[0])&&a<=o&&s.push(r[a]);for(let t=a+1;t<=o;t++)s.push(r[t]);return ls(r[o],i.point)||s.push(i.point),s}lineSliceAlong(t,e,r){let n=0;const i=[];for(let s=0;st&&0===i.length&&i.push(us(a,o,(t-(n-l))/l)),n>=e)return i.push(us(a,o,(e-(n-l))/l)),i;n>t&&i.push(o);}return i}bufferPoint(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[0]+n,t[1]+r]}bufferBBox(t,e){const r=e/this.ky,n=e/this.kx;return [t[0]-n,t[1]-r,t[2]+n,t[3]+r]}insideBBox(t,e){return cs(t[0]-e[0])>=0&&cs(t[0]-e[2])<=0&&t[1]>=e[1]&&t[1]<=e[3]}}function ls(t,e){return t[0]===e[0]&&t[1]===e[1]}function us(t,e,r){const n=cs(e[0]-t[0]);return [t[0]+n*r,t[1]+(e[1]-t[1])*r]}function cs(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}class hs{constructor(t=[],e=((t,e)=>te?1:0)){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this._up(this.length++);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return --this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=e[n],t=n;}e[t]=i;}}var ps=8192;function fs(t,e){return e.dist-t.dist}const ds=100,ms=50;function ys(t){const e=[1/0,1/0,-1/0,-1/0];if(e.length!==t.length)return !1;for(let r=0;r=t[0]&&t[1]t[1])return [null,null];const r=gs(t);if(e){if(2===r)return [t,null];const e=Math.floor(r/2);return [[t[0],t[0]+e],[t[0]+e,t[1]]]}{if(1===r)return [t,null];const e=Math.floor(r/2)-1;return [[t[0],t[0]+e],[t[0]+e+1,t[1]]]}}function vs(t,e){const r=[1/0,1/0,-1/0,-1/0];if(!xs(e,t.length))return r;for(let n=e[0];n<=e[1];++n)Fi(r,t[n]);return r}function _s(t){const e=[1/0,1/0,-1/0,-1/0];for(let r=0;re[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(i=t[1]-e[3]),t[3]=n)return n;if(Ui(i,s)){if(Cs(t,e))return 0}else if(Cs(e,t))return 0;let a=n;for(const n of t)for(let t=0,i=n.length,s=i-1;t=s)continue;const u=i.range1;if(gs(u)<=o){if(!xs(u,t.length))return NaN;if(e){const e=Ds(t,u,r,n);if(0===(s=Math.min(s,e)))return s}else for(let e=u[0];e<=u[1];++e){const i=Bs(t[e],r,n);if(0===(s=Math.min(s,i)))return s}}else {const r=bs(u,e);if(null!==r[0]){const e=ws(vs(t,r[0]),l,n);e=a)continue;const c=s.range1,h=s.range2;if(gs(c)<=l&&gs(h)<=u){if(!xs(c,t.length)||!xs(h,r.length))return NaN;if(e&&n?a=Math.min(a,zs(t,c,r,h,i)):e||n?e&&!n?a=Math.min(a,ks(r,h,t,c,i)):!e&&n&&(a=Math.min(a,ks(t,c,r,h,i))):a=Math.min(a,Es(t,c,r,h,i)),0===a)return a}else {const s=bs(c,e),l=bs(h,n);Vs(o,a,i,t,r,s[0],l[0]),Vs(o,a,i,t,r,s[0],l[1]),Vs(o,a,i,t,r,s[1],l[0]),Vs(o,a,i,t,r,s[1],l[1]);}}return a}function Fs(t,e,r,n,i=1/0){let s=i;const a=vs(t,[0,t.length-1]);for(const i of r)if(!(s!==1/0&&ws(a,vs(i,[0,i.length-1]),n)>=s)&&(s=Math.min(s,Os(t,e,i,!0,n,s)),0===s))return s;return s}function Us(t,e,r,n,i=1/0){let s=i;const a=vs(t,[0,t.length-1]);for(const i of r){if(s!==1/0&&ws(a,_s(i),n)>=s)continue;const r=Ls(t,e,i,n,s);if(isNaN(r))return r;if(0===(s=Math.min(s,r)))return s}return s}function Ns(t){return \"Point\"===t||\"MultiPoint\"===t||\"LineString\"===t||\"MultiLineString\"===t||\"Polygon\"===t||\"MultiPolygon\"===t}class js{constructor(t,e){this.type=Jn,this.geojson=t,this.geometries=e;}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires either one argument, but found ' ${t.length-1} instead.`);if(xi(t[1])){const e=t[1];if(\"FeatureCollection\"===e.type){for(let t=0;tr&&(t=r),t}class Gs{constructor(t,e,r){this.type=t,this.key=e,this.scope=r;}static parse(t,e){let r=e.expectedType;if(null==r&&(r=ni),t.length<2||t.length>3)return e.error(\"Invalid number of arguments for 'config' expression.\");const n=e.parse(t[1],1);if(!(n instanceof _i))return e.error(\"Key name of 'config' expression must be a string literal.\");if(t.length>=3){const i=e.parse(t[2],2);return i instanceof _i?new Gs(r,vi(n.value),vi(i.value)):e.error(\"Scope of 'config' expression must be a string literal.\")}return new Gs(r,vi(n.value))}evaluate(t){const e=[this.key,this.scope,t.scope].filter(Boolean).join(\"\u001f\"),r=t.getConfig(e);if(!r)return null;const{type:n,value:i,values:s,minValue:a,maxValue:o,stepValue:l}=r,u=r.default.evaluate(t);let c=u;if(i){const e=t.scope;t.scope=(e||\"\").split(\"\u001f\").slice(1).join(\"\u001f\"),c=i.evaluate(t),t.scope=e;}return n&&(c=qs(n,c)),void 0===c||void 0===a&&void 0===o&&void 0===l||(\"number\"==typeof c?c=$s(c,a,o,l):Array.isArray(c)&&(c=c.map((t=>\"number\"==typeof t?$s(t,a,o,l):t)))),void 0!==i&&void 0!==c&&s&&!s.includes(c)&&(c=u,n&&(c=qs(n,c))),(n&&n!==this.type||void 0!==c&&bi(c)!==this.type)&&(c=qs(this.type.kind,c)),c}eachChild(){}outputDefined(){return !1}serialize(){const t=[\"config\",this.key];return this.scope&&t.concat(this.key),t}}function Ys(t){if(t instanceof Bi){if(\"get\"===t.name&&1===t.args.length)return !1;if(\"feature-state\"===t.name)return !1;if(\"has\"===t.name&&1===t.args.length)return !1;if(\"properties\"===t.name||\"geometry-type\"===t.name||\"id\"===t.name)return !1;if(/^filter-/.test(t.name))return !1}if(t instanceof rs)return !1;if(t instanceof js)return !1;let e=!0;return t.eachChild((t=>{e&&!Ys(t)&&(e=!1);})),e}function Xs(t){if(t instanceof Bi&&\"feature-state\"===t.name)return !1;let e=!0;return t.eachChild((t=>{e&&!Xs(t)&&(e=!1);})),e}function Zs(t){if(t instanceof Gs)return !1;let e=!0;return t.eachChild((t=>{e&&!Zs(t)&&(e=!1);})),e}function Hs(t,e){if(t instanceof Bi&&e.indexOf(t.name)>=0)return !1;let r=!0;return t.eachChild((t=>{r&&!Hs(t,e)&&(r=!1);})),r}class Ks{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e;}static parse(t,e){if(2!==t.length||\"string\"!=typeof t[1])return e.error(\"'var' expression requires exactly one string literal argument.\");const r=t[1];return e.scope.has(r)?new Ks(r,e.scope.get(r)):e.error(`Unknown variable \"${r}\". Make sure \"${r}\" has been bound in an enclosing \"let\" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return !1}serialize(){return [\"var\",this.name]}}class Ws{constructor(t,e=[],r,n=new Kn,i=[],s,a){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(\"\"),this.scope=n,this.errors=i,this.expectedType=r,this._scope=s,this.options=a;}parse(t,e,r,n,i={}){return e||r?this.concat(e,r,n)._parse(t,i):this._parse(t,i)}_parse(t,e){function r(t,e,r){return \"assert\"===r?new Ai(e,[t]):\"coerce\"===r?new Pi(e,[t]):t}if(null!==t&&\"string\"!=typeof t&&\"boolean\"!=typeof t&&\"number\"!=typeof t||(t=[\"literal\",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use [\"literal\", []].');const n=\"string\"==typeof t[0]?this.registry[t[0]]:void 0;if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){const t=this.expectedType,n=i.type;if(\"string\"!==t.kind&&\"number\"!==t.kind&&\"boolean\"!==t.kind&&\"object\"!==t.kind&&\"array\"!==t.kind||\"value\"!==n.kind)if(\"color\"!==t.kind&&\"formatted\"!==t.kind&&\"resolvedImage\"!==t.kind||\"value\"!==n.kind&&\"string\"!==n.kind){if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||\"coerce\");else i=r(i,t,e.typeAnnotation||\"assert\");}if(!(i instanceof _i)&&\"resolvedImage\"!==i.type.kind&&Qs(i)){const t=new Ei(this._scope,this.options);try{i=new _i(i.type,i.evaluate(t));}catch(t){return this.error(t.message),null}}return i}return Pi.parse([\"to-array\",t],this)}return this.error(void 0===t?\"'undefined' value invalid. Use null instead.\":\"object\"==typeof t?'Bare objects invalid. Use [\"literal\", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,r){const n=\"number\"==typeof t?this.path.concat(t):this.path,i=r?this.scope.concat(r):this.scope;return new Ws(this.registry,n,e||null,i,this.errors,this._scope,this.options)}error(t,...e){const r=`${this.key}${e.map((t=>`[${t}]`)).join(\"\")}`;this.errors.push(new Hn(r,t));}checkSubtype(t,e){const r=ci(t,e);return r&&this.error(r),r}}var Js=Ws;function Qs(t){if(t instanceof Ks)return Qs(t.boundExpression);if(t instanceof Bi&&\"error\"===t.name)return !1;if(t instanceof Ci)return !1;if(t instanceof rs)return !1;if(t instanceof js)return !1;if(t instanceof Gs)return !1;const e=t instanceof Pi||t instanceof Ai;let r=!0;return t.eachChild((t=>{r=e?r&&Qs(t):r&&t instanceof _i;})),!!r&&Ys(t)&&Hs(t,[\"zoom\",\"heatmap-density\",\"line-progress\",\"raster-value\",\"sky-radial-progress\",\"accumulated\",\"is-supported-script\",\"pitch\",\"distance-from-center\",\"measure-light\",\"raster-particle-speed\"])}function ta(t,e){const r=t.length-1;let n,i,s=0,a=r,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),n=t[o],i=t[o+1],n<=e){if(o===r||ee))throw new wi(\"Input is not a number.\");a=o-1;}return 0}class ea{constructor(t,e,r){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e);}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error(\"Expected an even number of arguments.\");const r=e.parse(t[1],1,Jn);if(!r)return null;const n=[];let i=null;e.expectedType&&\"value\"!==e.expectedType.kind&&(i=e.expectedType);for(let r=1;r=s)return e.error('Input/output pairs for \"step\" expressions must be arranged with input values in strictly ascending order.',o);const u=e.parse(a,l,i);if(!u)return null;i=i||u.type,n.push([s,u]);}return new ea(i,r,n)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;return n>=e[i-1]?r[i-1].evaluate(t):r[ta(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=[\"step\",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}const ra=.95047,na=1.08883,ia=4/29,sa=6/29,aa=3*sa*sa,oa=sa*sa*sa,la=Math.PI/180,ua=180/Math.PI;function ca(t){return t>oa?Math.pow(t,1/3):t/aa+ia}function ha(t){return t>sa?t*t*t:aa*(t-ia)}function pa(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function fa(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function da(t){const e=fa(t.r),r=fa(t.g),n=fa(t.b),i=ca((.4124564*e+.3575761*r+.1804375*n)/ra),s=ca((.2126729*e+.7151522*r+.072175*n)/1);return {l:116*s-16,a:500*(i-s),b:200*(s-ca((.0193339*e+.119192*r+.9503041*n)/na)),alpha:t.a}}function ma(t){let e=(t.l+16)/116,r=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*ha(e),r=ra*ha(r),n=na*ha(n),new qn(pa(3.2404542*r-1.5371385*e-.4985314*n),pa(-.969266*r+1.8760108*e+.041556*n),pa(.0556434*r-.2040259*e+1.0572252*n),t.alpha)}function ya(t,e,r){const n=e-t;return t+r*(n>180||n<-180?n-360*Math.round(n/360):n)}const ga={forward:da,reverse:ma,interpolate:function(t,e,r){return {l:Gn(t.l,e.l,r),a:Gn(t.a,e.a,r),b:Gn(t.b,e.b,r),alpha:Gn(t.alpha,e.alpha,r)}}},xa={forward:function(t){const{l:e,a:r,b:n}=da(t),i=Math.atan2(n,r)*ua;return {h:i<0?i+360:i,c:Math.sqrt(r*r+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*la,r=t.c;return ma({l:t.l,a:Math.cos(e)*r,b:Math.sin(e)*r,alpha:t.alpha})},interpolate:function(t,e,r){return {h:ya(t.h,e.h,r),c:Gn(t.c,e.c,r),l:Gn(t.l,e.l,r),alpha:Gn(t.alpha,e.alpha,r)}}};var ba=Object.freeze({__proto__:null,hcl:xa,lab:ga});class va{constructor(t,e,r,n,i){this.type=t,this.operator=e,this.interpolation=r,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e);}static interpolationFactor(t,e,r,n){let i=0;if(\"exponential\"===t.name)i=_a(e,t.base,r,n);else if(\"linear\"===t.name)i=_a(e,1,r,n);else if(\"cubic-bezier\"===t.name){const s=t.controlPoints;i=new Oe(s[0],s[1],s[2],s[3]).solve(_a(e,1,r,n));}return i}static parse(t,e){let[r,n,i,...s]=t;if(!Array.isArray(n)||0===n.length)return e.error(\"Expected an interpolation type expression.\",1);if(\"linear\"===n[0])n={name:\"linear\"};else if(\"exponential\"===n[0]){const t=n[1];if(\"number\"!=typeof t)return e.error(\"Exponential interpolation requires a numeric base.\",1,1);n={name:\"exponential\",base:t};}else {if(\"cubic-bezier\"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>\"number\"!=typeof t||t<0||t>1)))return e.error(\"Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.\",1);n={name:\"cubic-bezier\",controlPoints:t};}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error(\"Expected an even number of arguments.\");if(i=e.parse(i,2,Jn),!i)return null;const a=[];let o=null;\"interpolate-hcl\"===r||\"interpolate-lab\"===r?o=ei:e.expectedType&&\"value\"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=r)return e.error('Input/output pairs for \"interpolate\" expressions must be arranged with input values in strictly ascending order.',i);const u=e.parse(n,l,o);if(!u)return null;o=o||u.type,a.push([r,u]);}return \"number\"===o.kind||\"color\"===o.kind||\"array\"===o.kind&&\"number\"===o.itemType.kind&&\"number\"==typeof o.N?new va(o,r,n,i,a):e.error(`Type ${li(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,r=this.outputs;if(1===e.length)return r[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return r[0].evaluate(t);const i=e.length;if(n>=e[i-1])return r[i-1].evaluate(t);const s=ta(e,n),a=va.interpolationFactor(this.interpolation,n,e[s],e[s+1]),o=r[s].evaluate(t),l=r[s+1].evaluate(t);return \"interpolate\"===this.operator?Xn[this.type.kind.toLowerCase()](o,l,a):\"interpolate-hcl\"===this.operator?xa.reverse(xa.interpolate(xa.forward(o),xa.forward(l),a)):ga.reverse(ga.interpolate(ga.forward(o),ga.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t=\"linear\"===this.interpolation.name?[\"linear\"]:\"exponential\"===this.interpolation.name?1===this.interpolation.base?[\"linear\"]:[\"exponential\",this.interpolation.base]:[\"cubic-bezier\"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;tci(n,t.type)));return new wa(s?ni:r,i)}evaluate(t){let e,r=null,n=0;for(const i of this.args){if(n++,r=i.evaluate(t),r&&r instanceof yi&&!r.available&&(e||(e=r),r=null,n===this.args.length))return e;if(null!==r)break}return r}eachChild(t){this.args.forEach(t);}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=[\"coalesce\"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class Ma{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e;}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result);}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const r=[];for(let n=1;n=r.length)throw new wi(`Array index out of bounds: ${e} > ${r.length-1}.`);if(e!==Math.floor(e))throw new wi(`Array index must be an integer, but found ${e} instead.`);return r[e]}eachChild(t){t(this.index),t(this.input);}outputDefined(){return !1}serialize(){return [\"at\",this.index.serialize(),this.input.serialize()]}}class Sa{constructor(t,e){this.type=ti,this.needle=t,this.haystack=e;}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,ni),n=e.parse(t[2],2,ni);return r&&n?hi(r.type,[ti,Qn,Jn,Wn,ni])?new Sa(r,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${li(r.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(null==r)return !1;if(!pi(e,[\"boolean\",\"string\",\"number\",\"null\"]))throw new wi(`Expected first argument to be of type boolean, string, number or null, but found ${li(bi(e))} instead.`);if(!pi(r,[\"string\",\"array\"]))throw new wi(`Expected second argument to be of type array or string, but found ${li(bi(r))} instead.`);return r.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack);}outputDefined(){return !0}serialize(){return [\"in\",this.needle.serialize(),this.haystack.serialize()]}}class Ia{constructor(t,e,r){this.type=Jn,this.needle=t,this.haystack=e,this.fromIndex=r;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,ni),n=e.parse(t[2],2,ni);if(!r||!n)return null;if(!hi(r.type,[ti,Qn,Jn,Wn,ni]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${li(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Jn);return i?new Ia(r,n,i):null}return new Ia(r,n)}evaluate(t){const e=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!pi(e,[\"boolean\",\"string\",\"number\",\"null\"]))throw new wi(`Expected first argument to be of type boolean, string, number or null, but found ${li(bi(e))} instead.`);if(!pi(r,[\"string\",\"array\"]))throw new wi(`Expected second argument to be of type array or string, but found ${li(bi(r))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return r.indexOf(e,n)}return r.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex);}outputDefined(){return !1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return [\"index-of\",this.needle.serialize(),this.haystack.serialize(),t]}return [\"index-of\",this.needle.serialize(),this.haystack.serialize()]}}class Ta{constructor(t,e,r,n,i,s){this.inputType=t,this.type=e,this.input=r,this.cases=n,this.outputs=i,this.otherwise=s;}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error(\"Expected an even number of arguments.\");let r,n;e.expectedType&&\"value\"!==e.expectedType.kind&&(n=e.expectedType);const i={},s=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(\"number\"==typeof t&&Math.floor(t)!==t)return u.error(\"Numeric branch labels must be integer values.\");if(r){if(u.checkSubtype(r,bi(t)))return null}else r=bi(t);if(void 0!==i[String(t)])return u.error(\"Branch labels must be unique.\");i[String(t)]=s.length;}const c=e.parse(l,a,n);if(!c)return null;n=n||c.type,s.push(c);}const a=e.parse(t[1],1,ni);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,n);return o?\"value\"!==a.type.kind&&e.concat(1).checkSubtype(r,a.type)?null:new Ta(r,n,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return (bi(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise);}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=[\"match\",this.input.serialize()],e=Object.keys(this.cases).sort(),r=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=r.length,r.push([this.cases[t],[t]])):r[e][1].push(t);}const i=t=>\"number\"===this.inputType.kind?Number(t):t;for(const[e,n]of r)t.push(1===n.length?i(n[0]):n.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}class ka{constructor(t,e,r){this.type=t,this.branches=e,this.otherwise=r;}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error(\"Expected an odd number of arguments.\");let r;e.expectedType&&\"value\"!==e.expectedType.kind&&(r=e.expectedType);const n=[];for(let i=1;ie.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=[\"case\"];return this.eachChild((e=>{t.push(e.serialize());})),t}}class Pa{constructor(t,e,r,n){this.type=t,this.input=e,this.beginIndex=r,this.endIndex=n;}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const r=e.parse(t[1],1,ni),n=e.parse(t[2],2,Jn);if(!r||!n)return null;if(!hi(r.type,[oi(ni),Qn,ni]))return e.error(`Expected first argument to be of type array or string, but found ${li(r.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Jn);return i?new Pa(r.type,r,n,i):null}return new Pa(r.type,r,n)}evaluate(t){const e=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(!pi(e,[\"string\",\"array\"]))throw new wi(`Expected first argument to be of type array or string, but found ${li(bi(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(r,n)}return e.slice(r)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex);}outputDefined(){return !1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return [\"slice\",this.input.serialize(),this.beginIndex.serialize(),t]}return [\"slice\",this.input.serialize(),this.beginIndex.serialize()]}}function za(t,e){return \"==\"===t||\"!=\"===t?\"boolean\"===e.kind||\"string\"===e.kind||\"number\"===e.kind||\"null\"===e.kind||\"value\"===e.kind:\"string\"===e.kind||\"number\"===e.kind||\"value\"===e.kind}function Ea(t,e,r,n){return 0===n.compare(e,r)}function Ba(t,e,r){const n=\"==\"!==t&&\"!=\"!==t;return class i{constructor(t,e,r){this.type=ti,this.lhs=t,this.rhs=e,this.collator=r,this.hasUntypedArgument=\"value\"===t.type.kind||\"value\"===e.type.kind;}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error(\"Expected two or three arguments.\");const r=t[0];let s=e.parse(t[1],1,ni);if(!s)return null;if(!za(r,s.type))return e.concat(1).error(`\"${r}\" comparisons are not supported for type '${li(s.type)}'.`);let a=e.parse(t[2],2,ni);if(!a)return null;if(!za(r,a.type))return e.concat(2).error(`\"${r}\" comparisons are not supported for type '${li(a.type)}'.`);if(s.type.kind!==a.type.kind&&\"value\"!==s.type.kind&&\"value\"!==a.type.kind)return e.error(`Cannot compare types '${li(s.type)}' and '${li(a.type)}'.`);n&&(\"value\"===s.type.kind&&\"value\"!==a.type.kind?s=new Ai(a.type,[s]):\"value\"!==s.type.kind&&\"value\"===a.type.kind&&(a=new Ai(s.type,[a])));let o=null;if(4===t.length){if(\"string\"!==s.type.kind&&\"string\"!==a.type.kind&&\"value\"!==s.type.kind&&\"value\"!==a.type.kind)return e.error(\"Cannot use collator to compare non-string types.\");if(o=e.parse(t[3],3,ii),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(n&&this.hasUntypedArgument){const e=bi(s),r=bi(a);if(e.kind!==r.kind||\"string\"!==e.kind&&\"number\"!==e.kind)throw new wi(`Expected arguments for \"${t}\" to be (string, string) or (number, number), but found (${e.kind}, ${r.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=bi(s),r=bi(a);if(\"string\"!==t.kind||\"string\"!==r.kind)return e(i,s,a)}return this.collator?r(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator);}outputDefined(){return !0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize());})),e}}}const Da=Ba(\"==\",(function(t,e,r){return e===r}),Ea),Ca=Ba(\"!=\",(function(t,e,r){return e!==r}),(function(t,e,r,n){return !Ea(0,e,r,n)})),Ra=Ba(\"<\",(function(t,e,r){return e\",(function(t,e,r){return e>r}),(function(t,e,r,n){return n.compare(e,r)>0})),La=Ba(\"<=\",(function(t,e,r){return e<=r}),(function(t,e,r,n){return n.compare(e,r)<=0})),Oa=Ba(\">=\",(function(t,e,r){return e>=r}),(function(t,e,r,n){return n.compare(e,r)>=0}));class Fa{constructor(t,e,r,n,i,s){this.type=Qn,this.number=t,this.locale=e,this.currency=r,this.unit=n,this.minFractionDigits=i,this.maxFractionDigits=s;}static parse(t,e){if(3!==t.length)return e.error(\"Expected two arguments.\");const r=e.parse(t[1],1,Jn);if(!r)return null;const n=t[2];if(\"object\"!=typeof n||Array.isArray(n))return e.error(\"NumberFormat options argument must be an object.\");let i=null;if(n.locale&&(i=e.parse(n.locale,1,Qn),!i))return null;let s=null;if(n.currency&&(s=e.parse(n.currency,1,Qn),!s))return null;let a=null;if(n.unit&&(a=e.parse(n.unit,1,Qn),!a))return null;let o=null;if(n[\"min-fraction-digits\"]&&(o=e.parse(n[\"min-fraction-digits\"],1,Jn),!o))return null;let l=null;return n[\"max-fraction-digits\"]&&(l=e.parse(n[\"max-fraction-digits\"],1,Jn),!l)?null:new Fa(r,i,s,a,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?\"currency\":this.unit&&\"unit\")||\"decimal\",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits);}outputDefined(){return !1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t[\"min-fraction-digits\"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t[\"max-fraction-digits\"]=this.maxFractionDigits.serialize()),[\"number-format\",this.number.serialize(),t]}}class Ua{constructor(t){this.type=Jn,this.input=t;}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const r=e.parse(t[1],1);return r?\"array\"!==r.type.kind&&\"string\"!==r.type.kind&&\"value\"!==r.type.kind?e.error(`Expected argument of type string or array, but found ${li(r.type)} instead.`):new Ua(r):null}evaluate(t){const e=this.input.evaluate(t);if(\"string\"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new wi(`Expected value to be of type string or array, but found ${li(bi(e))} instead.`)}eachChild(t){t(this.input);}outputDefined(){return !1}serialize(){const t=[\"length\"];return this.eachChild((e=>{t.push(e.serialize());})),t}}function Na(t){return function(){t=1831565813+(t|=0)|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const ja={\"==\":Da,\"!=\":Ca,\">\":Va,\"<\":Ra,\">=\":Oa,\"<=\":La,array:Ai,at:Aa,boolean:Ai,case:ka,coalesce:wa,collator:Ci,format:Si,image:Ii,in:Sa,\"index-of\":Ia,interpolate:va,\"interpolate-hcl\":va,\"interpolate-lab\":va,length:Ua,let:Ma,literal:_i,match:Ta,number:Ai,\"number-format\":Fa,object:Ai,slice:Pa,step:ea,string:Ai,\"to-boolean\":Pi,\"to-color\":Pi,\"to-number\":Pi,\"to-string\":Pi,var:Ks,within:rs,distance:js,config:Gs};function qa(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const s=i?i.evaluate(t):1,a=gi(e,r,n,s);if(a)throw new wi(a);return new qn(e/255*s,r/255*s,n/255*s,s)}function $a(t,[e,r,n,i]){e=e.evaluate(t),r=r.evaluate(t),n=n.evaluate(t);const s=i?i.evaluate(t):1,a=function(t,e,r,n){return \"number\"==typeof t&&t>=0&&t<=360?\"number\"==typeof e&&e>=0&&e<=100&&\"number\"==typeof r&&r>=0&&r<=100?void 0===n||\"number\"==typeof n&&n>=0&&n<=1?null:`Invalid hsla value [${[t,e,r,n].join(\", \")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(\"number\"==typeof n?[t,e,r,n]:[t,e,r]).join(\", \")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(\"number\"==typeof n?[t,e,r,n]:[t,e,r]).join(\", \")}]: 'h' must be between 0 and 360.`}(e,r,n,s);if(a)throw new wi(a);const o=`hsla(${e}, ${r}%, ${n}%, ${s})`,l=qn.parse(o);if(!l)throw new wi(`Failed to parse HSLA color: ${o}`);return l}function Ga(t,e){return t in e}function Ya(t,e){const r=e[t];return void 0===r?null:r}function Xa(t){return {type:t}}function Za(t){return {result:\"success\",value:t}}function Ha(t){return {result:\"error\",value:t}}function Ka(t,e){return !!t&&!!t.parameters&&t.parameters.indexOf(e)>-1}function Wa(t){return \"data-driven\"===t[\"property-type\"]}function Ja(t){return Ka(t.expression,\"measure-light\")}function Qa(t){return Ka(t.expression,\"zoom\")}function to(t){return !!t.expression&&t.expression.interpolated}function eo(t){return \"object\"==typeof t&&null!==t&&!Array.isArray(t)}function ro(t){return t}function no(t,e){const r=\"color\"===e.type,n=t.stops&&\"object\"==typeof t.stops[0][0],i=n||!(n||void 0!==t.property),s=t.type||(to(e)?\"exponential\":\"interval\");if(r&&((t=Zn({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],qn.parse(t[1])]))),t.default=qn.parse(t.default?t.default:e.default)),t.colorSpace&&\"rgb\"!==t.colorSpace&&!ba[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let a,o,l;if(\"exponential\"===s)a=oo;else if(\"interval\"===s)a=ao;else if(\"categorical\"===s){a=so,o=Object.create(null);for(const e of t.stops)o[e[0]]=e[1];l=typeof t.stops[0][0];}else {if(\"identity\"!==s)throw new Error(`Unknown function type \"${s}\"`);a=lo;}if(n){const r={},n=[];for(let e=0;et[0])),evaluate:({zoom:r},n)=>oo({stops:i,base:t.base},e,r).evaluate(r,n)}}if(i){const r=\"exponential\"===s?{name:\"exponential\",base:void 0!==t.base?t.base:1}:null;return {kind:\"camera\",interpolationType:r,interpolationFactor:va.interpolationFactor.bind(void 0,r),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:r})=>a(t,e,r,o,l)}}return {kind:\"source\",evaluate(r,n){const i=n&&n.properties?n.properties[t.property]:void 0;return void 0===i?io(t.default,e.default):a(t,e,i,o,l)}}}function io(t,e,r){return void 0!==t?t:void 0!==e?e:void 0!==r?r:void 0}function so(t,e,r,n,i){return io(typeof r===i?n[r]:void 0,t.default,e.default)}function ao(t,e,r){if(\"number\"!==Ti(r))return io(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[n-1][0])return t.stops[n-1][1];const i=ta(t.stops.map((t=>t[0])),r);return t.stops[i][1]}function oo(t,e,r){const n=void 0!==t.base?t.base:1;if(\"number\"!==Ti(r))return io(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(r<=t.stops[0][0])return t.stops[0][1];if(r>=t.stops[i-1][0])return t.stops[i-1][1];const s=ta(t.stops.map((t=>t[0])),r),a=function(t,e,r,n){const i=n-r,s=t-r;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(r,n,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1];let u=Xn[e.type]||ro;if(t.colorSpace&&\"rgb\"!==t.colorSpace){const e=ba[t.colorSpace];u=(t,r)=>e.reverse(e.interpolate(e.forward(t),e.forward(r),a));}return \"function\"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==r)return u(e,r,a)}}:u(o,l,a)}function lo(t,e,r){return \"color\"===e.type?r=qn.parse(r):\"formatted\"===e.type?r=mi.fromString(r.toString()):\"resolvedImage\"===e.type?r=yi.fromString(r.toString()):Ti(r)===e.type||\"enum\"===e.type&&e.values[r]||(r=void 0),io(r,t.default,e.default)}Bi.register(ja,{error:[{kind:\"error\"},[Qn],(t,[e])=>{throw new wi(e.evaluate(t))}],typeof:[Qn,[ni],(t,[e])=>li(bi(e.evaluate(t)))],\"to-rgba\":[oi(Jn,4),[ei],(t,[e])=>e.evaluate(t).toRenderColor(null).toArray()],rgb:[ei,[Jn,Jn,Jn],qa],rgba:[ei,[Jn,Jn,Jn,Jn],qa],hsl:[ei,[Jn,Jn,Jn],$a],hsla:[ei,[Jn,Jn,Jn,Jn],$a],has:{type:ti,overloads:[[[Qn],(t,[e])=>Ga(e.evaluate(t),t.properties())],[[Qn,ri],(t,[e,r])=>Ga(e.evaluate(t),r.evaluate(t))]]},get:{type:ni,overloads:[[[Qn],(t,[e])=>Ya(e.evaluate(t),t.properties())],[[Qn,ri],(t,[e,r])=>Ya(e.evaluate(t),r.evaluate(t))]]},\"feature-state\":[ni,[Qn],(t,[e])=>Ya(e.evaluate(t),t.featureState||{})],properties:[ri,[],t=>t.properties()],\"geometry-type\":[Qn,[],t=>t.geometryType()],id:[ni,[],t=>t.id()],zoom:[Jn,[],t=>t.globals.zoom],pitch:[Jn,[],t=>t.globals.pitch||0],\"distance-from-center\":[Jn,[],t=>t.distanceFromCenter()],\"measure-light\":[Jn,[Qn],(t,[e])=>t.measureLight(e.evaluate(t))],\"heatmap-density\":[Jn,[],t=>t.globals.heatmapDensity||0],\"line-progress\":[Jn,[],t=>t.globals.lineProgress||0],\"raster-value\":[Jn,[],t=>t.globals.rasterValue||0],\"raster-particle-speed\":[Jn,[],t=>t.globals.rasterParticleSpeed||0],\"sky-radial-progress\":[Jn,[],t=>t.globals.skyRadialProgress||0],accumulated:[ni,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],\"+\":[Jn,Xa(Jn),(t,e)=>{let r=0;for(const n of e)r+=n.evaluate(t);return r}],\"*\":[Jn,Xa(Jn),(t,e)=>{let r=1;for(const n of e)r*=n.evaluate(t);return r}],\"-\":{type:Jn,overloads:[[[Jn,Jn],(t,[e,r])=>e.evaluate(t)-r.evaluate(t)],[[Jn],(t,[e])=>-e.evaluate(t)]]},\"/\":[Jn,[Jn,Jn],(t,[e,r])=>e.evaluate(t)/r.evaluate(t)],\"%\":[Jn,[Jn,Jn],(t,[e,r])=>e.evaluate(t)%r.evaluate(t)],ln2:[Jn,[],()=>Math.LN2],pi:[Jn,[],()=>Math.PI],e:[Jn,[],()=>Math.E],\"^\":[Jn,[Jn,Jn],(t,[e,r])=>Math.pow(e.evaluate(t),r.evaluate(t))],sqrt:[Jn,[Jn],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Jn,[Jn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Jn,[Jn],(t,[e])=>Math.log(e.evaluate(t))],log2:[Jn,[Jn],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Jn,[Jn],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Jn,[Jn],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Jn,[Jn],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Jn,[Jn],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Jn,[Jn],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Jn,[Jn],(t,[e])=>Math.atan(e.evaluate(t))],min:[Jn,Xa(Jn),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Jn,Xa(Jn),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Jn,[Jn],(t,[e])=>Math.abs(e.evaluate(t))],round:[Jn,[Jn],(t,[e])=>{const r=e.evaluate(t);return r<0?-Math.round(-r):Math.round(r)}],floor:[Jn,[Jn],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Jn,[Jn],(t,[e])=>Math.ceil(e.evaluate(t))],\"filter-==\":[ti,[Qn,ni],(t,[e,r])=>t.properties()[e.value]===r.value],\"filter-id-==\":[ti,[ni],(t,[e])=>t.id()===e.value],\"filter-type-==\":[ti,[Qn],(t,[e])=>t.geometryType()===e.value],\"filter-<\":[ti,[Qn,ni],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n{const r=t.id(),n=e.value;return typeof r==typeof n&&r\":[ti,[Qn,ni],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>i}],\"filter-id->\":[ti,[ni],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>n}],\"filter-<=\":[ti,[Qn,ni],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n<=i}],\"filter-id-<=\":[ti,[ni],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r<=n}],\"filter->=\":[ti,[Qn,ni],(t,[e,r])=>{const n=t.properties()[e.value],i=r.value;return typeof n==typeof i&&n>=i}],\"filter-id->=\":[ti,[ni],(t,[e])=>{const r=t.id(),n=e.value;return typeof r==typeof n&&r>=n}],\"filter-has\":[ti,[ni],(t,[e])=>e.value in t.properties()],\"filter-has-id\":[ti,[],t=>null!==t.id()&&void 0!==t.id()],\"filter-type-in\":[ti,[oi(Qn)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],\"filter-id-in\":[ti,[oi(ni)],(t,[e])=>e.value.indexOf(t.id())>=0],\"filter-in-small\":[ti,[Qn,oi(ni)],(t,[e,r])=>r.value.indexOf(t.properties()[e.value])>=0],\"filter-in-large\":[ti,[Qn,oi(ni)],(t,[e,r])=>function(t,e,r,n){for(;r<=n;){const i=r+n>>1;if(e[i]===t)return !0;e[i]>t?n=i-1:r=i+1;}return !1}(t.properties()[e.value],r.value,0,r.value.length-1)],all:{type:ti,overloads:[[[ti,ti],(t,[e,r])=>e.evaluate(t)&&r.evaluate(t)],[Xa(ti),(t,e)=>{for(const r of e)if(!r.evaluate(t))return !1;return !0}]]},any:{type:ti,overloads:[[[ti,ti],(t,[e,r])=>e.evaluate(t)||r.evaluate(t)],[Xa(ti),(t,e)=>{for(const r of e)if(r.evaluate(t))return !0;return !1}]]},\"!\":[ti,[ti],(t,[e])=>!e.evaluate(t)],\"is-supported-script\":[ti,[Qn],(t,[e])=>{const r=t.globals&&t.globals.isSupportedScript;return !r||r(e.evaluate(t))}],upcase:[Qn,[Qn],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Qn,[Qn],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Qn,Xa(ni),(t,e)=>e.map((e=>vi(e.evaluate(t)))).join(\"\")],\"resolved-locale\":[Qn,[ii],(t,[e])=>e.evaluate(t).resolvedLocale()],random:[Jn,[Jn,Jn,ni],(t,e)=>{const[r,n,i]=e.map((e=>e.evaluate(t)));if(r>n)return r;if(r===n)return r;let s;if(\"string\"==typeof i)s=function(t){let e=0;if(0===t.length)return e;for(let r=0;rJSON.stringify(t))).join(\", \")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,\"undefined\"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function co(t){return Array.isArray(t)&&t.length>0&&\"string\"==typeof t[0]&&t[0]in ja}function ho(t,e,r,n){const i=new Js(ja,[],e?function(t){const e={color:ei,string:Qn,number:Jn,enum:Qn,boolean:ti,formatted:si,resolvedImage:ai};return \"array\"===t.type?oi(e[t.value]||ni,t.length):e[t.type]}(e):void 0,void 0,void 0,r,n),s=i.parse(t,void 0,void 0,void 0,e&&\"string\"===e.type?{typeAnnotation:\"coerce\"}:void 0);return s?Za(new uo(s,e,r,n)):Ha(i.errors)}class po{constructor(t,e,r){this.kind=t,this._styleExpression=e,this.isLightConstant=r,this.isStateDependent=\"constant\"!==t&&!Xs(e.expression),this.isConfigDependent=!Zs(e.expression);}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}}class fo{constructor(t,e,r,n,i){this.kind=t,this.zoomStops=r,this._styleExpression=e,this.isStateDependent=\"camera\"!==t&&!Xs(e.expression),this.isLightConstant=i,this.isConfigDependent=!Zs(e.expression),this.interpolationType=n;}evaluateWithoutErrorHandling(t,e,r,n,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,r,n,i,s)}evaluate(t,e,r,n,i,s){return this._styleExpression.evaluate(t,e,r,n,i,s)}interpolationFactor(t,e,r){return this.interpolationType?va.interpolationFactor(this.interpolationType,t,e,r):0}}function mo(t,e,r,n){if(\"error\"===(t=ho(t,e,r,n)).result)return t;const i=t.value.expression,s=Ys(i);if(!s&&!Wa(e))return Ha([new Hn(\"\",\"data expressions not supported\")]);const a=Hs(i,[\"zoom\",\"pitch\",\"distance-from-center\"]);if(!a&&!Qa(e))return Ha([new Hn(\"\",\"zoom expressions not supported\")]);const o=Hs(i,[\"measure-light\"]);if(!o&&!Ja(e))return Ha([new Hn(\"\",\"measure-light expression not supported\")]);const l=e.expression&&e.expression.relaxZoomRestriction,u=go(i);return u||a||l?u instanceof Hn?Ha([u]):u instanceof va&&!to(e)?Ha([new Hn(\"\",'\"interpolate\" expressions cannot be used with this property')]):Za(u?new fo(s?\"camera\":\"composite\",t.value,u.labels,u instanceof va?u.interpolation:void 0,o):new po(s?\"constant\":\"source\",t.value,o)):Ha([new Hn(\"\",'\"zoom\" expression may only be used as input to a top-level \"step\" or \"interpolate\" expression, or in the properties of atmosphere.')])}class yo{constructor(t,e){this._parameters=t,this._specification=e,Zn(this,no(this._parameters,this._specification));}static deserialize(t){return new yo(t._parameters,t._specification)}static serialize(t){return {_parameters:t._parameters,_specification:t._specification}}}function go(t){let e=null;if(t instanceof Ma)e=go(t.result);else if(t instanceof wa){for(const r of t.args)if(e=go(r),e)break}else (t instanceof ea||t instanceof va)&&t.input instanceof Bi&&\"zoom\"===t.input.name&&(e=t);return e instanceof Hn||t.eachChild((t=>{const r=go(t);r instanceof Hn?e=r:e&&r&&e!==r&&(e=new Hn(\"\",'Only one zoom-based \"step\" or \"interpolate\" subexpression may be used in an expression.'));})),e}var xo=vo,bo=3;function vo(t,e,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var i=new Int32Array(this.arrayBuffer);t=i[0],this.d=(e=i[1])+2*(r=i[2]);for(var s=0;s=c[f+0]&&n>=c[f+1])?(a[p]=!0,s.push(u[p])):a[p]=!1;}}},vo.prototype._forEachCell=function(t,e,r,n,i,s,a,o){for(var l=this._convertToCellCoord(t),u=this._convertToCellCoord(e),c=this._convertToCellCoord(r),h=this._convertToCellCoord(n),p=l;p<=c;p++)for(var f=u;f<=h;f++){var d=this.d*f+p;if((!o||o(this._convertFromCellCoord(p),this._convertFromCellCoord(f),this._convertFromCellCoord(p+1),this._convertFromCellCoord(f+1)))&&i.call(this,t,e,r,n,d,s,a,o))return}},vo.prototype._convertFromCellCoord=function(t){return (t-this.padding)/this.scale},vo.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},vo.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=bo+this.cells.length+1+1,r=0,n=0;n=0||(i[r]=Io(t[r],e)));t instanceof Error&&(i.message=t.message);}if(i.$name)throw new Error(\"$name property is reserved for worker serialization logic.\");return \"Object\"!==n&&(i.$name=n),i}throw new Error(\"can't serialize object of type \"+typeof t)}function To(t){if(null==t||\"boolean\"==typeof t||\"number\"==typeof t||\"string\"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||Ao(t)||So(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(To);if(\"object\"==typeof t){const e=t.$name||\"Object\";if(\"Map\"===e){const e=new Map;for(const r of Object.keys(t))\"$name\"!==r&&e.set(r,To(t[r]));return e}const{klass:r}=wo[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(t);const n=Object.create(r.prototype);for(const e of Object.keys(t))\"$name\"!==e&&(n[e]=To(t[e]));return n}throw new Error(\"can't deserialize object of type \"+typeof t)}const ko={\"Latin-1 Supplement\":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,\"Arabic Supplement\":t=>t>=1872&&t<=1919,\"Arabic Extended-A\":t=>t>=2208&&t<=2303,\"Hangul Jamo\":t=>t>=4352&&t<=4607,\"Unified Canadian Aboriginal Syllabics\":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,\"Unified Canadian Aboriginal Syllabics Extended\":t=>t>=6320&&t<=6399,\"General Punctuation\":t=>t>=8192&&t<=8303,\"Letterlike Symbols\":t=>t>=8448&&t<=8527,\"Number Forms\":t=>t>=8528&&t<=8591,\"Miscellaneous Technical\":t=>t>=8960&&t<=9215,\"Control Pictures\":t=>t>=9216&&t<=9279,\"Optical Character Recognition\":t=>t>=9280&&t<=9311,\"Enclosed Alphanumerics\":t=>t>=9312&&t<=9471,\"Geometric Shapes\":t=>t>=9632&&t<=9727,\"Miscellaneous Symbols\":t=>t>=9728&&t<=9983,\"Miscellaneous Symbols and Arrows\":t=>t>=11008&&t<=11263,\"CJK Radicals Supplement\":t=>t>=11904&&t<=12031,\"Kangxi Radicals\":t=>t>=12032&&t<=12255,\"Ideographic Description Characters\":t=>t>=12272&&t<=12287,\"CJK Symbols and Punctuation\":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,\"Hangul Compatibility Jamo\":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,\"Bopomofo Extended\":t=>t>=12704&&t<=12735,\"CJK Strokes\":t=>t>=12736&&t<=12783,\"Katakana Phonetic Extensions\":t=>t>=12784&&t<=12799,\"Enclosed CJK Letters and Months\":t=>t>=12800&&t<=13055,\"CJK Compatibility\":t=>t>=13056&&t<=13311,\"CJK Unified Ideographs Extension A\":t=>t>=13312&&t<=19903,\"Yijing Hexagram Symbols\":t=>t>=19904&&t<=19967,\"CJK Unified Ideographs\":t=>t>=19968&&t<=40959,\"Yi Syllables\":t=>t>=40960&&t<=42127,\"Yi Radicals\":t=>t>=42128&&t<=42191,\"Hangul Jamo Extended-A\":t=>t>=43360&&t<=43391,\"Hangul Syllables\":t=>t>=44032&&t<=55215,\"Hangul Jamo Extended-B\":t=>t>=55216&&t<=55295,\"Private Use Area\":t=>t>=57344&&t<=63743,\"CJK Compatibility Ideographs\":t=>t>=63744&&t<=64255,\"Arabic Presentation Forms-A\":t=>t>=64336&&t<=65023,\"Vertical Forms\":t=>t>=65040&&t<=65055,\"CJK Compatibility Forms\":t=>t>=65072&&t<=65103,\"Small Form Variants\":t=>t>=65104&&t<=65135,\"Arabic Presentation Forms-B\":t=>t>=65136&&t<=65279,\"Halfwidth and Fullwidth Forms\":t=>t>=65280&&t<=65519,\"CJK Unified Ideographs Extension B\":t=>t>=131072&&t<=173791};function Po(t){for(const e of t)if(Bo(e.charCodeAt(0)))return !0;return !1}function zo(t){for(const e of t)if(!Eo(e.charCodeAt(0)))return !1;return !0}function Eo(t){return !(ko.Arabic(t)||ko[\"Arabic Supplement\"](t)||ko[\"Arabic Extended-A\"](t)||ko[\"Arabic Presentation Forms-A\"](t)||ko[\"Arabic Presentation Forms-B\"](t))}function Bo(t){return !(746!==t&&747!==t&&(t<4352||!(ko[\"Bopomofo Extended\"](t)||ko.Bopomofo(t)||ko[\"CJK Compatibility Forms\"](t)&&!(t>=65097&&t<=65103)||ko[\"CJK Compatibility Ideographs\"](t)||ko[\"CJK Compatibility\"](t)||ko[\"CJK Radicals Supplement\"](t)||ko[\"CJK Strokes\"](t)||!(!ko[\"CJK Symbols and Punctuation\"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||ko[\"CJK Unified Ideographs Extension A\"](t)||ko[\"CJK Unified Ideographs\"](t)||ko[\"Enclosed CJK Letters and Months\"](t)||ko[\"Hangul Compatibility Jamo\"](t)||ko[\"Hangul Jamo Extended-A\"](t)||ko[\"Hangul Jamo Extended-B\"](t)||ko[\"Hangul Jamo\"](t)||ko[\"Hangul Syllables\"](t)||ko.Hiragana(t)||ko[\"Ideographic Description Characters\"](t)||ko.Kanbun(t)||ko[\"Kangxi Radicals\"](t)||ko[\"Katakana Phonetic Extensions\"](t)||ko.Katakana(t)&&12540!==t||!(!ko[\"Halfwidth and Fullwidth Forms\"](t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!ko[\"Small Form Variants\"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||ko[\"Unified Canadian Aboriginal Syllabics\"](t)||ko[\"Unified Canadian Aboriginal Syllabics Extended\"](t)||ko[\"Vertical Forms\"](t)||ko[\"Yijing Hexagram Symbols\"](t)||ko[\"Yi Syllables\"](t)||ko[\"Yi Radicals\"](t))))}function Do(t){return !(Bo(t)||function(t){return !!(ko[\"Latin-1 Supplement\"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||ko[\"General Punctuation\"](t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||ko[\"Letterlike Symbols\"](t)||ko[\"Number Forms\"](t)||ko[\"Miscellaneous Technical\"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||ko[\"Control Pictures\"](t)&&9251!==t||ko[\"Optical Character Recognition\"](t)||ko[\"Enclosed Alphanumerics\"](t)||ko[\"Geometric Shapes\"](t)||ko[\"Miscellaneous Symbols\"](t)&&!(t>=9754&&t<=9759)||ko[\"Miscellaneous Symbols and Arrows\"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||ko[\"CJK Symbols and Punctuation\"](t)||ko.Katakana(t)||ko[\"Private Use Area\"](t)||ko[\"CJK Compatibility Forms\"](t)||ko[\"Small Form Variants\"](t)||ko[\"Halfwidth and Fullwidth Forms\"](t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Co(t){return t>=1424&&t<=2303||ko[\"Arabic Presentation Forms-A\"](t)||ko[\"Arabic Presentation Forms-B\"](t)}function Ro(t,e){return !(!e&&Co(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||ko.Khmer(t))}function Vo(t){for(const e of t)if(Co(e.charCodeAt(0)))return !0;return !1}const Lo=\"deferred\",Oo=\"loading\",Fo=\"loaded\";let Uo=null,No=\"unavailable\",jo=null;const qo=function(t){t&&\"string\"==typeof t&&t.indexOf(\"NetworkError\")>-1&&(No=\"error\"),Uo&&Uo(t);};function $o(){Go.fire(new Dn(\"pluginStateChange\",{pluginStatus:No,pluginURL:jo}));}const Go=new Ln,Yo=function(){return No},Xo=function(){if(No!==Lo||!jo)throw new Error(\"rtl-text-plugin cannot be downloaded unless a pluginURL is specified\");No=Oo,$o(),jo&&en({url:jo},(t=>{t?qo(t):(No=Fo,$o());}));},Zo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>No===Fo||null!=Zo.applyArabicShaping,isLoading:()=>No===Oo,setState(t){No=t.pluginStatus,jo=t.pluginURL;},isParsed:()=>null!=Zo.applyArabicShaping&&null!=Zo.processBidirectionalText&&null!=Zo.processStyledBidirectionalText,getPluginURL:()=>jo};class Ho{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch,this.brightness=e.brightness):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0,this.brightness=0);}isSupportedScript(t){return function(t,e){for(const r of t)if(!Ro(r.charCodeAt(0),e))return !1;return !0}(t,Zo.isLoaded())}}class Ko{constructor(t,e,r,n){this.property=t,this.value=e,this.expression=function(t,e,r,n){if(eo(t))return new yo(t,e);if(co(t)||Array.isArray(t)&&t.length>0){const i=mo(t,e,r,n);if(\"error\"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(\", \"));return i.value}{let r=t;return \"string\"==typeof t&&\"color\"===e.type&&(r=qn.parse(t)),{kind:\"constant\",isConfigDependent:!1,evaluate:()=>r}}}(void 0===e?t.specification.default:e,t.specification,r,n);}isDataDriven(){return \"source\"===this.expression.kind||\"composite\"===this.expression.kind}possiblyEvaluate(t,e,r){return this.property.possiblyEvaluate(this,t,e,r)}}class Wo{constructor(t,e,r){this.property=t,this.value=new Ko(t,void 0,e,r);}transitioned(t,e){return new Qo(this.property,this.value,e,er({},t.transition,this.transition),t.now)}untransitioned(){return new Qo(this.property,this.value,null,{},0)}}class Jo{constructor(t,e,r){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._scope=e,this._options=r,this.isConfigDependent=!1;}getValue(t){return hr(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Wo(this._values[t].property,this._scope,this._options)),this._values[t].value=new Ko(this._values[t].property,null===e?void 0:hr(e),this._scope,this._options),this.isConfigDependent=this.isConfigDependent||this._values[t].value.expression.isConfigDependent;}setTransitionOrValue(t,e){e&&(this._options=e);const r=this._properties.properties;if(t)for(const e in t){const n=t[e];if(lr(e,\"-transition\")){const t=e.slice(0,-11);r[t]&&this.setTransition(t,n);}else r.hasOwnProperty(e)&&this.setValue(e,n);}}getTransition(t){return hr(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Wo(this._values[t].property)),this._values[t].transition=hr(e)||void 0;}serialize(){const t={};for(const e of Object.keys(this._values)){const r=this.getValue(e);void 0!==r&&(t[e]=r);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n);}return t}transitioned(t,e){const r=new tl(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].transitioned(t,e._values[n]);return r}untransitioned(){const t=new tl(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Qo{constructor(t,e,r,n,i){const s=n.delay||0,a=n.duration||0;i=i||0,this.property=t,this.value=e,this.begin=i+s,this.end=this.begin+a,t.specification.transition&&(n.delay||n.duration)&&(this.prior=r);}possiblyEvaluate(t,e,r){const n=t.now||0,i=this.value.possiblyEvaluate(t,e,r),s=this.prior;if(s){if(n>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(n\":1,\">=\":1,\"<\":1,\"<=\":1,\"in\":1,\"!in\":1,\"all\":1,\"any\":1,\"none\":1,\"has\":1,\"!has\":1}},\"geometry_type\":{\"type\":\"enum\",\"values\":{\"Point\":1,\"LineString\":1,\"Polygon\":1}},\"function\":{\"expression\":{\"type\":\"expression\"},\"stops\":{\"type\":\"array\",\"value\":\"function_stop\"},\"base\":{\"type\":\"number\",\"default\":1,\"minimum\":0},\"property\":{\"type\":\"string\",\"default\":\"$zoom\"},\"type\":{\"type\":\"enum\",\"values\":{\"identity\":1,\"exponential\":1,\"interval\":1,\"categorical\":1},\"default\":\"exponential\"},\"colorSpace\":{\"type\":\"enum\",\"values\":{\"rgb\":1,\"lab\":1,\"hcl\":1},\"default\":\"rgb\"},\"default\":{\"type\":\"*\",\"required\":false}},\"function_stop\":{\"type\":\"array\",\"minimum\":0,\"maximum\":24,\"value\":[\"number\",\"color\"],\"length\":2},\"expression\":{\"type\":\"array\",\"value\":\"*\",\"minimum\":1},\"fog\":{\"range\":{\"type\":\"array\",\"default\":[0.5,10],\"minimum\":-20,\"maximum\":20,\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true},\"transition\":true},\"high-color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#245cdf\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true},\"transition\":true},\"space-color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":[\"interpolate\",[\"linear\"],[\"zoom\"],4,\"#010b19\",7,\"#367ab9\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true},\"transition\":true},\"horizon-blend\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":[\"interpolate\",[\"linear\"],[\"zoom\"],4,0.2,7,0.1],\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true},\"transition\":true},\"star-intensity\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":[\"interpolate\",[\"linear\"],[\"zoom\"],5,0.35,6,0],\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true},\"transition\":true},\"vertical-range\":{\"type\":\"array\",\"default\":[0,0],\"minimum\":0,\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"],\"relaxZoomRestriction\":true}}},\"camera\":{\"camera-projection\":{\"type\":\"enum\",\"values\":{\"perspective\":1,\"orthographic\":1},\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"default\":\"perspective\",\"property-type\":\"data-constant\"}},\"colorTheme\":{\"data\":{\"type\":\"string\",\"property-type\":\"data-constant\",\"expression\":{}}},\"light\":{\"anchor\":{\"type\":\"enum\",\"default\":\"viewport\",\"values\":{\"map\":1,\"viewport\":1},\"property-type\":\"data-constant\",\"expression\":{\"parameters\":[\"zoom\"]}},\"position\":{\"type\":\"array\",\"default\":[1.15,210,30],\"length\":3,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"color\":{\"type\":\"color\",\"property-type\":\"data-constant\",\"default\":\"#ffffff\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"intensity\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"projection\":{\"name\":{\"type\":\"enum\",\"values\":{\"albers\":1,\"equalEarth\":1,\"equirectangular\":1,\"lambertConformalConic\":1,\"mercator\":1,\"naturalEarth\":1,\"winkelTripel\":1,\"globe\":1},\"default\":\"mercator\",\"required\":true},\"center\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"minimum\":[-180,-90],\"maximum\":[180,90]},\"parallels\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"minimum\":[-90,-90],\"maximum\":[90,90]}},\"terrain\":{\"source\":{\"type\":\"string\",\"required\":true},\"exaggeration\":{\"type\":\"number\",\"property-type\":\"data-constant\",\"default\":1,\"minimum\":0,\"maximum\":1000,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true}},\"paint\":[\"paint_fill\",\"paint_line\",\"paint_circle\",\"paint_heatmap\",\"paint_fill-extrusion\",\"paint_symbol\",\"paint_raster\",\"paint_raster-particle\",\"paint_hillshade\",\"paint_background\",\"paint_sky\",\"paint_model\"],\"paint_fill\":{\"fill-antialias\":{\"type\":\"boolean\",\"default\":true,\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"fill-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"fill-outline-color\":{\"type\":\"color\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"fill-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-pattern\":{\"type\":\"resolvedImage\",\"expression\":{\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"fill-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"}},\"paint_fill-extrusion\":{\"fill-extrusion-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-pattern\":{\"type\":\"resolvedImage\",\"expression\":{\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-height\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-base\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"fill-extrusion-vertical-gradient\":{\"type\":\"boolean\",\"default\":true,\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"fill-extrusion-ambient-occlusion-intensity\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"private\":true,\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"fill-extrusion-ambient-occlusion-radius\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"private\":true,\"default\":3,\"minimum\":0,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"fill-extrusion-ambient-occlusion-wall-radius\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":3,\"minimum\":0,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"fill-extrusion-ambient-occlusion-ground-radius\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":3,\"minimum\":0,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true},\"fill-extrusion-ambient-occlusion-ground-attenuation\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":0.69,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"fill-extrusion-flood-light-color\":{\"property-type\":\"data-constant\",\"type\":\"color\",\"experimental\":true,\"default\":\"#ffffff\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]}},\"fill-extrusion-flood-light-intensity\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":0,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]}},\"fill-extrusion-flood-light-wall-radius\":{\"property-type\":\"data-driven\",\"type\":\"number\",\"experimental\":true,\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\"]}},\"fill-extrusion-flood-light-ground-radius\":{\"property-type\":\"data-driven\",\"type\":\"number\",\"experimental\":true,\"default\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\"]}},\"fill-extrusion-flood-light-ground-attenuation\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":0.69,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"fill-extrusion-vertical-scale\":{\"property-type\":\"data-constant\",\"type\":\"number\",\"experimental\":true,\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"fill-extrusion-rounded-roof\":{\"property-type\":\"data-constant\",\"type\":\"boolean\",\"default\":true,\"experimental\":true,\"expression\":{\"parameters\":[\"zoom\"]}},\"fill-extrusion-cutoff-fade-range\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"},\"fill-extrusion-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"}},\"paint_line\":{\"line-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"line-width\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-gap-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-offset\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"line-dasharray\":{\"type\":\"array\",\"value\":\"number\",\"minimum\":0,\"expression\":{\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-pattern\":{\"type\":\"resolvedImage\",\"expression\":{\"parameters\":[\"zoom\",\"feature\"]},\"property-type\":\"data-driven\"},\"line-gradient\":{\"type\":\"color\",\"expression\":{\"interpolated\":true,\"parameters\":[\"line-progress\"]},\"property-type\":\"color-ramp\"},\"line-trim-offset\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"minimum\":[0,0],\"maximum\":[1,1],\"property-type\":\"constant\"},\"line-trim-fade-range\":{\"type\":\"array\",\"value\":\"number\",\"experimental\":true,\"length\":2,\"default\":[0,0],\"minimum\":[0,0],\"maximum\":[1,1],\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"line-trim-color\":{\"type\":\"color\",\"experimental\":true,\"default\":\"transparent\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"line-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"line-border-width\":{\"type\":\"number\",\"private\":true,\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-border-color\":{\"type\":\"color\",\"private\":true,\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\"]},\"property-type\":\"data-driven\"},\"line-occlusion-opacity\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"experimental\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"transition\":true,\"property-type\":\"data-constant\"}},\"paint_circle\":{\"circle-radius\":{\"type\":\"number\",\"default\":5,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-blur\":{\"type\":\"number\",\"default\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-scale\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-pitch-alignment\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"viewport\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"circle-stroke-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-stroke-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-stroke-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"circle-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"}},\"paint_heatmap\":{\"heatmap-radius\":{\"type\":\"number\",\"default\":30,\"minimum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"heatmap-weight\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"heatmap-intensity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"heatmap-color\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"heatmap-density\"],0,\"rgba(0, 0, 255, 0)\",0.1,\"royalblue\",0.3,\"cyan\",0.5,\"lime\",0.7,\"yellow\",1,\"red\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"heatmap-density\"]},\"property-type\":\"color-ramp\"},\"heatmap-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_symbol\":{\"icon-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-occlusion-opacity\":{\"type\":\"number\",\"minimum\":0,\"maximum\":1,\"default\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-emissive-strength\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-emissive-strength\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"icon-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-image-cross-fade\":{\"type\":\"number\",\"property-type\":\"data-driven\",\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"transition\":true},\"text-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-occlusion-opacity\":{\"type\":\"number\",\"minimum\":0,\"maximum\":1,\"default\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"overridable\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-halo-color\":{\"type\":\"color\",\"default\":\"rgba(0, 0, 0, 0)\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-halo-width\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-halo-blur\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"feature\",\"feature-state\",\"measure-light\"]},\"property-type\":\"data-driven\"},\"text-translate\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"default\":[0,0],\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"text-translate-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"map\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"icon-color-saturation\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"},\"icon-color-contrast\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"},\"icon-color-brightness-min\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"},\"icon-color-brightness-max\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"}},\"paint_raster\":{\"raster-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-color\":{\"type\":\"color\",\"expression\":{\"interpolated\":true,\"parameters\":[\"raster-value\"]},\"property-type\":\"color-ramp\"},\"raster-color-mix\":{\"type\":\"array\",\"default\":[0.2126,0.7152,0.0722,0],\"length\":4,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"raster-color-range\":{\"type\":\"array\",\"length\":2,\"value\":\"number\",\"property-type\":\"data-constant\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]}},\"raster-hue-rotate\":{\"type\":\"number\",\"default\":0,\"period\":360,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-min\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-brightness-max\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-saturation\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-contrast\":{\"type\":\"number\",\"default\":0,\"minimum\":-1,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-resampling\":{\"type\":\"enum\",\"values\":{\"linear\":1,\"nearest\":1},\"default\":\"linear\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-fade-duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"raster-array-band\":{\"type\":\"string\",\"required\":false,\"experimental\":true,\"property-type\":\"data-constant\"},\"raster-elevation\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"experimental\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_raster-particle\":{\"raster-particle-array-band\":{\"type\":\"string\",\"required\":false,\"property-type\":\"data-constant\"},\"raster-particle-count\":{\"type\":\"number\",\"default\":512,\"minimum\":1,\"property-type\":\"data-constant\"},\"raster-particle-color\":{\"type\":\"color\",\"expression\":{\"interpolated\":true,\"parameters\":[\"raster-particle-speed\"]},\"property-type\":\"color-ramp\"},\"raster-particle-max-speed\":{\"type\":\"number\",\"default\":1,\"minimum\":1,\"property-type\":\"data-constant\"},\"raster-particle-speed-factor\":{\"type\":\"number\",\"default\":0.2,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-particle-fade-opacity-factor\":{\"type\":\"number\",\"default\":0.98,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"raster-particle-reset-rate-factor\":{\"type\":\"number\",\"default\":0.8,\"minimum\":0,\"maximum\":1,\"property-type\":\"data-constant\"}},\"paint_hillshade\":{\"hillshade-illumination-direction\":{\"type\":\"number\",\"default\":335,\"minimum\":0,\"maximum\":359,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-illumination-anchor\":{\"type\":\"enum\",\"values\":{\"map\":1,\"viewport\":1},\"default\":\"viewport\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-exaggeration\":{\"type\":\"number\",\"default\":0.5,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"hillshade-shadow-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"hillshade-highlight-color\":{\"type\":\"color\",\"default\":\"#FFFFFF\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"hillshade-accent-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"},\"hillshade-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"}},\"paint_background\":{\"background-color\":{\"type\":\"color\",\"default\":\"#000000\",\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"background-pattern\":{\"type\":\"resolvedImage\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"background-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"background-emissive-strength\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\",\"measure-light\"]},\"property-type\":\"data-constant\"}},\"paint_sky\":{\"sky-type\":{\"type\":\"enum\",\"values\":{\"gradient\":1,\"atmosphere\":1},\"default\":\"atmosphere\",\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun\":{\"type\":\"array\",\"value\":\"number\",\"length\":2,\"minimum\":[0,0],\"maximum\":[360,180],\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-atmosphere-sun-intensity\":{\"type\":\"number\",\"default\":10,\"minimum\":0,\"maximum\":100,\"property-type\":\"data-constant\"},\"sky-gradient-center\":{\"type\":\"array\",\"value\":\"number\",\"default\":[0,0],\"length\":2,\"minimum\":[0,0],\"maximum\":[360,180],\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient-radius\":{\"type\":\"number\",\"default\":90,\"minimum\":0,\"maximum\":180,\"expression\":{\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"sky-gradient\":{\"type\":\"color\",\"default\":[\"interpolate\",[\"linear\"],[\"sky-radial-progress\"],0.8,\"#87ceeb\",1,\"white\"],\"expression\":{\"interpolated\":true,\"parameters\":[\"sky-radial-progress\"]},\"property-type\":\"color-ramp\"},\"sky-atmosphere-halo-color\":{\"type\":\"color\",\"default\":\"white\",\"property-type\":\"data-constant\"},\"sky-atmosphere-color\":{\"type\":\"color\",\"default\":\"white\",\"property-type\":\"data-constant\"},\"sky-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"}},\"paint_model\":{\"model-opacity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"transition\":true,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\"},\"model-rotation\":{\"type\":\"array\",\"value\":\"number\",\"length\":3,\"default\":[0,0,0],\"period\":360,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"zoom\"]},\"transition\":true},\"model-scale\":{\"type\":\"array\",\"value\":\"number\",\"length\":3,\"default\":[1,1,1],\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"zoom\"]},\"transition\":true},\"model-translation\":{\"type\":\"array\",\"value\":\"number\",\"length\":3,\"default\":[0,0,0],\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"zoom\"]},\"transition\":true},\"model-color\":{\"type\":\"color\",\"default\":\"#ffffff\",\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"measure-light\",\"zoom\"]},\"transition\":true},\"model-color-mix-intensity\":{\"type\":\"number\",\"property-type\":\"data-driven\",\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"measure-light\"]},\"transition\":true},\"model-type\":{\"type\":\"enum\",\"values\":{\"common-3d\":1,\"location-indicator\":1},\"default\":\"common-3d\",\"property-type\":\"data-constant\"},\"model-cast-shadows\":{\"type\":\"boolean\",\"default\":true,\"expression\":{},\"property-type\":\"data-constant\"},\"model-receive-shadows\":{\"type\":\"boolean\",\"default\":true,\"expression\":{},\"property-type\":\"data-constant\"},\"model-ambient-occlusion-intensity\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"property-type\":\"data-constant\",\"transition\":true},\"model-emissive-strength\":{\"type\":\"number\",\"property-type\":\"data-driven\",\"default\":0,\"minimum\":0,\"maximum\":5,\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"measure-light\"]},\"transition\":true},\"model-roughness\":{\"type\":\"number\",\"default\":1,\"minimum\":0,\"maximum\":1,\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\"]},\"transition\":true},\"model-height-based-emissive-strength-multiplier\":{\"type\":\"array\",\"default\":[1,1,1,1,0],\"length\":5,\"value\":\"number\",\"property-type\":\"data-driven\",\"expression\":{\"interpolated\":true,\"parameters\":[\"feature\",\"feature-state\",\"measure-light\"]},\"transition\":true},\"model-cutoff-fade-range\":{\"type\":\"number\",\"default\":0,\"minimum\":0,\"maximum\":1,\"expression\":{},\"property-type\":\"data-constant\"},\"model-front-cutoff\":{\"type\":\"array\",\"private\":true,\"value\":\"number\",\"property-type\":\"data-constant\",\"expression\":{\"interpolated\":true,\"parameters\":[\"zoom\"]},\"length\":3,\"default\":[0,0,1],\"minimum\":[0,0,0],\"maximum\":[1,1,1]}},\"transition\":{\"duration\":{\"type\":\"number\",\"default\":300,\"minimum\":0},\"delay\":{\"type\":\"number\",\"default\":0,\"minimum\":0}},\"property-type\":{\"data-driven\":{\"type\":\"property-type\"},\"color-ramp\":{\"type\":\"property-type\"},\"data-constant\":{\"type\":\"property-type\"},\"constant\":{\"type\":\"property-type\"}},\"promoteId\":{\"*\":{\"type\":\"string\"}}}');function ul(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function cl(t){if(Array.isArray(t))return t.map(cl);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const r in t)e[r]=cl(t[r]);return e}return ul(t)}function hl(t){if(!0===t||!1===t)return !0;if(!Array.isArray(t)||0===t.length)return !1;switch(t[0]){case\"has\":return t.length>=2&&\"$id\"!==t[1]&&\"$type\"!==t[1];case\"in\":return t.length>=3&&(\"string\"!=typeof t[1]||Array.isArray(t[2]));case\"!in\":case\"!has\":case\"none\":return !1;case\"==\":case\"!=\":case\">\":case\">=\":case\"<\":case\"<=\":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case\"any\":case\"all\":for(const e of t.slice(1))if(!hl(e)&&\"boolean\"!=typeof e)return !1;return !0;default:return !0}}function pl(t,e=\"fill\"){if(null==t)return {filter:()=>!0,needGeometry:!1,needFeature:!1};hl(t)||(t=bl(t));const r=t;let n=!0;try{n=function(t){if(!ml(t))return t;let e=cl(t);return dl(e),e=fl(e),e}(r);}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\\nand paste the contents of this message in the report.\\nThank you!\\nFilter Expression:\\n${JSON.stringify(r,null,2)}\\n `);}const i=ll[`filter_${e}`],s=ho(n,i);let a=null;if(\"error\"===s.result)throw new Error(s.value.map((t=>`${t.key}: ${t.message}`)).join(\", \"));a=(t,e,r)=>s.value.evaluate(t,e,{},r);let o=null,l=null;if(n!==r){const t=ho(r,i);if(\"error\"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(\", \"));o=(e,r,n,i,s)=>t.value.evaluate(e,r,{},n,void 0,void 0,i,s),l=!Ys(t.value.expression);}return {filter:a,dynamicFilter:o||void 0,needGeometry:xl(n),needFeature:!!l}}function fl(t){if(!Array.isArray(t))return t;const e=function(t){if(yl.has(t[0]))for(let e=1;efl(t)))}function dl(t){let e=!1;const r=[];if(\"case\"===t[0]){for(let n=1;n\",\">=\",\"<\",\"<=\",\"to-boolean\"]);function gl(t,e){return te?1:0}function xl(t){if(!Array.isArray(t))return !1;if(\"within\"===t[0]||\"distance\"===t[0])return !0;for(let e=1;e\"===e||\"<=\"===e||\">=\"===e?vl(t[1],t[2],e):\"any\"===e?(r=t.slice(1),[\"any\"].concat(r.map(bl))):\"all\"===e?[\"all\"].concat(t.slice(1).map(bl)):\"none\"===e?[\"all\"].concat(t.slice(1).map(bl).map(Ml)):\"in\"===e?_l(t[1],t.slice(2)):\"!in\"===e?Ml(_l(t[1],t.slice(2))):\"has\"===e?wl(t[1]):\"!has\"!==e||Ml(wl(t[1]));var r;}function vl(t,e,r){switch(t){case\"$type\":return [`filter-type-${r}`,e];case\"$id\":return [`filter-id-${r}`,e];default:return [`filter-${r}`,t,e]}}function _l(t,e){if(0===e.length)return !1;switch(t){case\"$type\":return [\"filter-type-in\",[\"literal\",e]];case\"$id\":return [\"filter-id-in\",[\"literal\",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?[\"filter-in-large\",t,[\"literal\",e.sort(gl)]]:[\"filter-in-small\",t,[\"literal\",e]]}}function wl(t){switch(t){case\"$type\":return !0;case\"$id\":return [\"filter-has-id\"];default:return [\"filter-has\",t]}}function Ml(t){return [\"!\",t]}const Al=\"\u001f\";function Sl(t,e){return e?`${t}${Al}${e}`:t}const Il=\"-transition\",Tl=new Set([\"fill\",\"line\",\"background\",\"hillshade\",\"raster\"]);class kl extends Ln{constructor(t,e,r,n,i){if(super(),this.id=t.id,this.fqid=Sl(this.id,r),this.type=t.type,this.scope=r,this.lut=n,this.options=i,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.isConfigDependent=!1,\"custom\"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,\"background\"!==t.type&&\"sky\"!==t.type&&\"slot\"!==t.type&&(this.source=t.source,this.sourceLayer=t[\"source-layer\"],this.filter=t.filter),t.slot&&(this.slot=t.slot),e.layout&&(this._unevaluatedLayout=new el(e.layout,this.scope,i),this.isConfigDependent=this.isConfigDependent||this._unevaluatedLayout.isConfigDependent),e.paint)){this._transitionablePaint=new Jo(e.paint,this.scope,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e]);for(const e in t.layout)this.setLayoutProperty(e,t.layout[e]);this.isConfigDependent=this.isConfigDependent||this._transitionablePaint.isConfigDependent,this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new nl(e.paint);}}onAdd(t){}onRemove(t){}isDraped(t){return Tl.has(this.type)}getLayoutProperty(t){return \"visibility\"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e){if(\"custom\"===this.type&&\"visibility\"===t)return void(this.visibility=e);const r=this._unevaluatedLayout;r._properties.properties[t]&&(r.setValue(t,e),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,\"visibility\"===t&&this.possiblyEvaluateVisibility());}possiblyEvaluateVisibility(){this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0});}getPaintProperty(t){return lr(t,Il)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e){const r=this._transitionablePaint,n=r._properties.properties;if(lr(t,Il)){const i=t.slice(0,-11);return n[i]&&r.setTransition(i,e||void 0),!1}if(!n[t])return !1;const i=r._values[t],s=i.value.isDataDriven(),a=i.value;r.setValue(t,e),this.isConfigDependent=this.isConfigDependent||r.isConfigDependent,this._handleSpecialPaintPropertyUpdate(t);const o=r._values[t].value,l=o.isDataDriven(),u=lr(t,\"pattern\")||\"line-dasharray\"===t;return l||s||u||this._handleOverridablePaintPropertyUpdate(t,a,o)}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getDefaultProgramParams(t,e,r){return null}_handleOverridablePaintPropertyUpdate(t,e,r){return !1}isHidden(t){return !!(this.minzoom&&t=this.maxzoom)||\"none\"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint);}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e);}serialize(){return cr({id:this.id,type:this.type,slot:this.slot,source:this.source,\"source-layer\":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()},((t,e)=>!(void 0===t||\"layout\"===e&&!Object.keys(t).length||\"paint\"===e&&!Object.keys(t).length)))}is3D(){return !1}isSky(){return !1}isTileClipped(){return !1}hasOffscreenPass(){return !1}hasShadowPass(){return !1}canCastShadows(){return !1}hasLightBeamPass(){return !1}cutoffRange(){return 0}tileCoverLift(){return 0}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof rl&&Wa(e.property.specification)&&(\"source\"===e.value.kind||\"composite\"===e.value.kind)&&e.value.isStateDependent)return !0}return !1}compileFilter(){this._filterCompiled||(this._featureFilter=pl(this.filter),this._filterCompiled=!0);}invalidateCompiledFilter(){this._filterCompiled=!1;}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}getLayerRenderingStats(){return this._stats}resetLayerRenderingStats(t){this._stats&&(\"shadow\"===t.renderPass?this._stats.numRenderedVerticesInShadowPass=0:this._stats.numRenderedVerticesInTransparentPass=0);}queryRadius(t){}queryIntersectsFeature(t,e,r,n,i,s,a,o,l){}queryIntersectsMatchingFeature(t,e,r,n){}}const Pl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class zl{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8;}}class El{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0);}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.add(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_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(t){this.reserve(t),this.length=t;}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e);}}_refreshViews(){throw new Error(\"StructArray#_refreshViews() must be implemented by each concrete StructArray layout\")}emplace(...t){throw new Error(\"StructArray#emplace() must be implemented by each concrete StructArray layout\")}emplaceBack(...t){throw new Error(\"StructArray#emplaceBack() must be implemented by each concrete StructArray layout\")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null;}}function Bl(t,e=1){let r=0,n=0;return {members:t.map((t=>{const i=Pl[t.type].BYTES_PER_ELEMENT,s=r=Dl(r,Math.max(e,i)),a=t.components||1;return n=Math.max(n,i),r+=i*a,{name:t.name,type:t.type,components:a,offset:s}})),size:Dl(r,Math.max(n,e)),alignment:e}}function Dl(t,e){return Math.ceil(t/e)*e}class Cl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=r,t}}Cl.prototype.bytesPerElement=4,Mo(Cl,\"StructArrayLayout2i4\");class Rl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.int16[i+0]=e,this.int16[i+1]=r,this.int16[i+2]=n,t}}Rl.prototype.bytesPerElement=6,Mo(Rl,\"StructArrayLayout3i6\");class Vl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.int16[s+0]=e,this.int16[s+1]=r,this.int16[s+2]=n,this.int16[s+3]=i,t}}Vl.prototype.bytesPerElement=8,Mo(Vl,\"StructArrayLayout4i8\");class Ll extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=5*t;return this.int16[a+0]=e,this.int16[a+1]=r,this.int16[a+2]=n,this.int16[a+3]=i,this.int16[a+4]=s,t}}Ll.prototype.bytesPerElement=10,Mo(Ll,\"StructArrayLayout5i10\");class Ol extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=6*t,u=12*t,c=3*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.uint8[u+4]=n,this.uint8[u+5]=i,this.uint8[u+6]=s,this.uint8[u+7]=a,this.float32[c+2]=o,t}}Ol.prototype.bytesPerElement=12,Mo(Ol,\"StructArrayLayout2i4ub1f12\");class Fl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.float32[s+0]=e,this.float32[s+1]=r,this.float32[s+2]=n,this.float32[s+3]=i,t}}Fl.prototype.bytesPerElement=16,Mo(Fl,\"StructArrayLayout4f16\");class Ul extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.float32[i+0]=e,this.float32[i+1]=r,this.float32[i+2]=n,t}}Ul.prototype.bytesPerElement=12,Mo(Ul,\"StructArrayLayout3f12\");class Nl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=6*t,o=3*t;return this.uint16[a+0]=e,this.uint16[a+1]=r,this.uint16[a+2]=n,this.uint16[a+3]=i,this.float32[o+2]=s,t}}Nl.prototype.bytesPerElement=12,Mo(Nl,\"StructArrayLayout4ui1f12\");class jl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=4*t;return this.uint16[s+0]=e,this.uint16[s+1]=r,this.uint16[s+2]=n,this.uint16[s+3]=i,t}}jl.prototype.bytesPerElement=8,Mo(jl,\"StructArrayLayout4ui8\");class ql extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.int16[o+3]=i,this.int16[o+4]=s,this.int16[o+5]=a,t}}ql.prototype.bytesPerElement=12,Mo(ql,\"StructArrayLayout6i12\");class $l extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,r,n,i,s,a,o,l,u,c,h)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=12*t;return this.int16[f+0]=e,this.int16[f+1]=r,this.int16[f+2]=n,this.int16[f+3]=i,this.uint16[f+4]=s,this.uint16[f+5]=a,this.uint16[f+6]=o,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=p,t}}$l.prototype.bytesPerElement=24,Mo($l,\"StructArrayLayout4i4ui4i24\");class Gl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,r,n,i,s)}emplace(t,e,r,n,i,s,a){const o=10*t,l=5*t;return this.int16[o+0]=e,this.int16[o+1]=r,this.int16[o+2]=n,this.float32[l+2]=i,this.float32[l+3]=s,this.float32[l+4]=a,t}}Gl.prototype.bytesPerElement=20,Mo(Gl,\"StructArrayLayout3i3f20\");class Yl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Yl.prototype.bytesPerElement=4,Mo(Yl,\"StructArrayLayout1ul4\");class Xl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Xl.prototype.bytesPerElement=4,Mo(Xl,\"StructArrayLayout1f4\");class Zl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=r,t}}Zl.prototype.bytesPerElement=4,Mo(Zl,\"StructArrayLayout2ui4\");class Hl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,r,n,i,s,a,o,l,u,c,h,p)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f){const d=20*t,m=10*t;return this.int16[d+0]=e,this.int16[d+1]=r,this.int16[d+2]=n,this.int16[d+3]=i,this.int16[d+4]=s,this.float32[m+3]=a,this.float32[m+4]=o,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[d+14]=c,this.uint32[m+8]=h,this.uint16[d+18]=p,this.uint16[d+19]=f,t}}Hl.prototype.bytesPerElement=40,Mo(Hl,\"StructArrayLayout5i4f1i1ul2ui40\");class Kl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=r,this.int16[l+2]=n,this.int16[l+4]=i,this.int16[l+5]=s,this.int16[l+6]=a,this.int16[l+7]=o,t}}Kl.prototype.bytesPerElement=16,Mo(Kl,\"StructArrayLayout3i2i2i16\");class Wl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.int16[o+6]=i,this.int16[o+7]=s,t}}Wl.prototype.bytesPerElement=16,Mo(Wl,\"StructArrayLayout2f1f2i16\");class Jl extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=12*t,a=3*t;return this.uint8[s+0]=e,this.uint8[s+1]=r,this.float32[a+1]=n,this.float32[a+2]=i,t}}Jl.prototype.bytesPerElement=12,Mo(Jl,\"StructArrayLayout2ub2f12\");class Ql extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,r)}emplace(t,e,r,n){const i=3*t;return this.uint16[i+0]=e,this.uint16[i+1]=r,this.uint16[i+2]=n,t}}Ql.prototype.bytesPerElement=6,Mo(Ql,\"StructArrayLayout3ui6\");class tu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_){const w=30*t,M=15*t,A=60*t;return this.int16[w+0]=e,this.int16[w+1]=r,this.int16[w+2]=n,this.float32[M+2]=i,this.float32[M+3]=s,this.uint16[w+8]=a,this.uint16[w+9]=o,this.uint32[M+5]=l,this.uint32[M+6]=u,this.uint32[M+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=f,this.float32[M+10]=d,this.float32[M+11]=m,this.uint8[A+48]=y,this.uint8[A+49]=g,this.uint8[A+50]=x,this.uint32[M+13]=b,this.int16[w+28]=v,this.uint8[A+58]=_,t}}tu.prototype.bytesPerElement=60,Mo(tu,\"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60\");class eu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I,T,k,P,z,E,B,D){const C=this.length;return this.resize(C+1),this.emplace(C,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I,T,k,P,z,E,B,D)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I,T,k,P,z,E,B,D,C){const R=22*t,V=44*t,L=88*t;return this.float32[R+0]=e,this.float32[R+1]=r,this.int16[V+4]=n,this.int16[V+5]=i,this.int16[V+6]=s,this.int16[V+7]=a,this.int16[V+8]=o,this.int16[V+9]=l,this.int16[V+10]=u,this.int16[V+11]=c,this.int16[V+12]=h,this.uint16[V+13]=p,this.uint16[V+14]=f,this.uint16[V+15]=d,this.uint16[V+16]=m,this.uint16[V+17]=y,this.uint16[V+18]=g,this.uint16[V+19]=x,this.uint16[V+20]=b,this.uint16[V+21]=v,this.uint16[V+22]=_,this.uint16[V+23]=w,this.uint16[V+24]=M,this.uint16[V+25]=A,this.uint16[V+26]=S,this.uint16[V+27]=I,this.uint32[R+14]=T,this.float32[R+15]=k,this.float32[R+16]=P,this.float32[R+17]=z,this.float32[R+18]=E,this.float32[R+19]=B,this.float32[R+20]=D,this.uint8[L+84]=C,t}}eu.prototype.bytesPerElement=88,Mo(eu,\"StructArrayLayout2f9i15ui1ul6f1ub88\");class ru extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,r,n,i)}emplace(t,e,r,n,i,s){const a=5*t;return this.float32[a+0]=e,this.float32[a+1]=r,this.float32[a+2]=n,this.float32[a+3]=i,this.float32[a+4]=s,t}}ru.prototype.bytesPerElement=20,Mo(ru,\"StructArrayLayout5f20\");class nu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=7*t;return this.float32[l+0]=e,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=i,this.float32[l+4]=s,this.float32[l+5]=a,this.float32[l+6]=o,t}}nu.prototype.bytesPerElement=28,Mo(nu,\"StructArrayLayout7f28\");class iu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e){const r=this.length;return this.resize(r+1),this.emplace(r,t,e)}emplace(t,e,r){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=r,t}}iu.prototype.bytesPerElement=8,Mo(iu,\"StructArrayLayout2f8\");class su extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t,e,r,n){const i=this.length;return this.resize(i+1),this.emplace(i,t,e,r,n)}emplace(t,e,r,n,i){const s=6*t;return this.uint32[3*t+0]=e,this.uint16[s+2]=r,this.uint16[s+3]=n,this.uint16[s+4]=i,t}}su.prototype.bytesPerElement=12,Mo(su,\"StructArrayLayout1ul3ui12\");class au extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}au.prototype.bytesPerElement=2,Mo(au,\"StructArrayLayout1ui2\");class ou extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){const y=this.length;return this.resize(y+1),this.emplace(y,t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m)}emplace(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y){const g=16*t;return this.float32[g+0]=e,this.float32[g+1]=r,this.float32[g+2]=n,this.float32[g+3]=i,this.float32[g+4]=s,this.float32[g+5]=a,this.float32[g+6]=o,this.float32[g+7]=l,this.float32[g+8]=u,this.float32[g+9]=c,this.float32[g+10]=h,this.float32[g+11]=p,this.float32[g+12]=f,this.float32[g+13]=d,this.float32[g+14]=m,this.float32[g+15]=y,t}}ou.prototype.bytesPerElement=64,Mo(ou,\"StructArrayLayout16f64\");class lu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer);}emplaceBack(t,e,r,n,i,s,a){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,r,n,i,s,a)}emplace(t,e,r,n,i,s,a,o){const l=10*t,u=5*t;return this.uint16[l+0]=e,this.uint16[l+1]=r,this.uint16[l+2]=n,this.uint16[l+3]=i,this.float32[u+2]=s,this.float32[u+3]=a,this.float32[u+4]=o,t}}lu.prototype.bytesPerElement=20,Mo(lu,\"StructArrayLayout4ui3f20\");class uu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.int16[1*t+0]=e,t}}uu.prototype.bytesPerElement=2,Mo(uu,\"StructArrayLayout1i2\");class cu extends El{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer);}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint8[1*t+0]=e,t}}cu.prototype.bytesPerElement=1,Mo(cu,\"StructArrayLayout1ub1\");class hu extends zl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}hu.prototype.size=40;class pu extends Hl{get(t){return new hu(this,t)}}Mo(pu,\"CollisionBoxArray\");class fu extends zl{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t;}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t;}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t;}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t;}}fu.prototype.size=60;class du extends tu{get(t){return new fu(this,t)}}Mo(du,\"PlacedSymbolArray\");class mu extends zl{get tileAnchorX(){return this._structArray.float32[this._pos4+0]}get tileAnchorY(){return this._structArray.float32[this._pos4+1]}get projectedAnchorX(){return this._structArray.int16[this._pos2+4]}get projectedAnchorY(){return this._structArray.int16[this._pos2+5]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+6]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+7]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+11]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get key(){return this._structArray.uint16[this._pos2+13]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+14]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+15]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+17]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+19]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+21]}get featureIndex(){return this._structArray.uint16[this._pos2+22]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+23]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numIconVertices(){return this._structArray.uint16[this._pos2+25]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+26]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+27]}get crossTileID(){return this._structArray.uint32[this._pos4+14]}set crossTileID(t){this._structArray.uint32[this._pos4+14]=t;}get textOffset0(){return this._structArray.float32[this._pos4+15]}get textOffset1(){return this._structArray.float32[this._pos4+16]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+17]}get zOffset(){return this._structArray.float32[this._pos4+18]}set zOffset(t){this._structArray.float32[this._pos4+18]=t;}get occlusionState(){return this._structArray.float32[this._pos4+19]}set occlusionState(t){this._structArray.float32[this._pos4+19]=t;}get occlusionOpacity(){return this._structArray.float32[this._pos4+20]}set occlusionOpacity(t){this._structArray.float32[this._pos4+20]=t;}get hasIconTextFit(){return this._structArray.uint8[this._pos1+84]}}mu.prototype.size=88;class yu extends eu{get(t){return new mu(this,t)}}Mo(yu,\"SymbolInstanceArray\");class gu extends Xl{getoffsetX(t){return this.float32[1*t+0]}}Mo(gu,\"GlyphOffsetArray\");class xu extends Cl{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}Mo(xu,\"SymbolLineVertexArray\");class bu extends zl{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}bu.prototype.size=12;class vu extends su{get(t){return new bu(this,t)}}Mo(vu,\"FeatureIndexArray\");class _u extends Zl{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}Mo(_u,\"FillExtrusionCentroidArray\");const wu=Bl([{name:\"a_pos\",components:2,type:\"Int16\"}],4),Mu=Bl([{name:\"a_pos_3\",components:3,type:\"Int16\"},{name:\"a_pos_normal_3\",components:3,type:\"Int16\"}]);class Au{constructor(t=[]){this.segments=t;}_prepareSegment(t,e,r,n){let i=this.segments[this.segments.length-1];return t>Au.MAX_VERTEX_ARRAY_LENGTH&&fr(`Max vertices per segment is ${Au.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!i||i.vertexLength+t>Au.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==n)&&(i={vertexOffset:e,primitiveOffset:r,vertexLength:0,primitiveLength:0},void 0!==n&&(i.sortKey=n),this.segments.push(i)),i}prepareSegment(t,e,r,n){return this._prepareSegment(t,e.length,r.length,n)}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy();}static simpleSegment(t,e,r,n){return new Au([{vertexOffset:t,primitiveOffset:e,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}}function Su(t,e){return 256*(t=Ke(Math.floor(t),0,255))+Ke(Math.floor(e),0,255)}Au.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Mo(Au,\"SegmentVector\");const Iu=Bl([{name:\"a_pattern\",components:4,type:\"Uint16\"},{name:\"a_pixel_ratio\",components:1,type:\"Float32\"}]),Tu=Bl([{name:\"a_dash\",components:4,type:\"Uint16\"}]);class ku{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1;}add(t,e,r,n){this.ids.push(Pu(t)),this.positions.push(e,r,n);}eachPosition(t,e){const r=Pu(t);let n=0,i=this.ids.length-1;for(;n>1;this.ids[t]>=r?i=t:n=t+1;}for(;this.ids[n]===r;)e(this.positions[3*n],this.positions[3*n+1],this.positions[3*n+2]),n++;}static serialize(t,e){const r=new Float64Array(t.ids),n=new Uint32Array(t.positions);return zu(r,n,0,r.length-1),e&&(e.add(r.buffer),e.add(n.buffer)),{ids:r,positions:n}}static deserialize(t){const e=new ku;let r;e.ids=t.ids,e.positions=t.positions;for(const t of e.ids)t!==r&&e.uniqueIds.push(t),r=t;return e.indexed=!0,e}}function Pu(t){const e=+t;return !isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Bn(String(t))}function zu(t,e,r,n){for(;r>1];let s=r-1,a=n+1;for(;;){do{s++;}while(t[s]i);if(s>=a)break;Eu(t,s,a),Eu(e,3*s,3*a),Eu(e,3*s+1,3*a+1),Eu(e,3*s+2,3*a+2);}a-r`u_${t}`)),this.type=r,this.context=n;}setUniform(t,e,r,n,i){const s=n.constantOr(this.value);e.set(t,i,s instanceof qn?s.toRenderColor(this.context.lut):s);}getBinding(t,e){return \"color\"===this.type?new Ou(t):new Cu(t)}}class Yu{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1;}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br);}setUniform(t,e,r,n,i){const s=\"u_pattern\"===i||\"u_dash\"===i?this.pattern:\"u_pixel_ratio\"===i?this.pixelRatio:null;s&&e.set(t,i,s);}getBinding(t,e){return \"u_pattern\"===e||\"u_dash\"===e?new Lu(t):new Cu(t)}}class Xu{constructor(t,e,r,n){this.expression=t,this.type=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:\"Float32\",components:\"color\"===r?2:1,offset:0}))),this.paintVertexArray=new n;}populatePaintArray(t,e,r,n,i,s,a){const o=this.paintVertexArray.length,l=this.expression.evaluate(new Ho(0,{brightness:s}),e,{},i,n,a);this.paintVertexArray.resize(t),this._setPaintValue(o,t,l,this.context);}updatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate({zoom:0,brightness:a},r,n,void 0,i);this._setPaintValue(t,e,o,this.context);}_setPaintValue(t,e,r,n){if(\"color\"===this.type){const i=$u(r.toRenderColor(n.lut));for(let r=t;r`u_${t}_t`)),this.type=r,this.useIntegerZoom=n,this.context=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:\"Float32\",components:\"color\"===r?4:2,offset:0}))),this.paintVertexArray=new s;}populatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate(new Ho(this.context.zoom,{brightness:s}),e,{},i,n,a),l=this.expression.evaluate(new Ho(this.context.zoom+1,{brightness:s}),e,{},i,n,a),u=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(u,t,o,l,this.context);}updatePaintArray(t,e,r,n,i,s,a){const o=this.expression.evaluate({zoom:this.context.zoom,brightness:a},r,n,void 0,i),l=this.expression.evaluate({zoom:this.context.zoom+1,brightness:a},r,n,void 0,i);this._setPaintValue(t,e,o,l,this.context);}_setPaintValue(t,e,r,n,i){if(\"color\"===this.type){const n=$u(r.toRenderColor(i.lut)),s=$u(r.toRenderColor(i.lut));for(let r=t;r!0)){this.binders={},this._buffers=[],this.context=e;const n=[];for(const i in t.paint._values){const s=t.paint.get(i);if(!r(i))continue;if(!(s instanceof rl&&Wa(s.property.specification)))continue;const a=Qu(i,t.type),o=s.value,l=s.property.specification.type,u=!!s.property.useIntegerZoom,c=\"line-dasharray\"===i||i.endsWith(\"pattern\"),h=\"line-dasharray\"===i&&\"constant\"!==t.layout.get(\"line-cap\").value.kind;if(\"constant\"!==o.kind||h)if(\"source\"===o.kind||h||c){const e=rc(i,l,\"source\");this.binders[i]=c?new Hu(o,a,l,e,t.id):new Xu(o,a,l,e),n.push(`/a_${i}`);}else {const t=rc(i,l,\"composite\");this.binders[i]=new Zu(o,a,l,u,e,t),n.push(`/z_${i}`);}else this.binders[i]=c?new Yu(o.value,a):new Gu(o.value,a,l,e),n.push(`/u_${i}`);}this.cacheKey=n.sort().join(\"\");}getMaxValue(t){const e=this.binders[t];return e instanceof Xu||e instanceof Zu?e.maxValue:0}populatePaintArrays(t,e,r,n,i,s,a){for(const o in this.binders){const l=this.binders[o];l.context=this.context,(l instanceof Xu||l instanceof Zu||l instanceof Hu)&&l.populatePaintArray(t,e,r,n,i,s,a);}}setConstantPatternPositions(t){for(const e in this.binders){const r=this.binders[e];r instanceof Yu&&r.setConstantPatternPositions(t);}}updatePaintArrays(t,e,r,n,i,s,a,o){let l=!1;const u=Object.keys(t),c=0!==u.length,h=c?u:e.uniqueIds;this.context.lut=i.lut;for(const u in this.binders){const p=this.binders[u];if(p.context=this.context,(p instanceof Xu||p instanceof Zu||p instanceof Hu)&&(!0===p.expression.isStateDependent||!1===p.expression.isLightConstant)){const f=i.paint.get(u);p.expression=f.value;for(const r of h){const i=t[r.toString()];e.eachPosition(r,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,s,a,o);}));}if(!c)for(const e of r.uniqueIds){const i=t[e.toString()];r.eachPosition(e,((t,e,r)=>{const l=n.feature(t);p.updatePaintArray(e,r,l,i,s,a,o);}));}l=!0;}}return l}defines(){const t=[];for(const e in this.binders){const r=this.binders[e];(r instanceof Gu||r instanceof Yu)&&t.push(...r.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)));}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const r=this.binders[e];if(r instanceof Xu||r instanceof Zu||r instanceof Hu)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Ku(n,e,r);this.needsUpload=!1,this._featureMap=new ku,this._featureMapWithoutIds=new ku,this._bufferOffset=0,this._idlessCounter=0;}populatePaintArrays(t,e,r,n,i,s,a,o){for(const r in this.programConfigurations)this.programConfigurations[r].populatePaintArrays(t,e,n,i,s,a,o);void 0!==e.id?this._featureMap.add(e.id,r,this._bufferOffset,t):(this._featureMapWithoutIds.add(this._idlessCounter,r,this._bufferOffset,t),this._idlessCounter+=1),this._bufferOffset=t,this.needsUpload=!0;}updatePaintArrays(t,e,r,n,i,s){for(const a of r)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(t,this._featureMap,this._featureMapWithoutIds,e,a,n,i,s||0)||this.needsUpload;}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1;}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy();}}const Ju={\"text-opacity\":[\"opacity\"],\"icon-opacity\":[\"opacity\"],\"text-occlusion-opacity\":[\"occlusion_opacity\"],\"icon-occlusion-opacity\":[\"occlusion_opacity\"],\"text-color\":[\"fill_color\"],\"icon-color\":[\"fill_color\"],\"text-emissive-strength\":[\"emissive_strength\"],\"icon-emissive-strength\":[\"emissive_strength\"],\"text-halo-color\":[\"halo_color\"],\"icon-halo-color\":[\"halo_color\"],\"text-halo-blur\":[\"halo_blur\"],\"icon-halo-blur\":[\"halo_blur\"],\"text-halo-width\":[\"halo_width\"],\"icon-halo-width\":[\"halo_width\"],\"line-gap-width\":[\"gapwidth\"],\"line-pattern\":[\"pattern\",\"pixel_ratio\"],\"fill-pattern\":[\"pattern\",\"pixel_ratio\"],\"fill-extrusion-pattern\":[\"pattern\",\"pixel_ratio\"],\"line-dasharray\":[\"dash\"]};function Qu(t,e){return Ju[t]||[t.replace(`${e}-`,\"\").replace(/-/g,\"_\")]}const tc={\"line-pattern\":{source:Nl,composite:Nl},\"fill-pattern\":{source:Nl,composite:Nl},\"fill-extrusion-pattern\":{source:Nl,composite:Nl},\"line-dasharray\":{source:jl,composite:jl}},ec={color:{source:iu,composite:Fl},number:{source:Xl,composite:iu}};function rc(t,e,r){const n=tc[t];return n&&n[r]||ec[e][r]}Mo(Gu,\"ConstantBinder\"),Mo(Yu,\"PatternConstantBinder\"),Mo(Xu,\"SourceExpressionBinder\"),Mo(Hu,\"PatternCompositeBinder\"),Mo(Zu,\"CompositeExpressionBinder\"),Mo(Ku,\"ProgramConfiguration\",{omit:[\"_buffers\"]}),Mo(Wu,\"ProgramConfigurationSet\");const nc=ps/Math.PI/2,ic=5,sc=6,ac=16383,oc=64,lc=[oc,32,16],uc=-nc,cc=nc;function hc(t,e,r,n=nc){return r=$e(r),[t*Math.sin(r)*n,-e*n,t*Math.cos(r)*n]}function pc(t,e,r){return hc(Math.cos($e(t)),Math.sin($e(t)),e,r)}const fc=6371008.8,dc=2*Math.PI*fc;class mc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error(\"Invalid LngLat latitude value: must be between -90 and 90\")}wrap(){return new mc(Je(this.lng,-180,180),this.lat)}toArray(){return [this.lng,this.lat]}toString(){return `LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,r=this.lat*e,n=t.lat*e,i=Math.sin(r)*Math.sin(n)+Math.cos(r)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return fc*Math.acos(Math.min(i,1))}toBounds(t=0){const e=360*t/40075017,r=e/Math.cos(Math.PI/180*this.lat);return new yc({lng:this.lng-r,lat:this.lat-e},{lng:this.lng+r,lat:this.lat+e})}toEcef(t){return pc(this.lat,this.lng,nc+t*nc/fc)}static convert(t){if(t instanceof mc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new mc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&\"object\"==typeof t&&null!==t)return new mc(Number(\"lng\"in t?t.lng:t.lon),Number(t.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 [, ]\")}}class yc{constructor(t,e){if(t)if(e)this.setSouthWest(t).setNorthEast(e);else if(4===t.length){const e=t;this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]);}else {const e=t;this.setSouthWest(e[0]).setNorthEast(e[1]);}}setNorthEast(t){return this._ne=t instanceof mc?new mc(t.lng,t.lat):mc.convert(t),this}setSouthWest(t){return this._sw=t instanceof mc?new mc(t.lng,t.lat):mc.convert(t),this}extend(t){const e=this._sw,r=this._ne;let n,i;if(t instanceof mc)n=t,i=t;else {if(!(t instanceof yc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(yc.convert(t)):this.extend(mc.convert(t)):\"object\"==typeof t&&null!==t&&t.hasOwnProperty(\"lat\")&&(t.hasOwnProperty(\"lon\")||t.hasOwnProperty(\"lng\"))?this.extend(mc.convert(t)):this;if(n=t._sw,i=t._ne,!n||!i)return this}return e||r?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),r.lng=Math.max(i.lng,r.lng),r.lat=Math.max(i.lat,r.lat)):(this._sw=new mc(n.lng,n.lat),this._ne=new mc(i.lng,i.lat)),this}getCenter(){return new mc((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 mc(this.getWest(),this.getNorth())}getSouthEast(){return new mc(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(t){const{lng:e,lat:r}=mc.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}static convert(t){return !t||t instanceof yc?t:new yc(t)}}var gc={};!function(t,e){!function(t){function e(t,e,n){var i=r(256*t,256*(e=Math.pow(2,n)-e-1),n),s=r(256*(t+1),256*(e+1),n);return i[0]+\",\"+i[1]+\",\"+s[0]+\",\"+s[1]}function r(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}t.getURL=function(t,r,n,i,s,a){return a=a||{},t+\"?\"+[\"bbox=\"+e(n,i,s),\"format=\"+(a.format||\"image/png\"),\"service=\"+(a.service||\"WMS\"),\"version=\"+(a.version||\"1.1.1\"),\"request=\"+(a.request||\"GetMap\"),\"srs=\"+(a.srs||\"EPSG:3857\"),\"width=\"+(a.width||256),\"height=\"+(a.height||256),\"layers=\"+r].join(\"&\")},t.getTileBBox=e,t.getMercCoords=r,Object.defineProperty(t,\"__esModule\",{value:!0});}(e);}(0,gc);var xc=gc;class bc{constructor(t,e,r){this.z=t,this.x=e,this.y=r,this.key=wc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const r=xc.getTileBBox(this.x,this.y,this.z),n=function(t,e,r){let n,i=\"\";for(let s=t;s>0;s--)n=1<this.canonical.z?new _c(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new _c(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return wc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return wc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new _c(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new _c(e,this.wrap,e,r,n),new _c(e,this.wrap,e,r+1,n),new _c(e,this.wrap,e,r,n+1),new _c(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.y{let e=t.canonical.x-1,r=t.wrap;return e<0&&(e=(1<{let e=t.canonical.x+1,r=t.wrap;return e===1<new _c(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new _c(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<=l?(Fc(t,e,r,u,c,s,h,o,l),Fc(t,u,c,n,i,h,a,o,l)):t.push(a);}function Uc(t,e,r){let n=t[0],i=n.x,s=n.y;e(n);const a=[n];for(let o=1;ot.x+1||nt.y+1)&&fr(\"Geometry exceeds allowed extent, reduce your vector tile buffer size\"),t}function Yc(t,e,r){const n=t.loadGeometry(),i=t.extent,s=ps/i;if(e&&r&&r.projection.isReprojectedInTileSpace){const s=1<{const r=zc((e.x+t.x/i)/s),n=Ec((e.y+t.y/i)/s),c=u.project(r,n);t.x=(c.x*a-o)*i,t.y=(c.y*a-l)*i;};for(let e=0;e=i||r.y<0||r.y>=i||(c(r),t.push(r));n[e]=t;}}for(const t of n)for(const e of t)Gc(e,s);return n}function Xc(t,e){return {type:t.type,id:t.id,properties:t.properties,geometry:e?Yc(t):[]}}function Zc(t,e,r,n,i){t.emplaceBack(2*e+(n+1)/2,2*r+(i+1)/2);}function Hc(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class Kc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Cl,this.indexArray=new Ql,this.segments=new Au,this.programConfigurations=new Wu(t.layers,{zoom:t.zoom,lut:t.lut}),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}updateFootprints(t,e){}populate(t,e,r,n){const i=this.layers[0],s=[];let a=null;\"circle\"===i.type&&(a=i.layout.get(\"circle-sort-key\"));for(const{feature:e,id:i,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Xc(e,t);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),u,r))continue;const c=a?a.evaluate(u,{},r):void 0,h={id:i,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Yc(e,r,n),patterns:{},sortKey:c};s.push(h);}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));let o=null;\"globe\"===n.projection.name&&(this.globeExtVertexArray=new ql,o=n.projection);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n,l=t[s].feature;this.addFeature(n,i,s,e.availableImages,r,o,e.brightness),e.featureIndex.insert(l,i,s,a,this.index);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,wu.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Mu.members))),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}addFeature(t,e,r,n,i,s,a){for(const r of e)for(const e of r){const r=e.x,n=e.y;if(r<0||r>=ps||n<0||n>=ps)continue;if(s){const t=s.projectTilePoint(r,n,i),e=s.upVector(i,r,n),a=this.globeExtVertexArray;Hc(a,t,e),Hc(a,t,e),Hc(a,t,e),Hc(a,t,e);}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),o=a.vertexLength;Zc(this.layoutVertexArray,r,n,-1,-1),Zc(this.layoutVertexArray,r,n,1,-1),Zc(this.layoutVertexArray,r,n,1,1),Zc(this.layoutVertexArray,r,n,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+2,o+3),a.vertexLength+=4,a.primitiveLength+=2;}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,{},n,i,a);}}function Wc(t,e){for(let r=0;r1){if(eh(t,e))return !0;for(let n=0;n1?r:r.sub(e)._mult(i)._add(e))}function sh(t,e){let r,n,i,s=!1;for(let a=0;ae.y!=i.y>e.y&&e.x<(i.x-n.x)*(e.y-n.y)/(i.y-n.y)+n.x&&(s=!s);}return s}function ah(t,e){let r=!1;for(let n=0,i=t.length-1;ne.y!=a.y>e.y&&e.x<(a.x-s.x)*(e.y-s.y)/(a.y-s.y)+s.x&&(r=!r);}return r}function oh(t,e,r,n,i){for(const s of t)if(e<=s.x&&r<=s.y&&n>=s.x&&i>=s.y)return !0;const s=[new Ne(e,r),new Ne(e,i),new Ne(n,i),new Ne(n,r)];if(t.length>2)for(const e of s)if(ah(t,e))return !0;for(let e=0;ei.x&&e.x>i.x||t.yi.y&&e.y>i.y)return !1;const s=dr(t,e,r[0]);return s!==dr(t,e,r[1])||s!==dr(t,e,r[2])||s!==dr(t,e,r[3])}function uh(t,e,r,n,i,s){let a=e.y-t.y,o=t.x-e.x;if(s=s||0){const t=a*a+o*o;if(0===t)return !0;const e=Math.sqrt(t);a/=e,o/=e;}return !((r.x-t.x)*a+(r.y-t.y)*o-s<0||(n.x-t.x)*a+(n.y-t.y)*o-s<0||(i.x-t.x)*a+(i.y-t.y)*o-s<0)}function ch(t,e,r,n,i,s,a){return !(uh(t,e,n,i,s,a)||uh(e,r,n,i,s,a)||uh(r,t,n,i,s,a)||uh(n,i,t,e,r,a)||uh(i,s,t,e,r,a)||uh(s,n,t,e,r,a))}function hh(t,e,r){const n=e.paint.get(t).value;return \"constant\"===n.kind?n.value:r.programConfigurations.get(e.id).getMaxValue(t)}function ph(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function fh(t,e,r,n,i){if(!e[0]&&!e[1])return t;const s=Ne.convert(e)._mult(i);\"viewport\"===r&&s._rotate(-n);const a=[];for(let e=0;e=0;if(0===a)return 0;a!==r.length&&(n=!1);}return n?2:1}function _h(t,e){for(const r of t.projections){const n=bh(e,t.points[0],r.axis);if(r.projection[1]n[1])return 0}return 1}function wh(e,r){let n=0;const i=[0,0,0,0];for(let s=0;s=0&&n++;return n}class Mh{constructor(e,r){this.points=e||new Array(8).fill([0,0,0]),this.planes=r||new Array(6).fill([0,0,0,0]),this.bounds=Ah.fromPoints(this.points),this.projections=[],this.frustumEdges=[t._.sub([],this.points[2],this.points[3]),t._.sub([],this.points[0],this.points[3]),t._.sub([],this.points[4],this.points[0]),t._.sub([],this.points[5],this.points[1]),t._.sub([],this.points[6],this.points[2]),t._.sub([],this.points[7],this.points[3])];for(const t of this.frustumEdges){const e=[0,-t[2],t[1]],r=[t[2],0,-t[0]];this.projections.push({axis:e,projection:bh(this.points,this.points[0],e)}),this.projections.push({axis:r,projection:bh(this.points,this.points[0],r)});}}static fromInvProjectionMatrix(e,r,n,i){const s=Math.pow(2,n),a=[[-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=>{const a=t.aA.transformMat4([],n,e),o=1/a[3]/r*s;return t.aA.mul(a,a,[o,o,i?1/a[3]:o,o])})),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const r=t._.sub([],a[e[0]],a[e[1]]),n=t._.sub([],a[e[2]],a[e[1]]),i=t._.normalize([],t._.cross([],r,n)),s=-t._.dot(i,a[e[1]]);return i.concat(s)})),l=[];for(let t=0;to[1]||o[0]>a[1])return 0}return 1}}class Ah{static fromPoints(e){const r=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const i of e)t._.min(r,r,i),t._.max(n,n,i);return new Ah(r,n)}static fromTileIdAndHeight(t,e,r){const n=1<t.max[e]||t.min[e]>this.max[e])return !1;return !0}intersectsAabbXY(t){return !(this.min[0]>t.max[0]||t.min[0]>this.max[0]||this.min[1]>t.max[1]||t.min[1]>this.max[1])}encapsulate(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t.min[e]),this.max[e]=Math.max(this.max[e],t.max[e]);}encapsulatePoint(t){for(let e=0;e<3;e++)this.min[e]=Math.min(this.min[e],t[e]),this.max[e]=Math.max(this.max[e],t[e]);}closestPoint(t){return [Math.max(Math.min(this.max[0],t[0]),this.min[0]),Math.max(Math.min(this.max[1],t[1]),this.min[1]),Math.max(Math.min(this.max[2],t[2]),this.min[2])]}}Mo(Ah,\"Aabb\");const Sh=Bl([{type:\"Float32\",name:\"a_globe_pos\",components:3},{type:\"Float32\",name:\"a_uv\",components:2}]),{members:Ih}=Sh,Th=Bl([{name:\"a_pos_3\",components:3,type:\"Int16\"}]);var kh=Bl([{name:\"a_pos\",type:\"Int16\",components:2}]);function Ph(t){return t*nc/fc}const zh=[new Ah([uc,uc,uc],[cc,cc,cc]),new Ah([uc,uc,uc],[0,0,cc]),new Ah([0,uc,uc],[cc,0,cc]),new Ah([uc,0,uc],[0,cc,cc]),new Ah([0,0,uc],[cc,cc,cc])];function Eh(e,r,n,i=!0){const s=t._.scale([],e._camera.position,e.worldSize),a=[r,n,1,1];t.aA.transformMat4(a,a,e.pixelMatrixInverse),t.aA.scale(a,a,1/a[3]);const o=t._.sub([],a,s),l=t._.normalize([],o),u=e.globeMatrix,c=[u[12],u[13],u[14]],h=t._.sub([],c,s),p=t._.length(h),f=t._.normalize([],h),d=e.worldSize/(2*Math.PI),m=t._.dot(f,l),y=Math.asin(d/p);if(y1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,Ke(r,0,1))+t.center[e]}function Ch(t){if(t.z<=1)return zh[t.z+2*t.y+t.x];const e=Uh(Fh(t));return Ah.fromPoints(e)}function Rh(e,r,n){return t._.scale(e,e,1-n),t._.scaleAndAdd(e,e,r,n)}function Vh(e,r){const n=Hh(r.zoom);if(0===n)return Ch(e);const i=Fh(e),s=Uh(i),a=Tc(i.getWest())*r.worldSize,o=Tc(i.getEast())*r.worldSize,l=kc(i.getNorth())*r.worldSize,u=kc(i.getSouth())*r.worldSize,c=[a,l,0],h=[o,l,0],p=[a,u,0],f=[o,u,0],d=t.ad.invert([],r.globeMatrix);return t._.transformMat4(c,c,d),t._.transformMat4(h,h,d),t._.transformMat4(p,p,d),t._.transformMat4(f,f,d),s[0]=Rh(s[0],p,n),s[1]=Rh(s[1],f,n),s[2]=Rh(s[2],h,n),s[3]=Rh(s[3],c,n),Ah.fromPoints(s)}function Lh(e,r,n){for(const i of e)t._.transformMat4(i,i,r),t._.scale(i,i,n);}function Oh(e,r,n,i){const s=r/e.worldSize,a=e.globeMatrix;if(n.z<=1){const t=Ch(n).getCorners();return Lh(t,a,s),Ah.fromPoints(t)}const o=Fh(n,i),l=Uh(o,nc+Ph(e._tileCoverLift));Lh(l,a,s);const u=Number.MAX_VALUE,c=[-u,-u,-u],h=[u,u,u];if(o.contains(e.center)){for(const e of l)t._.min(h,h,e),t._.max(c,c,e);c[2]=0;const r=e.point,n=[r.x*s,r.y*s,0];return t._.min(h,h,n),t._.max(c,c,n),new Ah(h,c)}if(e._tileCoverLift>0){for(const e of l)t._.min(h,h,e),t._.max(c,c,e);return new Ah(h,c)}const p=[a[12]*s,a[13]*s,a[14]*s],f=o.getCenter(),d=Ke(e.center.lat,-Dc,Dc),m=Ke(f.lat,-Dc,Dc),y=Tc(e.center.lng),g=kc(d);let x=y-Tc(f.lng);const b=g-kc(m);x>.5?x-=1:x<-.5&&(x+=1);let v=0;if(Math.abs(x)>Math.abs(b))v=x>=0?1:3;else {v=b>=0?0:2;const e=[a[4]*s,a[5]*s,a[6]*s],r=-Math.sin($e(b>=0?o.getSouth():o.getNorth()))*nc;t._.scaleAndAdd(p,p,e,r);}const _=l[v],w=l[(v+1)%4],M=new Bh(_,w,p),A=[Dh(M,0)||_[0],Dh(M,1)||_[1],Dh(M,2)||_[2]],S=Hh(e.zoom);if(S>0){const i=function({x:t,y:e,z:r},n,i,s,a){const o=1/(1<.5?p=-1:f<-.5&&(p=1),l=((l+p)*n-(s*=n))*i+s,u=((u+p)*n-s)*i+s,c=(c*n-(a*=n))*i+a,h=(h*n-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,r,e._pixelsPerMercatorPixel,y,g);for(let t=0;tMath.PI/2*1.01}const Jh=$e(85),Qh=Math.cos(Jh),tp=Math.sin(Jh),ep=t.ad.create(),rp=t=>{const e=[];return \"map\"===t.paint.get(\"circle-pitch-alignment\")&&e.push(\"PITCH_WITH_MAP\"),\"map\"===t.paint.get(\"circle-pitch-scale\")&&e.push(\"SCALE_WITH_MAP\"),e};function np(e,r,n,i,s,a,o,l,u){if(a&&e.queryGeometry.isAboveHorizon)return !1;a&&(u*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,h=n.projection.upVectorScale(c,n.center.lat,n.worldSize).metersToTile;for(const p of r)for(const r of p){const p=r.add(l),f=s&&n.elevation?n.elevation.exaggeration()*s.getElevationAt(p.x,p.y,!0):0,d=n.projection.projectTilePoint(p.x,p.y,c);if(f>0){const t=n.projection.upVector(c,p.x,p.y);d.x+=t[0]*h*f,d.y+=t[1]*h*f,d.z+=t[2]*h*f;}const m=a?p:ip(d.x,d.y,d.z,i),y=a?e.tilespaceRays.map((t=>op(t,f))):e.queryGeometry.screenGeometry,g=t.aA.transformMat4([],[d.x,d.y,d.z,1],i);if(!o&&a?u*=g[3]/n.cameraToCenterDistance:o&&!a&&(u*=n.cameraToCenterDistance/g[3]),a){const t=Ec((r.y/ps+c.y)/(1<t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError(\"out of range source coordinates for image copy\");if(i.width>e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError(\"out of range destination coordinates for image copy\");const l=t.data,u=e.data,c=4===s&&o;for(let o=0;o{e[t.evaluationKey]=s;const a=t.expression.evaluate(e);a&&(i.data[r+n+0]=Math.floor(255*a.r/a.a),i.data[r+n+1]=Math.floor(255*a.g/a.a),i.data[r+n+2]=Math.floor(255*a.b/a.a),i.data[r+n+3]=Math.floor(255*a.a));};if(t.clips)for(let e=0,i=0;e80*r){o=1/0,l=1/0;let e=-1/0,n=-1/0;for(let s=r;se&&(e=r),i>n&&(n=i);}u=Math.max(e-o,n-l),u=0!==u?32767/u:0;}return Sp(s,a,r,o,l,u,0),a}function Mp(t,e,r,n,i){let s;if(i===function(t,e,r,n){let i=0;for(let s=e,a=r-n;s0)for(let i=e;i=e;i-=n)s=$p(i/n|0,t[i],t[i+1],s);return s&&Op(s,s.next)&&(Gp(s),s=s.next),s}function Ap(t,e){if(!t)return t;e||(e=t);let r,n=t;do{if(r=!1,n.steiner||!Op(n,n.next)&&0!==Lp(n.prev,n,n.next))n=n.next;else {if(Gp(n),n=e=n.prev,n===n.next)break;r=!0;}}while(r||n!==e);return e}function Sp(t,e,r,n,i,s,a){if(!t)return;!a&&s&&function(t,e,r,n){let i=t;do{0===i.z&&(i.z=Dp(i.x,i.y,e,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,r=1;do{let n,i=t;t=null;let s=null;for(e=0;i;){e++;let a=i,o=0;for(let t=0;t0||l>0&&a;)0!==o&&(0===l||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:t=n,n.prevZ=s,s=n;i=a;}s.nextZ=null,r*=2;}while(e>1)}(i);}(t,n,i,s);let o=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(s?Tp(t,n,i,s):Ip(t))e.push(l.i,t.i,u.i),Gp(t),t=u.next,o=u.next;else if((t=u)===o){a?1===a?Sp(t=kp(Ap(t),e),e,r,n,i,s,2):2===a&&Pp(t,e,r,n,i,s):Sp(Ap(t),e,r,n,i,s,1);break}}}function Ip(t){const e=t.prev,r=t,n=t.next;if(Lp(e,r,n)>=0)return !1;const i=e.x,s=r.x,a=n.x,o=e.y,l=r.y,u=n.y,c=is?i>a?i:a:s>a?s:a,f=o>l?o>u?o:u:l>u?l:u;let d=n.next;for(;d!==e;){if(d.x>=c&&d.x<=p&&d.y>=h&&d.y<=f&&Rp(i,o,s,l,a,u,d.x,d.y)&&Lp(d.prev,d,d.next)>=0)return !1;d=d.next;}return !0}function Tp(t,e,r,n){const i=t.prev,s=t,a=t.next;if(Lp(i,s,a)>=0)return !1;const o=i.x,l=s.x,u=a.x,c=i.y,h=s.y,p=a.y,f=ol?o>u?o:u:l>u?l:u,y=c>h?c>p?c:p:h>p?h:p,g=Dp(f,d,e,r,n),x=Dp(m,y,e,r,n);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=g&&v&&v.z<=x;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==a&&Rp(o,c,l,h,u,p,b.x,b.y)&&Lp(b.prev,b,b.next)>=0)return !1;if(b=b.prevZ,v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==a&&Rp(o,c,l,h,u,p,v.x,v.y)&&Lp(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}for(;b&&b.z>=g;){if(b.x>=f&&b.x<=m&&b.y>=d&&b.y<=y&&b!==i&&b!==a&&Rp(o,c,l,h,u,p,b.x,b.y)&&Lp(b.prev,b,b.next)>=0)return !1;b=b.prevZ;}for(;v&&v.z<=x;){if(v.x>=f&&v.x<=m&&v.y>=d&&v.y<=y&&v!==i&&v!==a&&Rp(o,c,l,h,u,p,v.x,v.y)&&Lp(v.prev,v,v.next)>=0)return !1;v=v.nextZ;}return !0}function kp(t,e){let r=t;do{const n=r.prev,i=r.next.next;!Op(n,i)&&Fp(n,r,r.next,i)&&jp(n,i)&&jp(i,n)&&(e.push(n.i,r.i,i.i),Gp(r),Gp(r.next),r=t=i),r=r.next;}while(r!==t);return Ap(r)}function Pp(t,e,r,n,i,s){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.i!==t.i&&Vp(a,t)){let o=qp(a,t);return a=Ap(a,a.next),o=Ap(o,o.next),Sp(a,e,r,n,i,s,0),void Sp(o,e,r,n,i,s,0)}t=t.next;}a=a.next;}while(a!==t)}function zp(t,e){return t.x-e.x}function Ep(t,e){const r=function(t,e){let r=e;const n=t.x,i=t.y;let s,a=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const t=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>a&&(a=t,s=r.x=r.x&&r.x>=l&&n!==r.x&&Rp(is.x||r.x===s.x&&Bp(s,r)))&&(s=r,c=e);}r=r.next;}while(r!==o);return s}(t,e);if(!r)return e;const n=qp(r,t);return Ap(n,n.next),Ap(r,r.next)}function Bp(t,e){return Lp(t.prev,t,e.prev)<0&&Lp(e.next,t,t.next)<0}function Dp(t,e,r,n,i){return (t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Cp(t){let e=t,r=t;do{(e.x=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Vp(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Fp(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(jp(t,e)&&jp(e,t)&&function(t,e){let r=t,n=!1;const i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Lp(t.prev,t,e.prev)||Lp(t,e.prev,e))||Op(t,e)&&Lp(t.prev,t,t.next)>0&&Lp(e.prev,e,e.next)>0)}function Lp(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Op(t,e){return t.x===e.x&&t.y===e.y}function Fp(t,e,r,n){const i=Np(Lp(t,e,r)),s=Np(Lp(t,e,n)),a=Np(Lp(r,n,t)),o=Np(Lp(r,n,e));return i!==s&&a!==o||!(0!==i||!Up(t,r,e))||!(0!==s||!Up(t,n,e))||!(0!==a||!Up(r,t,n))||!(0!==o||!Up(r,e,n))}function Up(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Np(t){return t>0?1:t<0?-1:0}function jp(t,e){return Lp(t.prev,t,t.next)<0?Lp(t,e,t.next)>=0&&Lp(t,t.prev,e)>=0:Lp(t,e,t.prev)<0||Lp(t,t.next,e)<0}function qp(t,e){const r=Yp(t.i,t.x,t.y),n=Yp(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function $p(t,e,r,n){const i=Yp(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Gp(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Yp(t,e,r){return {i:t,x:e,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Xp(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,s;for(let e=0;e1)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Cl,this.indexArray=new Ql,this.indexArray2=new Zl,this.programConfigurations=new Wu(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new Au,this.segments2=new Au,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Hp(\"fill\",this.layers,e);const i=this.layers[0].layout.get(\"fill-sort-key\"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Xc(a,t);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:Yc(a,r,n),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Kp(\"fill\",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.availableImages,e.brightness);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,s){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,s);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,_p),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),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(t,e,r,n,i,s=[],a){for(const t of Xp(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;tt.cellIdx-e.cellIdx||t.triIdx-e.triIdx));let u=0;for(;uthis.max.x||this.min.x>t.x||t.y>this.max.y||this.min.y>t.y)return;const r=ef(t.x-this.min.x,this.xScale,this.cellsX),n=ef(t.y-this.min.y,this.yScale,this.cellsY),i=this.cells[n*this.cellsX+r];if(i){this._lazyInitLookup();for(let t=0;tthis.max.x||this.min.x>e.x)return;if(t.y>this.max.y||this.min.y>e.y)return;this._lazyInitLookup();const n=ef(t.x-this.min.x,this.xScale,this.cellsX),i=ef(e.x-this.min.x,this.xScale,this.cellsX),s=ef(t.y-this.min.y,this.yScale,this.cellsY),a=ef(e.y-this.min.y,this.yScale,this.cellsY);for(let t=s;t<=a;t++)for(let e=n;e<=i;e++){const n=this.cells[t*this.cellsX+e];if(n)for(let t=0;tt.fqid)),this.index=t.index,this.hasPattern=!1,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.footprints=[];}updateFootprints(t,e){for(const r of this.footprints)e.push({footprint:r,id:t});}populate(t,e,r,n){const i=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Xc(e,t);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),l,r))continue;const u={id:s,properties:e.properties,type:e.type,sourceLayerIndex:o,index:a,geometry:t?l.geometry:Yc(e,r,n),patterns:{}};i.push(u);}for(const n of i){const{geometry:i,index:s,sourceLayerIndex:a}=n;this.addFeature(n,i,s,r,{},e.availableImages,e.brightness),e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}isEmpty(){return 0===this.footprints.length}uploadPending(){return !1}upload(t){}update(t,e,r,n,i){}destroy(){}addFeature(t,e,r,n,i,s=[],a){for(const t of Xp(e,2)){const e=[],r=[],n=[],i=new Ne(1/0,1/0),s=new Ne(-1/0,-1/0);for(const a of t)if(0!==a.length){a!==t[0]&&n.push(r.length/2);for(let t=0;t>3;}if(i--,1===n||2===n)s+=t.readSVarint(),a+=t.readSVarint(),1===n&&(e&&o.push(e),e=[]),e.push(new ff(s,a));else {if(7!==n)throw new Error(\"unknown command \"+n);e&&e.push(e[0].clone());}}return e&&o.push(e),o},mf.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error(\"unknown command \"+r)}return [a,l,o,u]},mf.prototype.toGeoJSON=function(t,e,r){var n,i,s=this.extent*Math.pow(2,r),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=mf.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}vf.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error(\"feature index out of bounds\");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new xf(this._pbf,e,this.extent,this._keys,this._values)};var wf=bf;function Mf(t,e,r){if(3===t){var n=new wf(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n);}}var Af=pf.VectorTile=function(t,e){this.layers=t.readFields(Mf,{},e);},Sf=pf.VectorTileFeature=df;pf.VectorTileLayer=bf;class If extends Ne{constructor(t,e,r){super(t,e),this.z=r;}}class Tf extends If{constructor(t,e,r,n){super(t,e,r),this.w=n;}}function kf(t,e,r,n){const i=[],s=0===n?(t,e,r,n,i,s)=>{t.push(new Ne(s,r+(s-e)/(n-e)*(i-r)));}:(t,e,r,n,i,s)=>{t.push(new Ne(e+(s-r)/(i-r)*(n-e),s));};for(const a of t){const t=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let t=0;te&&s(a,o,l,u,c,e):h>r?p=e&&s(a,o,l,u,c,e),p>r&&h<=r&&s(a,o,l,u,c,r);}let o=i[i.length-1];const l=0===n?o.x:o.y;l>=e&&l<=r&&a.push(o),a.length&&(o=a[a.length-1],a[0].x===o.x&&a[0].y===o.y||a.push(a[0]),t.push(a));}t.length&&i.push(t);}return i}function Pf(t,e,r,n){const i=\"x\"===r?\"y\":\"x\",s=(n-t[r])/(e[r]-t[r]);t[i]=t[i]+(e[i]-t[i])*s,t[r]=n,t.hasOwnProperty(\"z\")&&(t.z=Gn(t.z,e.z,s)),t.hasOwnProperty(\"w\")&&(t.w=Gn(t.w,e.w,s));}function zf(t,e,r,n){const i=r,s=n;for(const r of [\"x\",\"y\"]){let n=t,a=e;n[r]>=a[r]&&(n=e,a=t),n[r]i&&Pf(n,a,r,i),n[r]s&&Pf(a,n,r,s);}}function Ef(t,e){return t.x-e.x||t.y-e.y}function Bf(t,e){return 0===Ef(t.min,e.min)&&0===Ef(t.max,e.max)}function Df(t,e){return !(t.min.x>e.max.x||t.max.xe.max.y||t.max.ynew Ne((t.x+s.x*ps)*o-a.x*ps,(t.y+s.y*ps)*o-a.y*ps)));}return Lf(r,i,t.indices,0,t.indices.length,0,0)}function Ff(t,e,r,n){const i=Math.pow(2,n.z-r.z);return new Ne((t+r.x*ps)*i-n.x*ps,(e+r.y*ps)*i-n.y*ps)}function Uf(t,e){const r=[];e.footprint.grid.queryPoint(t,r);const n=e.footprint.indices,i=e.footprint.vertices;for(let e=0;ee[a])return null}else {const o=1/n[a];let l=(t[a]-r[a])*o,u=(e[a]-r[a])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),us)return null}return i}function qf(t,e,r,n,i,s,a,o,l,u,c){const h=n-t,p=i-e,f=s-r,d=a-t,m=o-e,y=l-r,g=c[1]*y-c[2]*m,x=c[2]*d-c[0]*y,b=c[0]*m-c[1]*d,v=h*g+p*x+f*b;if(Math.abs(v)<1e-15)return null;const _=1/v,w=u[0]-t,M=u[1]-e,A=u[2]-r,S=(w*g+M*x+A*b)*_;if(S<0||S>1)return null;const I=M*f-A*p,T=A*h-w*f,k=w*p-M*h,P=(c[0]*I+c[1]*T+c[2]*k)*_;return P<0||S+P>1?null:(d*I+m*T+y*k)*_}function $f(t,e,r){return (t-e)/(r-e)}function Gf(t,e,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(t+1)*r-s,o=e*r,l=(e+1)*r-s;i[0]=t*r,i[1]=o,i[2]=a,i[3]=l;};let a=new Nf(n);const o=[];for(let e=0;e=1;n/=2){const t=r[r.length-1];a=new Nf(n);for(let e=0;e0;){const{idx:l,t:d,nodex:m,nodey:y,depth:g}=f.pop();if(this.leaves[l]){Gf(m,y,g,e,r,n,i,h,p);const l=1<=e[2])return d}continue}let x=0;for(let t=0;t=u[c[n]]&&(c.splice(n,0,t),r=!0);r||(c[x]=t),x++;}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(\"out of range source coordinates for DEM data\");return (e+1)*this.stride+(t+1)}static pack(t,e){const r=[0,0,0,0],n=Jf.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new dp({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error(\"dem dimension mismatch\");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;et.max.x&&(t.max.x=e.x,n=!0),e.yt.max.y&&(t.max.y=e.y,n=!0),((0===e.x||e.x===ps)&&e.x===r.x)!=((0===e.y||e.y===ps)&&e.y===r.y)&&this.processBorderOverlap(e,r),n&&this.checkBorderIntersection(e,r);}checkBorderIntersection(t,e){e.x<0!=t.x<0&&this.addBorderIntersection(0,Gn(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>ps!=t.x>ps&&this.addBorderIntersection(1,Gn(e.y,t.y,(ps-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Gn(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>ps!=t.y>ps&&this.addBorderIntersection(3,Gn(e.x,t.x,(ps-e.y)/(t.y-e.y)));}addBorderIntersection(t,e){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 r=this.borders[t];er[1]&&(r[1]=e);}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y);}else {const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x);}}centroid(){return 0===this.accCount?new Ne(0,0):new Ne(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(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0):0}}function dd(t,e){const r=t.add(e)._unit(),n=Ke(t.x*r.x+t.y*r.y,-1,1);var i,s,a;return i=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(i)))/4*sd*((s=t).x*(a=e).y-s.y*a.x<0?-1:1)}const md=[t=>t.x<0,t=>t.x>ps,t=>t.y<0,t=>t.y>ps];function yd(t,e,r,n){const i=[4];if(0===n)return i;r._mult(n);const s=t.sub(r),a=e.sub(r),o=[t,e,s,a];for(let t=0;t<4;t++)for(const e of o)if(md[t](e)){i.push(t);break}return i}class gd{constructor(t){this.vertexArray=new Ll,this.indexArray=new Ql,this.programConfigurations=new Wu(t.layers,{zoom:t.zoom,lut:t.lut},(t=>nd.includes(t))),this._segments=new Au,this.hiddenByLandmarkVertexArray=new cu,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new Au;}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(t,e,r,n=!1){const i=t.length;if(i>2){let s=Math.max(0,this._segments.get().length-1);const a=this._segments._prepareSegment(4*i,this.vertexArray.length,2*this._segmentToGroundQuads[s].length);let o;s!==this._segments.get().length-1&&(s++,this._segmentToGroundQuads[s]=[],this._segmentToRegionTriCounts[s]=[0,0,0,0,0]);{const e=t[0],r=t[1];o=dd(e.sub(t[i-1])._perp()._unit(),r.sub(e)._perp()._unit());}for(let l=0;lt.region-e.region));for(let r=0;rt+e),0);let s=0;for(let t=0;t<=4;t++){const e=i[t];if(0!==e){let r=this.regionSegments[t];r||(r=this.regionSegments[t]=new Au);const i={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+s,vertexLength:n.vertexLength,primitiveLength:e};r.get().push(i);}s+=e;}for(let t=0;t0?this.hiddenByLandmarkVertexBuffer=t.createVertexBuffer(this.hiddenByLandmarkVertexArray,uf.members,!0):this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.updateData(this.hiddenByLandmarkVertexArray),this._needsHiddenByLandmarkUpdate=!1);}destroy(){if(this.vertexBuffer){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.hiddenByLandmarkVertexBuffer&&this.hiddenByLandmarkVertexBuffer.destroy(),this._segments&&this._segments.destroy(),this.programConfigurations.destroy();for(let t=0;t<=4;t++){const e=this.regionSegments[t];e&&e.destroy();}}}}class xd{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.activeReplacements=[],this.replacementUpdateTime=0,this.centroidData=[],this.footprintIndices=new Ql,this.footprintVertices=new Cl,this.footprintSegments=[],this.layoutVertexArray=new Vl,this.centroidVertexArray=new _u,this.indexArray=new Ql,this.programConfigurations=new Wu(t.layers,{zoom:t.zoom,lut:t.lut},(t=>rd.includes(t))),this.segments=new Au,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.groundEffect=new gd(t),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[];}updateFootprints(t,e){}populate(t,e,r,n){this.features=[],this.hasPattern=Hp(\"fill-extrusion\",this.layers,e),this.featuresOnBorder=[],this.borderFeatureIndices=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=Lc(r),this.edgeRadius=this.layers[0].layout.get(\"fill-extrusion-edge-radius\")/this.tileToMeter;for(const{feature:i,id:s,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Xc(i,t);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),l,r))continue;const u={id:s,sourceLayerIndex:o,index:a,geometry:t?l.geometry:Yc(i,r,n),properties:i.properties,type:i.type,patterns:{}},c=this.layoutVertexArray.length;this.hasPattern?this.features.push(Kp(\"fill-extrusion\",this.layers,u,this.zoom,e)):this.addFeature(u,u.geometry,a,r,{},e.availableImages,n,e.brightness),e.featureIndex.insert(i,u.geometry,a,o,this.index,c);}this.sortBorders(),\"mercator\"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0;}addFeatures(t,e,r,n,i,s){for(const t of this.features){const{geometry:a}=t;this.addFeature(t,a,t.index,e,r,n,i,s);}this.sortBorders(),\"mercator\"===this.projection.name&&this.splitToSubtiles();}update(t,e,r,n,i){const s=0!==Object.keys(t).length;if(s&&!this.stateDependentLayers.length)return;const a=s?this.stateDependentLayers:this.layers;this.programConfigurations.updatePaintArrays(t,e,a,r,n,i),this.groundEffect.update(t,e,a,r,n,i);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload||this.groundEffect.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,hf),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,cf.members,!0)),this.groundEffect.upload(t)),this.groundEffect.uploadPaintProperties(t),this.programConfigurations.upload(t),this.uploaded=!0;}uploadCentroid(t){this.groundEffect.uploadHiddenByLandmark(t),this.needsCentroidUpdate&&(!this.centroidVertexBuffer&&this.centroidVertexArray.length>0?this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,lf.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(t,e,r,n,i,s,a,o){const l=this.layers[0].paint.get(\"fill-extrusion-flood-light-ground-radius\").evaluate(t,{})/this.tileToMeter,u=[new Ne(0,0),new Ne(ps,ps)],c=a.projection,h=\"globe\"===c.name,p=\"Polygon\"===ed[t.type],f=new fd;f.centroidDataIndex=this.centroidData.length;const d=new pd,m=this.layers[0].paint.get(\"fill-extrusion-base\").evaluate(t,{},n)<=0,y=this.layers[0].paint.get(\"fill-extrusion-height\").evaluate(t,{},n);d.height=y,d.vertexArrayOffset=this.layoutVertexArray.length,d.groundVertexArrayOffset=this.groundEffect.vertexArray.length,h&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new ql);const g=Xp(e,500);for(let t=g.length-1;t>=0;t--){const e=g[t];(0===e.length||(x=e[0]).every((t=>t.x<=0))||x.every((t=>t.x>=ps))||x.every((t=>t.y<=0))||x.every((t=>t.y>=ps)))&&g.splice(t,1);}var x;let b;if(h)b=Td(g,u,n);else {b=[];for(const t of g)b.push({polygon:t,bounds:u});}const v=p?this.edgeRadius:0,_=v>0&&this.zoom<17,w=(t,e)=>{if(0===t.length)return !1;const r=t[t.length-1];return e.x===r.x&&e.y===r.y};for(const{polygon:t,bounds:e}of b){let r=0,i=0;for(const e of t)p&&!e[0].equals(e[e.length-1])&&e.push(e[0]),i+=p?e.length-1:e.length;const s=this.segments.prepareSegment((p?5:4)*i,this.layoutVertexArray,this.indexArray);d.footprintSegIdx<0&&(d.footprintSegIdx=this.footprintSegments.length),d.polygonSegIdx<0&&(d.polygonSegIdx=this.polygonSegments.length);const a={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},o=new hd;if(o.vertexOffset=this.footprintVertices.length,o.indexOffset=3*this.footprintIndices.length,o.ringIndices=[],p){const i=[],a=[];r=s.vertexLength;for(let r=0;r4&&Ad(a[a.length-2],a[0],a[1]),u=v?vd(a[a.length-2],a[0],a[1],v):0;const y=[];let g,x,b;x=a[1].sub(a[0])._perp()._unit();let _=!0;for(let t=1,i=0;t0?1:0,T=l.dist(p);if(i+T>32768&&(i=0),v){b=M.sub(p)._perp()._unit();let t=_d(l,p,M,bd(x,b),v);isNaN(t)&&(t=0);const e=p.sub(l)._unit();l=l.add(e.mult(u))._round(),p=p.add(e.mult(-t))._round(),u=t,x=b,m&&this.zoom>=17&&(w(y,l)||y.push(l),w(y,p)||y.push(p));}const k=s.vertexLength,P=a.length>4&&Ad(l,p,M);let z=Sd(i,o,_);if(ld(this.layoutVertexArray,l.x,l.y,S,I,0,0,z),ld(this.layoutVertexArray,l.x,l.y,S,I,0,1,z),i+=T,z=Sd(i,P,!_),o=P,ld(this.layoutVertexArray,p.x,p.y,S,I,0,0,z),ld(this.layoutVertexArray,p.x,p.y,S,I,0,1,z),s.vertexLength+=4,this.indexArray.emplaceBack(k+0,k+1,k+2),this.indexArray.emplaceBack(k+1,k+3,k+2),s.primitiveLength+=2,v){const n=r+(1===t?a.length-2:t-2),i=1===t?r:n+1;if(this.indexArray.emplaceBack(k+1,n,k+3),this.indexArray.emplaceBack(n,i,k+3),s.primitiveLength+=2,void 0===g&&(g=k),!wd(M,a[t],e)){const e=t===a.length-1?g:s.vertexLength;this.indexArray.emplaceBack(k+2,k+3,e),this.indexArray.emplaceBack(k+3,e+1,e),this.indexArray.emplaceBack(k+3,i,e+1),s.primitiveLength+=3;}_=!_;}if(h){const t=this.layoutVertexExtArray,e=c.projectTilePoint(l.x,l.y,n),r=c.projectTilePoint(p.x,p.y,n),i=c.upVector(n,l.x,l.y),s=c.upVector(n,p.x,p.y);cd(t,e,i),cd(t,e,i),cd(t,r,s),cd(t,r,s);}}p&&(r+=a.length-1),m&&v&&this.zoom>=17&&(0!==y.length&&w(y,y[0])&&y.pop(),this.groundEffect.addData(y,e,l,v>0));}this.footprintSegments.push(o),a.triangleCount=this.indexArray.length-a.triangleArrayOffset,this.polygonSegments.push(a),++d.footprintSegLen,++d.polygonSegLen;}if(d.vertexCount=this.layoutVertexArray.length-d.vertexArrayOffset,d.groundVertexCount=this.groundEffect.vertexArray.length-d.groundVertexArrayOffset,0!==d.vertexCount){if(d.centroidXY=f.borders?ad:this.encodeCentroid(f,d),this.centroidData.push(d),f.borders){this.featuresOnBorder.push(f);const t=this.featuresOnBorder.length-1;for(let e=0;ethis.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]));}splitToSubtiles(){const t=[];for(let e=0;eps),i=2*n+(+(r.min.x+r.max.x>ps)^n);for(let n=0;nt.triangleSegmentIdx===e.triangleSegmentIdx?t.subtile-e.subtile:t.triangleSegmentIdx-e.triangleSegmentIdx));let r=0,n=0,i=0;for(const e of t){if(e.triangleSegmentIdx!==r)break;i++;}const s=t.length;for(;n!==t.length;){r=t[n].triangleSegmentIdx;let a=0,o=n,l=n;for(let e=o;e0&&this.triangleSubSegments.push({segment:c,min:s,max:u}),o=l;for(let e=o;e[t[0]*(1-r[0])+e[0]*r[0],t[1]*(1-r[1])+e[1]*r[1]],p=[],f=[];for(const t of this.triangleSubSegments){p[0]=t.min.x/ps,p[1]=t.min.y/ps,f[0]=t.max.x/ps,f[1]=t.max.y/ps;const e=h(l,u,p),s=h(l,u,f);if(0===new Ah([e[0],e[1],n],[s[0],s[1],i]).intersectsPrecise(r)){o&&(c.segments.push(o),o=void 0);continue}const a=t.segment;o&&o.vertexOffset!==a.vertexOffset&&(c.segments.push(o),o=void 0),o?(o.vertexLength+=a.vertexLength,o.primitiveLength+=a.primitiveLength):o={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}};}return o&&c.segments.push(o),c}encodeCentroid(t,e){const r=t.centroid(),n=e.span(),i=Math.min(7,Math.round(n.x*this.tileToMeter/10)),s=Math.min(7,Math.round(n.y*this.tileToMeter/10));return new Ne(Ke(r.x,1,ps-1)<<3|i,Ke(r.y,1,ps-1)<<3|s)}encodeBorderCentroid(t){if(!t.borders)return new Ne(0,0);const e=t.borders,r=Number.MAX_VALUE;if(e[0][0]!==r||e[1][0]!==r){const t=e[0][0]!==r?0:1;return new Ne(6|(e[0][0]!==r?0:65528),(e[t][0]+e[t][1])/2<<3|6)}{const t=e[2][0]!==r?2:3;return new Ne((e[t][0]+e[t][1])/2<<3|6,6|(e[2][0]!==r?0:65528))}}showCentroid(t){const e=this.centroidData[t.centroidDataIndex];e.flags&=od,e.centroidXY.x=0,e.centroidXY.y=0,this.writeCentroidToBuffer(e);}writeCentroidToBuffer(t){this.groundEffect.updateHiddenByLandmark(t);const e=t.vertexArrayOffset,r=t.vertexCount+t.vertexArrayOffset,n=t.flags&od?ad:t.centroidXY,i=this.centroidVertexArray.geta_centroid_pos0(e);if(this.centroidVertexArray.geta_centroid_pos1(e)!==n.y||i!==n.x){for(let t=e;tr.max.x||r.min.x>e.max.x||e.min.y>r.max.y||r.min.y>e.max.y))for(let s=0;se!=l>e&&t<(this.footprintVertices.int16[2*(o+s.vertexOffset)+0]-r)*(e-a)/(l-a)+r&&(n=!n);}a=r;}}return n}getHeightAtTileCoord(t,e){let r=Number.NEGATIVE_INFINITY,n=!0;const i=4*(t+ps)*ps+(e+ps);if(this.partLookup.hasOwnProperty(i)){const t=this.partLookup[i];return t?{height:t.height,hidden:!!(t.flags&od)}:void 0}for(const s of this.centroidData)t>s.max.x||s.min.x>t||e>s.max.y||s.min.y>e||this.footprintContainsPoint(t,e,s)&&s&&s.height>r&&(r=s.height,this.partLookup[i]=s,n=!!(s.flags&od));if(r!==Number.NEGATIVE_INFINITY)return {height:r,hidden:n};this.partLookup[i]=void 0;}}function bd(t,e){const r=t.add(e)._unit();return t.x*r.x+t.y*r.y}function vd(t,e,r,n){const i=e.sub(t)._perp()._unit(),s=r.sub(e)._perp()._unit();return _d(t,e,r,bd(i,s),n)}function _d(t,e,r,n,i){const s=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(r)/3,i*s/n)}function wd(t,e,r){return t.xr[1].x&&e.x>r[1].x||t.yr[1].y&&e.y>r[1].y}function Md(t,e){return t.xe[1].x||t.ye[1].y}function Ad(t,e,r){if(t.x<0||t.x>=ps||e.x<0||e.x>=ps||r.x<0||r.x>=ps)return !1;const n=r.sub(e),i=n.perp(),s=t.sub(e);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function Sd(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function Id(){const t=Math.PI/32,e=Math.tan(t),r=fc;return r*Math.sqrt(1+2*e*e)-r}function Td(t,e,r){const n=1<{for(const r of t)a.push({polygon:r,bounds:e});},l=Math.ceil(Math.log2(r)),u=Math.ceil(Math.log2(n)),c=l-u,h=[];for(let t=0;t0?0:1);for(let t=0;te+1?f.push({polygons:p,bounds:t,depth:e+1}):o(p,t);}if(d.length){const t=[new Ne(0===r?c:n.x,1===r?c:n.y),a];h.length>e+1?f.push({polygons:d,bounds:t,depth:e+1}):o(d,t);}}return a}(t,e,Math.ceil((s-i)/11.25),Math.ceil((a-o)/11.25),1,((t,e,i)=>{if(0===t)return .5*(e+i);{const t=Ec((r.y+e/ps)/n);return (kc(.5*(Ec((r.y+i/ps)/n)+t))*n-r.y)*ps}}))}function kd(t,e,r,n,i,s){const a=Math.pow(2,n.z-i.z);for(let o=0;o1&&(a=t[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(a.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=t[s];for(let r=0;r1&&(a=t[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n=\"round\"===e,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return fr(\"LineAtlas out of space\"),null;0===t.length&&t.push(1);let a=0;for(let e=0;et.fqid)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.hasZOffset=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new Ol,this.layoutVertexArray2=new Fl,this.patternVertexArray=new Ul,this.indexArray=new Ql,this.programConfigurations=new Wu(t.layers,{zoom:t.zoom,lut:t.lut}),this.segments=new Au,this.maxLineLength=0,this.zOffsetVertexArray=new Xl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.tessellationStep=t.tessellationStep?t.tessellationStep:ps/64;}updateFootprints(t,e){}populate(t,e,r,n){this.hasPattern=Hp(\"line\",this.layers,e);const i=this.layers[0].layout.get(\"line-sort-key\"),s=this.layers[0].layout.get(\"line-z-offset\");this.hasZOffset=!s.isConstant()||!!s.constantOr(0);const a=[];for(const{feature:e,id:s,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Xc(e,t);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),u,r))continue;const c=i?i.evaluate(u,{},r):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:Yc(e,r,n),patterns:{},sortKey:c};a.push(h);}i&&a.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:o,featureIndex:l}=e,u=this.addConstantDashes(o);for(const n of a){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(u&&this.addFeatureDashes(n,o),this.hasPattern){const t=Kp(\"line\",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,o.positions,e.availableImages,e.brightness);l.insert(t[s].feature,i,s,a,this.index);}}addConstantDashes(t){let e=!1;for(const r of this.layers){const n=r.paint.get(\"line-dasharray\").value,i=r.layout.get(\"line-cap\").value;if(\"constant\"!==n.kind||\"constant\"!==i.kind)e=!0;else {const e=i.value,r=n.value;if(!r)continue;t.addDash(r,e);}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get(\"line-dasharray\").value,s=n.layout.get(\"line-cap\").value;if(\"constant\"===i.kind&&\"constant\"===s.kind)continue;let a,o;if(\"constant\"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:r},t);o=\"constant\"===s.kind?s.value:s.evaluate({zoom:r},t),e.addDash(a,o),t.patterns[n.id]=e.getKey(a,o);}}update(t,e,r,n,i){const s=0!==Object.keys(t).length;s&&!this.stateDependentLayers.length||this.programConfigurations.updatePaintArrays(t,e,s?this.stateDependentLayers:this.layers,r,n,i);}addFeatures(t,e,r,n,i,s){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n,s);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ld)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=t.createVertexBuffer(this.patternVertexArray,Fd)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,$d.members,!0)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Rd),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty(\"mapbox_clip_start\")&&t.properties.hasOwnProperty(\"mapbox_clip_end\"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s,a){const o=this.layers[0].layout,l=o.get(\"line-join\").evaluate(t,{}),u=o.get(\"line-cap\").evaluate(t,{}),c=o.get(\"line-miter-limit\"),h=o.get(\"line-round-limit\");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,n,l,u,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,s,n,a);}addLine(t,e,r,n,i,s,a){this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.currentVertex=void 0;const o={zoom:this.zoom,lineProgress:void 0},l=this.layers[0].layout,u=\"none\"===n;if(this.patternJoinNone=this.hasPattern&&u,this.segmentStart=0,this.segmentStartf32=0,this.segmentPoints=[],this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[h-1].equals(t[h-2]);)h--;let p=0;for(;p0;if(k&&r>p){const t=m.dist(y);if(t>2*f){const e=m.sub(m.sub(y)._mult(f/t)._round());this.updateDistance(y,e),this.addCurrentVertex(e,x,0,0,d,v),y=e;}}if(_&&\"round\"===w&&(Is&&(w=\"bevel\"),\"bevel\"===w&&(I>2&&(w=\"flipbevel\"),I100)A=b.mult(-1);else {const t=I*x.add(b).mag()/x.sub(b).mag();A._perp()._mult(t*(P?-1:1));}this.addCurrentVertex(m,A,0,0,d,v),this.addCurrentVertex(m,A.mult(-1),0,0,d,v);}else if(\"bevel\"===w||\"fakeround\"===w){const t=-Math.sqrt(I*I-1),e=P?t:0,r=P?0:t;if(y&&this.addCurrentVertex(m,x,e,r,d,v),\"fakeround\"===w){const t=Math.round(180*T/Math.PI/20);for(let e=1;e2*f){const e=m.add(g.sub(m)._mult(f/t)._round());this.updateDistance(m,e),this.addCurrentVertex(e,b,0,0,d,v),m=e;}}}}addVerticesTo(t,e,r,n,i,s,a,o,l,u){const c=(e.w-t.w)/this.tessellationStep|0;if(c>1){this.lineSoFar=t.w;const h=(e.x-t.x)/c,p=(e.y-t.y)/c,f=(e.z-t.z)/c,d=(e.w-t.w)/c;for(let e=1;e=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,u),o.primitiveLength++),s?this.e2=u:this.e1=u,null!=l&&this.zOffsetVertexArray.emplaceBack(l);}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}function em(t,e,r){return t.xr||t.yr}Mo(tm,\"LineBucket\",{omit:[\"layers\",\"patternFeatures\",\"currentVertex\",\"currentVertexIsOutside\"]});const rm=new ol({\"line-cap\":new sl(ll.layout_line[\"line-cap\"]),\"line-join\":new sl(ll.layout_line[\"line-join\"]),\"line-miter-limit\":new il(ll.layout_line[\"line-miter-limit\"]),\"line-round-limit\":new il(ll.layout_line[\"line-round-limit\"]),\"line-sort-key\":new sl(ll.layout_line[\"line-sort-key\"]),\"line-z-offset\":new sl(ll.layout_line[\"line-z-offset\"]),visibility:new il(ll.layout_line.visibility)});var nm={paint:new ol({\"line-opacity\":new sl(ll.paint_line[\"line-opacity\"]),\"line-color\":new sl(ll.paint_line[\"line-color\"]),\"line-translate\":new il(ll.paint_line[\"line-translate\"]),\"line-translate-anchor\":new il(ll.paint_line[\"line-translate-anchor\"]),\"line-width\":new sl(ll.paint_line[\"line-width\"]),\"line-gap-width\":new sl(ll.paint_line[\"line-gap-width\"]),\"line-offset\":new sl(ll.paint_line[\"line-offset\"]),\"line-blur\":new sl(ll.paint_line[\"line-blur\"]),\"line-dasharray\":new sl(ll.paint_line[\"line-dasharray\"]),\"line-pattern\":new sl(ll.paint_line[\"line-pattern\"]),\"line-gradient\":new al(ll.paint_line[\"line-gradient\"]),\"line-trim-offset\":new il(ll.paint_line[\"line-trim-offset\"]),\"line-trim-fade-range\":new il(ll.paint_line[\"line-trim-fade-range\"]),\"line-trim-color\":new il(ll.paint_line[\"line-trim-color\"]),\"line-emissive-strength\":new il(ll.paint_line[\"line-emissive-strength\"]),\"line-border-width\":new sl(ll.paint_line[\"line-border-width\"]),\"line-border-color\":new sl(ll.paint_line[\"line-border-color\"]),\"line-occlusion-opacity\":new il(ll.paint_line[\"line-occlusion-opacity\"])}),layout:rm};function im(t,e,r){return e*(ps/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}function sm(t,e){return 1/im(t,1,e.tileZoom)}function am(t,e,r,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,r.paint.get(\"line-translate\"),r.paint.get(\"line-translate-anchor\"))}const om=t=>{const e=[];lm(t)&&e.push(\"RENDER_LINE_DASH\"),t.paint.get(\"line-gradient\")&&e.push(\"RENDER_LINE_GRADIENT\");const r=t.paint.get(\"line-trim-offset\");0===r[0]&&0===r[1]||e.push(\"RENDER_LINE_TRIM_OFFSET\"),0!==t.paint.get(\"line-border-width\").constantOr(1)&&e.push(\"RENDER_LINE_BORDER\");const n=\"none\"===t.layout.get(\"line-join\").constantOr(\"miter\"),i=!!t.paint.get(\"line-pattern\").constantOr(1);return n&&i&&e.push(\"LINE_JOIN_NONE\"),e};function lm(t){const e=t.paint.get(\"line-dasharray\").value;return e.value||\"constant\"!==e.kind}class um{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e */\nread:function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},write:function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*m;}},hm=fm,pm=cm;function fm(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}fm.Varint=0,fm.Fixed64=1,fm.Bytes=2,fm.Fixed32=5;var dm=4294967296,mm=1/dm,ym=\"undefined\"==typeof TextDecoder?null:new TextDecoder(\"utf8\");function gm(t){return t.type===fm.Bytes?t.readVarint()+t.pos:t.pos+1}function xm(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function bm(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function vm(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function Em(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}fm.prototype={destroy:function(){this.buf=null;},readFields:function(t,e,r){for(r=r||this.length;this.pos>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Pm(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Em(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Pm(this.buf,this.pos)+Pm(this.buf,this.pos+4)*dm;return this.pos+=8,t},readSFixed64:function(){var t=Pm(this.buf,this.pos)+Em(this.buf,this.pos+4)*dm;return this.pos+=8,t},readFloat:function(){var t=pm.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=pm.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return xm(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return xm(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return xm(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return xm(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return xm(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return xm(t,n,e);throw new Error(\"Expected varint not more than 10 bytes\")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ym?function(t,e,r){return ym.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n=\"\",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==fm.Bytes)return t.push(this.readVarint(e));var r=gm(this);for(t=t||[];this.pos127;);else if(e===fm.Bytes)this.pos=this.readVarint()+this.pos;else if(e===fm.Fixed32)this.pos+=4;else {if(e!==fm.Fixed64)throw new Error(\"Unimplemented type: \"+e);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error(\"Given varint doesn't fit into 10 bytes\");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&bm(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),pm.write(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),pm.write(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&bm(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,e,r){this.writeTag(t,fm.Bytes),this.writeRawMessage(e,r);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,vm,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,_m,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Am,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,wm,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Mm,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Sm,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Im,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Tm,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,km,e);},writeBytesField:function(t,e){this.writeTag(t,fm.Bytes),this.writeBytes(e);},writeFixed32Field:function(t,e){this.writeTag(t,fm.Fixed32),this.writeFixed32(e);},writeSFixed32Field:function(t,e){this.writeTag(t,fm.Fixed32),this.writeSFixed32(e);},writeFixed64Field:function(t,e){this.writeTag(t,fm.Fixed64),this.writeFixed64(e);},writeSFixed64Field:function(t,e){this.writeTag(t,fm.Fixed64),this.writeSFixed64(e);},writeVarintField:function(t,e){this.writeTag(t,fm.Varint),this.writeVarint(e);},writeSVarintField:function(t,e){this.writeTag(t,fm.Varint),this.writeSVarint(e);},writeStringField:function(t,e){this.writeTag(t,fm.Bytes),this.writeString(e);},writeFloatField:function(t,e){this.writeTag(t,fm.Fixed32),this.writeFloat(e);},writeDoubleField:function(t,e){this.writeTag(t,fm.Fixed64),this.writeDouble(e);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}};var Bm=p(hm);const Dm=[\"id\",\"tile\",\"layer\",\"source\",\"sourceLayer\",\"state\"];class Cm{constructor(t,e,r,n,i){this.type=\"Feature\",this._vectorTileFeature=t,this._z=e,this._x=r,this._y=n,this.properties=t.properties,this.id=i;}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t;}toJSON(){const t={type:\"Feature\",state:void 0,geometry:this.geometry,properties:this.properties};for(const e of Dm)void 0!==this[e]&&(t[e]=this[e]);return t}}class Rm{constructor(){this.state={},this.stateChanges={},this.deletedStates={};}updateState(t,e,r){const n=String(e);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][n]=this.stateChanges[t][n]||{},er(this.stateChanges[t][n],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==n&&(this.deletedStates[t][e]=null);}else if(this.deletedStates[t]&&null===this.deletedStates[t][n]){this.deletedStates[t][n]={};for(const e in this.state[t][n])r[e]||(this.deletedStates[t][n][e]=null);}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][n]&&null===this.deletedStates[t][n][e]&&delete this.deletedStates[t][n][e];}removeFeatureState(t,e,r){if(null===this.deletedStates[t])return;const n=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},r&&void 0!==e)null!==this.deletedStates[t][n]&&(this.deletedStates[t][n]=this.deletedStates[t][n]||{},this.deletedStates[t][n][r]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][n])for(r in this.deletedStates[t][n]={},this.stateChanges[t][n])this.deletedStates[t][n][r]=null;else this.deletedStates[t][n]=null;else this.deletedStates[t]=null;}getState(t,e){const r=String(e),n=er({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return {};if(this.deletedStates[t]){const r=this.deletedStates[t][e];if(null===r)return {};for(const t in r)delete n[t];}return n}initializeTileState(t,e){t.setFeatureState(this.state,e);}coalesceChanges(t,e){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const e={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),er(this.state[t][r],this.stateChanges[t][r]),e[r]=this.state[t][r];r[t]=e;}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const e={};if(null===this.deletedStates[t])for(const r in this.state[t])e[r]={},this.state[t][r]={};else for(const r in this.deletedStates[t]){if(null===this.deletedStates[t][r])this.state[t][r]={};else if(this.state[t][r])for(const e of Object.keys(this.deletedStates[t][r]))delete this.state[t][r][e];e[r]=this.state[t][r];}r[t]=r[t]||{},er(r[t],e);}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const n in t)t[n].setFeatureState(r,e);}}class Vm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new _o(ps,16,0),this.featureIndexArray=new vu,this.promoteId=e,this.is3DTile=!1;}insert(t,e,r,n,i,s=0,a=0){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(r,n,i,s);const l=this.grid;for(let t=0;t=0&&n[3]>=0&&l.insert(o,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Af(new Bm(this.rawTileData)).layers,this.sourceLayerCoder=new um(this.vtLayers?Object.keys(this.vtLayers).sort():[\"_geojsonTileLayer\"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=pl(i.filter),a=t.tileResult,o=t.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>oh(a.bufferedTilespaceGeometry,t,e,r,n)));u.sort(Om);let c=null;o.elevation&&u.length>0&&(c=Qf.create(o.elevation,this.tileID));const h={};let p;for(let l=0;l(m||(m=Yc(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(a,e,n,m,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,s,a,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),m=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Xc(m,!0);if(!r.filter(new Ho(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Ho(this.tileID.overscaledZ),m))return;const y=this.getId(m,d);for(let e=0;e{const a=e instanceof nl?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Om(t,e){return e-t}Mo(Vm,\"FeatureIndex\",{omit:[\"rawTileData\",\"sourceLayerCoder\"]});var Fm=24;const Um=128;function Nm(t,e){const{expression:r}=e;if(\"constant\"===r.kind)return {kind:\"constant\",layoutSize:r.evaluate(new Ho(t+1))};if(\"source\"===r.kind)return {kind:\"source\"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;i{t.text=function(t,e,r){const n=e.layout.get(\"text-transform\").evaluate(r,{});return \"uppercase\"===n?t=t.toLocaleUpperCase():\"lowercase\"===n&&(t=t.toLocaleLowerCase()),Zo.applyArabicShaping&&(t=Zo.applyArabicShaping(t)),t}(t.text,e,r);})),t}const Ym={\"!\":\"︕\",\"#\":\"#\",$:\"$\",\"%\":\"%\",\"&\":\"&\",\"(\":\"︵\",\")\":\"︶\",\"*\":\"*\",\"+\":\"+\",\",\":\"︐\",\"-\":\"︲\",\".\":\"・\",\"/\":\"/\",\":\":\"︓\",\";\":\"︔\",\"<\":\"︿\",\"=\":\"=\",\">\":\"﹀\",\"?\":\"︖\",\"@\":\"@\",\"[\":\"﹇\",\"\\\\\":\"\\",\"]\":\"﹈\",\"^\":\"^\",_:\"︳\",\"`\":\"`\",\"{\":\"︷\",\"|\":\"―\",\"}\":\"︸\",\"~\":\"~\",\"¢\":\"¢\",\"£\":\"£\",\"¥\":\"¥\",\"¦\":\"¦\",\"¬\":\"¬\",\"¯\":\" ̄\",\"–\":\"︲\",\"—\":\"︱\",\"‘\":\"﹃\",\"’\":\"﹄\",\"“\":\"﹁\",\"”\":\"﹂\",\"…\":\"︙\",\"‧\":\"・\",\"₩\":\"₩\",\"、\":\"︑\",\"。\":\"︒\",\"〈\":\"︿\",\"〉\":\"﹀\",\"《\":\"︽\",\"》\":\"︾\",\"「\":\"﹁\",\"」\":\"﹂\",\"『\":\"﹃\",\"』\":\"﹄\",\"【\":\"︻\",\"】\":\"︼\",\"〔\":\"︹\",\"〕\":\"︺\",\"〖\":\"︗\",\"〗\":\"︘\",\"!\":\"︕\",\"(\":\"︵\",\")\":\"︶\",\",\":\"︐\",\"-\":\"︲\",\".\":\"・\",\":\":\"︓\",\";\":\"︔\",\"<\":\"︿\",\">\":\"﹀\",\"?\":\"︖\",\"[\":\"﹇\",\"]\":\"﹈\",\"_\":\"︳\",\"{\":\"︷\",\"|\":\"―\",\"}\":\"︸\",\"⦅\":\"︵\",\"⦆\":\"︶\",\"。\":\"︒\",\"「\":\"﹁\",\"」\":\"﹂\",\"←\":\"↑\",\"→\":\"↓\"};function Xm(t){return \"︶\"===t||\"﹈\"===t||\"︸\"===t||\"﹄\"===t||\"﹂\"===t||\"︾\"===t||\"︼\"===t||\"︺\"===t||\"︘\"===t||\"﹀\"===t||\"︐\"===t||\"︓\"===t||\"︔\"===t||\"`\"===t||\" ̄\"===t||\"︑\"===t||\"︒\"===t}function Zm(t){return \"︵\"===t||\"﹇\"===t||\"︷\"===t||\"﹃\"===t||\"﹁\"===t||\"︽\"===t||\"︻\"===t||\"︹\"===t||\"︗\"===t||\"︿\"===t}const Hm=3;function Km(t,e,r){e.glyphs=[],1===t&&r.readMessage(Wm,e);}function Wm(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(Jm,{});e.glyphs.push({id:t,bitmap:new pp({width:i+2*Hm,height:s+2*Hm},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}else 4===t?e.ascender=r.readSVarint():5===t&&(e.descender=r.readSVarint());}function Jm(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}const Qm=Hm,ty={horizontal:1,vertical:2,horizontalOnly:3};class ey{constructor(){this.scale=1,this.fontStack=\"\",this.imageName=null;}static forText(t,e){const r=new ey;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new ey;return e.imageName=t,e}}class ry{constructor(){this.text=\"\",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(t,e){const r=new ry;for(let n=0;n=0&&r>=t&&iy[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new ry;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(ey.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function ny(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d){const m=ry.fromFeature(t,i);h===ty.vertical&&m.verticalizePunctuation(p);let y=[];const g=function(t,e,r,n,i,s){if(!t)return [];const a=[],o=function(t,e,r,n,i,s){let a=0;for(let r=0;r=0;let u=0;for(let r=0;r0&&s>_&&(_=s);}else {const t=r[o.fontStack];if(!t)continue;t[m]&&(A=t[m]);const n=e[o.fontStack];if(!n)continue;const s=n.glyphs[m];if(!s)continue;if(b=s.metrics,I=8203!==m?Fm:0,y){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;w-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function gy(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=Gn(n.x,i.x,c),p=Gn(n.y,i.y,c),f=new my(h,p,0,i.angleTo(n),r);return !a||yy(t,f,o,a,e)?f:void 0}l+=s;}}function _y(t,e,r,n,i,s,a,o,l){const u=xy(n,s,a),c=by(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new my(g,x,0,m,e);n&&!yy(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=wy(t,h/2,r,n,i,s,a,!0,l)),f}function My(t,e,r,n,i){const s=[];for(let a=0;a=n&&u.x>=n||(a.x>=n?a=new Ne(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=n&&(u=new Ne(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new Ne(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new Ne(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],s.push(l)),l.push(u)))));}}return s}function Ay(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();tt.hasImage(e,r))),t.dispatchRenderCallbacks(this.haveRenderCallbacks,r);for(const n in t.getUpdatedImages(r))this.patchUpdatedImage(this.iconPositions[n],t.getImage(n,r),e),this.patchUpdatedImage(this.patternPositions[n],t.getImage(n,r),e);}patchUpdatedImage(t,e,r){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,i]=t.tl,s=!!Object.keys(this.patternPositions).length;r.update(e.data,{useMipmap:s},{x:n,y:i});}}Mo(Iy,\"ImagePosition\"),Mo(Ty,\"ImageAtlas\");const ky=1e20;function Py(t,e,r,n,i,s,a,o,l){for(let u=e;u-1);l++,s[l]=o,a[l]=u,a[l+1]=ky;}for(let o=0,l=0;o{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=n.glyphs[e];if(void 0!==i)return void r(null,{stack:t,id:e,glyph:i});if(i=this._tinySDF(n,t,e),i)return n.glyphs[e]=i,void r(null,{stack:t,id:e,glyph:i});const a=Math.floor(e/256);if(256*a>65535)return void r(new Error(\"glyphs > 65535 not supported\"));if(n.ranges[a])return void r(null,{stack:t,id:e,glyph:i});let o=n.requests[a];o||(o=n.requests[a]=[],Dy.loadGlyphRange(t,a,s,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[a]=!0;}for(const r of o)r(t,e);delete n.requests[a];}))),o.push(((n,i)=>{n?r(n):i&&r(null,{stack:t,id:e,glyph:i.glyphs[e]||null});}));}),((t,e)=>{if(t)r(t);else if(e){const t={};for(const{stack:r,id:n,glyph:i}of e)void 0===t[r]&&(t[r]={}),void 0===t[r].glyphs&&(t[r].glyphs={}),t[r].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},t[r].ascender=this.entries[r].ascender,t[r].descender=this.entries[r].descender;r(null,t);}}));}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==By.none&&(this.localGlyphMode===By.all?!!this.localFontFamily:!!this.localFontFamily&&(ko[\"CJK Unified Ideographs\"](t)||ko[\"Hangul Syllables\"](t)||ko.Hiragana(t)||ko.Katakana(t)||ko[\"CJK Symbols and Punctuation\"](t)||ko[\"CJK Unified Ideographs Extension A\"](t)||ko[\"CJK Unified Ideographs Extension B\"](t)))}_tinySDF(t,e,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=t.tinySDF;if(!i){let r=\"400\";/bold/i.test(e)?r=\"900\":/medium/i.test(e)?r=\"500\":/light/i.test(e)&&(r=\"200\"),i=t.tinySDF=new Dy.TinySDF({fontFamily:n,fontWeight:r,fontSize:24*Ey,buffer:3*Ey,radius:8*Ey}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const s=String.fromCodePoint(r),{data:a,width:o,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:f}=i.draw(s);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new pp({width:o,height:l},a),metrics:{width:u/Ey,height:c/Ey,left:h/Ey,top:p/Ey-27,advance:f/Ey,localGlyph:!0}}}}Dy.loadGlyphRange=function(t,e,r,n,i){const s=256*e,a=s+255,o=n.transformRequest(n.normalizeGlyphsURL(r).replace(\"{fontstack}\",t).replace(\"{range}\",`${s}-${a}`),Wr.Glyphs);en(o,((t,e)=>{if(t)i(t);else if(e){const t={},r=function(t){return new Bm(t).readFields(Km,{})}(e);for(const e of r.glyphs)t[e.id]=e;i(null,{glyphs:t,ascender:r.ascender,descender:r.descender});}}));},Dy.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i=\"sans-serif\",fontWeight:s=\"normal\",fontStyle:a=\"normal\"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const o=this.size=t+4*e,l=this._createCanvas(o),u=this.ctx=l.getContext(\"2d\",{willReadFrequently:!0});u.font=`${a} ${s} ${t}px ${i}`,u.textBaseline=\"alphabetic\",u.textAlign=\"left\",u.fillStyle=\"black\",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o);}_createCanvas(t){const e=document.createElement(\"canvas\");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(t),a=Math.ceil(r),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),f={data:p,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return f;const{ctx:d,buffer:m,gridInner:y,gridOuter:g}=this;d.clearRect(m,m,o,l),d.fillText(t,m,m+a);const x=d.getImageData(m,m,o,l);g.fill(ky,0,h),y.fill(0,0,h);for(let t=0;t0?t*t:0,y[n]=t<0?t*t:0;}}Py(g,0,0,u,c,u,this.f,this.v,this.z),Py(y,m,m,o,l,u,this.f,this.v,this.z);for(let t=0;tt+e[1]-e[0],d=h.reduce(f,0),m=p.reduce(f,0),y=o-d,g=l-m;let x=0,b=d,v=0,_=m,w=0,M=y,A=0,S=g;if(s.content&&n){const t=s.content;x=Vy(h,0,t[0]),v=Vy(p,0,t[1]),b=Vy(h,t[0],t[2]),_=Vy(p,t[1],t[3]),w=t[0]-x,A=t[1]-v,M=t[2]-t[0]-b,S=t[3]-t[1]-_;}const I=(n,i,o,l)=>{const h=Oy(n.stretch-x,b,u,t.left),p=Fy(n.fixed-w,M,n.stretch,d),f=Oy(i.stretch-v,_,c,t.top),y=Fy(i.fixed-A,S,i.stretch,m),g=Oy(o.stretch-x,b,u,t.left),I=Fy(o.fixed-w,M,o.stretch,d),T=Oy(l.stretch-v,_,c,t.top),k=Fy(l.fixed-A,S,l.stretch,m),P=new Ne(h,f),z=new Ne(g,f),E=new Ne(g,T),B=new Ne(h,T),D=new Ne(p/a,y/a),C=new Ne(I/a,k/a),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),r=[e,-t,t,e];P._matMult(r),z._matMult(r),B._matMult(r),E._matMult(r);}const V=n.stretch+n.fixed,L=o.stretch+o.fixed,O=i.stretch+i.fixed,F=l.stretch+l.fixed,U=t.imageSecondary;return {tl:P,tr:z,bl:B,br:E,texPrimary:{x:s.paddedRect.x+Cy+V,y:s.paddedRect.y+Cy+O,w:L-V,h:F-O},texSecondary:U?{x:U.paddedRect.x+Cy+V,y:U.paddedRect.y+Cy+O,w:L-V,h:F-O}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:C,minFontScaleX:M/a/u,minFontScaleY:S/a/c,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const t=Ly(h,y,d),e=Ly(p,g,m);for(let r=0;rs)&&(s=e.x),(!t||e.y>a)&&(a=e.y);}const l=Math.min(s-n,a-i);let u=l/2;const c=new hs([],jy);if(0===l)return new Ne(n,i);for(let e=n;eh.d||!h.d)&&(h=n,r&&console.log(\"found best %d after %d probes\",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=e||(u=n.h/2,c.push(new qy(n.p.x-u,n.p.y-u,u,t)),c.push(new qy(n.p.x+u,n.p.y-u,u,t)),c.push(new qy(n.p.x-u,n.p.y+u,u,t)),c.push(new qy(n.p.x+u,n.p.y+u,u,t)),p+=4);}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function jy(t,e){return e.max-t.max}class qy{constructor(t,e,r,n){this.p=new Ne(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,ih(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}}const $y=Number.POSITIVE_INFINITY,Gy=Math.sqrt(2);function Yy(t,[e,r]){let n=0,i=0;if(r===$y){e<0&&(e=0);const r=e/Gy;switch(t){case\"top-right\":case\"top-left\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":i=7-r;break;case\"bottom\":i=7-e;break;case\"top\":i=e-7;}switch(t){case\"top-right\":case\"bottom-right\":n=-r;break;case\"top-left\":case\"bottom-left\":n=r;break;case\"left\":n=e;break;case\"right\":n=-e;}}else {switch(e=Math.abs(e),r=Math.abs(r),t){case\"top-right\":case\"top-left\":case\"top\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":case\"bottom\":i=7-r;}switch(t){case\"top-right\":case\"bottom-right\":case\"right\":n=-e;break;case\"top-left\":case\"bottom-left\":case\"left\":n=e;}}return [n,i]}function Xy(t){switch(t){case\"right\":case\"top-right\":case\"bottom-right\":return \"right\";case\"left\":case\"top-left\":case\"bottom-left\":return \"left\"}return \"center\"}function Zy(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d){let m=s.textMaxSize.evaluate(e,{},h);void 0===m&&(m=a);const y=t.layers[0].layout,g=y.get(\"icon-offset\").evaluate(e,{},h),x=Jy(r.horizontal)||r.vertical,b=\"globe\"===p.name,v=Fm,_=a/v,w=t.tilePixelRatio*m/v,M=(E=t.overscaling,t.zoom>18&&E>2&&(E>>=1),Math.max(ps/(512*E),1)*y.get(\"symbol-spacing\")),A=y.get(\"text-padding\")*t.tilePixelRatio,S=y.get(\"icon-padding\")*t.tilePixelRatio,I=$e(y.get(\"text-max-angle\")),T=\"map\"===y.get(\"text-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),k=\"map\"===y.get(\"icon-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),P=y.get(\"symbol-placement\"),z=M/2;var E;const B=y.get(\"icon-text-fit\").evaluate(e,{},h),D=y.get(\"icon-text-fit-padding\").evaluate(e,{},h),C=\"none\"!==B;let R;!1===t.hasAnyIconTextFit&&C&&(t.hasAnyIconTextFit=!0),n&&C&&(t.allowVerticalPlacement&&r.vertical&&(R=dy(n,r.vertical,B,D,g,_)),x&&(n=dy(n,x,B,D,g,_)));const V=(a,o,m)=>{if(o.x<0||o.x>=ps||o.y<0||o.y>=ps)return;let y=null;if(b){const{x:t,y:e,z:r}=p.projectTilePoint(o.x,o.y,m);y={anchor:new my(t,e,r,0,void 0),up:p.upVector(m,o.x,o.y)};}!function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g,x,b,v,_,w,M,A,S,I){const T=t.addToLineVertexArray(e,n);let k,P,z,E,B,D,C,R=0,V=0,L=0,O=0,F=-1,U=-1;const N={};let j=Bn(\"\");const q=r?r.anchor:e,$=\"none\"!==l.layout.get(\"icon-text-fit\").evaluate(v,{},A);let G=0,Y=0;if(void 0===l._unevaluatedLayout.getValue(\"text-radial-offset\")?[G,Y]=l.layout.get(\"text-offset\").evaluate(v,{},A).map((t=>t*Fm)):(G=l.layout.get(\"text-radial-offset\").evaluate(v,{},A)*Fm,Y=$y),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)D=tg(t),o&&(C=tg(o));else {const r=l.layout.get(\"text-rotate\").evaluate(v,{},A)+90;z=Qy(u,q,e,c,h,p,t,f,r,m),o&&(E=Qy(u,q,e,c,h,p,o,g,r));}}if(s){const n=l.layout.get(\"icon-rotate\").evaluate(v,{},A),i=Ry(s,n,w,$),a=o?Ry(o,n,w,$):void 0;P=Qy(u,q,e,c,h,p,s,g,n),R=4*i.length;const f=t.iconSizeData;let d=null;\"source\"===f.kind?(d=[Um*l.layout.get(\"icon-size\").evaluate(v,{},A)],d[0]>Ky&&fr(`${t.layerIds[0]}: Value for \"icon-size\" is >= ${Hy}. Reduce your \"icon-size\".`)):\"composite\"===f.kind&&(d=[Um*_.compositeIconSizes[0].evaluate(v,{},A),Um*_.compositeIconSizes[1].evaluate(v,{},A)],(d[0]>Ky||d[1]>Ky)&&fr(`${t.layerIds[0]}: Value for \"icon-size\" is >= ${Hy}. Reduce your \"icon-size\".`)),t.addSymbols(t.icon,i,d,b,x,v,!1,r,e,T.lineStartIndex,T.lineLength,-1,M,A,S,I),F=t.icon.placedSymbolArray.length-1,a&&(V=4*a.length,t.addSymbols(t.icon,a,d,b,x,v,ty.vertical,r,e,T.lineStartIndex,T.lineLength,-1,M,A,S,I),U=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=i.horizontal[n];k||(j=Bn(s.text),d?B=tg(s):k=Qy(u,q,e,c,h,p,s,f,l.layout.get(\"text-rotate\").evaluate(v,{},A),m));const o=1===s.positionedLines.length;if(L+=Wy(t,r,e,s,a,l,d,v,m,T,i.vertical?ty.horizontal:ty.horizontalOnly,o?Object.keys(i.horizontal):[n],N,F,_,M,A,S),o)break}i.vertical&&(O+=Wy(t,r,e,i.vertical,a,l,d,v,m,T,ty.vertical,[\"vertical\"],N,U,_,M,A,S));let X=-1;const Z=(t,e)=>t?Math.max(t,e):e;X=Z(B,X),X=Z(D,X),X=Z(C,X);const H=X>-1?1:0;t.glyphOffsetArray.length>=65535&&fr(\"Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907\"),void 0!==v.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,v.sortKey),t.symbolInstances.emplaceBack(e.x,e.y,q.x,q.y,q.z,N.right>=0?N.right:-1,N.center>=0?N.center:-1,N.left>=0?N.left:-1,N.vertical>=0?N.vertical:-1,F,U,j,void 0!==k?k:t.collisionBoxArray.length,void 0!==k?k+1:t.collisionBoxArray.length,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==P?P:t.collisionBoxArray.length,void 0!==P?P+1:t.collisionBoxArray.length,E||t.collisionBoxArray.length,E?E+1:t.collisionBoxArray.length,c,L,O,R,V,H,0,G,Y,X,0,1,1,$?1:0);}(t,o,y,a,r,n,i,R,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,A,T,l,0,S,k,g,e,s,u,c,h,f,d);};if(\"line\"===P)for(const i of My(e.geometry,0,0,ps,ps)){const e=_y(i,M,I,r.vertical||x,n,v,w,t.overscaling,ps);for(const r of e)x&&eg(t,x.text,z,r)||V(i,r,h);}else if(\"line-center\"===P){for(const t of e.geometry)if(t.length>1){const e=vy(t,I,r.vertical||x,n,v,w);e&&V(t,e,h);}}else if(\"Polygon\"===e.type)for(const t of Xp(e.geometry,0)){const e=Ny(t,16);V(t[0],new my(e.x,e.y,0,0,void 0),h);}else if(\"LineString\"===e.type)for(const t of e.geometry)V(t,new my(t[0].x,t[0].y,0,0,void 0),h);else if(\"Point\"===e.type)for(const t of e.geometry)for(const e of t)V([e],new my(e.x,e.y,0,0,void 0),h);}const Hy=255,Ky=Hy*Um;function Wy(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m,y,g){const x=function(t,e,r,n,i,s,a,o){const l=[];if(0===e.positionedLines.length)return l;const u=n.layout.get(\"text-rotate\").evaluate(s,{})*Math.PI/180,c=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,f=h/p;let d=e.top-r[1];for(let t=0;tKy&&fr(`${t.layerIds[0]}: Value for \"text-size\" is >= ${Hy}. Reduce your \"text-size\".`)):\"composite\"===b.kind&&(v=[Um*d.compositeTextSizes[0].evaluate(o,{},y),Um*d.compositeTextSizes[1].evaluate(o,{},y)],(v[0]>Ky||v[1]>Ky)&&fr(`${t.layerIds[0]}: Value for \"text-size\" is >= ${Hy}. Reduce your \"text-size\".`)),t.addSymbols(t.text,x,v,l,a,o,c,e,r,u.lineStartIndex,u.lineLength,f,m,y,g,!1);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function Jy(t){for(const e in t)return t[e];return null}function Qy(t,e,r,n,i,s,a,o,l,u){let c=a.top,h=a.bottom,p=a.left,f=a.right;const d=a.collisionPadding;if(d&&(p-=d[0],c-=d[1],f+=d[2],h+=d[3]),l){const t=new Ne(p,c),e=new Ne(f,c),r=new Ne(p,h),n=new Ne(f,h),i=$e(l);let s=new Ne(0,0);u&&(s=new Ne(u[0],u[1])),t._rotateAround(i,s),e._rotateAround(i,s),r._rotateAround(i,s),n._rotateAround(i,s),p=Math.min(t.x,e.x,r.x,n.x),f=Math.max(t.x,e.x,r.x,n.x),c=Math.min(t.y,e.y,r.y,n.y),h=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,p,c,f,h,o,n,i,s),t.length-1}function tg(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function eg(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])b&&(v(t,u,n,i,o,l),v(u,r,o,l,s,a));}v(h,p,n,s,i,s),v(p,f,i,s,i,a),v(f,d,i,a,n,a),v(d,h,n,a,n,s),m-=b,y-=b,g+=b,x+=b;const _=1/Math.max(g-m,x-y);return {scale:_,x:m*_,y:y*_,x2:g*_,y2:x*_,projection:e}}function ig(t,{x:e,y:r},n=0){return new Ne(((e-n)*t.scale-t.x)*ps,(r*t.scale-t.y)*ps)}const sg=t.ad.identity(new Float32Array(16));class ag{constructor(t){this.spec=t,this.name=t.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(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new mc(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return Pc(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return rg(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const i=t.horizonLineFromTop(!1),s=new Ne(e,Math.max(i,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(s,n))}pointCoordinate3D(t,e,r){const n=new Ne(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation&&t.elevation.visibleDemTiles.length)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-mg+r&&(e=-mg+r):e>mg-r&&(e=mg-r);const s=i/Math.pow(yg(e),n);let a=s*Math.sin(n*t),o=i-s*Math.cos(n*t);return a=.5*(a/Math.PI+.5),o=.5*(o/Math.PI+.5),{x:a,y:this.southernCenter?o:1-o,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(t)*s);const l=Ke(Ge(o/r)+this.center[0],-180,180),u=Ke(Ge(2*Math.atan(Math.pow(n/a,1/r))-mg),-Dc,Dc);return new mc(l,this.southernCenter?-u:u)}}class xg extends ag{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:Tc(t),y:kc(e),z:0}}unproject(t,e){const r=zc(t),n=Ec(e);return new mc(r,n)}}const bg=$e(Dc);class vg extends ag{project(t,e){const r=(e=$e(e))*e,n=r*r;return {x:.5*((t=$e(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const t=s*s;i=(r*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),r=Ke(r-i,-bg,bg);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=Ke(Ge(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=Ge(r);return new mc(a,o)}}const _g=$e(Dc);class wg extends ag{project(t,e){e=$e(e),t=$e(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),s=Math.sin(i)/i,a=.5*(t*n+2*r*Math.sin(t/2)/s)||0,o=.5*(e+Math.sin(e)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,d=p*p,m=1-c*h*h,y=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,x=.5*(2*g*i*p+2*r/Math.PI)-t,b=.5*(g*s+n)-e,v=.5*y*(c*d+g*i*h*u)+1/Math.PI,_=y*(f*l/4-g*s*p),w=.125*y*(l*p-g*s*c*f),M=.5*y*(u*h+g*d*i)+.5,A=_*w-M*v;a=(b*_-x*M)/A,o=(x*w-b*v)/A,r=Ke(r-a,-Math.PI,Math.PI),n=Ke(n-o,-_g,_g);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new mc(Ge(r),Ge(n))}}class Mg extends ag{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos($e(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:$e(t)*n*r+.5,y:-Math.sin($e(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,s=Ke(Ge((t-.5)/r)/n,-180,180),a=Math.asin(Ke(i*n,-1,1)),o=Ke(Ge(a),-Dc,Dc);return new mc(s,o)}}class Ag extends xg{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit=\"pixels\",this.unsupportedLayers=[\"debug\"],this.range=[3,5];}projectTilePoint(e,r,n){const i=Nh(e,r,n),s=$h(Ch(n));return t._.transformMat4(i,i,s),{x:i[0],y:i[1],z:i[2]}}locationPoint(e,r){const n=pc(r.lat,r.lng),i=t._.normalize([],n),s=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(r),e._centerAltitude):e._centerAltitude,a=Pc(1,0)*ps*s;t._.scaleAndAdd(n,n,i,a);const o=t.ad.identity(new Float64Array(16));return t.ad.multiply(o,e.pixelMatrix,e.globeMatrix),t._.transformMat4(n,n,o),new Ne(n[0],n[1])}pixelsPerMeter(t,e){return Pc(1,0)*e}pixelSpaceConversion(t,e,r){const n=Pc(1,t)*e,i=Gn(Pc(1,45)*e,n,r);return this.pixelsPerMeter(t,e)/i}createTileMatrix(e,r,n){const i=Gh(Ch(n.canonical));return t.ad.multiply(new Float64Array(16),e.globeMatrix,i)}createInversionMatrix(e,r){const{center:n}=e,i=$h(Ch(r));return t.ad.rotateY(i,i,$e(n.lng)),t.ad.rotateX(i,i,$e(n.lat)),t.ad.scale(i,i,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(i)}pointCoordinate(t,e,r,n){return Eh(t,e,r,!0)||new Oc(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !Eh(t,e.x,e.y,!1)}farthestPixelDistance(e){const r=function(e,r){const n=e.cameraToCenterDistance,i=e._centerAltitude*r,s=e._camera,a=e._camera.forward(),o=t._.add([],t._.scale([],a,-n),[0,0,i]),l=e.worldSize/(2*Math.PI),u=[0,0,-l],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),p=t._.scale([],s.up(),h),f=t._.scale([],s.right(),h*c),d=t._.normalize([],t._.add([],t._.add([],a,p),f)),m=[];let y;if(new gh(o,d).closestPointOnSphere(u,l,m)){const r=t._.add([],m,u),n=t._.sub([],r,o);y=Math.cos(e.fovAboveCenter)*t._.length(n);}else {const e=t._.sub([],o,u),r=t._.sub([],u,o);t._.normalize(r,r);const n=t._.length(e)-l;y=Math.sqrt(n*(n+2*l));const i=Math.acos(y/(l+n))-Math.acos(t._.dot(a,r));y*=Math.cos(i);}return 1.01*y}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=Hh(e.zoom);if(n>0){const t=rg(e,Pc(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),s=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Gn(r,t+i*(1-Math.cos(s)),Math.pow(n,10))}return r}upVector(t,e,r){return Nh(e,r,t,1)}upVectorScale(t){return {metersToTile:Ph(jh(Ch(t)))}}}function Sg(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case\"mercator\":return new xg(t);case\"equirectangular\":return new dg(t);case\"naturalEarth\":return new vg(t);case\"equalEarth\":return new fg(t);case\"winkelTripel\":return new wg(t);case\"albers\":return r?new Mg(t):new og(t);case\"lambertConformalConic\":return r?new Mg(t):new gg(t);case\"globe\":return new Ag(t)}throw new Error(`Invalid projection name: ${t.name}`)}class Ig{constructor(t,e,r,n){this.id=Ig.uniqueIdxCounter,Ig.uniqueIdxCounter++,this.context=t;const i=t.gl;this.buffer=i.createBuffer(),this.dynamicDraw=Boolean(r),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),i.bufferData(i.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||n||e.destroy();}bind(){this.context.bindElementBuffer.set(this.buffer);}updateData(t){this.id=Ig.uniqueIdxCounter,Ig.uniqueIdxCounter++;const e=this.context.gl;this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer);}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer);}}Ig.uniqueIdxCounter=0;class Tg{constructor(t,e,r){this.func=t,this.mask=e,this.range=r;}}Tg.ReadOnly=!1,Tg.ReadWrite=!0,Tg.disabled=new Tg(519,Tg.ReadOnly,[0,1]);const kg=7680;class Pg{constructor(t,e,r,n,i,s){this.test=t,this.ref=e,this.mask=r,this.fail=n,this.depthFail=i,this.pass=s;}}Pg.disabled=new Pg({func:519,mask:0},0,0,kg,kg,kg);const zg=771;class Eg{constructor(t,e,r,n){this.blendFunction=t,this.blendColor=e,this.mask=r,this.blendEquation=n;}}Eg.Replace=[1,0,1,0],Eg.disabled=new Eg(Eg.Replace,qn.transparent,[!1,!1,!1,!1]),Eg.unblended=new Eg(Eg.Replace,qn.transparent,[!0,!0,!0,!0]),Eg.alphaBlended=new Eg([1,zg,1,zg],qn.transparent,[!0,!0,!0,!0]),Eg.alphaBlendedNonPremultiplied=new Eg([770,zg,770,zg],qn.transparent,[!0,!0,!0,!0]),Eg.multiply=new Eg([774,0,774,0],qn.transparent,[!0,!0,!0,!0]);const Bg=1029,Dg=2305;class Cg{constructor(t,e,r){this.enable=t,this.mode=e,this.frontFace=r;}}Cg.disabled=new Cg(!1,Bg,Dg),Cg.backCCW=new Cg(!0,Bg,Dg),Cg.backCW=new Cg(!0,Bg,2304),Cg.frontCW=new Cg(!0,1028,2304),Cg.frontCCW=new Cg(!0,1028,Dg);const Rg=Sf.types,Vg=[{name:\"a_fade_opacity\",components:1,type:\"Uint8\",offset:0}];function Lg(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=o?Math.min(Ky,Math.round(o[0])):0,d=o?Math.min(Ky,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),s,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function Og(t,e,r){t.emplaceBack(e,r);}function Fg(t,e,r,n,i,s,a){t.emplaceBack(e,r,n,i,s,a);}function Ug(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function Ng(t){for(const e of t.sections)if(Vo(e.text))return !0;return !1}class jg{constructor(t){this.layoutVertexArray=new $l,this.indexArray=new Ql,this.programConfigurations=t,this.segments=new Au,this.dynamicLayoutVertexArray=new Fl,this.opacityVertexArray=new Yl,this.occlusionQueryOpacityVertexArray=new Xl,this.placedSymbolArray=new du,this.iconTransitioningVertexArray=new Zl,this.globeExtVertexArray=new Gl,this.zOffsetVertexArray=new Xl;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length&&0===this.iconTransitioningVertexArray.length}upload(t,e,r,n,i){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Ud.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,jd.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Vg,!0),this.occlusionQueryOpacityVertexBuffer=t.createVertexBuffer(this.occlusionQueryOpacityVertexArray,qd.members,!0),this.iconTransitioningVertexArray.length>0&&(this.iconTransitioningVertexBuffer=t.createVertexBuffer(this.iconTransitioningVertexArray,Gd.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Nd.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||i)&&(this.zOffsetVertexBuffer=t.createVertexBuffer(this.zOffsetVertexArray,$d.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.occlusionQueryOpacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy());}}Mo(jg,\"SymbolBuffers\");class qg{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new Au,this.collisionVertexArray=new Jl,this.collisionVertexArrayExt=new Fl;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Yd.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,Xd.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Mo(qg,\"CollisionBuffers\");class $g{constructor(e){this.queries=new Map,this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.lut=e.lut,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.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=t.ad.identity([]),this.placementViewportMatrix=t.ad.identity([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Nm(this.zoom,r[\"text-size\"]),this.iconSizeData=Nm(this.zoom,r[\"icon-size\"]);const n=this.layers[0].layout,i=n.get(\"symbol-sort-key\"),s=n.get(\"symbol-z-order\");this.canOverlap=n.get(\"text-allow-overlap\")||n.get(\"icon-allow-overlap\")||n.get(\"text-ignore-placement\")||n.get(\"icon-ignore-placement\"),this.sortFeaturesByKey=\"viewport-y\"!==s&&void 0!==i.constantOr(1),this.sortFeaturesByY=(\"viewport-y\"===s||\"auto\"===s&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get(\"text-writing-mode\").map((t=>ty[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID,this.projection=e.projection,this.hasAnyZOffset=!1,this.zOffsetSortDirty=!1,this.zOffsetBuffersNeedUpload=n.get(\"symbol-z-elevate\"),this.activeReplacements=[],this.replacementUpdateTime=0;}createArrays(){this.text=new jg(new Wu(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^text/.test(t)))),this.icon=new jg(new Wu(this.layers,{zoom:this.zoom,lut:this.lut},(t=>/^icon/.test(t)))),this.glyphOffsetArray=new gu,this.lineVertexArray=new xu,this.symbolInstances=new yu;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&(\"constant\"!==l.value.kind||l.value.value.length>0),p=\"constant\"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,f=a.get(\"symbol-sort-key\");if(this.features=[],!h&&!p)return;const d=r.iconDependencies,m=r.glyphDependencies,y=r.availableImages,g=new Ho(this.zoom);for(const{feature:r,id:u,index:c,sourceLayerIndex:x}of e){const e=s._featureFilter.needGeometry,b=Xc(r,e);if(!s._featureFilter.filter(g,b,n))continue;if(e||(b.geometry=Yc(r,n,i)),o&&1!==r.type&&n.z<=5){const e=b.geometry,r=.98078528056,i=(e,i)=>{const s=Nh(e.x,e.y,n,1),a=Nh(i.x,i.y,n,1);return t._.dot(s,a)=0;for(const r of v.sections)if(r.image)d[r.image.namePrimary]=!0;else {const n=Po(v.toString()),i=r.fontStack||t,s=m[i]=m[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n);}}}\"line\"===a.get(\"symbol-placement\")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n,i){const s=0!==Object.keys(t).length;if(s&&!this.stateDependentLayers.length)return;const a=s?this.stateDependentLayers:this.layers;this.text.programConfigurations.updatePaintArrays(t,e,a,r,n,i),this.icon.programConfigurations.updatePaintArrays(t,e,a,r,n,i);}updateOcclusionOpacities(t,e,r){if(!e.useOcclusionQueries)return !1;const n=this;if(\"globe\"===n.projection.name)return !1;let i=!1;n.hasTextData()&&(i=i||0!==n.text.occlusionQueryOpacityVertexArray.length),n.hasIconData()&&(i=i||0!==n.icon.occlusionQueryOpacityVertexArray.length);const s=n.layers[0].paint,a=s.get(\"icon-occlusion-opacity\").constantOr(0),o=s.get(\"text-occlusion-opacity\").constantOr(0);if(!n.layers[0].hasInitialOcclusionOpacityProperties||1===a&&1===o)return !1;let l=!i;for(let t=0;t.5?1:-1)*e.fadeSpeed*r*.001,i.occlusionOpacity=Ke(i.occlusionOpacity,0,1),l=l||i.occlusionOpacity!==s;}if(!l)return !1;let u=0,c=0;const h=(t,e,r,n)=>{let i=0,s=0;r?(i=c,c+=n,s=c):(i=u,u+=n,s=u),s>e.occlusionQueryOpacityVertexArray.length&&e.occlusionQueryOpacityVertexArray.resize(s);const a=t.occlusionOpacity;for(let t=0;t0;if((r>0||i>0)&&(h(e,n.text,!1,r),h(e,n.text,!1,i)),a){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=e;t>=0&&h(e,n.icon,!0,s),r>=0&&h(e,n.icon,!0,e.numVerticalIconVertices);}}return n.hasTextData()&&n.text.occlusionQueryOpacityVertexBuffer&&(n.text.occlusionQueryOpacityVertexBuffer.length{r+=e,r>t.length&&t.resize(r);for(let i=-e;i<0;i++)t.emplace(i+r,n);},e=(t,e,r)=>{n+=e,n>t.length&&t.resize(n);for(let i=-e;i<0;i++)t.emplace(i+n,r);};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let r=0,n=0;for(let r=0;r0;if((i>0||s>0)&&(t(this.text.zOffsetVertexArray,i,o),t(this.text.zOffsetVertexArray,s,o)),l){const{placedIconSymbolIndex:t,verticalPlacedIconSymbolIndex:r}=n;t>=0&&e(this.icon.zOffsetVertexArray,a,o),r>=0&&e(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,o);}}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(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload,this.zOffsetBuffersNeedUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Sg(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();for(const t of this.queries.values())t.destroy();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:r}of e)this.lineVertexArray.emplaceBack(t,r);return {lineStartIndex:r,lineLength:this.lineVertexArray.length-r}}addSymbols(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,m){const y=t.indexArray,g=t.layoutVertexArray,x=t.globeExtVertexArray,b=t.segments.prepareSegment(4*e.length,g,y,this.canOverlap?s.sortKey:void 0),v=this.glyphOffsetArray.length,_=b.vertexLength,w=this.allowVerticalPlacement&&a===ty.vertical?Math.PI/2:0,M=s.text&&s.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),s=jm(this.textSizeData,t,i)/Fm;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=jm(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r,n){t.emplaceBack(e,-r,-r,n),t.emplaceBack(e,r,-r,n),t.emplaceBack(e,r,r,n),t.emplaceBack(e,-r,r,n);}_updateTextDebugCollisionBoxes(t,e,r,n,i,s){for(let a=n;a0}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(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let t=0;tthis.symbolInstances.get(e).zOffset-this.symbolInstances.get(t).zOffset))}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:s,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:o}=e;r>=0&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&this.addIndicesForPlacedSymbol(this.text,n),i>=0&&i!==n&&i!==r&&this.addIndicesForPlacedSymbol(this.text,i),s>=0&&this.addIndicesForPlacedSymbol(this.text,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),o>=0&&this.addIndicesForPlacedSymbol(this.icon,o);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Mo($g,\"SymbolBucket\",{omit:[\"layers\",\"collisionBoxArray\",\"features\",\"compareText\"]}),$g.addDynamicAttributes=Ug;class Gg{constructor(t,e,r,n){this.context=t,this.format=r,this.texture=t.gl.createTexture(),this.update(e,n);}update(t,e,r){const{width:n,height:i}=t,{context:s}=this,{gl:a}=s;if(a.bindTexture(a.TEXTURE_2D,this.texture),s.pixelStoreUnpackFlipY.set(!1),s.pixelStoreUnpack.set(1),s.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!e||!1!==e.premultiply)),this.useMipmap=Boolean(e&&e.useMipmap),r||this.size&&this.size[0]===n&&this.size[1]===i){const{x:e,y:s}=r||{x:0,y:0};if(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap)a.texSubImage2D(a.TEXTURE_2D,0,e,s,a.RGBA,a.UNSIGNED_BYTE,t);else {let r=this.format,o=a.UNSIGNED_BYTE;this.format===a.R32F&&(r=a.RED,o=a.FLOAT),a.texSubImage2D(a.TEXTURE_2D,0,e,s,n,i,r,o,t.data);}}else if(this.size=[n,i],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||ImageBitmap&&t instanceof ImageBitmap){let e=this.format;this.format===a.R8&&(e=a.RED),a.texImage2D(a.TEXTURE_2D,0,this.format,e,a.UNSIGNED_BYTE,t);}else {let e=this.format,r=this.format,s=a.UNSIGNED_BYTE,o=!1;this.format===a.DEPTH_COMPONENT&&(e=a.DEPTH_COMPONENT16,s=a.UNSIGNED_SHORT),this.format===a.DEPTH_STENCIL&&(e=a.DEPTH24_STENCIL8,s=a.UNSIGNED_INT_24_8,o=!0),this.format===a.R8&&(r=a.RED),this.format===a.R32F&&(s=a.FLOAT,r=a.RED),!this.useMipmap&&o?a.texStorage2D(a.TEXTURE_2D,1,e,n,i):a.texImage2D(a.TEXTURE_2D,0,e,n,i,0,r,s,t.data);}this.useMipmap&&a.generateMipmap(a.TEXTURE_2D);}bind(t,e,r=!1){const{context:n}=this,{gl:i}=n;i.bindTexture(i.TEXTURE_2D,this.texture),t!==this.minFilter&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.useMipmap&&!r?t===i.NEAREST?i.NEAREST_MIPMAP_NEAREST:i.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),e!==this.wrapS&&(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,e),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,e),this.wrapS=e);}bindExtraParam(t,e,r,n){const{context:i}=this,{gl:s}=i;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),this.magFilter=e),t!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?t===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:t),this.minFilter=t),r!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,r),this.wrapS=r),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}}class Yg{constructor(t,e){this.context=t,this.texture=e;}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_2D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}}const Xg=32,Zg=33,Hg=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,r=0,n=0,i=0,s=0,a=0,o=0;for(1&e?i=s=a=Xg:r=n=o=Xg;(e>>=1)>1;){const t=r+i>>1,l=n+s>>1;1&e?(i=r,s=n,r=a,n=o):(r=i,n=s,i=a,s=o),a=t,o=l;}const l=4*t;Hg[l+0]=r,Hg[l+1]=n,Hg[l+2]=i,Hg[l+3]=s;}const Kg=new Uint16Array(2178),Wg=new Uint8Array(1089),Jg=new Uint16Array(1089);function Qg(t){return 0===t?-.03125:32===t?.03125:0}var tx=Bl([{name:\"a_pos\",type:\"Int16\",components:2},{name:\"a_texture_pos\",type:\"Int16\",components:2}]),ex=Bl([{name:\"a_index\",type:\"Int16\",components:1}]);const rx=(()=>({type:2,extent:ps,loadGeometry:()=>[[new Ne(0,0),new Ne(ps+1,0),new Ne(ps+1,ps+1),new Ne(0,ps+1),new Ne(0,0)]]}))();class nx{constructor(t,e,r,n,i){this.tileID=t,this.uid=nr(),this.uses=0,this.tileSize=e,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state=\"loading\",n&&n.transform&&(this.projection=n.transform.projection);}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)r[e.fqid]=n;}}return r}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof $g){if(this.hasSymbolBuckets=!0,!r)break;e.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof $g&&e.hasRTLText){this.hasRTLText=!0,Zo.isLoading()||Zo.isLoaded()||\"deferred\"!==Yo()||Xo();break}}this.queryPadding=0;for(const t in this.buckets){const r=this.buckets[t],n=e.style.getOwnLayer(t);if(!n)continue;const i=n.queryRadius(r);this.queryPadding=Math.max(this.queryPadding,i);}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas),this._lastUpdatedBrightness=t.brightness;}else this.collisionBoxArray=new pu;}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state=\"unloaded\";}}getBucket(t){return this.buckets[t.fqid]}upload(t){for(const e in this.buckets){const r=this.buckets[e];r.uploadPending()&&r.upload(t);}const e=t.gl,r=this.imageAtlas;if(r&&!r.uploaded){const n=!!Object.keys(r.patternPositions).length;this.imageAtlasTexture=new Gg(t,r.image,e.RGBA,{useMipmap:n}),this.imageAtlas.uploaded=!0;}this.glyphAtlasImage&&(this.glyphAtlasTexture=new Gg(t,this.glyphAtlasImage,e.R8),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Gg(t,this.lineAtlas.image,e.R8),this.lineAtlas.uploaded=!0);}prepare(t,e,r){if(this.imageAtlas&&this.imageAtlasTexture&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture,r),!e||!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData)return;const n=e.style.getBrightness();(this._lastUpdatedBrightness||n)&&(this._lastUpdatedBrightness&&n&&Math.abs(this._lastUpdatedBrightness-n)<.001||(this._lastUpdatedBrightness=n,this.updateBuckets(void 0,e)));}queryRenderedFeatures(t,e,r,n,i,s,a,o){return this.latestFeatureIndex&&(this.latestFeatureIndex.rawTileData||this.latestFeatureIndex.is3DTile)?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:a,transform:s,params:i,tileTransform:this.tileTransform},t,e,r):{}}querySourceFeatures(t,e){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),i=e?e.sourceLayer:\"\",s=n._geojsonTileLayer||n[i];if(!s)return;const a=pl(e&&e.filter),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let e=0;et)r=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,r=Hg[e+0],n=Hg[e+1],i=Hg[e+2],s=Hg[e+3],a=r+i>>1,o=n+s>>1,l=a+o-n,u=o+r-a,c=n*Zg+r,h=s*Zg+i,p=o*Zg+a,f=Math.hypot((Kg[2*c+0]+Kg[2*h+0])/2-Kg[2*p+0],(Kg[2*c+1]+Kg[2*h+1])/2-Kg[2*p+1])>=16;Wg[p]=Wg[p]||(f?1:0),t<1022&&(Wg[p]=Wg[p]||Wg[(n+u>>1)*Zg+(r+l>>1)]||Wg[(s+u>>1)*Zg+(i+l>>1)]);}const i=new Vl,s=new Ql;let a=0;function o(t,e){const r=e*Zg+t;return 0===Jg[r]&&(i.emplaceBack(Kg[2*r+0],Kg[2*r+1],t*ps/Xg,e*ps/Xg),Jg[r]=++a),Jg[r]-1}function l(t,e,r,n,i,a){const u=t+r>>1,c=e+n>>1;if(Math.abs(t-i)+Math.abs(e-a)>1&&Wg[c*Zg+u])l(i,a,t,e,u,c),l(r,n,i,a,u,c);else {const l=o(t,e),u=o(r,n),c=o(i,a);s.emplaceBack(l,u,c);}}return l(0,0,Xg,Xg,Xg,0),l(Xg,Xg,0,0,0,Xg),{vertices:i,indices:s}}(this.tileID.canonical,e);n=t.vertices,i=t.indices;}else {n=new Vl,i=new Ql;for(const{x:t,y:e}of r)n.emplaceBack(t,e,0,0);const t=wp(n.int16,void 0,4);for(let e=0;e0&&(o=t.ad.invert(new Float64Array(16),r.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,i,r,s,o,a),this._makeGlobeTileDebugTextBuffer(e,i,r,s,o,a);}_globePoint(e,r,n,i,s,a,o){let l=Nh(e,r,n);if(a){const s=1<.5?p=-1:h<-.5&&(p=1);let f=(e/ps+n.x)/s+p,d=(r/ps+n.y)/s;f=(f-u)*i._pixelsPerMercatorPixel+u,d=(d-c)*i._pixelsPerMercatorPixel+c;const m=[f*i.worldSize,d*i.worldSize,0];t._.transformMat4(m,m,a),l=Rh(l,m,o);}return t._.transformMat4(l,l,s)}_makeGlobeTileDebugBorderBuffer(t,e,r,n,i,s){const a=new Cl,o=new au,l=new Rl,u=(t,u,c,h,p)=>{const f=(c-t)/(p-1),d=(h-u)/(p-1),m=a.length;for(let c=0;cc*t+e;for(let t=0;t\n * @license BSD-3-Clause\n * @version 11.2.11\n */class px{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e;}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev);}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null);}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0));}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,n=this.resetTtl){let i;if(r||this.has(t)){if(i=this.items[t],i.value=e,!1===r&&n&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,r=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==r&&(r.next=e),null!==e&&(e.prev=r);}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}function fx(t,e){if(4!==e.length)throw new Error(`Expected data of dimension 4 but got ${e.length}.`);let r=e[3];for(let n=2;n>=1;n--){const i=1===n?1:0,s=2===n?1:0;for(let n=0;n>>1^-(1&t[e]);return t}function mx(t,e){switch(e){case\"uint32\":return t;case\"uint16\":for(let e=0;e>4|(61440&r)>>8|(240&n)<<4|61440&n,t[e+1]=15&r|(3840&r)>>4|(15&n)<<8|(3840&n)<<4;}return t;case\"uint8\":for(let e=0;e>6|(192&n)>>4|(192&i)>>2|192&s,t[e+1]=(48&r)>>4|(48&n)>>2|48&i|(48&s)<<2,t[e+2]=(12&r)>>2|12&n|(12&i)<<2|(12&s)<<4,t[e+3]=3&r|(3&n)<<2|(3&i)<<4|(3&s)<<6;}return t;default:throw new Error(`Invalid pixel format, \"${e}\"`)}}class yx extends Error{constructor(t){super(t),this.name=\"MRTError\";}}var gx=Uint8Array,xx=Uint16Array,bx=Int32Array,vx=new gx([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]),_x=new gx([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]),wx=new gx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mx=function(t,e){for(var r=new xx(31),n=0;n<31;++n)r[n]=e+=1<>1|(21845&Px)<<1;kx[Px]=((65280&(zx=(61680&(zx=(52428&zx)>>2|(13107&zx)<<2))>>4|(3855&zx)<<4))>>8|(255&zx)<<8)>>1;}var Ex=function(t,e,r){for(var n=t.length,i=0,s=new xx(e);i>l]=u;}else for(a=new xx(n),i=0;i>15-t[i]);return a},Bx=new gx(288);for(Px=0;Px<144;++Px)Bx[Px]=8;for(Px=144;Px<256;++Px)Bx[Px]=9;for(Px=256;Px<280;++Px)Bx[Px]=7;for(Px=280;Px<288;++Px)Bx[Px]=8;var Dx=new gx(32);for(Px=0;Px<32;++Px)Dx[Px]=5;var Cx=Ex(Bx,9,1),Rx=Ex(Dx,5,1),Vx=function(t){for(var e=t[0],r=1;re&&(e=t[r]);return e},Lx=function(t,e,r){var n=e/8|0;return (t[n]|t[n+1]<<8)>>(7&e)&r},Ox=function(t,e){var r=e/8|0;return (t[r]|t[r+1]<<8|t[r+2]<<16)>>(7&e)},Fx=[\"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\"],Ux=function(t,e,r){var n=new Error(e||Fx[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,Ux),!r)throw n;return n},Nx=new gx(0),jx=\"undefined\"!=typeof TextDecoder&&new TextDecoder;try{jx.decode(Nx,{stream:!0});}catch(t){}const qx={gzip_data:\"gzip\"};const $x={0:\"uint32\",1:\"uint32\",2:\"uint16\",3:\"uint8\"},Gx={uint32:1,uint16:2,uint8:4},Yx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};class Xx{constructor(t=1){this.x=NaN,this.y=NaN,this.z=NaN,this.layers={},this._cacheSize=t;}getLayer(t){return this.layers[t]}getHeaderLength(t){const e=new Uint8Array(t),r=new DataView(t);if(13!==e[0])throw new yx(\"File is not a valid MRT.\");return r.getUint32(1,!0)}parseHeader(t){const e=new Uint8Array(t),r=this.getHeaderLength(t);if(e.length= ${r} but got buffer of length ${e.length}`);const n=function(t,e){return t.readFields(ix,{header_length:0,x:0,y:0,z:0,layers:[]},void 0)}(new Bm(e.subarray(0,r)));if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new yx(`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 t of n.layers)this.layers[t.name]=new Zx(t,{cacheSize:this._cacheSize});return this}createDecodingTask(t){const e=[],r=this.getLayer(t.layerName);for(let n=0;nt.lastBlock)continue;if(r._blocksInProgress.has(n))continue;const o={layerName:r.name,firstByte:s,lastByte:a,pixelFormat:r.pixelFormat,blockIndex:n,blockShape:[i.bands.length].concat(r.bandShape),buffer:r.buffer,codec:i.codec.codec,filters:i.filters.map((t=>t.filter))};r._blocksInProgress.add(n),e.push(o);}return new Hx(e,(()=>{e.forEach((t=>r._blocksInProgress.delete(t.blockIndex)));}),((t,n)=>{if(e.forEach((t=>r._blocksInProgress.delete(t.blockIndex))),t)throw t;n.forEach((t=>{this.getLayer(t.layerName).processDecodedData(t);}));}))}}class Zx{constructor({version:t,name:e,units:r,tilesize:n,pixel_format:i,buffer:s,data_index:a},o){if(this.version=t,1!==this.version)throw new yx(`Cannot parse raster layer encoded with MRT version ${t}`);this.name=e,this.units=r,this.tileSize=n,this.buffer=s,this.pixelFormat=$x[i],this.dataIndex=a,this.bandShape=[n+2*s,n+2*s,Gx[this.pixelFormat]],this._decodedBlocks=function(t=1e3,e=0,r=!1){if(isNaN(t)||t<0)throw new TypeError(\"Invalid max value\");if(isNaN(e)||e<0)throw new TypeError(\"Invalid ttl value\");if(\"boolean\"!=typeof r)throw new TypeError(\"Invalid resetTtl value\");return new px(t,e,r)}(o?o.cacheSize:5),this._blocksInProgress=new Set;}processDecodedData(t){const e=t.blockIndex.toString();this._decodedBlocks.get(e)||this._decodedBlocks.set(e,t.data);}getBlockForBand(t){let e=0;switch(typeof t){case\"string\":for(const[r,n]of this.dataIndex.entries()){for(const[i,s]of n.bands.entries())if(s===t)return {bandIndex:e+i,blockIndex:r,blockBandIndex:i};e+=n.bands.length;}break;case\"number\":for(const[r,n]of this.dataIndex.entries()){if(t>=e&&t=0}hasDataForBand(t){const{blockIndex:e}=this.getBlockForBand(t);return e>=0&&!!this._decodedBlocks.get(e.toString())}getBandView(t){const{blockIndex:e,blockBandIndex:r}=this.getBlockForBand(t),n=this._decodedBlocks.get(e.toString());if(!n)throw new yx(`Data for band ${JSON.stringify(t)} of layer \"${this.name}\" not decoded.`);const i=this.dataIndex[e],s=this.bandShape.reduce(((t,e)=>t*e),1),a=r*s,o=n.subarray(a,a+s);return {data:o,bytes:new Uint8Array(o.buffer).subarray(o.byteOffset,o.byteOffset+o.byteLength),tileSize:this.tileSize,buffer:this.buffer,offset:i.offset,scale:i.scale}}}class Hx{constructor(t,e,r){this.tasks=t,this._onCancel=e,this._onComplete=r,this._finalized=!1;}cancel(){this._finalized||(this._onCancel(),this._finalized=!0);}complete(t,e){this._finalized||(this._onComplete(t,e),this._finalized=!0);}}Xx.performDecoding=function(t,e){return Promise.all(e.tasks.map((e=>{const{layerName:r,firstByte:n,lastByte:i,pixelFormat:s,blockShape:a,blockIndex:o,filters:l,codec:u}=e,c=new Uint8Array(t).subarray(n,i+1),h=new Uint32Array(a[0]*a[1]*a[2]);let p;if(\"gzip_data\"!==u)throw new Error(`Unhandled codec: ${u}`);return p=function(t,e){if(!globalThis.DecompressionStream&&\"gzip_data\"===e)return Promise.resolve(((s=function(t){31==t[0]&&139==t[1]&&8==t[2]||Ux(6,\"invalid gzip data\");var e=t[3],r=10;4&e&&(r+=2+(t[10]|t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(2&e)}(i=t))+8>i.length&&Ux(6,\"invalid gzip data\"),function(t,e,r,n){var i=t.length;if(!i||e.f&&!e.l)return r||new gx(0);var s=!r,a=s||2!=e.i,o=e.i;s&&(r=new gx(3*i));var l,u,c=function(t){var e=r.length;if(t>e){var n=new gx(Math.max(2*e,t));n.set(r),r=n;}},h=e.f||0,p=e.p||0,f=e.b||0,d=e.l,m=e.d,y=e.m,g=e.n,x=8*i;do{if(!d){h=Lx(t,p,1);var b=Lx(t,p+1,3);if(p+=3,!b){var v=t[(E=4+((p+7)/8|0))-4]|t[E-3]<<8,_=E+v;if(_>i){o&&Ux(0);break}a&&c(f+v),r.set(t.subarray(E,_),f),e.b=f+=v,e.p=p=8*_,e.f=h;continue}if(1==b)d=Cx,m=Rx,y=9,g=5;else if(2==b){var w=Lx(t,p,31)+257,M=Lx(t,p+10,15)+4,A=w+Lx(t,p+5,31)+1;p+=14;for(var S=new gx(A),I=new gx(19),T=0;T>4)<16)S[T++]=E;else {var D=0,C=0;for(16==E?(C=3+Lx(t,p,3),p+=2,D=S[T-1]):17==E?(C=3+Lx(t,p,7),p+=3):18==E&&(C=11+Lx(t,p,127),p+=7);C--;)S[T++]=D;}}var R=S.subarray(0,w),V=S.subarray(w);y=Vx(R),g=Vx(V),d=Ex(R,y,1),m=Ex(V,g,1);}else Ux(1);if(p>x){o&&Ux(0);break}}a&&c(f+131072);for(var L=(1<>4;if((p+=15&D)>x){o&&Ux(0);break}if(D||Ux(2),U<256)r[f++]=U;else {if(256==U){F=p,d=null;break}var N=U-254;U>264&&(N=Lx(t,p,(1<<($=vx[T=U-257]))-1)+Sx[T],p+=$);var j=m[Ox(t,p)&O],q=j>>4;if(j||Ux(3),p+=15&j,V=Tx[q],q>3){var $=_x[q];V+=Ox(t,p)&(1<<$)-1,p+=$;}if(p>x){o&&Ux(0);break}a&&c(f+131072);var G=f+N;if(fl.length)&&(u=l.length),new gx(l.subarray(0,u))):r.subarray(0,f)}(i.subarray(s,-8),{i:2},new gx(((r=i)[(n=r.length)-4]|r[n-3]<<8|r[n-2]<<16|r[n-1]<<24)>>>0))));var r,n,i,s;const a=qx[e];if(!a)throw new Error(`Unhandled codec: ${e}`);const o=new globalThis.DecompressionStream(a);return new Response(new Blob([t]).stream().pipeThrough(o)).arrayBuffer().then((t=>new Uint8Array(t)))}(c,u).then((t=>(function(t,e){t.readFields(cx,e);}(new Bm(t),h),new(0,Yx[s])(h.buffer)))),p.then((t=>{for(let e=l.length-1;e>=0;e--)switch(l[e]){case\"delta_filter\":fx(t,a);break;case\"zigzag_filter\":dx(t);break;case\"bitshuffle_filter\":mx(t,s);break;default:throw new Error(`Unhandled filter \"${l[e]}\"`)}return {layerName:r,blockIndex:o,data:t}})).catch((t=>{throw t}))})))};class Kx extends nx{constructor(t,e,r,n,i){super(t,e,r,n,i),this._workQueue=[],this._fetchQueue=[],this._isHeaderLoaded=!1;}setTexture(t,e){const r=e.context,n=r.gl;this.texture=this.texture||e.getTileTexture(t.width),this.texture&&this.texture instanceof Gg?this.texture.update(t,{useMipmap:!1,premultiply:!1}):this.texture=new Gg(r,t,n.RGBA,{useMipmap:!1,premultiply:!1});}flushQueues(){for(;this._workQueue.length;)this._workQueue.pop()();for(;this._fetchQueue.length;)this._fetchQueue.pop()();}fetchHeader(t=16384,e){const r=this._mrt=new Xx(30),n=Object.assign({},this.requestParams,{headers:{Range:\"bytes=0-\"+(t-1)}});return this.entireBuffer=null,this.request=en(n,((n,i,s,a)=>{if(n)e(n);else try{const n=r.getHeaderLength(i);if(n>t)return void(this.request=this.fetchHeader(n,e));r.parseHeader(i),this._isHeaderLoaded=!0;let o=0;for(const t of Object.values(r.layers))o=Math.max(o,t.dataIndex[t.dataIndex.length-1].last_byte);i.byteLength>=o&&(this.entireBuffer=i),e(null,this.entireBuffer||i,s,a);}catch(t){e(t);}})),this.request}fetchBand(t,e,r){const n=this._mrt;if(!this._isHeaderLoaded||!n)return void r(new Error(\"Tile header is not ready\"));const i=this.actor;if(!i)return void r(new Error(\"Can't fetch tile band without an actor\"));let s;const a=(n,i)=>{s.complete(n,i),n?r(n):(this.updateTextureDescriptor(t,e),r(null,this.textureDescriptor&&this.textureDescriptor.img));},o=(t,e)=>{if(t)return r(t);const n=i.send(\"decodeRasterArray\",{buffer:e,task:s},a,void 0,!0);this._workQueue.push((()=>{n&&n.cancel(),s.cancel();}));},l=n.getLayer(t);if(!l)return void r(new Error(`Unknown sourceLayer \"${t}\"`));if(l.hasDataForBand(e))return this.updateTextureDescriptor(t,e),void r(null,this.textureDescriptor?this.textureDescriptor.img:null);const u=l.getDataRange([e]);if(s=n.createDecodingTask(u),!s||s.tasks.length)if(this.flushQueues(),this.entireBuffer)o(null,this.entireBuffer.slice(u.firstByte,u.lastByte+1));else {const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${u.firstByte}-${u.lastByte}`}}),e=en(t,o);this._fetchQueue.push((()=>{e.cancel(),s.cancel();}));}else r(null);}updateNeeded(t,e){return (!this.textureDescriptor||this.textureDescriptor.band!==e||this.textureDescriptor.layer!==t)&&\"errored\"!==this.state}updateTextureDescriptor(t,e){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(e)||!r.hasDataForBand(e))return;const{bytes:n,tileSize:i,buffer:s,offset:a,scale:o}=r.getBandView(e),l=i+2*s,u={data:n,width:l,height:l},c=this.texture;c&&c instanceof Gg&&c.update(u,{useMipmap:!1,premultiply:!1}),this.textureDescriptor={layer:t,band:e,img:u,buffer:s,offset:a,tileSize:i,format:r.pixelFormat,mix:[o,256*o,65536*o,16777216*o]};}}class Wx{constructor(t,e){this.max=t,this.onRemove=e,this.reset();}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,r){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const i={value:e,timeout:void 0};if(void 0!==r&&(i.timeout=setTimeout((()=>{this.remove(t,i);}),r)),this.data[n].push(i),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const r in this.data)for(const n of this.data[r])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t);}}class Jx extends Ln{constructor(t,e,r){super(),this.id=t,this._onlySymbols=r,e.on(\"data\",(t=>{\"source\"===t.dataType&&\"metadata\"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&\"source\"===t.dataType&&\"content\"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),e.on(\"error\",(()=>{this._sourceErrored=!0;})),this._source=e,this._tiles={},this._cache=new Wx(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this.castsShadows=!1,this.tileCoverLift=0,this._coveredTiles={},this._shadowCasterTiles={},this._state=new Rm,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(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const t in this._tiles){const e=this._tiles[t];if(\"errored\"!==e.state&&(\"loaded\"!==e.state||!e.bucketsLoaded()))return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,t.isExtraShadowCaster=this._shadowCasterTiles[t.tileID.key],this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t)}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t)}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const r=this._tiles[e];r.upload(t),r.prepare(this.map.style.imageManager,this.map?this.map.painter:null,this._source.scope);}}getIds(){return tr(this._tiles).map((t=>t.tileID)).sort(Qx).map((t=>t.key))}getRenderableIds(t,e){const r=[];for(const n in this._tiles)this._isIdRenderable(+n,t,e)&&r.push(this._tiles[n]);return t?r.sort(((t,e)=>{const r=t.tileID,n=e.tileID,i=new Ne(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new Ne(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||s.y-i.y||s.x-i.x})).map((t=>t.tileID.key)):r.map((t=>t.tileID)).sort(Qx).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return !!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e,r){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())&&(r||!this._shadowCasterTiles[t])}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)\"errored\"!==this._tiles[t].state&&this._reloadTile(+t,\"reloading\");}}_reloadTile(t,e){const r=this._tiles[t];r&&(\"loading\"!==r.state&&(r.state=e),this._loadTile(r,this._tileLoaded.bind(this,r,t,e)));}_tileLoaded(t,e,r,n){if(n)if(t.state=\"errored\",404!==n.status)this._source.fire(new Cn(n,{tile:t}));else {if(!(t.tileID.key in this._loadedParentTiles))return void this._source.fire(new Dn(\"data\",{dataType:\"source\",sourceDataType:\"error\",sourceId:this._source.id}));if(\"raster-dem\"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id);}else this.update(this.transform);}else t.timeAdded=Dr.now(),\"expired\"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),\"raster-dem\"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Dn(\"data\",{dataType:\"source\",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[s]&&(t.neighboringTiles[s].backfilled=!0)));}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,r,n){for(const i in this._tiles){let s=this._tiles[i];if(n[i]||!s.hasData()||s.tileID.overscaledZ<=e||s.tileID.overscaledZ>r)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>e+1;){const t=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[t.key],s&&s.hasData()&&(a=t);}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){n[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=e?r:null}for(let r=t.overscaledZ-1;r>=e;r--){const e=t.scaledTo(r),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const r=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,i=Math.floor(r*n*5),s=\"number\"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a=\"number\"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(a);}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const r in this._tiles){const n=this._tiles[r];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n;}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t]);}}update(t,e,r,n){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let i;if(this.updateCacheSize(t,e),\"globe\"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={},this.used||this.usedForTerrain){if(this._source.tileID)i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new _c(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y)));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,i=n.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.minzoom<=1&&\"globe\"===t.projection.name&&(i.push(new _c(1,0,1,0,0)),i.push(new _c(1,0,1,1,0)),i.push(new _c(1,0,1,0,1)),i.push(new _c(1,0,1,1,1)));}else if(i=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile){const t=this._source.hasTile.bind(this._source);i=i.filter((e=>t(e)));}}else i=[];if(i.length>0&&this.castsShadows&&n&&\"globe\"!==this.transform.projection.name&&!this.usedForTerrain&&!tb(this._source.type)){const s=t.coveringZoomLevel({tileSize:e||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),a=Math.min(s,this._source.maxzoom),o=t.extendTileCoverForShadows(i,n,a);for(const t of o)this._shadowCasterTiles[t.key]=!0,i.push(t);}const s=this._updateRetainedTiles(i);if(tb(this._source.type)&&0!==i.length){const t={},e={},r=Object.keys(s);for(const n of r){const r=s[n],i=this._tiles[n];if(!i||i.fadeEndTime&&i.fadeEndTime<=Dr.now())continue;const a=this.findLoadedParent(r,Math.max(r.overscaledZ-Jx.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),e[n]=r;}const n=i[i.length-1].overscaledZ;for(const t in this._tiles){const r=this._tiles[t];if(s[t]||!r.hasData())continue;let i=r.tileID;for(;i.overscaledZ>n;){i=i.scaledTo(i.overscaledZ-1);const n=this._tiles[i.key];if(n&&n.hasData()&&e[i.key]){s[t]=r.tileID;break}}}for(const e in t)s[e]||(this._coveredTiles[e]=!0,s[e]=t[e]);}for(const t in s)this._tiles[t].clearFadeHold();const a=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r}(this._tiles,s);for(const t of a){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t);}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const r={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),i=t[0].overscaledZ,s=Math.max(i-Jx.maxOverzooming,this._source.minzoom),a=Math.max(i+Jx.maxUnderzooming,this._source.minzoom),o={};for(const r of t){const t=this._addTile(r);e[r.key]=r,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],r=this.getTile(t);if(r&&r.hasData()){e[t.key]=t;continue}}else {const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let i=t.wasRequested();for(let a=n.overscaledZ-1;a>=s;--a){const s=n.scaledTo(a);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&i&&(t=this._addTile(s)),t&&(e[s.key]=s,i=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let r,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){r=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(r=this._getLoadedTile(t),r)break;n=t;}for(const t of e)this._loadedParentTiles[t]=r;}}_addTile(t){let e=this._tiles[t.key];if(e)return !0!==e.isExtraShadowCaster||!!this._shadowCasterTiles[t.key]||this._reloadTile(t.key,\"reloading\"),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const r=Boolean(e);if(!r){const r=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();e=\"raster-array\"===this._source.type?new Kx(t,n,this.transform.tileZoom,r,this._isRaster):new nx(t,n,this.transform.tileZoom,r,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state));}return e?(e.uses++,this._tiles[t.key]=e,r||this._source.fire(new Dn(\"dataloading\",{tile:e,coord:e.tileID,dataType:\"source\"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,\"expired\"),delete this._timers[t];}),r));}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&\"reloading\"!==e.state||\"empty\"===e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);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,e,r){const n=[],i=this.transform;if(!i)return n;const s=\"globe\"===i.projection.name,a=Tc(i.center.lng);for(const o in this._tiles){const l=this._tiles[o];if(r&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(s){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(Ke(a,...eb(t,-1))-a),Math.abs(Ke(a,...eb(t,1))-a)];u=[0,2*e.indexOf(Math.min(...e))-1];}else {const e=[Math.abs(Ke(a,...eb(t,-1))-a),Math.abs(Ke(a,...eb(t,0))-a),Math.abs(Ke(a,...eb(t,1))-a)];u=[e.indexOf(Math.min(...e))-1];}}else u=[0];for(const r of u){const s=t.containsTile(l,i,e,r);s&&n.push(s);}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(t){return this._getRenderableCoordinates(t)}_getRenderableCoordinates(t,e){const r=this.getRenderableIds(t,e).map((t=>this._tiles[t].tileID)),n=\"globe\"===this.transform.projection.name;for(const t of r)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped()),t.expandedProjMatrix=n?this.transform.calculateProjMatrix(t.toUnwrapped(),!1,!0):t.projMatrix;return r}sortCoordinatesByDistance(t){const e=t.slice(),r=this.transform._camera.position,n=this.transform._camera.forward(),i={};for(const t of e){const e=1/(1<i[t.key]-i[e.key])),e}hasTransition(){if(this._source.hasTransition())return !0;if(tb(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=Dr.now())return !0}return !1}setFeatureState(t,e,r){this._state.updateState(t=t||\"_geojsonTileLayer\",e,r);}removeFeatureState(t,e,r){this._state.removeFeatureState(t=t||\"_geojsonTileLayer\",e,r);}getFeatureState(t,e){return this._state.getState(t=t||\"_geojsonTileLayer\",e)}setDependencies(t,e,r){const n=this._tiles[t];n&&n.setDependencies(e,r);}reloadTilesForDependencies(t,e){for(const r in this._tiles)this._tiles[r].hasDependency(t,e)&&this._reloadTile(+r,\"reloading\");this._cache.filter((r=>!r.hasDependency(t,e)));}_preloadTiles(t,e){if(!this._sourceLoaded){const r=()=>{this._sourceLoaded&&(this._source.off(\"data\",r),this._preloadTiles(t,e));};return void this._source.on(\"data\",r)}const r=new Map,n=Array.isArray(t)?t:[t],i=this.map.painter.terrain,s=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.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 t of e)r.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1);}Qe(Array.from(r.values()),((t,e)=>{const r=new nx(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(t=>{\"raster-dem\"===this._source.type&&r.dem&&this._backfillDEM(r),e(t,r);}));}),e);}}function Qx(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function tb(t){return \"raster\"===t||\"image\"===t||\"video\"===t||\"custom\"===t}function eb(t,e){const r=1<0?e+2*t:t}rb.useIntegerZoom=!0;const ib=new ol({\"symbol-placement\":new il(ll.layout_symbol[\"symbol-placement\"]),\"symbol-spacing\":new il(ll.layout_symbol[\"symbol-spacing\"]),\"symbol-avoid-edges\":new il(ll.layout_symbol[\"symbol-avoid-edges\"]),\"symbol-sort-key\":new sl(ll.layout_symbol[\"symbol-sort-key\"]),\"symbol-z-order\":new il(ll.layout_symbol[\"symbol-z-order\"]),\"symbol-z-elevate\":new il(ll.layout_symbol[\"symbol-z-elevate\"]),\"icon-allow-overlap\":new il(ll.layout_symbol[\"icon-allow-overlap\"]),\"icon-ignore-placement\":new il(ll.layout_symbol[\"icon-ignore-placement\"]),\"icon-optional\":new il(ll.layout_symbol[\"icon-optional\"]),\"icon-rotation-alignment\":new il(ll.layout_symbol[\"icon-rotation-alignment\"]),\"icon-size\":new sl(ll.layout_symbol[\"icon-size\"]),\"icon-text-fit\":new sl(ll.layout_symbol[\"icon-text-fit\"]),\"icon-text-fit-padding\":new sl(ll.layout_symbol[\"icon-text-fit-padding\"]),\"icon-image\":new sl(ll.layout_symbol[\"icon-image\"]),\"icon-rotate\":new sl(ll.layout_symbol[\"icon-rotate\"]),\"icon-padding\":new il(ll.layout_symbol[\"icon-padding\"]),\"icon-keep-upright\":new il(ll.layout_symbol[\"icon-keep-upright\"]),\"icon-offset\":new sl(ll.layout_symbol[\"icon-offset\"]),\"icon-anchor\":new sl(ll.layout_symbol[\"icon-anchor\"]),\"icon-pitch-alignment\":new il(ll.layout_symbol[\"icon-pitch-alignment\"]),\"text-pitch-alignment\":new il(ll.layout_symbol[\"text-pitch-alignment\"]),\"text-rotation-alignment\":new il(ll.layout_symbol[\"text-rotation-alignment\"]),\"text-field\":new sl(ll.layout_symbol[\"text-field\"]),\"text-font\":new sl(ll.layout_symbol[\"text-font\"]),\"text-size\":new sl(ll.layout_symbol[\"text-size\"]),\"text-max-width\":new sl(ll.layout_symbol[\"text-max-width\"]),\"text-line-height\":new sl(ll.layout_symbol[\"text-line-height\"]),\"text-letter-spacing\":new sl(ll.layout_symbol[\"text-letter-spacing\"]),\"text-justify\":new sl(ll.layout_symbol[\"text-justify\"]),\"text-radial-offset\":new sl(ll.layout_symbol[\"text-radial-offset\"]),\"text-variable-anchor\":new il(ll.layout_symbol[\"text-variable-anchor\"]),\"text-anchor\":new sl(ll.layout_symbol[\"text-anchor\"]),\"text-max-angle\":new il(ll.layout_symbol[\"text-max-angle\"]),\"text-writing-mode\":new il(ll.layout_symbol[\"text-writing-mode\"]),\"text-rotate\":new sl(ll.layout_symbol[\"text-rotate\"]),\"text-padding\":new il(ll.layout_symbol[\"text-padding\"]),\"text-keep-upright\":new il(ll.layout_symbol[\"text-keep-upright\"]),\"text-transform\":new sl(ll.layout_symbol[\"text-transform\"]),\"text-offset\":new sl(ll.layout_symbol[\"text-offset\"]),\"text-allow-overlap\":new il(ll.layout_symbol[\"text-allow-overlap\"]),\"text-ignore-placement\":new il(ll.layout_symbol[\"text-ignore-placement\"]),\"text-optional\":new il(ll.layout_symbol[\"text-optional\"]),visibility:new il(ll.layout_symbol.visibility)});var sb={paint:new ol({\"icon-opacity\":new sl(ll.paint_symbol[\"icon-opacity\"]),\"icon-occlusion-opacity\":new sl(ll.paint_symbol[\"icon-occlusion-opacity\"]),\"icon-emissive-strength\":new sl(ll.paint_symbol[\"icon-emissive-strength\"]),\"text-emissive-strength\":new sl(ll.paint_symbol[\"text-emissive-strength\"]),\"icon-color\":new sl(ll.paint_symbol[\"icon-color\"]),\"icon-halo-color\":new sl(ll.paint_symbol[\"icon-halo-color\"]),\"icon-halo-width\":new sl(ll.paint_symbol[\"icon-halo-width\"]),\"icon-halo-blur\":new sl(ll.paint_symbol[\"icon-halo-blur\"]),\"icon-translate\":new il(ll.paint_symbol[\"icon-translate\"]),\"icon-translate-anchor\":new il(ll.paint_symbol[\"icon-translate-anchor\"]),\"icon-image-cross-fade\":new sl(ll.paint_symbol[\"icon-image-cross-fade\"]),\"text-opacity\":new sl(ll.paint_symbol[\"text-opacity\"]),\"text-occlusion-opacity\":new sl(ll.paint_symbol[\"text-occlusion-opacity\"]),\"text-color\":new sl(ll.paint_symbol[\"text-color\"],{runtimeType:ei,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),\"text-halo-color\":new sl(ll.paint_symbol[\"text-halo-color\"]),\"text-halo-width\":new sl(ll.paint_symbol[\"text-halo-width\"]),\"text-halo-blur\":new sl(ll.paint_symbol[\"text-halo-blur\"]),\"text-translate\":new il(ll.paint_symbol[\"text-translate\"]),\"text-translate-anchor\":new il(ll.paint_symbol[\"text-translate-anchor\"]),\"icon-color-saturation\":new il(ll.paint_symbol[\"icon-color-saturation\"]),\"icon-color-contrast\":new il(ll.paint_symbol[\"icon-color-contrast\"]),\"icon-color-brightness-min\":new il(ll.paint_symbol[\"icon-color-brightness-min\"]),\"icon-color-brightness-max\":new il(ll.paint_symbol[\"icon-color-brightness-max\"])}),layout:ib};class ab{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Wn,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Mo(ab,\"FormatSectionOverride\",{omit:[\"defaultValue\"]});class ob extends kl{constructor(e,r,n,i){super(e,sb,r,n,i),this._colorAdjustmentMatrix=t.ad.identity([]),this.hasInitialOcclusionOpacityProperties=void 0!==e.paint&&(\"icon-occlusion-opacity\"in e.paint||\"text-occlusion-opacity\"in e.paint);}recalculate(t,e){super.recalculate(t,e),\"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 r=this.layout.get(\"text-writing-mode\");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values[\"text-writing-mode\"]=t;}else this.layout._values[\"text-writing-mode\"]=\"point\"===this.layout.get(\"symbol-placement\")?[\"horizontal\"]:[\"horizontal\",\"vertical\"];this._setPaintOverrides();}getColorAdjustmentMatrix(e,r,n,i){return this._saturation===e&&this._contrast===r&&this._brightnessMin===n&&this._brightnessMax===i||(this._colorAdjustmentMatrix=function(e,r,n,i){e=Er(e),r=zr(r);const s=t.ad.create(),a=e/3,o=1-2*a,l=[o,a,a,0,a,o,a,0,a,a,o,0,0,0,0,1],u=.5-.5*r,c=i-n;return t.ad.multiply(s,[c,0,0,0,0,c,0,0,0,0,c,0,n,n,n,1],[r,0,0,0,0,r,0,0,0,0,r,0,u,u,u,1]),t.ad.multiply(s,s,l),s}(e,r,n,i),this._saturation=e,this._contrast=r,this._brightnessMin=n,this._brightnessMax=i),this._colorAdjustmentMatrix}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||co(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):\"\"))}(e.properties,i)}createBucket(t){return new $g(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of sb.paint.overridableProperties){if(!ob.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new ab(e),n=new uo(r,e.property.specification,this.scope,this.options);let i=null;i=\"constant\"===e.value.kind||\"source\"===e.value.kind?new po(\"source\",n):new fo(\"composite\",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new rl(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&ob.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get(\"text-field\"),n=sb.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if(\"constant\"===r.value.kind&&r.value.value instanceof mi)s(r.value.value.sections);else if(\"source\"===r.value.kind){const t=e=>{i||(e instanceof _i&&bi(e.value)===si?s(e.value.sections):e instanceof Si?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramIds(){const t=0!==this.paint.get(\"icon-opacity\").constantOr(1),e=0!==this.paint.get(\"text-opacity\").constantOr(1),r=[];return t&&r.push(\"symbolIcon\"),e&&r.push(\"symbolSDF\"),r}getDefaultProgramParams(t,e,r){return {config:new Ku(this,{zoom:e,lut:r}),overrideFog:!1}}}const lb=new ol({visibility:new il(ll.layout_background.visibility)});var ub={paint:new ol({\"background-color\":new il(ll.paint_background[\"background-color\"]),\"background-pattern\":new il(ll.paint_background[\"background-pattern\"]),\"background-opacity\":new il(ll.paint_background[\"background-opacity\"]),\"background-emissive-strength\":new il(ll.paint_background[\"background-emissive-strength\"])}),layout:lb};const cb=new ol({visibility:new il(ll.layout_raster.visibility)});var hb={paint:new ol({\"raster-opacity\":new il(ll.paint_raster[\"raster-opacity\"]),\"raster-color\":new al(ll.paint_raster[\"raster-color\"]),\"raster-color-mix\":new il(ll.paint_raster[\"raster-color-mix\"]),\"raster-color-range\":new il(ll.paint_raster[\"raster-color-range\"]),\"raster-hue-rotate\":new il(ll.paint_raster[\"raster-hue-rotate\"]),\"raster-brightness-min\":new il(ll.paint_raster[\"raster-brightness-min\"]),\"raster-brightness-max\":new il(ll.paint_raster[\"raster-brightness-max\"]),\"raster-saturation\":new il(ll.paint_raster[\"raster-saturation\"]),\"raster-contrast\":new il(ll.paint_raster[\"raster-contrast\"]),\"raster-resampling\":new il(ll.paint_raster[\"raster-resampling\"]),\"raster-fade-duration\":new il(ll.paint_raster[\"raster-fade-duration\"]),\"raster-emissive-strength\":new il(ll.paint_raster[\"raster-emissive-strength\"]),\"raster-array-band\":new il(ll.paint_raster[\"raster-array-band\"]),\"raster-elevation\":new il(ll.paint_raster[\"raster-elevation\"])}),layout:cb};function pb(e,r,n,i,s,a,o,l){const u=[e,r,1,n,i,1,s,a,1],c=[o,l,1],h=t.bC.adjoint([],u),[p,f,d]=t._.transformMat3(c,c,h);return t.bC.multiply(u,u,[p,0,0,0,f,0,0,0,d])}function fb(e,r,n,i,s,a,o,l){const u=function(e,r,n,i,s,a,o,l){const u=pb(0,0,1,0,1,1,0,1),c=pb(e,r,n,i,s,a,o,l),h=t.bC.adjoint([],u);return t.bC.multiply(c,c,h)}(e,r,n,i,s,a,o,l);return [u[2]/u[8]/ps,u[5]/u[8]/ps]}function db(t){return [t[0],Math.min(Math.max(t[1],-Dc),Dc)]}class mb extends Ln{constructor(t,e,r,n){super(),this.id=t,this.dispatcher=r,this.coordinates=e.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=e,this._dirty=!1;}load(t,e){if(this._loaded=e||!1,this.fire(new Dn(\"dataloading\",{dataType:\"source\"})),this.url=this.options.url,!this.url)return t&&(this.coordinates=t),this._loaded=!0,void this._finishLoading();this._imageRequest=on(this.map._requestManager.transformRequest(this.url,Wr.Image),((e,r)=>{this._imageRequest=null,this._loaded=!0,e?this.fire(new Cn(e)):r&&(this.image=r instanceof HTMLImageElement?Dr.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading());}));}loaded(){return this._loaded}updateImage(t){return t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}setTexture(t){if(!(t.handle instanceof WebGLTexture))throw new Error(\"The provided handle is not a WebGLTexture instance\");return this.texture=new Yg(this.map.painter.context,t.handle),this.width=t.dimensions[0],this.height=t.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Dn(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})));}onAdd(t){this.map=t,this.load();}onRemove(t){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Yg||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy());}setCoordinates(t){if(this.coordinates=t,this._boundsArray=void 0,this._unsupportedCoords=!1,!t.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let e=t[0][1],r=t[0][1];for(const n of t)n[1]>r&&(r=n[1]),n[1]Dc?this.onNorthPole=!0:n<-Dc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const e=t.map(Oc.fromLngLat);this.tileID=function(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(const s of t)e=Math.min(e,s.x),r=Math.min(r,s.y),n=Math.max(n,s.x),i=Math.max(i,s.y);const s=Math.max(n-e,i-r),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),o=Math.pow(2,a);let l=Math.floor((e+n)/2*o);return l>1&&(l-=1),new bc(a,l,Math.floor((r+i)/2*o))}(e),this.minzoom=this.maxzoom=this.tileID.z;}return this.fire(new Dn(\"data\",{dataType:\"source\",sourceDataType:\"content\"})),this}_clear(){this._boundsArray=void 0,this._unsupportedCoords=!1;}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];\"loaded\"!==e.state&&(e.state=\"loaded\",e.texture=this.texture);}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const r=ng(new bc(0,0,0),this.map.transform.projection),n=[r.projection.project(this.coordinates[0][0],this.coordinates[0][1]),r.projection.project(this.coordinates[1][0],this.coordinates[1][1]),r.projection.project(this.coordinates[2][0],this.coordinates[2][1]),r.projection.project(this.coordinates[3][0],this.coordinates[3][1])];if(!function(t){const e=t[1].x-t[0].x,r=t[1].y-t[0].y,n=t[2].x-t[1].x,i=t[2].y-t[1].y,s=t[3].x-t[2].x,a=t[3].y-t[2].y,o=t[0].x-t[3].x,l=t[0].y-t[3].y,u=e*i-n*r,c=n*a-s*i,h=s*l-o*a,p=o*r-e*l;return u>0&&c>0&&h>0&&p>0||u<0&&c<0&&h<0&&p<0}(n))return console.warn(\"Image source coordinates are defining non-convex area in the Mercator projection\"),void(this._unsupportedCoords=!0);const i=ng(this.tileID,this.map.transform.projection),[s,a,o,l]=this.coordinates.map((t=>{const e=i.projection.project(t[0],t[1]);return ig(i,e)._round()}));this.perspectiveTransform=fb(s.x,s.y,a.x,a.y,o.x,o.y,l.x,l.y);const u=this._boundsArray=new Vl;u.emplaceBack(s.x,s.y,0,0),u.emplaceBack(a.x,a.y,ps,0),u.emplaceBack(l.x,l.y,0,ps),u.emplaceBack(o.x,o.y,ps,ps),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,tx.members),this.boundsSegments=Au.simpleSegment(0,0,4,2);const c=[],h=function(t){return [db(t[0]),db(t[1]),db(t[2]),db(t[3])]}(this.coordinates),[p,f,d,m]=function(t){let e=t[0][0],r=e,n=t[0][1],i=n;for(let s=1;sr&&(r=t[s][0]),t[s][1]i&&(i=t[s][1]);return [e,n,r-e,i-n]}(h);{const i=new Vl,[s,a,o,l]=function(t){let e=t[0].x,r=e,n=t[0].y,i=n;for(let s=1;sr&&(r=t[s].x),t[s].yi&&(i=t[s].y);return [e,n,r-e,i-n]}(n),u=t=>[(t.x-s)/o,(t.y-a)/l],[h,y,g,x]=n.map(u),b=function(e,r,n,i,s,a,o,l){const u=pb(0,0,1,0,1,1,0,1),c=pb(e,r,n,i,s,a,o,l),h=t.bC.adjoint([],c);return t.bC.multiply(u,u,h)}(h[0],h[1],y[0],y[1],g[0],g[1],x[0],x[1]);this.elevatedGlobePerspectiveTransform=fb(h[0],h[1],y[0],y[1],g[0],g[1],x[0],x[1]);const v=(e,r)=>{c.push(e.lng);const n=Math.round((e.lng-p)/d*ps),s=Math.round((e.lat-f)/m*ps),a=u(r),o=t._.transformMat3([],[a[0],a[1],1],b),l=Math.round(o[0]/o[2]*ps),h=Math.round(o[1]/o[2]*ps);i.emplaceBack(n,s,l,h);},_=n[3].x-n[0].x,w=n[3].y-n[0].y,M=n[2].x-n[1].x,A=n[2].y-n[1].y;for(let t=0;t<65;t++){const e=t/64,i=[n[0].x+e*_,n[0].y+e*w],s=[n[1].x+e*M,n[1].y+e*A],a=s[0]-i[0],o=s[1]-i[1];for(let t=0;t<65;t++){const e=t/64,n={x:i[0]+a*e,y:i[1]+o*e,z:0};v(r.projection.unproject(n.x,n.y),n);}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(i,tx.members);}{this.maxLongitudeTriangleSize=0;let t=[],r=new Ql;const n=(e,n,i)=>{r.emplaceBack(e,n,i);const s=c[e],a=c[n],o=c[i],l=Math.min(Math.min(s,a),o),u=Math.max(Math.max(s,a),o)-l;u>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=u),t.push(l+u/2);};for(let t=0;t<64;t++)for(let e=0;e<64;e++){const r=65*t+e,i=r+1,s=r+65,a=s+1;n(r,s,i),n(i,s,a);}[t,r]=function(t,e){const r=Array.from({length:t.length},((t,e)=>e));r.sort(((e,r)=>t[e]-t[r]));const n=[],i=new Ql;for(let s=0;s{s.segments.push({vertexOffset:0,primitiveOffset:t,vertexLength:e.segments[0].vertexLength,primitiveLength:r,sortKey:void 0,vaos:{}});},o=.51*this.maxLongitudeTriangleSize;if(Math.abs(r[0]-n)<=o){const t=Pr(r,0,r.length,n+o);return t===r.length||a(t,kr(r,t+1,r.length,n+360-o)-t),s}n0){const n=function(e,r){const n=r.worldSize,i=Pc(1,0)*n*Rc(r.center.lat,r.zoom)/Yh(n),s=Pc(1,r.center.lat)*n,a=t.ad.identity([]);return t.ad.rotateY(a,a,$e(r.center.lng)),t.ad.rotateX(a,a,$e(r.center.lat)),t.ad.translate(a,a,[0,0,nc]),t.ad.scale(a,a,[i,i,i*s]),t.ad.translate(a,a,[r.point.x-.5*n,r.point.y-.5*n,0]),t.ad.multiply(a,a,e),t.ad.multiply(a,r.globeMatrix,a)}(e,r);return function(e,r,n){const i=(e,r,n)=>{const i=t._.length(e),s=t._.length(r),a=Rh(e,r,n);return t._.scale(a,a,1/t._.length(a)*Gn(i,s,n))},s=i([e[0],e[1],e[2]],[r[0],r[1],r[2]],n),a=i([e[4],e[5],e[6]],[r[4],r[5],r[6]],n),o=i([e[8],e[9],e[10]],[r[8],r[9],r[10]],n),l=Rh([e[12],e[13],e[14]],[r[12],r[13],r[14]],n);return [s[0],s[1],s[2],0,a[0],a[1],a[2],0,o[0],o[1],o[2],0,l[0],l[1],l[2],1]}(s,n,i)}return s}function Rb(t,e,r,n){const i=Ah.projectAabbCorners(n,r);let s=Number.MAX_VALUE,a=-1;for(let t=0;tnew Ne(i[t][0],i[t][1]);let l;switch(a){case 0:case 6:l=[o(1),o(5),o(4),o(7),o(3),o(2),o(1)];break;case 1:case 7:l=[o(0),o(4),o(5),o(6),o(2),o(3),o(0)];break;case 3:case 5:l=[o(1),o(0),o(4),o(7),o(6),o(2),o(1)];break;default:l=[o(1),o(5),o(6),o(7),o(3),o(0),o(1)];}if(Wc(t,l))return s}const Vb=Bl([{name:\"a_pos_3f\",components:3,type:\"Float32\"}]),Lb=Bl([{name:\"a_color_3f\",components:3,type:\"Float32\"}]),Ob=Bl([{name:\"a_color_4f\",components:4,type:\"Float32\"}]),Fb=Bl([{name:\"a_uv_2f\",components:2,type:\"Float32\"}]),Ub=Bl([{name:\"a_normal_3f\",components:3,type:\"Float32\"}]),Nb=Bl([{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\"}]),jb=Bl([{name:\"a_pbr\",components:4,type:\"Uint16\"},{name:\"a_heightBasedEmissiveStrength\",components:3,type:\"Float32\"}]);class qb{constructor(t,e,r,n){this.message=(t?`${t}: `:\"\")+r,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__);}}function $b(t,e){const r=-1===t.indexOf(\"://\");try{return new URL(t,r&&e?\"http://example.com\":void 0),!0}catch(t){return !1}}class Gb{constructor(t,e){this.feature=t,this.instancedDataOffset=e,this.instancedDataCount=0,this.rotation=[0,0,0],this.scale=[1,1,1],this.translation=[0,0,0];}}class Yb{constructor(){this.instancedDataArray=new ou,this.instancesEvaluatedElevation=[],this.features=[],this.idToFeaturesIndex={};}}class Xb{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.fqid)),this.projection=t.projection,this.index=t.index,this.hasZoomDependentProperties=this.layers[0].isZoomDependent(),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.hasPattern=!1,this.instancesPerModel={},this.validForExaggeration=0,this.maxVerticalOffset=0,this.maxScale=0,this.maxHeight=0,this.lookupDim=this.zoom>this.canonical.z?256:this.zoom>15?75:100,this.instanceCount=0,this.terrainElevationMin=0,this.terrainElevationMax=0,this.validForDEMTile={id:null,timestamp:0},this.modelUris=[],this.modelsRequested=!1,this.activeReplacements=[],this.replacementUpdateTime=0;}updateFootprints(t,e){}populate(t,e,r,n){this.tileToMeter=Lc(r);const i=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:s,id:a,index:o,sourceLayerIndex:l}of t){const t=null!=a?a:s.properties&&s.properties.hasOwnProperty(\"id\")?s.properties.id:void 0,u=Xc(s,i);if(!this.layers[0]._featureFilter.filter(new Ho(this.zoom),u,r))continue;const c={id:t,sourceLayerIndex:l,index:o,geometry:i?u.geometry:Yc(s,r,n),properties:s.properties,type:s.type,patterns:{}},h=this.addFeature(c,c.geometry,u);h&&e.featureIndex.insert(s,c.geometry,o,l,this.index,this.instancesPerModel[h].instancedDataArray.length,ps/32);}this.lookup=null;}update(t,e,r,n){for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];for(const e in t)r.idToFeaturesIndex.hasOwnProperty(e)&&(this.evaluate(r.features[r.idToFeaturesIndex[e]],t[e],r,!0),this.uploaded=!1);}this.maxHeight=0;}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return !1;let e=!1;for(const r in this.instancesPerModel){const n=this.instancesPerModel[r];for(const r of n.features){const i=this.layers[0],s=r.feature,a=this.canonical,o=i.paint.get(\"model-rotation\").evaluate(s,{},a),l=i.paint.get(\"model-scale\").evaluate(s,{},a),u=i.paint.get(\"model-translation\").evaluate(s,{},a);t._.exactEquals(r.rotation,o)&&t._.exactEquals(r.scale,l)&&t._.exactEquals(r.translation,u)||(this.evaluate(r,r.featureStates,n,!0),e=!0);}}return e}updateReplacement(t,e,r){if(e.updateTime===this.replacementUpdateTime)return !1;this.replacementUpdateTime=e.updateTime;const n=e.getReplacementRegionsForTile(t.toUnwrapped(),!0);if(Cf(this.activeReplacements,n))return !1;this.activeReplacements=n;let i=!1;for(const e in this.instancesPerModel){const n=this.instancesPerModel[e],s=n.instancedDataArray;for(const e of n.features){const n=e.instancedDataOffset,a=e.instancedDataCount;for(let e=0;eps?o-ps:o;const l=Math.floor(o),u=s.float32[a+1];let c=!1;for(const e of this.activeReplacements)if(!(e.orderl||l>e.max.x||e.min.y>u||u>e.max.y)&&(c=Uf(Ff(l,u,t.canonical,e.footprintTileId.canonical),e),c))break;s.float32[a]=c?o+ps:o,i=i||c;}}}return i}isEmpty(){for(const t in this.instancesPerModel)if(0!==this.instancesPerModel[t].instancedDataArray.length)return !1;return !0}uploadPending(){return !this.uploaded}upload(t){if(!this.uploaded)for(const e in this.instancesPerModel){const r=this.instancesPerModel[e];r.instancedDataArray.length<0||0===r.instancedDataArray.length||(r.instancedDataBuffer?r.instancedDataBuffer.updateData(r.instancedDataArray):r.instancedDataBuffer=t.createVertexBuffer(r.instancedDataArray,Nb.members,!0,void 0,this.instanceCount));}this.uploaded=!0;}destroy(){for(const t in this.instancesPerModel){const e=this.instancesPerModel[t];0!==e.instancedDataArray.length&&e.instancedDataBuffer&&e.instancedDataBuffer.destroy();}const t=this.layers[0].modelManager;if(t&&this.modelUris)for(const e of this.modelUris)t.removeModel(e,\"\");}addFeature(t,e,r){const n=this.layers[0],i=n.layout.get(\"model-id\").evaluate(r,{},this.canonical);if(!i)return fr(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),i;$b(i,!1)&&(this.modelUris.includes(i)||this.modelUris.push(i)),this.instancesPerModel[i]||(this.instancesPerModel[i]=new Yb);const s=this.instancesPerModel[i],a=s.instancedDataArray,o=new Gb(r,a.length);for(const t of e)for(const e of t){if(e.x<0||e.x>=ps||e.y<0||e.y>=ps)continue;const t=(this.lookupDim-1)/ps,r=this.lookupDim*(e.y*t|0)+e.x*t|0;if(this.lookup){if(0!==this.lookup[r])continue;this.lookup[r]=1;}this.instanceCount++;const n=a.length;a.resize(n+1),s.instancesEvaluatedElevation.push(0),a.float32[16*n]=e.x,a.float32[16*n+1]=e.y;}return o.instancedDataCount=s.instancedDataArray.length-o.instancedDataOffset,o.instancedDataCount>0&&(t.id&&(s.idToFeaturesIndex[t.id]=s.features.length),s.features.push(o),this.evaluate(o,{},s,!1)),i}getModelUris(){return this.modelUris}evaluate(t,e,r,n){const i=this.layers[0],s=t.feature,a=this.canonical,o=t.rotation=i.paint.get(\"model-rotation\").evaluate(s,e,a),l=t.scale=i.paint.get(\"model-scale\").evaluate(s,e,a),u=t.translation=i.paint.get(\"model-translation\").evaluate(s,e,a),c=i.paint.get(\"model-color\").evaluate(s,e,a);c.a=i.paint.get(\"model-color-mix-intensity\").evaluate(s,e,a);const h=[];this.maxVerticalOffset10?this.tileToMeter:Lc(a,f)),o[s+4]=u[0],o[s+5]=u[1],o[s+6]=u[2]+l,o[s+7]=h[0],o[s+8]=h[1],o[s+9]=h[2],o[s+10]=h[4],o[s+11]=h[5],o[s+12]=h[6],o[s+13]=h[8],o[s+14]=h[9],o[s+15]=h[10],r.instancesEvaluatedElevation[i]=u[2];}}}Mo(Xb,\"ModelBucket\",{omit:[\"layers\"]}),Mo(Yb,\"PerModelAttributes\"),Mo(Gb,\"ModelFeature\");const Zb=new ol({visibility:new il(ll.layout_model.visibility),\"model-id\":new sl(ll.layout_model[\"model-id\"])});var Hb={paint:new ol({\"model-opacity\":new il(ll.paint_model[\"model-opacity\"]),\"model-rotation\":new sl(ll.paint_model[\"model-rotation\"]),\"model-scale\":new sl(ll.paint_model[\"model-scale\"]),\"model-translation\":new sl(ll.paint_model[\"model-translation\"]),\"model-color\":new sl(ll.paint_model[\"model-color\"]),\"model-color-mix-intensity\":new sl(ll.paint_model[\"model-color-mix-intensity\"]),\"model-type\":new il(ll.paint_model[\"model-type\"]),\"model-cast-shadows\":new il(ll.paint_model[\"model-cast-shadows\"]),\"model-receive-shadows\":new il(ll.paint_model[\"model-receive-shadows\"]),\"model-ambient-occlusion-intensity\":new il(ll.paint_model[\"model-ambient-occlusion-intensity\"]),\"model-emissive-strength\":new sl(ll.paint_model[\"model-emissive-strength\"]),\"model-roughness\":new sl(ll.paint_model[\"model-roughness\"]),\"model-height-based-emissive-strength-multiplier\":new sl(ll.paint_model[\"model-height-based-emissive-strength-multiplier\"]),\"model-cutoff-fade-range\":new il(ll.paint_model[\"model-cutoff-fade-range\"]),\"model-front-cutoff\":new il(ll.paint_model[\"model-front-cutoff\"])}),layout:Zb};const Kb=64,Wb={CoordinateSpaceTile:1,CoordinateSpaceYUp:2,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Jb(e,r,n,i,s,a,o,l,u,c=!1){const h=n.zoom,p=n.project(i),f=Rc(i.lat,h),d=1/f;t.ad.identity(e),t.ad.translate(e,e,[p.x+o[0]*d,p.y+o[1]*d,o[2]]);let m=1,y=1;const g=n.worldSize;if(c){if(\"mercator\"===n.projection.name){let e=0;n.elevation&&(e=n.elevation.getAtPointOrZero(new Oc(p.x/g,p.y/g),0));const r=t.aA.transformMat4([],[p.x,p.y,e,1],n.projMatrix)[3]/n.cameraToCenterDistance;m=r,y=r*Rc(n.center.lat,h);}else if(\"globe\"===n.projection.name){const r=Cb(e,n),s=t.ad.multiply([],n.projMatrix,r),a=[0,0,0,1];t.aA.transformMat4(a,a,s);const o=a[3]/n.cameraToCenterDistance,l=Hh(h),u=n.projection.pixelsPerMeter(i.lat,g)*Rc(i.lat,h),c=n.projection.pixelsPerMeter(n.center.lat,g)*Rc(n.center.lat,h);m=o/Gn(u,Cc(n.center.lat),l),y=o*f/u,m*=c,y*=c;}}else m=d;t.ad.scale(e,e,[m,m,y]);const x=[...e],b=r.orientation,v=[];if(Bb(v,[b[0]+s[0],b[1]+s[1],b[2]+s[2]],a),t.ad.multiply(e,x,v),l&&n.elevation){let s=0;const a=[];if(u&&n.elevation){s=function(e,r,n,i,s){const a=r.elevation;if(!a)return 0;const o=Ah.projectAabbCorners(n,i),l=Pc(1,s.lat)*r.worldSize,u=function(e,r){const n=[0,0,1],i=[{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 s of i){const i=e[s.corners[0]],a=e[s.corners[1]],o=e[s.corners[2]],l=[a[0]-i[0],a[1]-i[1],r*(a[2]-i[2])],u=t._.cross(l,l,[o[0]-i[0],o[1]-i[1],r*(o[2]-i[2])]);t._.normalize(u,u),s.dotProductWithUp=t._.dot(u,n);}return i.sort(((t,e)=>t.dotProductWithUp-e.dotProductWithUp)),i[0].corners}(o,l),c=o[u[0]],h=o[u[1]],p=o[u[2]],f=o[u[3]],d=a.getAtPointOrZero(new Oc(c[0]/r.worldSize,c[1]/r.worldSize),0),m=a.getAtPointOrZero(new Oc(h[0]/r.worldSize,h[1]/r.worldSize),0),y=a.getAtPointOrZero(new Oc(p[0]/r.worldSize,p[1]/r.worldSize),0),g=a.getAtPointOrZero(new Oc(f[0]/r.worldSize,f[1]/r.worldSize),0),x=(d+g)/2,b=(m+y)/2;return x>b?m=e.gl.NEAREST_MIPMAP_NEAREST}),t.uploaded=!0,t.image=null);}function tv(t,e,r){t.indexBuffer=e.createIndexBuffer(t.indexArray,!1,!0),t.vertexBuffer=e.createVertexBuffer(t.vertexArray,Vb.members,!1,!0),t.normalArray&&(t.normalBuffer=e.createVertexBuffer(t.normalArray,Ub.members,!1,!0)),t.texcoordArray&&(t.texcoordBuffer=e.createVertexBuffer(t.texcoordArray,Fb.members,!1,!0)),t.colorArray&&(t.colorBuffer=e.createVertexBuffer(t.colorArray,(12===t.colorArray.bytesPerElement?Lb:Ob).members,!1,!0)),t.featureArray&&(t.pbrBuffer=e.createVertexBuffer(t.featureArray,jb.members,!0)),t.segments=Au.simpleSegment(0,0,t.vertexArray.length,t.indexArray.length);const n=t.material;n.pbrMetallicRoughness.baseColorTexture&&Qb(n.pbrMetallicRoughness.baseColorTexture,e),n.pbrMetallicRoughness.metallicRoughnessTexture&&Qb(n.pbrMetallicRoughness.metallicRoughnessTexture,e),n.normalTexture&&Qb(n.normalTexture,e),n.occlusionTexture&&Qb(n.occlusionTexture,e,r),n.emissionTexture&&Qb(n.emissionTexture,e);}function ev(t,e,r){if(t.meshes)for(const n of t.meshes)tv(n,e,r);if(t.children)for(const n of t.children)ev(n,e,r);}function rv(t){if(t.meshes)for(const e of t.meshes)e.indexArray.destroy(),e.vertexArray.destroy(),e.colorArray&&e.colorArray.destroy(),e.normalArray&&e.normalArray.destroy(),e.texcoordArray&&e.texcoordArray.destroy(),e.featureArray&&e.featureArray.destroy();if(t.children)for(const e of t.children)rv(e);}function nv(t){if(t.meshes)for(const r of t.meshes)r.vertexBuffer&&(r.vertexBuffer.destroy(),r.indexBuffer.destroy(),r.normalBuffer&&r.normalBuffer.destroy(),r.texcoordBuffer&&r.texcoordBuffer.destroy(),r.colorBuffer&&r.colorBuffer.destroy(),r.pbrBuffer&&r.pbrBuffer.destroy(),r.segments.destroy(),r.material&&((e=r.material).pbrMetallicRoughness.baseColorTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture&&e.pbrMetallicRoughness.baseColorTexture.gfxTexture.destroy(),e.pbrMetallicRoughness.metallicRoughnessTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture&&e.pbrMetallicRoughness.metallicRoughnessTexture.gfxTexture.destroy(),e.normalTexture&&e.normalTexture.gfxTexture&&e.normalTexture.gfxTexture.destroy(),e.emissionTexture&&e.emissionTexture.gfxTexture&&e.emissionTexture.gfxTexture.destroy(),e.occlusionTexture&&e.occlusionTexture.gfxTexture&&e.occlusionTexture.gfxTexture.destroy()));var e;if(t.children)for(const e of t.children)nv(e);}class iv{constructor(t){this._callback=t,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 sv{constructor(){this.tasks={},this.taskQueue=[],or([\"process\"],this),this.invoker=new iv(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,\"message\"===t?0:\"maybePrepare\"!==t||e?\"parseTile\"!==t||e?\"parseTile\"===t&&e?300-r:\"maybePrepare\"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){try{t();}finally{}return null}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:\"\",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(\"\"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||gr()){const t=this.callbacks[r],n=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:\"message\"});n&&(this.cancelCallbacks[r]=n);}else this.processTask(r,e);}processTask(t,e){if(delete this.cancelCallbacks[t],\"\"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(To(e.error)):r(null,To(e.data)));}else {const r=new Set,n=e.hasCallback?(e,n)=>{this.target.postMessage({id:t,type:\"\",sourceMapId:this.mapId,error:e?Io(e):null,data:Io(n,r)},r);}:t=>{},i=To(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(\".\");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source,i.scope)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener(\"message\",this.receive,!1);}}class ov{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=nr();const r=this.workerPool.acquire(this.id);for(let t=0;t{this.ready=!0;}));}broadcast(t,e,r){Qe(this.actors,((r,n)=>{r.send(t,e,n);}),r=r||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove();})),this.actors=[],this.workerPool.release(this.id);}}ov.Actor=av;var lv={workerUrl:\"\",workerClass:null,workerParams:void 0};function uv(){return null!=lv.workerClass?new lv.workerClass:new self.Worker(lv.workerUrl,lv.workerParams)}const cv=\"mapboxgl_preloaded_worker_pool\";class hv{constructor(){this.active={};}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length{t.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[cv]}numActive(){return Object.keys(this.active).length}}let pv;function fv(){return pv||(pv=new hv),pv}hv.workerCount=2;let dv,mv,yv,gv,xv,bv=null;function vv(){return gr()&&self.worker&&self.worker.dracoUrl?self.worker.dracoUrl:mv||n.DRACO_URL}function _v(){if(gr()&&self.worker&&self.worker.meshoptUrl)return self.worker.meshoptUrl;if(gv)return gv;const t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]);if(\"object\"!=typeof WebAssembly)throw new Error(\"WebAssembly not supported, cannot instantiate meshoptimizer\");return gv=WebAssembly.validate(t)?n.MESHOPT_SIMD_URL:n.MESHOPT_URL,gv}const wv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Mv={5120:\"DT_INT8\",5121:\"DT_UINT8\",5122:\"DT_INT16\",5123:\"DT_UINT16\",5125:\"DT_UINT32\",5126:\"DT_FLOAT32\"},Av={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Sv(t,e,r){const n=r.json.bufferViews.length,i=r.buffers.length;e.bufferView=n,r.json.bufferViews[n]={buffer:i,byteLength:t.byteLength},r.buffers[i]=t;}const Iv=\"KHR_draco_mesh_compression\";function Tv(t,e){const r=t.extensions&&t.extensions[Iv];if(!r)return;const n=new yv.Decoder,i=Cv(e,r.bufferView),s=new yv.Mesh;if(!n.DecodeArrayToMesh(i,i.byteLength,s))throw new Error(\"Failed to decode Draco mesh\");const a=e.json.accessors[t.indices],o=wv[a.componentType],l=a.count*o.BYTES_PER_ELEMENT,u=yv._malloc(l);o===Uint16Array?n.GetTrianglesUInt16Array(s,l,u):n.GetTrianglesUInt32Array(s,l,u),Sv(yv.memory.buffer.slice(u,u+l),a,e),yv._free(u);for(const i of Object.keys(r.attributes)){const a=n.GetAttributeByUniqueId(s,r.attributes[i]),o=e.json.accessors[t.attributes[i]],l=Mv[o.componentType],u=o.count*Av[o.type]*wv[o.componentType].BYTES_PER_ELEMENT,c=yv._malloc(u);n.GetAttributeDataArrayForAllPoints(s,a,yv[l],u,c),Sv(yv.memory.buffer.slice(c,c+u),o,e),yv._free(c);}n.destroy(),s.destroy(),delete t.extensions[Iv];}const kv=\"EXT_meshopt_compression\";function Pv(t,e){if(!t.extensions||!t.extensions[kv])return;const r=t.extensions[kv],n=new Uint8Array(e.buffers[r.buffer],r.byteOffset||0,r.byteLength||0),i=new Uint8Array(r.count*r.byteStride);xv.decodeGltfBuffer(i,r.count,r.byteStride,n,r.mode,r.filter),t.buffer=e.buffers.length,t.byteOffset=0,e.buffers[t.buffer]=i.buffer,delete t.extensions[kv];}const zv=1179937895,Ev=new TextDecoder(\"utf8\");function Bv(t,e){return new URL(t,e).href}function Dv(t,e,r,n){return fetch(Bv(t.uri,n)).then((t=>t.arrayBuffer())).then((t=>{e.buffers[r]=t;}))}function Cv(t,e){const r=t.json.bufferViews[e];return new Uint8Array(t.buffers[r.buffer],r.byteOffset||0,r.byteLength)}function Rv(t,e,r,n){if(t.uri){const i=Bv(t.uri,n);return fetch(i).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{e.images[r]=t;}))}if(void 0!==t.bufferView){const n=Cv(e,t.bufferView),i=new Blob([n],{type:t.mimeType});return createImageBitmap(i).then((t=>{e.images[r]=t;}))}}function Vv(t,e=0,r){const n={json:null,images:[],buffers:[]};if(new Uint32Array(t,e,1)[0]===zv){const r=new Uint32Array(t,e);let i=2;const s=(r[i++]>>2)-3,a=r[i++]>>2;if(i++,n.json=JSON.parse(Ev.decode(r.subarray(i,i+a))),i+=a,i{const t=[],e=o&&o.includes(Iv),i=o&&o.includes(kv);if(e&&t.push(function(){if(!yv)return dv||(dv=function(t){let e,r=null;function n(){e=new Uint8Array(r.buffer);}function i(){throw new Error(\"Unexpected Draco error.\")}const s={a:{a:i,d:function(t,r,n){return e.copyWithin(t,r,r+n)},c:function(t){const i=e.length,s=Math.max(t>>>0,Math.ceil(1.2*i)),a=Math.ceil((s-i)/65536);try{return r.grow(a),n(),!0}catch(t){return !1}},b:i}};return (WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(t,s):t.then((t=>t.arrayBuffer())).then((t=>WebAssembly.instantiate(t,s)))).then((t=>{const{Rb:i,Qb:s,P:a,T:o,X:l,Ja:u,La:c,Qa:h,Va:p,Wa:f,eb:d,jb:m,f:y,e:g,yb:x,zb:b,Ab:v,Bb:_,Db:w,Gb:M}=t.instance.exports;r=g;const A=(()=>{let t=0,r=0,n=0,a=0;return o=>{n&&(i(a),i(t),r+=n,n=t=0),t||(r+=128,t=s(r));const l=o.length+7&-8;let u=t;l>=r&&(n=l,u=a=s(l));for(let t=0;t{yv=t,dv=void 0;})))}()),i&&t.push(function(){if(xv)return;const t=function(t){let e;const r=WebAssembly.instantiateStreaming(t,{}).then((t=>{e=t.instance,e.exports.__wasm_call_ctors();})),n={NONE:\"\",OCTAHEDRAL:\"meshopt_decodeFilterOct\",QUATERNION:\"meshopt_decodeFilterQuat\",EXPONENTIAL:\"meshopt_decodeFilterExp\"},i={ATTRIBUTES:\"meshopt_decodeVertexBuffer\",TRIANGLES:\"meshopt_decodeIndexBuffer\",INDICES:\"meshopt_decodeIndexSequence\"};return {ready:r,supported:!0,decodeGltfBuffer(t,r,s,a,o,l){!function(t,e,r,n,i,s,a){const o=t.exports.sbrk,l=n+3&-4,u=o(l*i),c=o(s.length),h=new Uint8Array(t.exports.memory.buffer);h.set(s,c);const p=e(u,n,i,c,s.length);if(0===p&&a&&a(u,l,i),r.set(h.subarray(u,u+n*i)),o(u-o(0)),0!==p)throw new Error(`Malformed buffer data: ${p}`)}(e,e.exports[i[o]],t,r,s,a,e.exports[n[l]]);}}}(fetch(_v()));return t.ready.then((()=>{xv=t;}))}()),s)for(let e=0;e{if(e&&a)for(const{primitives:t}of a)for(const e of t)Tv(e,n);if(i&&a&&l)for(const t of l)Pv(t,n);return n}))}))}function Lv(t,e){const r=t.json.bufferViews[e.bufferView],n=wv[e.componentType];return new n(t.buffers[r.buffer],(e.byteOffset||0)+(r.byteOffset||0),e.count*(r.byteStride&&r.byteStride!==Av[e.type]*n.BYTES_PER_ELEMENT?r.byteStride/n.BYTES_PER_ELEMENT:Av[e.type]))}function Ov(t,e,r,n){const i=wv[e.componentType],s=function(t){switch(t){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(i),a=t.json.bufferViews[e.bufferView],o=a.byteStride?a.byteStride/i.BYTES_PER_ELEMENT:Av[e.type],l=r.float32,u=l.length/r.capacity;for(let t=0,r=0;t0){for(let i=0;i0){s.texcoordArray=new iu;const t=e.json.accessors[i.TEXCOORD_0];s.texcoordArray.resize(t.count);const r=Lv(e,t);Ov(e,t,s.texcoordArray,r);}if(void 0!==i._FEATURE_ID_RGBA4444){const t=e.json.accessors[i._FEATURE_ID_RGBA4444];e.json.extensionsUsed&&e.json.extensionsUsed.includes(\"EXT_meshopt_compression\")&&(s.featureData=Lv(e,t));}void 0!==i._FEATURE_RGBA4444&&(s.featureData=new Uint32Array(Lv(e,e.json.accessors[i._FEATURE_RGBA4444]).buffer));const h=t.material;return s.material=function(t,e){const{emissiveFactor:r=[0,0,0],alphaMode:n=\"OPAQUE\",alphaCutoff:i=.5,normalTexture:s,occlusionTexture:a,emissiveTexture:o,doubleSided:l}=t,{baseColorFactor:u=[1,1,1,1],metallicFactor:c=1,roughnessFactor:h=1,baseColorTexture:p,metallicRoughnessTexture:f}=t.pbrMetallicRoughness||{},d=a?e[a.index]:void 0;if(a&&a.extensions&&a.extensions.KHR_texture_transform&&d){const t=a.extensions.KHR_texture_transform;d.offsetScale=[t.offset[0],t.offset[1],t.scale[0],t.scale[1]];}return {pbrMetallicRoughness:{baseColorFactor:new qn(...u),metallicFactor:c,roughnessFactor:h,baseColorTexture:p?e[p.index]:void 0,metallicRoughnessTexture:f?e[f.index]:void 0},doubleSided:l,emissiveFactor:r,alphaMode:n,alphaCutoff:i,normalTexture:s?e[s.index]:void 0,occlusionTexture:d,emissionTexture:o?e[o.index]:void 0,defined:void 0===t.defined}}(void 0!==h?e.json.materials[h]:{defined:!1},r),s}function Uv(e,r,n){const{matrix:i,rotation:s,translation:a,scale:o,mesh:l,extras:u,children:c}=e,h={};if(h.matrix=i||t.ad.fromRotationTranslationScale([],s||[0,0,0,1],a||[0,0,0],o||[1,1,1]),void 0!==l){h.meshes=n[l];const t=h.anchor=[0,0];for(const e of h.meshes){const{min:r,max:n}=e.aabb;t[0]+=r[0]+n[0],t[1]+=r[1]+n[1];}t[0]=Math.floor(t[0]/h.meshes.length/2),t[1]=Math.floor(t[1]/h.meshes.length/2);}if(u&&(u.id&&(h.id=u.id),u.lights&&(h.lights=function(t){if(!t.length)return [];const e=function(t){const e=atob(t),r=new Uint8Array(e.length);for(let t=0;t1&&n[n.length-1].equals(n[0])&&n.pop();let i=0;for(let t=0;t0&&n.reverse();const s=wp(n.flatMap((t=>[t.x,t.y])),[]);return 0===s.length?null:{vertices:n,indices:s}}function qv(e,r){const n=[],i=[];let s=0;const a=[];for(const o of e){s=n.length;const e=o.vertexArray.float32,l=o.indexArray.uint16;for(let i=0;i0&&([i[t+1],i[t+2]]=[i[t+2],i[t+1]]);}return {vertices:n,indices:i}}function $v(t){const e=function(t,e){const r=[],n=WebGL2RenderingContext;if(t.json.textures)for(const i of t.json.textures){const s={magFilter:n.LINEAR,minFilter:n.NEAREST,wrapS:n.REPEAT,wrapT:n.REPEAT};void 0!==i.sampler&&Object.assign(s,t.json.samplers[i.sampler]),r.push({image:e[i.source],sampler:s,uploaded:!1});}return r}(t,t.images),r=function(t,e){const r=[];for(const n of t.json.meshes){const i=[];for(const r of n.primitives)i.push(Fv(r,t,e));r.push(i);}return r}(t,e),{scenes:n,scene:i,nodes:s}=t.json,a=n?n[i||0].nodes:s,o=[];for(const e of a)o.push(Uv(s[e],t,r));return function(t,e,r){const n={},i=new Set;for(let s=0;s0){const e=Array.from(i.values()).sort(((t,e)=>t-e));for(let r=e.length-1;r>=0;r--)t.splice(e[r],1);}}(o,a,t.json.nodes),o}function Gv(t){t.heightmap=new Float32Array(4096),t.heightmap.fill(-1);const e=t.vertexArray.float32,r=t.aabb.min[0]-1,n=t.aabb.min[1]-1,i=Kb/(t.aabb.max[0]-r+2),s=Kb/(t.aabb.max[1]-n+2);for(let a=0;at.heightmap[u*Kb+l]&&(t.heightmap[u*Kb+l]=o);}}function Yv(e,r){const n={};n.indexArray=new Ql,n.indexArray.reserve(4*e.length),n.vertexArray=new Ul,n.vertexArray.reserve(10*e.length),n.colorArray=new Fl,n.vertexArray.reserve(10*e.length);let i=0;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*r,a=[-s.normal[1],s.normal[0],0],o=Math.min(.29,.1*s.width/s.depth),l=s.width-2*s.depth*r*(o+.01),u=t._.scaleAndAdd([],s.pos,a,l/2),c=t._.scaleAndAdd([],s.pos,a,-l/2),h=[u[0],u[1],u[2]+s.height],p=[c[0],c[1],c[2]+s.height],f=t._.scaleAndAdd([],s.normal,a,o);t._.scale(f,f,e);const d=t._.scaleAndAdd([],s.normal,a,-o);t._.scale(d,d,e),t._.add(f,u,f),t._.add(d,c,d),u[2]+=.1,c[2]+=.1,n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(h[0],h[1],h[2]),n.vertexArray.emplaceBack(p[0],p[1],p[2]),n.vertexArray.emplaceBack(u[0],u[1],u[2]),n.vertexArray.emplaceBack(c[0],c[1],c[2]),n.vertexArray.emplaceBack(f[0],f[1],f[2]),n.vertexArray.emplaceBack(d[0],d[1],d[2]);const m=l/e/2;n.colorArray.emplaceBack(-m-o,-1,m,.8),n.colorArray.emplaceBack(m+o,-1,m,.8),n.colorArray.emplaceBack(-m,0,m,1.3),n.colorArray.emplaceBack(m,0,m,1.3),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(m+o,-.8,m,.7),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(0,0,m,1.3),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.colorArray.emplaceBack(m+o,-1.2,m,.8),n.indexArray.emplaceBack(6+i,4+i,8+i),n.indexArray.emplaceBack(7+i,9+i,5+i),n.indexArray.emplaceBack(0+i,1+i,2+i),n.indexArray.emplaceBack(1+i,3+i,2+i),i+=10;}const s={defined:!0,emissiveFactor:[0,0,0]},a={};return a.baseColorFactor=qn.white,s.pbrMetallicRoughness=a,n.material=s,n.aabb=new Ah([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),n}const Xv=new Float32Array(262144),Zv=new Uint8Array(262144);function Hv(t){let e=0;if(t.meshes)for(const r of t.meshes)e=Math.max(e,r.aabb.max[2]);if(t.children)for(const r of t.children)e=Math.max(e,Hv(r));return e}function Kv(t,e,r){if(t.meshes)for(const n of t.meshes)n.aabb.min[0]!==1/0&&r.insert(e,n.aabb.min[0],n.aabb.min[1],n.aabb.max[0],n.aabb.max[1]);if(t.children)for(const n of t.children)Kv(n,e,r);}const Wv=[\"\",\"wall\",\"door\",\"roof\",\"window\",\"lamp\",\"logo\"];class Jv{constructor(t){this.node=t,this.evaluatedRMEA=[[1,0,0,1],[1,0,0,1],[1,0,0,1],[1,0,0,1],[.4,1,0,1],[1,0,0,1],[1,0,0,1]],this.hiddenByReplacement=!1,this.evaluatedScale=[1,1,1],this.evaluatedColor=[],this.emissionHeightBasedParams=[],this.feature={type:\"Point\",id:t.id,geometry:[],properties:{height:Hv(t)}},this.aabb=this._getLocalBounds();}_getLocalBounds(){if(!this.node.meshes)return new Ah([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);if(!this.aabb){let t=0;const e=new Ah([1/0,1/0,1/0],[-1/0,-1/0,-1/0]);for(const r of this.node.meshes)this.node.lightMeshIndex!==t&&(r.transformedAabb=Ah.applyTransformFast(r.aabb,this.node.matrix),e.encapsulate(r.transformedAabb)),t++;this.aabb=e;}return this.aabb}}class Qv{constructor(t,e,r,n,i,s){this.id=e,this.modelTraits|=Wb.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=Wb.HasMapboxMeshFeatures),n&&(this.modelTraits|=Wb.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:\"mercator\"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=i,this.dirty=!0,this.needsUpload=!1,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Jv(e)),Kv(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);}updateFootprints(t,e){for(const r of this.getNodesInfo()){const n=r.node;n.footprint&&e.push({footprint:n.footprint,id:t});}}update(){console.log(\"Update 3D model bucket\");}populate(){console.log(\"populate 3D model bucket\");}uploadPending(){return !this.uploaded||this.needsUpload}upload(t){if(!this.needsUpload)return;const e=this.getNodesInfo();for(const r of e){const e=r.node;this.uploaded?this.updatePbrBuffer(e):ev(e,t,!0);}for(const t of e)rv(t.node);this.uploaded=!0,this.needsUpload=!1;}updatePbrBuffer(t){let e=!1;if(!t.meshes)return e;for(const r of t.meshes)r.pbrBuffer&&(r.pbrBuffer.updateData(r.featureArray),e=!0);return e}needsReEvaluation(t,e,r){const n=t.transform.projectionOptions,i=t.style.getBrightness(),s=this.brightness!==i;return !!(!this.uploaded||this.dirty||n.name!==this.projection.name||t_(r.paint.get(\"model-color\").value,s)||t_(r.paint.get(\"model-color-mix-intensity\").value,s)||t_(r.paint.get(\"model-roughness\").value,s)||t_(r.paint.get(\"model-emissive-strength\").value,s)||t_(r.paint.get(\"model-height-based-emissive-strength-multiplier\").value,s))&&(this.projection=n,this.brightness=i,!0)}evaluateScale(t,e){if(t.transform.zoom===this.zoom)return;this.zoom=t.transform.zoom;const r=this.getNodesInfo(),n=this.id.canonical;for(const t of r){const r=t.feature;t.evaluatedScale=e.paint.get(\"model-scale\").evaluate(r,{},n);}}evaluate(t){const e=this.getNodesInfo();for(const r of e){if(!r.node.meshes)continue;const e=r.feature,n=r.node.meshes&&r.node.meshes[0].featureData,i=r.evaluatedColor[2],s=r.evaluatedRMEA[2],a=this.id.canonical;if(r.hasTranslucentParts=!1,n){for(let n=0;n=t)continue;const h=Xv[u],p=Math.abs(h);p>o&&(a=h,o=p,l=i,c=e);}if(o>.1){const s=1-(t+.5*Math.abs(l*c))/u;let o=e._dem.get(n,r)+a*s;const h=e._dem.get(n+l,r+c),p=e._dem.get(n-l,r-c,!0);(o-h)*(o-p)>0&&(o=(h+p)/2),Xv[i]=e._dem.set(n,r,o),Zv[i]=t;}}}}}a&&(e._demTile.needsDEMTextureUpload=!0,e._dem._timestamp=Dr.now());}getNodesInfo(){return this.nodesInfo}destroy(){const t=this.getNodesInfo();for(const e of t)rv(e.node),nv(e.node);}isEmpty(){return !this.nodesInfo.length}updateReplacement(t,e){if(e.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=e.updateTime;const r=e.getReplacementRegionsForTile(t.toUnwrapped()),n=this.getNodesInfo();for(let t=0;tt.footprint===e.footprint));}}getHeightAtTileCoord(e,r){const n=this.getNodesInfo(),i=[],s=[0,0,0],a=t.ad.identity([]);for(let o=0;oc.max[0]||r>c.max[1])continue;if(!0===l.node.hidden)return {height:0,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]};t.ad.invert(a,l.node.matrix),s[0]=e,s[1]=r,t._.transformMat4(s,s,a);const h=(s[0]-u.aabb.min[0])/(u.aabb.max[0]-u.aabb.min[0])*Kb|0,p=Math.min(63,(s[1]-u.aabb.min[1])/(u.aabb.max[1]-u.aabb.min[1])*Kb|0)*Kb+Math.min(63,h),f=u.heightmap[p];if(!(f<0&&l.node.footprint)){if(l.hiddenByReplacement)return;return {height:f,maxHeight:l.feature.properties.height,hidden:!1,verticalScale:l.evaluatedScale[2]}}if(l.node.footprint.grid.query(new Ne(e,r),new Ne(e,r),i),i.length>0)return {height:void 0,maxHeight:l.feature.properties.height,hidden:l.hiddenByReplacement,verticalScale:l.evaluatedScale[2]}}}}function t_(t,e){return !t.isLightConstant&&e}function e_(t,e,r,n,i,s,a,o){let l=(61440&e|(61440&e)>>4)>>8,u=(3840&e|(3840&e)>>4)>>4,c=240&e|(240&e)>>4;r[3]>0&&(l=Gn(l,255*r[0],r[3]),u=Gn(u,255*r[1],r[3]),c=Gn(c,255*r[2],r[3]));const h=l<<8|u,p=c<<8|Math.floor(255*n[3]),f=function(t){const e=Ke(t,0,2);return Math.min(Math.round(.5*e*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],d=Ke(i[0],0,1),m=Ke(i[1],0,1),y=Ke(i[2],0,1),g=Ke(i[3],0,1);let x,b,v,_;if(d!==m&&a!==s&&m!==d){const t=a-s;b=1/(t*(m-d)),v=-(s+t*d)/(t*(m-d));const e=Ke(i[4],-1,1);_=Math.pow(10,e),x=255*y<<8|255*g;}else x=65535,b=0,v=1,_=1;if(t.emplaceBack(h,p,f,x,b,v,_),o){const t=o.length;o.clear();for(let e=0;e>16&65535,o=s?e>>16&65535:65535&e,l=(15&o)<8?15&o:0,u=t.evaluatedRMEA[l],c=t.evaluatedColor[l],h=t.emissionHeightBasedParams[l];let p;if(a&&2===l&&n.lights&&(p=new lu,p.resize(10*n.lights.length)),e_(r.featureArray,i,c,u,h,r.aabb.min[2],r.aabb.max[2],p),p&&a){a=!1;const t=n.meshes[n.lightMeshIndex];t.featureArray=p,t.featureArray._trim();}}r.featureArray._trim(),i++;}}function n_(t,e,r,n){const i=1<t.polygon)).flat());const g=d?l:null,[x,b]=function(e,r,n,i,s,a,o,l,u,c,h){return \"globe\"===e.projection.name?function(e,r,n,i,s,a,o,l,u,c,h){const p=[],f=[],d=e.projection.upVectorScale(h,e.center.lat,e.worldSize).metersToTile,m=[0,0,0,1],y=[0,0,0,1],g=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},x=Id();n>0&&(n+=x),i+=x;for(const x of r){const r=[],b=[];for(const p of x){const f=p.x+s.x,x=p.y+s.y,v=e.projection.projectTilePoint(f,x,h),_=e.projection.upVector(h,p.x,p.y);let w=n,M=i;if(o){const t=Dd(f,x,n,i,o,l,u,c);w+=t.base,M+=t.top;}0!==n?g(m,v.x+_[0]*d*w,v.y+_[1]*d*w,v.z+_[2]*d*w):g(m,v.x,v.y,v.z),g(y,v.x+_[0]*d*M,v.y+_[1]*d*M,v.z+_[2]*d*M),t._.transformMat4(m,m,a),t._.transformMat4(y,y,a),r.push(new If(m[0],m[1],m[2])),b.push(new If(y[0],y[1],y[2]));}p.push(r),f.push(b);}return [p,f]}(e,r,n,i,s,a,o,l,u,c,h):o?function(e,r,n,i,s,a,o,l,u){const c=[],h=[],p=[0,0,0,1];for(const f of e){const e=[],d=[];for(const c of f){const h=c.x+i.x,f=c.y+i.y,m=Dd(h,f,r,n,a,o,l,u);p[0]=h,p[1]=f,p[2]=m.base,p[3]=1,t.aA.transformMat4(p,p,s),p[3]=Math.max(p[3],1e-5);const y=new If(p[0]/p[3],p[1]/p[3],p[2]/p[3]);p[0]=h,p[1]=f,p[2]=m.top,p[3]=1,t.aA.transformMat4(p,p,s),p[3]=Math.max(p[3],1e-5);const g=new If(p[0]/p[3],p[1]/p[3],p[2]/p[3]);e.push(y),d.push(g);}c.push(e),h.push(d);}return [c,h]}(r,n,i,s,a,o,l,u,c):function(t,e,r,n,i){const s=[],a=[],o=i[8]*e,l=i[9]*e,u=i[10]*e,c=i[11]*e,h=i[8]*r,p=i[9]*r,f=i[10]*r,d=i[11]*r;for(const e of t){const t=[],r=[];for(const s of e){const e=s.x+n.x,a=s.y+n.y,m=i[0]*e+i[4]*a+i[12],y=i[1]*e+i[5]*a+i[13],g=i[2]*e+i[6]*a+i[14],x=i[3]*e+i[7]*a+i[15],b=m+o,v=y+l,_=g+u,w=Math.max(x+c,1e-5),M=m+h,A=y+p,S=g+f,I=Math.max(x+d,1e-5);t.push(new If(b/w,v/w,_/w)),r.push(new If(M/I,A/I,S/I));}s.push(t),a.push(r);}return [s,a]}(r,n,i,s,a)}(a,i,p,h,c,o,g,f,m,a.center.lat,e.tileID.canonical),v=e.queryGeometry;return function(t,e,r){let n=1/0;Qc(r,e)&&(n=Bd(r,e[0]));for(let i=0;i=3)for(let e=0;e>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const i=s_[15&r];if(!i)throw new Error(\"Unrecognized array type.\");const[s]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new a_(a,s,i,t)}constructor(t,e=64,r=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const i=s_.indexOf(this.ArrayType),s=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(i<0)throw new Error(`Unexpected typed array class: ${r}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+s+a+o),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+o,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+i]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t);}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return o_(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,n){if(!this._finished)throw new Error(\"Data not yet indexed - call index.finish().\");const{ids:i,coords:s,nodeSize:a}=this,o=[0,i.length-1,0],l=[];for(;o.length;){const u=o.pop()||0,c=o.pop()||0,h=o.pop()||0;if(c-h<=a){for(let a=h;a<=c;a++){const o=s[2*a],u=s[2*a+1];o>=t&&o<=r&&u>=e&&u<=n&&l.push(i[a]);}continue}const p=h+c>>1,f=s[2*p],d=s[2*p+1];f>=t&&f<=r&&d>=e&&d<=n&&l.push(i[p]),(0===u?t<=f:e<=d)&&(o.push(h),o.push(p-1),o.push(1-u)),(0===u?r>=f:n>=d)&&(o.push(p+1),o.push(c),o.push(1-u));}return l}within(t,e,r){if(!this._finished)throw new Error(\"Data not yet indexed - call index.finish().\");const{ids:n,coords:i,nodeSize:s}=this,a=[0,n.length-1,0],o=[],l=r*r;for(;a.length;){const u=a.pop()||0,c=a.pop()||0,h=a.pop()||0;if(c-h<=s){for(let r=h;r<=c;r++)h_(i[2*r],i[2*r+1],t,e)<=l&&o.push(n[r]);continue}const p=h+c>>1,f=i[2*p],d=i[2*p+1];h_(f,d,t,e)<=l&&o.push(n[p]),(0===u?t-r<=f:e-r<=d)&&(a.push(h),a.push(p-1),a.push(1-u)),(0===u?t+r>=f:e+r>=d)&&(a.push(p+1),a.push(c),a.push(1-u));}return o}}function o_(t,e,r,n,i,s){if(i-n<=r)return;const a=n+i>>1;l_(t,e,a,n,i,s),o_(t,e,r,n,a-1,1-s),o_(t,e,r,a+1,i,1-s);}function l_(t,e,r,n,i,s){for(;i>n;){if(i-n>600){const a=i-n+1,o=r-n+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(o-a/2<0?-1:1);l_(t,e,r,Math.max(n,Math.floor(r-o*u/a+c)),Math.min(i,Math.floor(r+(a-o)*u/a+c)),s);}const a=e[2*r+s];let o=n,l=i;for(u_(t,e,n,r),e[2*i+s]>a&&u_(t,e,n,i);oa;)l--;}e[2*n+s]===a?u_(t,e,n,l):(l++,u_(t,e,l,i)),l<=r&&(n=l+1),r<=l&&(i=l-1);}}function u_(t,e,r,n){c_(t,r,n),c_(e,2*r,2*n),c_(e,2*r+1,2*n+1);}function c_(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function h_(t,e,r,n){const i=t-r,s=e-n;return i*i+s*s}t.$=We,t.A=Hs,t.B=Ys,t.C=qn,t.D=Bi,t.E=Ln,t.G=hl,t.H=eo,t.I=Ig,t.J=Ja,t.K=function(t){const e=t.value;let r=[];if(!e)return r;const n=Ti(e);return \"string\"!==n?(r=r.concat([new qb(t.key,e,`string expected, \"${n}\" found`)]),r):($b(e,!0)||(r=r.concat([new qb(t.key,e,`invalid url \"${e}\"`)])),r)},t.L=ll,t.M=class{constructor(t,e,r,n){this.id=t,this.position=null!=e?new mc(e[0],e[1]):new mc(0,0),this.orientation=null!=r?r:[0,0,0],this.nodes=n,this.uploaded=!1,this.aabb=new Ah([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),this.matrix=[];}_applyTransformations(e,r){if(t.ad.multiply(e.matrix,r,e.matrix),e.meshes)for(const t of e.meshes){const r=Ah.applyTransformFast(t.aabb,e.matrix);this.aabb.encapsulate(r);}if(e.children)for(const t of e.children)this._applyTransformations(t,e.matrix);}computeBoundsAndApplyParent(){const e=t.ad.identity([]);for(const t of this.nodes)this._applyTransformations(t,e);}computeModelMatrix(t,e,r,n,i,s,a=!1){Jb(this.matrix,this,t.transform,this.position,e,r,n,i,s,a);}upload(t){if(!this.uploaded){for(const e of this.nodes)ev(e,t);for(const t of this.nodes)rv(t);this.uploaded=!0;}}destroy(){for(const t of this.nodes)nv(t);}},t.N=ol,t.O=il,t.P=Ne,t.Q=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return yr(t.expression.evaluate(e))}interpolate(t,e,r){return {x:Gn(t.x,e.x,r),y:Gn(t.y,e.y,r),z:Gn(t.z,e.z,r),azimuthal:Gn(t.azimuthal,e.azimuthal,r),polar:Gn(t.polar,e.polar,r)}}},t.R=Wr,t.S=uu,t.T=Gg,t.U=Jo,t.V=qb,t.W=er,t.X=Ho,t.Y=Oc,t.Z=fo,t.a=Eg,t.a$=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return Zh(e,r,t.worldSize,n,i)},t.a0=nl,t.a1=Hh,t.a2=Gn,t.a3=ps,t.a4=Yn,t.a5=class{constructor(t){this.specification=t;}possiblyEvaluate(t,e){return function([t,e]){const r=yr([1,t,e]);return {x:r.x,y:r.y,z:r.z}}(t.expression.evaluate(e))}interpolate(t,e,r){return {x:Gn(t.x,e.x,r),y:Gn(t.y,e.y,r),z:Gn(t.z,e.z,r)}}},t.a6=Uu,t.a7=Du,t.a8=Ru,t.a9=Ou,t.aB=function(e,r){const{x:n,y:i}=e.point,s=Zh(n,i,e.worldSize/e._pixelsPerMercatorPixel,0,0);return t.ad.multiply(s,s,Gh(Ch(r)))},t.aD=qm,t.aE=ty,t.aF=jm,t.aG=function(t,e,r,n,i){const s=5*e+2;t.float32[s+0]=r,t.float32[s+1]=n,t.float32[s+2]=i;},t.aH=Ug,t.aI=mc,t.aJ=Sg,t.aK=vc,t.aL=_c,t.aM=Mh,t.aN=Tb,t.aO=bc,t.aP=Oh,t.aQ=function(t,e,r,n,i,s,a,o,l){if(\"globe\"===l.name)return Oh(t,e,new bc(r,n,i),!1);const u=ng({z:r,x:n,y:i},l);return new Ah([(s+u.x/u.scale)*e,e*(u.y/u.scale),a],[(s+u.x2/u.scale)*e,e*(u.y2/u.scale),o])},t.aR=function(t,e,r){let n=0;for(let r=0;r<2;++r){const i=0;t[r]>i&&(n+=(t[r]-i)*(t[r]-i)),e[r]0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!Wh(e,new mc(e.center.lat,90)),i[0]>0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!Wh(e,new mc(e.center.lat,-90))]},t.aW=function(e,r){const{scale:n}=e.tileTransform,i=n*ps/(e.tileSize*Math.pow(2,r.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return t.aC.scale(new Float32Array(4),r.inverseAdjustmentMatrix,[i,i])},t.aX=kb,t.aY=Ib,t.aZ=function(e){const r=Ib(e,!0);return t.aC.invert([],[r[0],r[1],r[4],r[5]])},t.a_=xh,t.aa=Cu,t.ab=$e,t.ac=function(t,e,r){const n=Math.sqrt(t*t+e*e+r*r),i=n>0?Math.acos(r/n)*qe:0;let s=0!==t||0!==e?Math.atan2(-e,-t)*qe+90:0;return s<0&&(s+=360),[n,s,i]},t.ae=Tg,t.af=Cg,t.ag=Pg,t.ah=function(t,e){const r={};for(let n=0;nOr&&(t.getActor().send(\"enforceCacheSizeLimit\",Lr),qr=0);},t.an=gn,t.ao=class{constructor(t){this.entries={},this.scheduler=t;}request(t,e,r,n){const i=this.entries[t]=this.entries[t]||{callbacks:[]};if(i.result){const[t,r]=i.result;return this.scheduler?this.scheduler.add((()=>{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}},t.ap=function(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:\"parseTile\",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=en(t.request,((t,n,i,s)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new Af(new Bm(n)),rawData:n,cacheControl:i,expires:s});}));return ()=>{n.cancel(),e();}}),e)},t.aq=Vu,t.ar=class extends Bu{constructor(t){super(t),this.current=Nu;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},t.as=Lu,t.at=Ke,t.au=Je,t.aw=Tr,t.ax=Pc,t.ay=Ec,t.az=function(t,e,r){t[4*e+0]=r[0],t[4*e+1]=r[1],t[4*e+2]=r[2],t[4*e+3]=r[3];},t.b=Au,t.b$=od,t.b0=Ge,t.b1=ic,t.b2=function(t){const e=Math.round((t+45+360)%360/90)%4;return Ye[e]},t.b3=45,t.b4=Ic,t.b5=Lc,t.b6=Ah,t.b7=yr,t.b8=function(t){return [Math.pow(t[0],1/2.2),Math.pow(t[1],1/2.2),Math.pow(t[2],1/2.2)]},t.b9=Xe,t.bA=function(t,e){return [Math.pow(t[0],2.2)*e,Math.pow(t[1],2.2)*e,Math.pow(t[2],2.2)*e]},t.bB=im,t.bD=Xh,t.bE=Er,t.bF=zr,t.bG=256,t.bH=function(e,r){const n=[0,0,0],i=$h(Ch(r.canonical));return t._.transformMat4(n,n,i),t._.transformMat4(n,n,e),n},t.bI=t=>({u_camera_to_center_distance:new Cu(t),u_extrude_scale:new qu(t),u_device_pixel_ratio:new Cu(t),u_matrix:new Uu(t),u_inv_rot_matrix:new Uu(t),u_merc_center:new Ru(t),u_tile_id:new Vu(t),u_zoom_transition:new Cu(t),u_up_dir:new Vu(t),u_emissive_strength:new Cu(t)}),t.bJ=t=>({u_matrix:new Uu(t),u_pixels_to_tile_units:new qu(t),u_device_pixel_ratio:new Cu(t),u_units_to_pixels:new Ru(t),u_dash_image:new Du(t),u_gradient_image:new Du(t),u_image_height:new Cu(t),u_texsize:new Ru(t),u_tile_units_to_pixels:new Cu(t),u_alpha_discard_threshold:new Cu(t),u_trim_offset:new Ru(t),u_trim_fade_range:new Ru(t),u_trim_color:new Lu(t),u_emissive_strength:new Cu(t)}),t.bK=t=>({u_matrix:new Uu(t),u_texsize:new Ru(t),u_pixels_to_tile_units:new qu(t),u_device_pixel_ratio:new Cu(t),u_image:new Du(t),u_units_to_pixels:new Ru(t),u_tile_units_to_pixels:new Cu(t),u_alpha_discard_threshold:new Cu(t),u_trim_offset:new Ru(t)}),t.bL=Wl,t.bM=Hd,t.bN=Fm,t.bO=$m,t.bP=Yy,t.bQ=hy,t.bR=rp,t.bS=(t,e,r,n,i,s)=>{const a=t.transform,o=\"globe\"===a.projection.name;let l;if(\"map\"===s.paint.get(\"circle-pitch-alignment\"))if(o){const t=Xh(a.zoom,e.canonical)*a._pixelsPerMercatorPixel;l=Float32Array.from([t,0,0,t]);}else l=a.calculatePixelsToTileUnitsMatrix(r);else l=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:t.transform.getCameraToCenterDistance(a.projection),u_matrix:t.translatePosMatrix(e.projMatrix,r,s.paint.get(\"circle-translate\"),s.paint.get(\"circle-translate-anchor\")),u_device_pixel_ratio:Dr.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:ep,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0],u_emissive_strength:s.paint.get(\"circle-emissive-strength\")};if(o){u.u_inv_rot_matrix=n,u.u_merc_center=i,u.u_tile_id=[e.canonical.x,e.canonical.y,1<{const a=t.transform;return {u_matrix:am(t,e,r,n),u_texsize:e.imageAtlasTexture?e.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:sm(e,a),u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:s}},t.bV=(t,e,r,n,i,s,a)=>{const o=t.transform,l=o.calculatePixelsToTileUnitsMatrix(e);return {u_matrix:am(t,e,r,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:s,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:lm(r)&&e.lineAtlasTexture?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:sm(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:r.paint.get(\"line-trim-fade-range\"),u_trim_color:r.paint.get(\"line-trim-color\").toRenderColor(r.lut).toArray01(),u_emissive_strength:r.paint.get(\"line-emissive-strength\")}},t.bW=sr,t.bX=gp,t.bY=Id,t.bZ=Mc,t.b_=xd,t.ba=function(t,e,r){const n=Hh(r.zoom),i=t.style.map._antialias,s=e.options.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return 0===n&&!i&&!s},t.bb=function(e){const r=e.pixelsPerMeter,n=r/Pc(1,e.center.lat),i=t.ad.identity(new Float64Array(16));return t.ad.translate(i,i,[e.point.x,e.point.y,0]),t.ad.scale(i,i,[n,n,r]),Float32Array.from(i)},t.bc=Fh,t.bd=function(t){const e=Dc-5;t=Ke(t,-e,e)/e*90;const r=Math.pow(Math.abs(Math.sin($e(t))),3);return Math.round(r*(lc.length-1))},t.be=function(e,r,n,i){const s=r.getNorth(),a=r.getSouth(),o=r.getWest(),l=r.getEast(),u=1<0){const e=180/i;t.bC.multiply(d,d,[e/c+1,0,0,0,e/h+1,0,-.5*e/p,.5*e/f,1]);}return d[2]=u,d[5]=e.x,d[8]=e.y,d},t.bf=$h,t.bg=Ch,t.bh=function(e,r,n){const i=t.ad.identity(new Float64Array(16)),s=(r/(1<{}}},t.bo=Yg,t.bp=or,t.bq=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return !1;const r=e.getSource().maxzoom,n=1<1)return e;const i=n.getSource().maxzoom,s=1<{const a=this.getAtTileOffset(e,s.x,s.y),o=i.upVector(e.canonical,s.x,s.y),l=i.upVectorScale(e.canonical,r,n).metersToTile;return t._.scale(o,o,a*l),o}}getForTilePoints(t,e,r,n){if(this.isUsingMockSource())return !1;const i=Qf.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<=0?t.slice(0,e):t},t.cV=function(t){return t.indexOf(Al)>=0},t.cW=function(t){const e=t.indexOf(Al);return e>=0?t.slice(e+1):\"\"},t.cX=function(t){const e=[],r=t.id;return void 0===r&&e.push({message:`layers.${r}: missing required property \"id\"`}),void 0===t.render&&e.push({message:`layers.${r}: missing required method \"render\"`}),t.renderingMode&&\"2d\"!==t.renderingMode&&\"3d\"!==t.renderingMode&&e.push({message:`layers.${r}: property \"renderingMode\" must be either \"2d\" or \"3d\"`}),e},t.cY=function(t,e,r,n){return \"custom\"===t.type?new _b(t,e):new i_[t.type](t,e,r,n)},t.cZ=cr,t.c_=Go,t.ca=1,t.cb=zg,t.cc=0,t.cd=nu,t.ce=function(t,e,r,n,i){return Ke((t-e)/(r-e)*(i-n)+n,n,i)},t.cf=Na,t.cg=Rc,t.ch=class{constructor(t,e,r,n){this.context=t,this.format=n,this.size=r,this.texture=t.gl.createTexture();const[i,s,a]=this.size,{gl:o}=t;o.bindTexture(o.TEXTURE_3D,this.texture),t.pixelStoreUnpackFlipY.set(!1),t.pixelStoreUnpack.set(1),t.pixelStoreUnpackPremultiplyAlpha.set(!1);let l=this.format,u=o.UNSIGNED_BYTE;this.format===o.DEPTH_COMPONENT&&(l=o.DEPTH_COMPONENT16,u=o.UNSIGNED_SHORT),this.format===o.R8&&(n=o.RED),this.format===o.R32F&&(u=o.FLOAT,n=o.RED),o.texImage3D(o.TEXTURE_3D,0,l,i,s,a,0,n,u,e.data);}bind(t,e){const{context:r}=this,{gl:n}=r;n.bindTexture(n.TEXTURE_3D,this.texture),t!==this.minFilter&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MAG_FILTER,t),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_MIN_FILTER,t),this.minFilter=t),e!==this.wrapS&&(n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_3D,n.TEXTURE_WRAP_T,e),this.wrapS=e);}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null;}},t.ci=Cb,t.cj=[1,1,1],t.ck=Qf,t.cl=Wb,t.cm=Zl,t.cn=iu,t.co=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Ne(1/0,1/0),max:new Ne(-1/0,-1/0)};}clear(){this._activeRegions.length>0&&++this._updateTime,this._activeRegions=[],this._prevRegions=[];}get updateTime(){return this._updateTime}getReplacementRegionsForTile(t,e=!1){const r=Rf(new Ne(0,0),new Ne(ps,ps),t),n=[];if(e&&!Df(r,this._globalClipBounds))return n;for(const e of this._activeRegions){if(e.hiddenByOverlap)continue;if(!Df(r,e))continue;const i=Vf(e.min,e.max,t);n.push({min:i.min,max:i.max,sourceId:this._sourceIds[e.priority],footprint:e.footprint,footprintTileId:e.tileId,order:e.order,clipMask:e.clipMask});}return n}setSources(t){this._setSources(t.map((t=>({getSourceId:()=>t.cache.id,getFootprints:()=>{const e=[];for(const r of t.cache.getVisibleCoordinates()){const n=t.cache.getTile(r).buckets[t.layer];n&&n.updateFootprints(r.toUnwrapped(),e);}return e},getOrder:()=>t.order,getClipMask:()=>t.clipMask}))));}_addSource(t){const e=t.getFootprints();if(0===e.length)return;const r=t.getOrder(),n=t.getClipMask();for(const t of e){if(!t.footprint)continue;const e=Rf(t.footprint.min,t.footprint.max,t.id);this._activeRegions.push({min:e.min,max:e.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:t.id,footprint:t.footprint,order:r,clipMask:n});}this._sourceIds.push(t.getSourceId());}_computeReplacement(){this._activeRegions.sort(((t,e)=>t.priority-e.priority||Ef(t.min,e.min)||Ef(t.max,e.max)));let t=this._activeRegions.length!==this._prevRegions.length;if(!t){let e=0;for(;!t&&e!==this._activeRegions.length;){const r=this._activeRegions[e],n=this._prevRegions[e];t=r.priority!==n.priority||!Bf(r,n)||r.order!==n.order||r.clipMask!==n.clipMask,++e;}}if(t){++this._updateTime;for(const t of this._activeRegions)t.order!==1/0&&(this._globalClipBounds.min.x=Math.min(this._globalClipBounds.min.x,t.min.x),this._globalClipBounds.min.y=Math.min(this._globalClipBounds.min.y,t.min.y),this._globalClipBounds.max.x=Math.max(this._globalClipBounds.max.x,t.max.x),this._globalClipBounds.max.y=Math.max(this._globalClipBounds.max.y,t.max.y));const t=t=>{const e=this._activeRegions;if(t>=e.length)return t;const r=e[t].priority;for(;t1){let e=0,r=t(e);for(;e!==r;){let n=e;const i=e;for(;n!==r;){const t=this._activeRegions[n];t.hiddenByOverlap=!1;for(let e=0;e=0;e--)this._addSource(t[e]);this._computeReplacement();}},t.cp=Vl,t.cq=tx,t.cr=au,t.cs=class{constructor(t){this._createGrid(t),this._createPoles(t);}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();}_fillGridMeshWithLods(t,e){const r=new Cl,n=new Ql,i=[],s=t+1+2,a=e[0]+1,o=e[0]+1+(1+e.length),l=(t,e,r)=>{let n=t===s-1?t-2:0===t?t:t-1;return n+=r?24575:0,[n,e]};for(let t=0;tt()));},t.dB=lv,t.dC=vv,t.dD=function(t){mv=Dr.resolveURL(t),bv||(bv=new ov(fv(),new Ln)),bv.broadcast(\"setDracoUrl\",mv);},t.dE=_v,t.dF=function(t){gv=Dr.resolveURL(t),bv||(bv=new ov(fv(),new Ln)),bv.broadcast(\"setMeshoptUrl\",gv);},t.dG=tr,t.dH=Mo,t.dI=pp,t.dJ=Ey,t.dK=ng,t.dL=pu,t.dM=um,t.dN=Vm,t.dO=Kd,t.dP=ur,t.dQ=Ty,t.dR=$g,t.dS=function(t,e,r,n,i,s,a,o,l,u,c){t.createArrays(),t.tilePixelRatio=ps/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const h=t.layers[0].layout,p=t.layers[0]._unevaluatedLayout._values,f={};if(\"composite\"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;f.compositeTextSizes=[p[\"text-size\"].possiblyEvaluate(new Ho(e),o),p[\"text-size\"].possiblyEvaluate(new Ho(r),o)];}if(\"composite\"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;f.compositeIconSizes=[p[\"icon-size\"].possiblyEvaluate(new Ho(e),o),p[\"icon-size\"].possiblyEvaluate(new Ho(r),o)];}f.layoutTextSize=p[\"text-size\"].possiblyEvaluate(new Ho(l+1),o),f.layoutIconSize=p[\"icon-size\"].possiblyEvaluate(new Ho(l+1),o),f.textMaxSize=p[\"text-size\"].possiblyEvaluate(new Ho(18),o);const d=\"map\"===h.get(\"text-rotation-alignment\")&&\"point\"!==h.get(\"symbol-placement\"),m=h.get(\"text-size\");let y=!1;for(const e of t.features)if(e.icon&&e.icon.nameSecondary){y=!0;break}for(const s of t.features){const l=h.get(\"text-font\").evaluate(s,{},o).join(\",\"),p=m.evaluate(s,{},o),g=f.layoutTextSize.evaluate(s,{},o),x=(f.layoutIconSize.evaluate(s,{},o),{horizontal:{},vertical:void 0}),b=s.text;let v,_=[0,0];if(b){const n=b.toString(),a=h.get(\"text-letter-spacing\").evaluate(s,{},o)*Fm,u=h.get(\"text-line-height\").evaluate(s,{},o)*Fm,c=zo(n)?a:0,f=h.get(\"text-anchor\").evaluate(s,{},o),m=h.get(\"text-variable-anchor\");if(!m){const t=h.get(\"text-radial-offset\").evaluate(s,{},o);_=t?Yy(f,[t*Fm,$y]):h.get(\"text-offset\").evaluate(s,{},o).map((t=>t*Fm));}let y=d?\"center\":h.get(\"text-justify\").evaluate(s,{},o);const v=\"point\"===h.get(\"symbol-placement\"),w=v?h.get(\"text-max-width\").evaluate(s,{},o)*Fm:1/0,M=s=>{t.allowVerticalPlacement&&Po(n)&&(x.vertical=ny(b,e,r,i,l,w,u,f,s,c,_,ty.vertical,!0,g,p));};if(!d&&m){const t=\"auto\"===y?m.map((t=>Xy(t))):[y];let n=!1;for(let s=0;s=0||!Po(n)){const t=ny(b,e,r,i,l,w,u,f,y,c,_,ty.horizontal,!1,g,p);t&&(x.horizontal[y]=t);}M(v?\"left\":y);}}let w=!1;if(s.icon&&s.icon.namePrimary){const e=n[s.icon.namePrimary];e&&(v=fy(i[s.icon.namePrimary],s.icon.nameSecondary?i[s.icon.nameSecondary]:void 0,h.get(\"icon-offset\").evaluate(s,{},o),h.get(\"icon-anchor\").evaluate(s,{},o)),w=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&fr(\"Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer\"),(e.pixelRatio!==t.pixelRatio||0!==h.get(\"icon-rotate\").constantOr(1))&&(t.iconsNeedLinear=!0));}const M=Jy(x.horizontal)||x.vertical;t.iconsInText||(t.iconsInText=!!M&&M.iconsInText),(M||v)&&Zy(t,s,x,v,n,f,g,0,_,w,a,o,u,c,y);}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray);},t.dT=tm,t.dU=Wp,t.dV=Af,t.dW=Bm,t.dX=Jf,t.dY=Xx,t.dZ=Sf,t.d_=pf,t.da=Kh,t.db=function(e){const r=[0,0,0],n=t.ad.identity(new Float64Array(16));return t.ad.multiply(n,e.pixelMatrix,e.globeMatrix),t._.transformMat4(r,r,n),new Ne(r[0],r[1])},t.dc=c,t.dd=u,t.de=function(t){const e=t.navigator?t.navigator.userAgent:null;return !!function(t){if(null==Sr){const e=t.navigator?t.navigator.userAgent:null;Sr=!!t.safari||!(!e||!(/\\b(iPad|iPhone|iPod)\\b/.test(e)||e.match(\"Safari\")&&!e.match(\"Chrome\")));}return Sr}(t)&&e&&(e.match(\"Version/15.4\")||e.match(\"Version/15.5\")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.df=nr,t.dg=class{constructor(t,e,r){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!r,this._createSkuToken();}_createSkuToken(){const t=function(){let t=\"\";for(let e=0;e<10;e++)t+=\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"[Math.floor(62*Math.random())];return {token:[\"1\",ln,t].join(\"\"),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt;}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,r){if(!s(t))return t;const n=hn(t);return n.params.push(`sdk=js-${e}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(t,e){if(!s(t))return t;const r=hn(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeModelURL(t,e){if(!s(t))return t;const r=hn(t);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(t,e,r,n){if(!s(t))return t;const i=hn(t);return i.path=`/v4/${i.authority}.json`,i.params.push(\"secure\"),r&&i.params.push(`language=${r}`),n&&i.params.push(`worldview=${n}`),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,r,n){const i=hn(t);return s(t)?(i.path=`/styles/v1${i.path}/sprite${e}${r}`,this._makeAPIURL(i,this._customAccessToken||n)):(i.path+=`${e}${r}`,pn(i))}normalizeTileURL(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!s(t))return t;const i=hn(t);i.path=i.path.replace(/(\\.(png|jpg)\\d*)(?=$)/,`${e||r&&\"raster\"!==i.authority&&512===r?\"@2x\":\"\"}${$r.supported?\".webp\":\"$1\"}`),\"raster\"===i.authority?i.path=`/${n.RASTER_URL_PREFIX}${i.path}`:\"rasterarrays\"===i.authority?i.path=`/${n.RASTERARRAYS_URL_PREFIX}${i.path}`:\"3dtiles\"===i.authority?i.path=`/${n.TILES3D_URL_PREFIX}${i.path}`:(i.path=i.path.replace(/^.+\\/v4\\//,\"/\"),i.path=`/${n.TILE_URL_VERSION}${i.path}`);const a=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(i.params)||n.ACCESS_TOKEN;return n.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&i.params.push(`sku=${this._skuToken}`),this._makeAPIURL(i,a)}canonicalizeTileURL(t,e){const r=hn(t);if(!r.path.match(/^(\\/v4\\/|\\/(raster|rasterarrays)\\/v1\\/)/)||!r.path.match(/\\.[\\w]+$/))return t;let i=\"mapbox://\";r.path.match(/^\\/raster\\/v1\\//)?i+=`raster/${r.path.replace(`/${n.RASTER_URL_PREFIX}/`,\"\")}`:r.path.match(/^\\/rasterarrays\\/v1\\//)?i+=`rasterarrays/${r.path.replace(`/${n.RASTERARRAYS_URL_PREFIX}/`,\"\")}`:i+=`tiles/${r.path.replace(`/${n.TILE_URL_VERSION}/`,\"\")}`;let s=r.params;return e&&(s=s.filter((t=>!t.match(/^access_token=/)))),s.length&&(i+=`?${s.join(\"&\")}`),i}canonicalizeTileset(t,e){const r=!!e&&s(e),n=[];for(const e of t.tiles||[])i(e)?n.push(this.canonicalizeTileURL(e,r)):n.push(e);return n}_makeAPIURL(t,e){const r=\"See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes\",i=hn(n.API_URL);if(t.protocol=i.protocol,t.authority=i.authority,\"http\"===t.protocol){const e=t.params.indexOf(\"secure\");e>=0&&t.params.splice(e,1);}if(\"/\"!==i.path&&(t.path=`${i.path}${t.path}`),!n.REQUIRE_ACCESS_TOKEN)return pn(t);if(e=e||n.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(\"s\"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter((t=>-1===t.indexOf(\"access_token\"))),t.params.push(`access_token=${e||\"\"}`),pn(t)}},t.dh=function(t,e){e?In.add(t):In.delete(t);},t.di=$r,t.dj=Mn,t.dk=Sn,t.dl=un,t.dm=bn,t.dn=_n,t.dp=function(t){In.delete(t);},t.dq=An,t.dr=xn,t.ds=Qe,t.dt=e,t.du=function(t,e){Lr=t,Or=e;},t.dv=function(t,e,r=!1){if(No===Lo||No===Oo||No===Fo)throw new Error(\"setRTLTextPlugin cannot be called multiple times.\");jo=Dr.resolveURL(t),No=Lo,Uo=e,$o(),r||Xo();},t.dw=Yo,t.dx=function(){fv().acquire(cv);},t.dy=function(){const t=pv;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(cv),pv=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()\"));},t.dz=hv,t.e=Dr,t.e0=hm,t.e1=p,t.e2=en,t.e3=function(t){let e=0;if(new Uint32Array(t,0,1)[0]!==zv){const r=new Uint32Array(t,0,7),[,,n,i,s,a]=r;e=r.byteLength+i+s+a+s,(n!==t.byteLength||e>=t.byteLength)&&fr(\"Invalid b3dm header information.\");}return Vv(t,e)},t.e4=function(t,e){const r=$v(t);for(const t of r){for(const e of t.meshes)Gv(e);t.lights&&(t.lightMeshIndex=t.meshes.length,t.meshes.push(Yv(t.lights,e)));}return r},t.e5=Qv,t.e6=av,t.e7=Zo,t.e8=function(t){jr(),Fr&&Fr.then((e=>{e.keys().then((r=>{for(let n=0;nt.arrayBuffer())).then((e=>Vv(e,0,t)))},t.m=class extends qb{},t.n=Ti,t.o=Zn,t.p=ex,t.q=Wa,t.r=Qa,t.s=to,t.t=co,t.u=ul,t.v=cl,t.w=fr,t.x=mo,t.y=ho,t.z=Xs;}));\n\ndefine([\"./shared\"],(function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function s(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 o of e)t+=`${s(o)},`;return `${t}]`}let t=\"{\";for(const o of Object.keys(e).sort())t+=`${o}:${s(e[o])},`;return `${t}}`}function o(t){let o=\"\";for(const i of e.cE)o+=`/${s(t[i])}`;return o}class i{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,s,i){this._options=i;for(const s of t)this._layerConfigs[s.id]=s,(this._layers[s.id]=e.cY(s,this.scope,null,this._options)).compileFilter(),this.keyCache[s.id]&&delete this.keyCache[s.id];for(const e of s)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const s={};for(let i=0;ithis._layers[e.id])),s=t[0];if(\"none\"===s.visibility)continue;const o=s.source||\"\";let i=this.familiesBySource[o];i||(i=this.familiesBySource[o]={});const n=s.sourceLayer||\"_geojsonTileLayer\";let r=i[n];r||(r=i[n]=[]),r.push(t);}}}const n=1*e.dJ;class r{constructor(t){const s={},o=[];for(const e in t){const i=t[e],r=s[e]={};for(const e in i.glyphs){const t=i.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const s=t.metrics.localGlyph?n:1,a={x:0,y:0,w:t.bitmap.width+2*s,h:t.bitmap.height+2*s};o.push(a),r[e]=a;}}const{w:i,h:r}=e.j(o),a=new e.dI({width:i||1,height:r||1});for(const o in t){const i=t[o];for(const t in i.glyphs){const r=i.glyphs[+t];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const l=s[o][t],c=r.metrics.localGlyph?n:1;e.dI.copy(r.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},r.bitmap);}}this.image=a,this.positions=s;}}e.dH(r,\"GlyphAtlas\");class a{constructor(t){this.tileID=new e.aL(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.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.dK(t.tileID.canonical,t.projection),this.projection=t.projection,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep;}parse(t,s,o,i,n){this.status=\"parsing\",this.data=t,this.collisionBoxArray=new e.dL;const a=new e.dM(Object.keys(t.layers).sort()),c=new e.dN(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u=new e.dO(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:u,availableImages:o,brightness:this.brightness},f=s.familiesBySource[this.source];for(const s in f){const i=t.layers[s];if(!i)continue;let n=!1,r=!1,u=!1;for(const e of f[s])\"symbol\"===e[0].type?n=!0:r=!0,e[0].is3D()&&\"model\"!==e[0].type&&(u=!0);if(this.extraShadowCaster&&!u)continue;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!r)continue;1===i.version&&e.w(`Vector tile source \"${this.source}\" layer \"${s}\" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=a.encode(s),g=[];for(let e=0;e=t.maxzoom||\"none\"!==t.visibility&&(l(e,this.zoom,d.brightness,o),(h[t.id]=t.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep})).populate(g,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(e.map((e=>e.id)))));}}let p,g,m,y;u.trim();const x={type:\"maybePrepare\",isSymbolTile:this.isSymbolTile,zoom:this.zoom},w=()=>{if(p)return this.status=\"done\",n(p);if(this.extraShadowCaster)this.status=\"done\",n(null,{buckets:e.dG(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:d.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(g&&m&&y){const t=new r(g),s=new e.dQ(m,y,this.lut);for(const i in h){const n=h[i];n instanceof e.dR?(l(n.layers,this.zoom,d.brightness,o),e.dS(n,g,t.positions,m,s.iconPositions,this.showCollisionBoxes,o,this.tileID.canonical,this.tileZoom,this.projection,this.brightness)):n.hasPattern&&(n instanceof e.dT||n instanceof e.dU||n instanceof e.b_)&&(l(n.layers,this.zoom,d.brightness,o),n.addFeatures(d,this.tileID.canonical,s.patternPositions,o,this.tileTransform,this.brightness));}this.status=\"done\",n(null,{buckets:e.dG(h).filter((e=>!e.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:u,imageAtlas:s,brightness:d.brightness});}};if(!this.extraShadowCaster){const t=e.dP(d.glyphDependencies,(e=>Object.keys(e).map(Number)));Object.keys(t).length?i.send(\"getGlyphs\",{uid:this.uid,stacks:t,scope:this.scope},((e,t)=>{p||(p=e,g=t,w());}),void 0,!1,x):g={};const s=Object.keys(d.iconDependencies);s.length?i.send(\"getImages\",{icons:s,source:this.source,scope:this.scope,tileID:this.tileID,type:\"icons\"},((e,t)=>{p||(p=e,m=t,w());}),void 0,!1,x):m={};const o=Object.keys(d.patternDependencies);o.length?i.send(\"getImages\",{icons:o,source:this.source,scope:this.scope,tileID:this.tileID,type:\"patterns\"},((e,t)=>{p||(p=e,y=t,w());}),void 0,!1,x):y={};}w();}}function l(t,s,o,i){const n=new e.X(s,{brightness:o});for(const e of t)e.recalculate(n,i);}class c extends e.E{constructor(t,s,o,i,n,r){super(),this.actor=t,this.layerIndex=s,this.availableImages=o,this.loadVectorData=n||e.ap,this.loading={},this.loaded={},this.deduped=new e.ao(t.scheduler),this.isSpriteLoaded=i,this.scheduler=t.scheduler,this.brightness=r;}loadTile(s,o){const i=s.uid,n=s&&s.request,r=n&&n.collectResourceTiming,l=this.loading[i]=new a(s);l.abort=this.loadVectorData(s,((a,c)=>{const h=!this.loading[i];if(delete this.loading[i],h||a||!c)return l.status=\"done\",h||(this.loaded[i]=l),o(a);const u=c.rawData,d={};c.expires&&(d.expires=c.expires),c.cacheControl&&(d.cacheControl=c.cacheControl),l.vectorTile=c.vectorTile||new e.dV(new e.dW(u));const f=()=>{l.parse(l.vectorTile,this.layerIndex,this.availableImages,this.actor,((s,i)=>{if(s||!i)return o(s);const a={};if(r){const e=t(n);e.length>0&&(a.resourceTiming=JSON.parse(JSON.stringify(e)));}o(null,e.W({rawTileData:u.slice(0)},i,d,a));}));};this.isSpriteLoaded?f():this.once(\"isSpriteLoaded\",(()=>{this.scheduler?this.scheduler.add(f,{type:\"parseTile\",isSymbolTile:s.isSymbolTile,zoom:s.tileZoom}):f();})),this.loaded=this.loaded||{},this.loaded[i]=l;}));}reloadTile(t,s){const o=this.loaded,i=t.uid;if(o&&o[i]){const n=o[i];n.showCollisionBoxes=t.showCollisionBoxes,n.projection=t.projection,n.brightness=t.brightness,n.tileTransform=e.dK(t.tileID.canonical,t.projection),n.extraShadowCaster=t.extraShadowCaster,n.lut=t.lut;const r=(e,t)=>{const o=n.reloadCallback;o&&(delete n.reloadCallback,n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,o)),s(e,t);};\"parsing\"===n.status?n.reloadCallback=r:\"done\"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,r):r());}else s(null,void 0);}abortTile(e,t){const s=e.uid,o=this.loading[s];o&&(o.abort&&o.abort(),delete this.loading[s]),t();}removeTile(e,t){const s=this.loaded,o=e.uid;s&&s[o]&&delete s[o],t();}}class h{loadTile(t,s){const{uid:o,encoding:i,rawImageData:n,padding:r}=t,a=ImageBitmap&&n instanceof ImageBitmap?this.getImageData(n,r):n;s(null,new e.dX(o,a,i,r<1));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext(\"2d\",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const s=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),s}}class u{decodeRasterArray({task:t,buffer:s},o){e.dY.performDecoding(s,t).then((e=>{o(null,e);}),(e=>{o(e);}));}}const d=e.dZ.prototype.toGeoJSON;let f=class{constructor(t){this._feature=t,this.extent=e.a3,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 s of this._feature.geometry)t.push([new e.P(s[0],s[1])]);return t}{const t=[];for(const s of this._feature.geometry){const o=[];for(const t of s)o.push(new e.P(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,s){return d.call(this,e,t,s)}},p=class{constructor(t){this.layers={_geojsonTileLayer:this},this.name=\"_geojsonTileLayer\",this.extent=e.a3,this.length=t.length,this._features=t;}feature(e){return new f(this._features[e])}};const g=64/4096;class m{constructor(){this.features=new Map;}clear(){this.features.clear();}load(e=[],t){for(const s of e){const e=s.id;if(null==e)continue;let o=this.features.get(e);o&&this.updateCache(o,t),s.geometry?(o=x(s),this.updateCache(o,t),this.features.set(e,o)):this.features.delete(e),this.updateCache(o,t);}}updateCache(e,t){for(const{canonical:s,uid:o}of Object.values(t)){const{z:i,x:n,y:r}=s;y(e,Math.pow(2,i),n,r)&&delete t[o];}}getTile(e,t,s){const o=Math.pow(2,e),i=[];for(const e of this.features.values())y(e,o,t,s)&&i.push(v(e,o,t,s));return {features:i}}getFeatures(){return [...this.features.values()]}}function y({minX:e,minY:t,maxX:s,maxY:o},i,n,r){return e<(n+1+g)/i&&t<(r+1+g)/i&&s>(n-g)/i&&o>(r-g)/i}function x(e){const{id:t,geometry:s,properties:o}=e;if(!s)return;if(\"GeometryCollection\"===s.type)throw new Error(\"GeometryCollection not supported in dynamic mode.\");const{type:i,coordinates:n}=s,r={id:t,type:1,geometry:[],tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=r.geometry;if(\"Point\"===i)w(n,a,r);else if(\"MultiPoint\"===i)for(const e of n)w(e,a,r);else if(\"LineString\"===i)r.type=2,S(n,a,r);else if(\"MultiLineString\"===i)r.type=2,b(n,a,r);else if(\"Polygon\"===i)r.type=3,b(n,a,r,!0);else {if(\"MultiPolygon\"!==i)throw new Error(\"Input data is not a valid GeoJSON object.\");r.type=3;for(const e of n)b(e,a,r,!0);}return r}function w([t,s],o,i){const n=e.aj(t);let r=e.ak(s);r=r<0?0:r>1?1:r,o.push(n,r),i.minX=Math.min(i.minX,n),i.minY=Math.min(i.minY,r),i.maxX=Math.max(i.maxX,n),i.maxY=Math.max(i.maxY,r);}function S(e,t,s,o=!1,i=!1){const n=[];for(const t of e)w(t,n,s);t.push(n),o&&function(e,t){let s=0;for(let t=0,o=e.length,i=o-2;t0===t)for(let t=0,s=e.length;t>31}function X(e,t){for(var s=e.loadGeometry(),o=e.type,i=0,n=0,r=s.length,a=0;ae},J=Math.fround||(W=new Float32Array(1),e=>(W[0]=+e,W[0]));var W;const B=3,R=5,V=6;class ${constructor(e){this.options=Object.assign(Object.create(G),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[];}load(e){const{log:t,minZoom:s,maxZoom:o}=this.options;t&&console.time(\"total time\");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;const n=[];for(let t=0;t=s;e--){const s=+Date.now();r=this.trees[e]=this._createTree(this._cluster(r,e)),t&&console.log(\"z%d: %d clusters in %dms\",e,r.numItems,+Date.now()-s);}return t&&console.timeEnd(\"total time\"),this}getClusters(e,t){let s=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)s=-180,i=180;else if(s>i){const e=this.getClusters([s,o,180,n],t),r=this.getClusters([-180,o,i,n],t);return e.concat(r)}const r=this.trees[this._limitZoom(t)],a=r.range(K(s),H(n),K(i),H(o)),l=r.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+R]>1?U(l,t,this.clusterProps):this.points[l[t+B]]);}return c}getChildren(e){const t=this._getOriginId(e),s=this._getOriginZoom(e),o=\"No cluster with the specified id.\",i=this.trees[s];if(!i)throw new Error(o);const n=i.data;if(t*this.stride>=n.length)throw new Error(o);const r=this.options.radius/(this.options.extent*Math.pow(2,s-1)),a=i.within(n[t*this.stride],n[t*this.stride+1],r),l=[];for(const t of a){const s=t*this.stride;n[s+4]===e&&l.push(n[s+R]>1?U(n,s,this.clusterProps):this.points[n[s+B]]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,s){const o=[];return this._appendLeaves(o,e,t=t||10,s=s||0,0),o}getTile(e,t,s){const o=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:n,radius:r}=this.options,a=r/n,l=(s-a)/i,c=(s+1+a)/i,h={features:[]};return this._addTileFeatures(o.range((t-a)/i,l,(t+1+a)/i,c),o.data,t,s,i,h),0===t&&this._addTileFeatures(o.range(1-a/i,l,1,c),o.data,i,s,i,h),t===i-1&&this._addTileFeatures(o.range(0,l,a/i,c),o.data,-1,s,i,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const s=this.getChildren(e);if(t++,1!==s.length)break;e=s[0].properties.cluster_id;}return t}_appendLeaves(e,t,s,o,i){const n=this.getChildren(t);for(const t of n){const n=t.properties;if(n&&n.cluster?i+n.point_count<=o?i+=n.point_count:i=this._appendLeaves(e,n.cluster_id,s,o,i):i1;let l,c,h;if(a)l=q(t,e,this.clusterProps),c=t[e],h=t[e+1];else {const s=this.points[t[e+B]];l=s.properties;const[o,i]=s.geometry.coordinates;c=K(o),h=H(i);}const u={type:1,geometry:[[Math.round(this.options.extent*(c*i-s)),Math.round(this.options.extent*(h*i-o))]],tags:l};let d;d=a||this.options.generateId?t[e+B]:this.points[t[e+B]].id,void 0!==d&&(u.id=d),n.features.push(u);}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(Math.floor(+e),this.options.maxZoom+1))}_cluster(e,t){const{radius:s,extent:o,reduce:i,minPoints:n}=this.options,r=s/(o*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let s=0;st&&(f+=a[s+R]);}if(f>d&&f>=n){let e,n=o*d,r=h*d,p=-1;const g=(s/c<<5)+(t+1)+this.points.length;for(const o of u){const l=o*c;if(a[l+2]<=t)continue;a[l+2]=t;const h=a[l+R];n+=a[l]*h,r+=a[l+1]*h,a[l+4]=g,i&&(e||(e=this._map(a,s,!0),p=this.clusterProps.length,this.clusterProps.push(e)),i(e,this._map(a,l)));}a[s+4]=g,l.push(n/f,r/f,1/0,g,-1,f),i&&l.push(p);}else {for(let e=0;e1)for(const e of u){const s=e*c;if(!(a[s+2]<=t)){a[s+2]=t;for(let e=0;e>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t,s){if(e[t+R]>1){const o=this.clusterProps[e[t+V]];return s?Object.assign({},o):o}const o=this.points[e[t+B]].properties,i=this.options.map(o);return s&&i===o?Object.assign({},i):i}}function U(e,t,s){return {type:\"Feature\",id:e[t+B],properties:q(e,t,s),geometry:{type:\"Point\",coordinates:[(o=e[t],360*(o-.5)),Q(e[t+1])]}};var o;}function q(e,t,s){const o=e[t+R],i=o>=1e4?`${Math.round(o/1e3)}k`:o>=1e3?Math.round(o/100)/10+\"k\":o,n=e[t+V],r=-1===n?{}:Object.assign({},s[n]);return Object.assign(r,{cluster:!0,cluster_id:e[t+B],point_count:o,point_count_abbreviated:i})}function K(e){return e/360+.5}function H(e){const t=Math.sin(e*Math.PI/180),s=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return s<0?0:s>1?1:s}function Q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function ee(e,t,s,o){let i=o;const n=t+(s-t>>1);let r,a=s-t;const l=e[t],c=e[t+1],h=e[s],u=e[s+1];for(let o=t+3;oi)r=o,i=t;else if(t===i){const e=Math.abs(o-n);eo&&(r-t>3&&ee(e,t,r,o),e[r+2]=i,s-r>3&&ee(e,r,s,o));}function te(e,t,s,o,i,n){let r=i-s,a=n-o;if(0!==r||0!==a){const l=((e-s)*r+(t-o)*a)/(r*r+a*a);l>1?(s=i,o=n):l>0&&(s+=r*l,o+=a*l);}return r=e-s,a=t-o,r*r+a*a}function se(e,t,s,o){const i={id:e??null,type:t,geometry:s,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(\"Point\"===t||\"MultiPoint\"===t||\"LineString\"===t)oe(i,s);else if(\"Polygon\"===t)oe(i,s[0]);else if(\"MultiLineString\"===t)for(const e of s)oe(i,e);else if(\"MultiPolygon\"===t)for(const e of s)oe(i,e[0]);return i}function oe(e,t){for(let s=0;s0&&(r+=o?(i*l-a*n)/2:Math.sqrt(Math.pow(a-i,2)+Math.pow(l-n,2))),i=a,n=l;}const a=t.length-3;t[2]=1,ee(t,0,a,s),t[a+2]=1,t.size=Math.abs(r),t.start=0,t.end=t.size;}function ae(e,t,s,o){for(let i=0;i1?1:s}function he(e,t,s,o,i,n,r,a){if(o/=t,n>=(s/=t)&&r=o)return null;const l=[];for(const t of e){const e=t.geometry;let n=t.type;const r=0===i?t.minX:t.minY,c=0===i?t.maxX:t.maxY;if(r>=s&&c=o)continue;let h=[];if(\"Point\"===n||\"MultiPoint\"===n)ue(e,h,s,o,i);else if(\"LineString\"===n)de(e,h,s,o,i,!1,a.lineMetrics);else if(\"MultiLineString\"===n)pe(e,h,s,o,i,!1);else if(\"Polygon\"===n)pe(e,h,s,o,i,!0);else if(\"MultiPolygon\"===n)for(const t of e){const e=[];pe(t,e,s,o,i,!0),e.length&&h.push(e);}if(h.length){if(a.lineMetrics&&\"LineString\"===n){for(const e of h)l.push(se(t.id,n,e,t.tags));continue}\"LineString\"!==n&&\"MultiLineString\"!==n||(1===h.length?(n=\"LineString\",h=h[0]):n=\"MultiLineString\"),\"Point\"!==n&&\"MultiPoint\"!==n||(n=3===h.length?\"Point\":\"MultiPoint\"),l.push(se(t.id,n,h,t.tags));}}return l.length?l:null}function ue(e,t,s,o,i){for(let n=0;n=s&&r<=o&&ge(t,e[n],e[n+1],e[n+2]);}}function de(e,t,s,o,i,n,r){let a=fe(e);const l=0===i?me:ye;let c,h,u=e.start;for(let d=0;ds&&(h=l(a,f,p,m,y,s),r&&(a.start=u+c*h)):x>o?w=s&&(h=l(a,f,p,m,y,s),S=!0),w>o&&x<=o&&(h=l(a,f,p,m,y,o),S=!0),!n&&S&&(r&&(a.end=u+c*h),t.push(a),a=fe(e)),r&&(u+=c);}let d=e.length-3;const f=e[d],p=e[d+1],g=0===i?f:p;g>=s&&g<=o&&ge(a,f,p,e[d+2]),d=a.length-3,n&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&ge(a,a[0],a[1],a[2]),a.length&&t.push(a);}function fe(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pe(e,t,s,o,i,n){for(const r of e)de(r,t,s,o,i,n,!1);}function ge(e,t,s,o){e.push(t,s,o);}function me(e,t,s,o,i,n){const r=(n-t)/(o-t);return ge(e,n,s+(i-s)*r,1),r}function ye(e,t,s,o,i,n){const r=(n-s)/(i-s);return ge(e,t+(o-t)*r,n,1),r}function xe(e,t){const s=[];for(let o=0;o0&&t.size<(i?r:o))return void(s.numPoints+=t.length/3);const a=[];for(let e=0;er)&&(s.numSimplified++,a.push(t[e],t[e+1])),s.numPoints++;i&&function(e,t){let s=0;for(let t=0,o=e.length,i=o-2;t0===t)for(let t=0,s=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 o=function(e,t){const s=[];if(\"FeatureCollection\"===e.type)for(let o=0;o1&&console.time(\"creation\"),d=this.tiles[u]=ve(e,t,s,o,l),this.tileCoords.push({z:t,x:s,y:o}),c)){c>1&&(console.log(\"tile z%d-%d-%d (features: %d, points: %d, simplified: %d)\",t,s,o,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==i){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else {if(t===l.maxZoom||t===i)continue;if(null!=i){const e=i-t;if(s!==n>>e||o!==r>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time(\"clipping\");const f=.5*l.buffer/l.extent,p=.5-f,g=.5+f,m=1+f;let y=null,x=null,w=null,S=null,b=he(e,h,s-f,s+g,0,d.minX,d.maxX,l),v=he(e,h,s+p,s+m,0,d.minX,d.maxX,l);e=null,b&&(y=he(b,h,o-f,o+g,1,d.minY,d.maxY,l),x=he(b,h,o+p,o+m,1,d.minY,d.maxY,l),b=null),v&&(w=he(v,h,o-f,o+g,1,d.minY,d.maxY,l),S=he(v,h,o+p,o+m,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd(\"clipping\"),a.push(y||[],t+1,2*s,2*o),a.push(x||[],t+1,2*s,2*o+1),a.push(w||[],t+1,2*s+1,2*o),a.push(S||[],t+1,2*s+1,2*o+1);}}getTile(e,t,s){e=+e,t=+t,s=+s;const o=this.options,{extent:i,debug:n}=o;if(e<0||e>24)return null;const r=1<1&&console.log(\"drilling down to z%d-%d-%d\",e,t,s);let l,c=e,h=t,u=s;for(;!l&&c>0;)c--,h>>=1,u>>=1,l=this.tiles[Pe(c,h,u)];return l&&l.source?(n>1&&(console.log(\"found parent tile z%d-%d-%d\",c,h,u),console.time(\"drilling down\")),this.splitTile(l.source,c,h,u,e,t,s),n>1&&console.timeEnd(\"drilling down\"),this.tiles[a]?Se(this.tiles[a],i):null):null}}function Pe(e,t,s){return 32*((1<{if(r||!a)return o(r);if(\"object\"!=typeof a)return o(new Error(`Input data given to '${s.source}' is not a valid GeoJSON object.`));{try{if(s.filter){const t=e.y(s.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)));}s.dynamic?(\"Feature\"===a.type&&(a={type:\"FeatureCollection\",features:[a]}),s.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),s.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=s.cluster?new $(function({superclusterOptions:t,clusterProperties:s}){if(!s||!t)return t;const o={},i={},n={accumulated:null,zoom:0},r={properties:null},a=Object.keys(s);for(const t of a){const[n,r]=s[t],a=e.y(r),l=e.y(\"string\"==typeof n?[n,[\"accumulated\"],[\"get\",t]]:n);o[t]=a.value,i[t]=l.value;}return t.map=e=>{r.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(n,r);return t},t.reduce=(e,t)=>{r.properties=t;for(const t of a)n.accumulated=e[t],e[t]=i[t].evaluate(n,r);},t}(s)).load(a.features):s.dynamic?this._dynamicIndex:function(e,t){return new Te(e,t)}(a,s.geojsonVtOptions);}catch(e){return o(e)}const r={};if(n){const e=t(i);e&&(r.resourceTiming={},r.resourceTiming[s.source]=JSON.parse(JSON.stringify(e)));}o(null,r);}}));}reloadTile(e,t){const s=this.loaded;return s&&s[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,s){if(t.request)e.g(t.request,s);else {if(\"string\"!=typeof t.data)return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return s(null,JSON.parse(t.data))}catch(e){return s(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class Le{constructor(t,s){this.tileID=new e.aL(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=s;}parse(t,s,o,i){this.status=\"parsing\";const n=new e.aL(o.tileID.overscaledZ,o.tileID.wrap,o.tileID.canonical.z,o.tileID.canonical.x,o.tileID.canonical.y),r={},a=s.familiesBySource[o.source],l=new e.dN(n,o.promoteId);return l.bucketLayerIDs=[],l.is3DTile=!0,e.e3(t).then((t=>{if(!t)return i(new Error(\"Could not parse tile\"));const s=e.e4(t,1/e.b5(o.tileID.canonical)),c=t.json.extensionsUsed&&t.json.extensionsUsed.includes(\"MAPBOX_mesh_features\")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,h=t.json.extensionsUsed&&t.json.extensionsUsed.includes(\"EXT_meshopt_compression\"),u=new e.X(this.zoom,{brightness:this.brightness});for(const t in a)for(const o of a[t]){const t=o[0];l.bucketLayerIDs.push(o.map((e=>e.id))),t.recalculate(u,[]);const i=new e.e5(s,n,c,h,this.brightness,l);c||(i.needsUpload=!0),r[t.fqid]=i,i.evaluate(t);}this.status=\"done\",i(null,{buckets:r,featureIndex:l});})).catch((e=>i(new Error(e.message))))}}class De{constructor(e,t,s,o,i,n){this.actor=e,this.layerIndex=t,this.brightness=n,this.loading={},this.loaded={};}loadTile(t,s){const o=t.uid,i=this.loading[o]=new Le(t,this.brightness);e.e2(t.request,((e,n)=>{const r=!this.loading[o];return delete this.loading[o],r||e?(i.status=\"done\",r||(this.loaded[o]=i),s(e)):n&&0!==n.byteLength?void i.parse(n,this.layerIndex,t,((e,t)=>{i.status=\"done\",this.loaded=this.loaded||{},this.loaded[o]=i,e||!t?s(e):s(null,t);})):(i.status=\"done\",this.loaded[o]=i,s())}));}reloadTile(e,t){const s=this.loaded,o=e.uid;if(s&&s[o]){const i=s[o];i.projection=e.projection,i.brightness=e.brightness;const n=(s,o)=>{i.reloadCallback&&(delete i.reloadCallback,this.loadTile(e,t)),t(s,o);};\"parsing\"===i.status?i.reloadCallback=n:\"done\"===i.status&&this.loadTile(e,t);}}abortTile(e,t){const s=e.uid;this.loading[s]&&delete this.loading[s],t();}removeTile(e,t){const s=this.loaded,o=e.uid;s&&s[o]&&delete s[o],t();}}class je{constructor(t){this.self=t,this.actor=new e.e6(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.aJ({name:\"mercator\"}),this.workerSourceTypes={vector:c,geojson:_e,\"batched-model\":De},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name \"${e}\" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.e7.isParsed())throw new Error(\"RTL text plugin already registered.\");e.e7.applyArabicShaping=t.applyArabicShaping,e.e7.processBidirectionalText=t.processBidirectionalText,e.e7.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,s){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],delete this.rasterArrayWorkerSource,s();}checkIfReady(e,t,s){s();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,{scope:s,isLoaded:o}){if(this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={}),this.isSpriteLoaded[t][s]=o,this.workerSources[t]&&this.workerSources[t][s])for(const i in this.workerSources[t][s]){const n=this.workerSources[t][s][i];for(const t in n){const s=n[t];s instanceof c&&(s.isSpriteLoaded=o,s.fire(new e.f(\"isSpriteLoaded\")));}}}setImages(e,{scope:t,images:s},o){if(this.availableImages[e]||(this.availableImages[e]={}),this.availableImages[e][t]=s,this.workerSources[e]&&this.workerSources[e][t]){for(const o in this.workerSources[e][t]){const i=this.workerSources[e][t][o];for(const e in i)i[e].availableImages=s;}o();}else o();}setProjection(t,s){this.projections[t]=e.aJ(s);}setBrightness(e,t,s){this.brightness=t,s();}setLayers(e,t,s){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),s();}updateLayers(e,t,s){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),s();}loadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,s);}loadDEMTile(e,t,s){this.getDEMWorkerSource(e,t.source,t.scope).loadTile(t,s);}decodeRasterArray(e,t,s){this.getRasterArrayWorkerSource().decodeRasterArray(t,s);}reloadTile(e,t,s){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,s);}abortTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,s);}removeTile(e,t,s){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,s);}removeSource(e,t,s){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const o=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,s):s();}loadWorkerSource(e,t,s){try{this.self.importScripts(t.url),s();}catch(e){s(e.toString());}}syncRTLPluginState(t,s,o){try{e.e7.setState(s);const t=e.e7.getPluginURL();if(e.e7.isLoaded()&&!e.e7.isParsed()&&null!=t){this.self.importScripts(t);const s=e.e7.isParsed();o(s?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),s);}}catch(e){o(e.toString());}}setDracoUrl(e,t){this.dracoUrl=t;}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let s=this.availableImages[e][t];return s||(s=[]),s}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let s=this.layerIndexes[e][t];return s||(s=this.layerIndexes[e][t]=new i,s.scope=t),s}getWorkerSource(e,t,s,o){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][o]||(this.workerSources[e][o]={}),this.workerSources[e][o][t]||(this.workerSources[e][o][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),this.workerSources[e][o][t][s]||(this.workerSources[e][o][t][s]=new this.workerSourceTypes[t]({send:(t,s,o,i,n,r)=>{this.actor.send(t,s,o,e,n,r);},scheduler:this.actor.scheduler},this.getLayerIndex(e,o),this.getAvailableImages(e,o),this.isSpriteLoaded[e][o],void 0,this.brightness)),this.workerSources[e][o][t][s]}getDEMWorkerSource(e,t,s){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][s]||(this.demWorkerSources[e][s]={}),this.demWorkerSources[e][s][t]||(this.demWorkerSources[e][s][t]=new h),this.demWorkerSources[e][s][t]}getRasterArrayWorkerSource(){return this.rasterArrayWorkerSource||(this.rasterArrayWorkerSource=new u),this.rasterArrayWorkerSource}enforceCacheSizeLimit(t,s){e.e8(s);}getWorkerPerformanceMetrics(e,t,s){s(void 0,void 0);}}return \"undefined\"!=typeof WorkerGlobalScope&&\"undefined\"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new je(self)),je}));\n\ndefine([\"./shared\"],(function(e){function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return !1;for(let o=0;o{window.removeEventListener(\"click\",u,!0);}),0);}function p(e,t){const i=e.getBoundingClientRect();return g(e,i,t)}function f(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r=0?0:e.button}function g(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.P((o.clientX-i.left)*r,(o.clientY-i.top)*r)}class v{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages=new Set;}isDirty(){return this._changed}setDirty(){this._changed=!0;}getUpdatedSourceCaches(){return this._updatedSourceCaches}updateSourceCache(e,t){this._updatedSourceCaches[e]=t,this.setDirty();}discardSourceCacheUpdate(e){delete this._updatedSourceCaches[e];}updateLayer(e){const t=e.scope;this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._updatedLayers[t].add(e.id),this.setDirty();}removeLayer(e){const t=e.scope;this._removedLayers[t]=this._removedLayers[t]||{},this._updatedLayers[t]=this._updatedLayers[t]||new Set,this._removedLayers[t][e.id]=e,this._updatedLayers[t].delete(e.id),this._updatedPaintProps.delete(e.fqid),this.setDirty();}getRemovedLayer(e){return this._removedLayers[e.scope]?this._removedLayers[e.scope][e.id]:null}discardLayerRemoval(e){this._removedLayers[e.scope]&&delete this._removedLayers[e.scope][e.id];}getLayerUpdatesByScope(){const e={};for(const t in this._updatedLayers)e[t]=e[t]||{},e[t].updatedIds=Array.from(this._updatedLayers[t].values());for(const t in this._removedLayers)e[t]=e[t]||{},e[t].removedIds=Object.keys(this._removedLayers[t]);return e}getUpdatedPaintProperties(){return this._updatedPaintProps}updatePaintProperties(e){this._updatedPaintProps.add(e.fqid),this.setDirty();}getUpdatedImages(){return Array.from(this._updatedImages.values())}updateImage(e){this._updatedImages.add(e),this.setDirty();}resetUpdatedImages(){this._updatedImages.clear();}reset(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages.clear();}}const x={Int8:\"BYTE\",Uint8:\"UNSIGNED_BYTE\",Int16:\"SHORT\",Uint16:\"UNSIGNED_SHORT\",Int32:\"INT\",Uint32:\"UNSIGNED_INT\",Float32:\"FLOAT\"};class y{constructor(e,t,i,o,r,a){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=o,this.instanceCount=a,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.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 b{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 w extends b{getDefault(){return e.C.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class T extends b{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1);}}class E extends b{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1);}}class C extends b{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 S extends b{getDefault(){return !0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1);}}class I extends b{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1);}}class L extends b{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 P extends b{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 A extends b{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 R extends b{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 D extends b{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 M extends b{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1);}}class z extends b{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 O extends b{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 F extends b{getDefault(){return e.C.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1);}}class B extends b{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 k extends b{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 N extends b{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1);}}class U extends b{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1);}}let G=class extends b{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1);}};class j extends b{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1);}}class V extends b{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 W extends b{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 Z extends b{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 q extends b{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 H extends b{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 $ extends b{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1;}}class X extends b{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1);}}class Y extends b{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 K extends b{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 Q extends b{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 J extends b{constructor(e,t){super(e),this.context=e,this.parent=t;}getDefault(){return null}}class ee extends J{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 te extends J{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 ie extends J{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 oe extends te{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class re{constructor(e,t,i,o,r){this.context=e,this.width=t,this.height=i;const a=this.framebuffer=e.gl.createFramebuffer();o&&(this.colorAttachment=new ee(e,a)),r&&(this.depthAttachmentType=r,this.depthAttachment=\"renderbuffer\"===r?new te(e,a):new ie(e,a));}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 ae{constructor(e,t){this.gl=e,this.clearColor=new w(this),this.clearDepth=new T(this),this.clearStencil=new E(this),this.colorMask=new C(this),this.depthMask=new S(this),this.stencilMask=new I(this),this.stencilFunc=new L(this),this.stencilOp=new P(this),this.stencilTest=new A(this),this.depthRange=new R(this),this.depthTest=new D(this),this.depthFunc=new M(this),this.blend=new z(this),this.blendFunc=new O(this),this.blendColor=new F(this),this.blendEquation=new B(this),this.cullFace=new k(this),this.cullFaceSide=new N(this),this.frontFace=new U(this),this.program=new G(this),this.activeTexture=new j(this),this.viewport=new V(this),this.bindFramebuffer=new W(this),this.bindRenderbuffer=new Z(this),this.bindTexture=new q(this),this.bindVertexBuffer=new H(this),this.bindElementBuffer=new $(this),this.bindVertexArrayOES=new X(this),this.pixelStoreUnpack=new Y(this),this.pixelStoreUnpackPremultiplyAlpha=new K(this),this.pixelStoreUnpackFlipY=new Q(this),this.options=t?{...t}:{},this.options.extTextureFilterAnisotropicForceOff||(this.extTextureFilterAnisotropic=e.getExtension(\"EXT_texture_filter_anisotropic\")||e.getExtension(\"MOZ_EXT_texture_filter_anisotropic\")||e.getExtension(\"WEBKIT_EXT_texture_filter_anisotropic\"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))),this.extDebugRendererInfo=e.getExtension(\"WEBGL_debug_renderer_info\"),this.extDebugRendererInfo&&(this.renderer=e.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=e.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension(\"OES_texture_float_linear\")),this.extRenderToTextureHalfFloat=e.getExtension(\"EXT_color_buffer_half_float\"),this.extTimerQuery=e.getExtension(\"EXT_disjoint_timer_query_webgl2\"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),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(t,i,o){return new e.I(this,t,i,o)}createVertexBuffer(e,t,i,o,r){return new y(this,e,t,i,o,r)}createRenderbuffer(e,t,i){const o=this.gl,r=o.createRenderbuffer();return this.bindRenderbuffer.set(r),o.renderbufferStorage(o.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,o){return new re(this,e,t,i,o)}clear({color:e,depth:t,stencil:i,colorMask:o}){const r=this.gl;let a=0;e&&(a|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set(o||[!0,!0,!0,!0])),void 0!==t&&(a|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(a|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(a);}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(i){t(i.blendFunction,e.a.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor),i.blendEquation?this.blendEquation.set(i.blendEquation):this.blendEquation.setDefault()),this.colorMask.set(i.mask);}unbindVAO(){this.bindVertexArrayOES.set(null);}}class ne{constructor(e){this._gl=e.gl,this._query=this._gl.createQuery(),this._isFree=!0;}begin(){this._gl.beginQuery(this._gl.ANY_SAMPLES_PASSED,this._query),this._isFree=!1;}end(){this._gl.endQuery(this._gl.ANY_SAMPLES_PASSED);}isResultAvailable(){return this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT_AVAILABLE)}consumeResult(){const e=this._gl.getQueryParameter(this._query,this._gl.QUERY_RESULT);return this._isFree=!0,e}isFree(){return this._isFree}destroy(){this._gl.deleteQuery(this._query);}}class se{constructor(e){this.useOcclusionQueries=!0,this.visualizeOcclusions=\"none\",this.occlusionQueryFrameWindow=5,this.occluderSize=32,this.fadeSpeed=7,this.depthOffset=-1e-4,e.registerParameter(this,[\"Symbols\"],\"useOcclusionQueries\"),e.registerParameter(this,[\"Symbols\"],\"visualizeOcclusions\",{options:{none:\"none\",zPass:\"zPass\",zTest:\"zTest\"}}),e.registerParameter(this,[\"Symbols\"],\"occlusionQueryFrameWindow\",{min:1,max:30,step:1}),e.registerParameter(this,[\"Symbols\"],\"occluderSize\",{min:1,max:100,step:1}),e.registerParameter(this,[\"Symbols\"],\"fadeSpeed\",{min:.1,max:50,step:.1}),e.registerParameter(this,[\"Symbols\"],\"depthOffset\",{min:-.001,max:0,step:1e-4});}}class le{constructor(t,i,o,r){const a={width:o[0],height:o[1],data:null},n=t.gl;this.targetColorTexture=new e.T(t,a,n.RGBA,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,a,n.RGBA,{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 o=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,o.RGBA,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,o.RGBA,{premultiply:!1,useMipmap:!1});const a=new e.S;a.reserve(r);for(let e=0;e{if(!i)return;const o=e.c(i),r=new e.M(t,void 0,void 0,o);return r.computeBoundsAndApplyParent(),r})).catch((o=>{if(o&&404===o.status)return null;this.fire(new e.d(new Error(`Could not load model ${t} from ${i}: ${o.message}`)));}))}load(t,i){this.models[i]||(this.models[i]={});const o=Object.keys(t);this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+o.length;const r=[];for(const e of o)r.push(this.loadModel(e,t[e]));Promise.allSettled(r).then((t=>{for(let e=0;e{this.fire(new e.d(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){return !!this.getModel(e,t)}getModel(e,t){return this.models[t]||(this.models[t]={}),this.models[t][e]?this.models[t][e].model:void 0}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.hasModel(e,i)&&this.models[i][e].numReferences++,this.load({[e]:this.requestManager.normalizeModelURL(t)},i);}addModels(e,t){this.models[t]||(this.models[t]={});const i={};for(const o in e)this.models[t][o]={},i[o]=this.requestManager.normalizeModelURL(e[o]);this.load(i,t);}addModelsFromBucket(e,t){this.models[t]||(this.models[t]={});const i={};for(const o of e)this.hasModel(o,t)?this.models[t][o].numReferences++:i[o]=this.requestManager.normalizeModelURL(o);this.load(i,t);}removeModel(e,t){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences)){const i=this.models[t][e].model;delete this.models[t][e],i.destroy();}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context);}}function he(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class _e extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded={},this.requestors=[],this.patterns={},this.atlasImage={},this.atlasTexture={},this.dirty=!0;}createScope(t){this.images[t]={},this.loaded[t]=!1,this.updatedImages[t]={},this.patterns[t]={},this.callbackDispatchedThisFrame[t]={},this.atlasImage[t]=new e.i({width:1,height:1});}isLoaded(){for(const e in this.loaded)if(!this.loaded[e])return !1;return !0}setLoaded(e,t){if(this.loaded[t]!==e&&(this.loaded[t]=e,e)){for(const{ids:e,callback:i}of this.requestors)this._notify(e,t,i);this.requestors=[];}}hasImage(e,t){return !!this.getImage(e,t)}getImage(e,t){return this.images[t][e]}addImage(e,t,i){this._validate(e,i)&&(this.images[t][e]=i);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.d(new Error(`Image \"${t}\" has invalid \"stretchX\" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.d(new Error(`Image \"${t}\" has invalid \"stretchY\" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.d(new Error(`Image \"${t}\" has invalid \"content\" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]a)return [new e.V(i,o,`${o} is greater than the maximum value ${a}`)]}return []}function fe(t){const i=t.valueSpec,o=e.u(t.value.type);let r,a,n,s={};const l=\"categorical\"!==o&&void 0===t.value.property,c=!l,h=\"array\"===e.n(t.value.stops)&&\"array\"===e.n(t.value.stops[0])&&\"object\"===e.n(t.value.stops[0][0]),_=ue({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 r=t.value;return i=i.concat(de({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),\"array\"===e.n(r)&&0===r.length&&i.push(new e.V(t.key,r,\"array must have at least one stop\")),i},default:function(e){return ze({key:e.key,value:e.value,valueSpec:i,style:e.style,styleSpec:e.styleSpec})}}});return \"identity\"===o&&l&&_.push(new e.V(t.key,t.value,'missing required property \"property\"')),\"identity\"===o||t.value.stops||_.push(new e.V(t.key,t.value,'missing required property \"stops\"')),\"exponential\"===o&&t.valueSpec.expression&&!e.s(t.valueSpec)&&_.push(new e.V(t.key,t.value,\"exponential functions not supported\")),t.styleSpec.$version>=8&&(c&&!e.q(t.valueSpec)?_.push(new e.V(t.key,t.value,\"property functions not supported\")):l&&!e.r(t.valueSpec)&&_.push(new e.V(t.key,t.value,\"zoom functions not supported\"))),\"categorical\"!==o&&!h||void 0!==t.value.property||_.push(new e.V(t.key,t.value,'\"property\" property is required')),_;function u(t){let o=[];const r=t.value,l=t.key;if(\"array\"!==e.n(r))return [new e.V(l,r,`array expected, ${e.n(r)} found`)];if(2!==r.length)return [new e.V(l,r,`array length 2 expected, length ${r.length} found`)];if(h){if(\"object\"!==e.n(r[0]))return [new e.V(l,r,`object expected, ${e.n(r[0])} found`)];if(void 0===r[0].zoom)return [new e.V(l,r,\"object stop key must have zoom\")];if(void 0===r[0].value)return [new e.V(l,r,\"object stop key must have value\")];const i=e.u(r[0].zoom);if(\"number\"!=typeof i)return [new e.V(l,r[0].zoom,\"stop zoom values must be numbers\")];if(n&&n>i)return [new e.V(l,r[0].zoom,\"stop zoom values must appear in ascending order\")];i!==n&&(n=i,a=void 0,s={}),o=o.concat(ue({key:`${l}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:pe,value:d}}));}else o=o.concat(d({key:`${l}[0]`,value:r[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},r));return e.t(e.v(r[1]))?o.concat([new e.V(`${l}[1]`,r[1],\"expressions are not allowed in function stops.\")]):o.concat(ze({key:`${l}[1]`,value:r[1],valueSpec:i,style:t.style,styleSpec:t.styleSpec}))}function d(t,n){const l=e.n(t.value),c=e.u(t.value),h=null!==t.value?t.value:n;if(r){if(l!==r)return [new e.V(t.key,h,`${l} stop domain type must match previous stop domain type ${r}`)]}else r=l;if(\"number\"!==l&&\"string\"!==l&&\"boolean\"!==l&&\"number\"!=typeof c&&\"string\"!=typeof c&&\"boolean\"!=typeof c)return [new e.V(t.key,h,\"stop domain value must be a number, string, or boolean\")];if(\"number\"!==l&&\"categorical\"!==o){let r=`number expected, ${l} found`;return e.q(i)&&void 0===o&&(r+='\\nIf you intended to use a categorical function, specify `\"type\": \"categorical\"`.'),[new e.V(t.key,h,r)]}return \"categorical\"!==o||\"number\"!==l||\"number\"==typeof c&&isFinite(c)&&Math.floor(c)===c?\"categorical\"!==o&&\"number\"===l&&\"number\"==typeof c&&\"number\"==typeof a&&void 0!==a&&cnew e.V(`${t.key}${i.key}`,t.value,i.message)));const o=i.value.expression||i.value._styleExpression.expression;if(\"property\"===t.expressionContext&&\"text-font\"===t.propertyKey&&!o.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(o))return [new e.V(t.key,t.value,'\"feature-state\" data expressions are not supported with layout properties.')];if(\"filter\"===t.expressionContext)return ge(o,t);if(t.expressionContext&&0===t.expressionContext.indexOf(\"cluster\")){if(!e.A(o,[\"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.B(o))return [new e.V(t.key,t.value,\"Feature data expressions are not supported with initial expression part of cluster properties.\")]}return []}function ge(t,i){const o=new Set([\"zoom\",\"feature-state\",\"pitch\",\"distance-from-center\"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)o.delete(e);if(0===o.size)return [];const r=[];return t instanceof e.D&&o.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(...ge(e,i));})),r)}function ve(t){const i=t.key,o=t.value,r=t.valueSpec,a=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.u(o))&&a.push(new e.V(i,o,`expected one of [${r.values.join(\", \")}], ${JSON.stringify(o)} found`)):-1===Object.keys(r.values).indexOf(e.u(o))&&a.push(new e.V(i,o,`expected one of [${Object.keys(r.values).join(\", \")}], ${JSON.stringify(o)} found`)),a}function xe(t){return e.G(e.v(t.value))?me(e.o({},t,{expressionContext:\"filter\",valueSpec:t.styleSpec[`filter_${t.layerType||\"fill\"}`]})):ye(t)}function ye(t){const i=t.value,o=t.key;if(\"array\"!==e.n(i))return [new e.V(o,i,`array expected, ${e.n(i)} found`)];const r=t.styleSpec;let a,n=[];if(i.length<1)return [new e.V(o,i,\"filter array must have at least 1 element\")];switch(n=n.concat(ve({key:`${o}[0]`,value:i[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),e.u(i[0])){case\"<\":case\"<=\":case\">\":case\">=\":i.length>=2&&\"$type\"===e.u(i[1])&&n.push(new e.V(o,i,`\"$type\" cannot be use with operator \"${i[0]}\"`));case\"==\":case\"!=\":3!==i.length&&n.push(new e.V(o,i,`filter array for operator \"${i[0]}\" must have 3 elements`));case\"in\":case\"!in\":i.length>=2&&(a=e.n(i[1]),\"string\"!==a&&n.push(new e.V(`${o}[1]`,i[1],`string expected, ${a} found`)));for(let s=2;s{t in o&&i.push(new e.V(r,o[t],`\"${t}\" is prohibited for ref layers`));})),a.layers.forEach((i=>{e.u(i.id)===l&&(t=i);})),t?t.ref?i.push(new e.V(r,o.ref,\"ref cannot reference another ref layer\")):s=e.u(t.type):\"string\"==typeof l&&i.push(new e.V(r,o.ref,`ref layer \"${l}\" not found`));}else if(\"background\"!==s&&\"sky\"!==s&&\"slot\"!==s)if(o.source){const t=a.sources&&a.sources[o.source],n=t&&e.u(t.type);t?\"vector\"===n&&\"raster\"===s?i.push(new e.V(r,o.source,`layer \"${o.id}\" requires a raster source`)):\"raster\"===n&&\"raster\"!==s?i.push(new e.V(r,o.source,`layer \"${o.id}\" requires a vector source`)):\"vector\"!==n||o[\"source-layer\"]?\"raster-dem\"===n&&\"hillshade\"!==s?i.push(new e.V(r,o.source,\"raster-dem source can only be used with layer type 'hillshade'.\")):\"raster-array\"!==n||[\"raster\",\"raster-particle\"].includes(s)?\"line\"!==s||!o.paint||!o.paint[\"line-gradient\"]&&!o.paint[\"line-trim-offset\"]||\"geojson\"===n&&t.lineMetrics?\"raster-particle\"===s&&\"raster-array\"!==n&&i.push(new e.V(r,o.source,`layer \"${o.id}\" requires a 'raster-array' source.`)):i.push(new e.V(r,o,`layer \"${o.id}\" specifies a line-gradient, which requires a GeoJSON source with \\`lineMetrics\\` enabled.`)):i.push(new e.V(r,o.source,\"raster-array source can only be used with layer type 'raster'.\")):i.push(new e.V(r,o,`layer \"${o.id}\" must specify a \"source-layer\"`)):i.push(new e.V(r,o.source,`source \"${o.source}\" not found`));}else i.push(new e.V(r,o,'missing required property \"source\"'));return i=i.concat(ue({key:r,value:o,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{\"*\":()=>[],type:()=>ze({key:`${r}.type`,value:o.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,object:o,objectKey:\"type\"}),filter:t=>xe(e.o({layerType:s},t)),layout:t=>ue({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{\"*\":t=>Te(e.o({layerType:s},t))}}),paint:t=>ue({layer:o,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{\"*\":t=>we(e.o({layerType:s,layer:o},t))}})}})),i}function Ce(t){const i=t.value,o=t.key,r=e.n(i);return \"string\"!==r?[new e.V(o,i,`string expected, ${r} found`)]:[]}const Se={promoteId:function({key:t,value:i}){if(\"string\"===e.n(i))return Ce({key:t,value:i});{const e=[];for(const o in i)e.push(...Ce({key:`${t}.${o}`,value:i[o]}));return e}}};function Ie(t){const i=t.value,o=t.key,r=t.styleSpec,a=t.style;if(!i.type)return [new e.V(o,i,'\"type\" is required')];const n=e.u(i.type);let s=[];switch([\"vector\",\"raster\",\"raster-dem\",\"raster-array\"].includes(n)&&(i.url||i.tiles||s.push(new e.m(o,i,'Either \"url\" or \"tiles\" is required.'))),n){case\"vector\":case\"raster\":case\"raster-dem\":case\"raster-array\":return s=s.concat(ue({key:o,value:i,valueSpec:r[`source_${n.replace(\"-\",\"_\")}`],style:t.style,styleSpec:r,objectElementValidators:Se})),s;case\"geojson\":if(s=ue({key:o,value:i,valueSpec:r.source_geojson,style:a,styleSpec:r,objectElementValidators:Se}),i.cluster)for(const e in i.clusterProperties){const[t,r]=i.clusterProperties[e],a=\"string\"==typeof t?[t,[\"accumulated\"],[\"get\",e]]:t;s.push(...me({key:`${o}.${e}.map`,value:r,expressionContext:\"cluster-map\"})),s.push(...me({key:`${o}.${e}.reduce`,value:a,expressionContext:\"cluster-reduce\"}));}return s;case\"video\":return ue({key:o,value:i,valueSpec:r.source_video,style:a,styleSpec:r});case\"image\":return ue({key:o,value:i,valueSpec:r.source_image,style:a,styleSpec:r});case\"canvas\":return [new e.V(o,null,\"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.\",\"source.canvas\")];default:return ve({key:`${o}.type`,value:i.type,valueSpec:{values:Le(r)},style:a,styleSpec:r})}}function Le(e){return e.source.reduce(((t,i)=>{const o=e[i];return \"enum\"===o.type.type&&(t=t.concat(Object.keys(o.type.values))),t}),[])}function Pe(t){const i=t.value,o=t.styleSpec,r=o.light,a=t.style;let n=[];const s=e.n(i);if(void 0===i)return n;if(\"object\"!==s)return n=n.concat([new e.V(\"light\",i,`object expected, ${s} found`)]),n;for(const t in i){const s=t.match(/^(.*)-transition$/);n=n.concat(s&&r[s[1]]&&r[s[1]].transition?ze({key:t,value:i[t],valueSpec:o.transition,style:a,styleSpec:o}):r[t]?ze({key:t,value:i[t],valueSpec:r[t],style:a,styleSpec:o}):[new e.V(t,i[t],`unknown property \"${t}\"`)]);}return n}function Ae(t){const i=t.value;let o=[];if(!i)return o;const r=e.n(i);if(\"object\"!==r)return o=o.concat([new e.V(\"light-3d\",i,`object expected, ${r} found`)]),o;const a=t.styleSpec,n=a[\"light-3d\"],s=t.key,l=t.style,c=t.style.lights;for(const t of [\"type\",\"id\"])if(!(t in i))return o=o.concat([new e.V(\"light-3d\",i,`missing property ${t} on light`)]),o;if(i.type&&c)for(let r=0;r[],array:de,boolean:function(t){const i=t.value,o=t.key,r=e.n(i);return \"boolean\"!==r?[new e.V(o,i,`boolean expected, ${r} found`)]:[]},number:pe,color:function(t){const i=t.key,o=t.value,r=e.n(o);return \"string\"!==r?[new e.V(i,o,`color expected, ${r} found`)]:null===e.F(o)?[new e.V(i,o,`color expected, \"${o}\" found`)]:[]},enum:ve,filter:xe,function:fe,layer:Ee,object:ue,source:Ie,model:e.K,light:Pe,\"light-3d\":Ae,terrain:Re,fog:De,string:Ce,formatted:function(e){return 0===Ce(e).length?[]:me(e)},resolvedImage:function(e){return 0===Ce(e).length?[]:me(e)},projection:function(t){const i=t.value,o=t.styleSpec,r=o.projection,a=t.style;let n=[];const s=e.n(i);if(\"object\"===s)for(const e in i)n=n.concat(ze({key:e,value:i[e],valueSpec:r[e],style:a,styleSpec:o}));else \"string\"!==s&&(n=n.concat([new e.V(\"projection\",i,`object or string expected, ${s} found`)]));return n},import:function(t){const{value:i,styleSpec:o}=t,{data:r,...a}=i;Object.defineProperty(a,\"__line__\",{value:i.__line__,enumerable:!1});let n=ue(e.o({},t,{value:a,valueSpec:o.import}));return \"\"===e.u(a.id)&&n.push(new e.V(`${t.key}.id`,a,\"import id can't be an empty string\")),r&&(n=n.concat(Fe(r,o,{key:`${t.key}.data`}))),n}};function ze(t,i=!1){const o=t.value,r=t.valueSpec,a=t.styleSpec;if(r.expression&&e.H(e.u(o)))return fe(t);if(r.expression&&e.t(e.v(o)))return me(t);if(r.type&&Me[r.type]){const o=Me[r.type](t);return !0===i&&o.length>0&&\"array\"===e.n(t.value)?me(t):o}return ue(e.o({},t,{valueSpec:r.type?a[r.type]:r}))}function Oe(t){const i=t.value,o=t.key,r=Ce(t);return r.length||(-1===i.indexOf(\"{fontstack}\")&&r.push(new e.V(o,i,'\"glyphs\" url must include a \"{fontstack}\" token')),-1===i.indexOf(\"{range}\")&&r.push(new e.V(o,i,'\"glyphs\" url must include a \"{range}\" token'))),r}function Fe(t,i=e.L,o={}){return ze({key:o.key||\"\",value:t,valueSpec:i.$root,styleSpec:i,style:t,objectElementValidators:{glyphs:Oe,\"*\":()=>[]}})}function Be(t,i=e.L){return $e(Fe(t,i))}const ke=e=>$e(Ie(e)),Ne=e=>$e(Pe(e)),Ue=e=>$e(Ae(e)),Ge=e=>$e(Re(e)),je=e=>$e(De(e)),Ve=e=>$e(Ee(e)),We=e=>$e(xe(e)),Ze=e=>$e(we(e)),qe=e=>$e(Te(e)),He=t=>$e(e.K(t));function $e(e){return e.slice().sort(((e,t)=>e.line&&t.line?e.line-t.line:0))}function Xe(t,i){let o=!1;if(i&&i.length)for(const r of i)r instanceof e.m?e.w(r.message):(t.fire(new e.d(new Error(r.message))),o=!0);return o}const Ye=new e.N({anchor:new e.O(e.L.light.anchor),position:new e.Q(e.L.light.position),color:new e.O(e.L.light.color),intensity:new e.O(e.L.light.intensity)});class Ke extends e.E{constructor(t,i=\"flat\"){super(),this._transitionable=new e.U(Ye),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned();}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(Ne,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,o){return (!o||!1!==o.validate)&&Xe(this,t.call(Be,e.W({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.L})))}}const Qe=new e.N({source:new e.O(e.L.terrain.source),exaggeration:new e.O(e.L.terrain.exaggeration)});let Je=class extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._transitionable=new e.U(Qe,o,r),this._transitionable.setTransitionOrValue(t,r),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i;}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.X(t)).get(\"exaggeration\")}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.Z}};const et=45,tt=65,it=.05;function ot(t,i,o,r){const a=e.$(et,tt,o),[n,s]=rt(t,r);let l=1-Math.min(1,Math.exp((i-n)/(s-n)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*a*t.alpha}function rt(e,t){const i=.5/Math.tan(.5*t);return [e.range[0]+i,e.range[1]+i]}function at(t,i,o,r,a){const n=e._.transformMat4([],[i,o,r],a.mercatorFogMatrix);return ot(t,e._.length(n),a.pitch,a._fov)}function nt(t,i,o,r,a,n,s){const l=[[o,r,0],[a,r,0],[a,n,0],[o,n,0]];let c=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(const t of l){const o=e._.transformMat4([],t,i),r=e._.length(o);c=Math.min(c,r),h=Math.max(h,r);}return [ot(t,c,s.pitch,s._fov),ot(t,h,s.pitch,s._fov)]}const st=new e.N({range:new e.O(e.L.fog.range),color:new e.O(e.L.fog.color),\"high-color\":new e.O(e.L.fog[\"high-color\"]),\"space-color\":new e.O(e.L.fog[\"space-color\"]),\"horizon-blend\":new e.O(e.L.fog[\"horizon-blend\"]),\"star-intensity\":new e.O(e.L.fog[\"star-intensity\"]),\"vertical-range\":new e.O(e.L.fog[\"vertical-range\"])});class lt extends e.E{constructor(t,i,o,r){super(),this._transitionable=new e.U(st,o,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.a0(st),this.scope=o;}get state(){const t=this._transform,i=\"globe\"===t.projection.name,o=e.a1(t.zoom),r=this.properties.get(\"range\"),a=[.5,3];return {range:i?[e.a2(a[0],r[0],o),e.a2(a[1],r[1],o)]:r,horizonBlend:this.properties.get(\"horizon-blend\"),alpha:this.properties.get(\"color\").a}}get(){return this._transitionable.serialize()}set(t,i,o={}){if(this._validate(je,t,o))return;const r=e.W({},t);for(const t of Object.keys(e.L.fog))void 0===r[t]&&(r[t]=e.L.fog[t].default);this._options=r,this._transitionable.setTransitionOrValue(this._options,i);}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.$(et,tt,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,o){const r=e.Y.fromLngLat(i),a=o.elevation?o.elevation.getAtPointOrZero(r):0;return at(t,r.x,r.y,a,o)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return [1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return nt(this.state,i,0,0,e.a3,e.a3,this._transform)}getOpacityForBounds(e,t,i,o,r){return this._transform.projection.supportsFog?nt(this.state,e,t,i,o,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?rt(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return !1;const i=[4,5,6,7];for(const o of i){const i=t.points[o];let r;if(i[2]>=0)r=i;else {const a=t.points[o-4];r=e.a4(a,i,a[2]/(a[2]-i[2]));}if(at(this.state,r[0],r[1],0,this._transform)>=it)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,o){return (!o||!1!==o.validate)&&Xe(this,t.call(Be,e.W({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.L})))}}class ct extends e.E{constructor(t,i,o,r){super(),this.scope=o,this._options=t,this.properties=new e.a0(i),this._transitionable=new e.U(i,o,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\")}}const ht=new e.N({color:new e.O(e.L.properties_light_ambient.color),intensity:new e.O(e.L.properties_light_ambient.intensity)}),_t=new e.N({direction:new e.a5(e.L.properties_light_directional.direction),color:new e.O(e.L.properties_light_directional.color),intensity:new e.O(e.L.properties_light_directional.intensity),\"cast-shadows\":new e.O(e.L.properties_light_directional[\"cast-shadows\"]),\"shadow-intensity\":new e.O(e.L.properties_light_directional[\"shadow-intensity\"])});var ut=\"\\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\",dt=\"\\nout vec4 glFragColor;highp float unpack_depth(highp vec4 rgba_depth)\\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\\n#ifdef INDICATOR_CUTOUT\\nuniform vec2 u_indicator_cutout_centers;uniform vec4 u_indicator_cutout_params;\\n#endif\\nvec4 applyCutout(vec4 color) {\\n#ifdef INDICATOR_CUTOUT\\nfloat holeMinOpacity=u_indicator_cutout_params.x;float holeRadius=max(u_indicator_cutout_params.y,0.0);float holeAspectRatio=u_indicator_cutout_params.z;float fadeStart=u_indicator_cutout_params.w;float distA=distance(vec2(gl_FragCoord.x,gl_FragCoord.y*holeAspectRatio),vec2(u_indicator_cutout_centers[0],u_indicator_cutout_centers[1]*holeAspectRatio));return color*min(smoothstep(fadeStart,holeRadius,distA)+holeMinOpacity,1.0);\\n#else\\nreturn color;\\n#endif\\n}\\n#ifdef DEBUG_WIREFRAME\\n#define HANDLE_WIREFRAME_DEBUG \\\\\\nglFragColor=vec4(0.7,0.0,0.0,0.7); \\\\\\ngl_FragDepth=gl_FragCoord.z-0.0001;\\n#else\\n#define HANDLE_WIREFRAME_DEBUG\\n#endif\\n#ifdef RENDER_CUTOFF\\nuniform highp vec4 u_cutoff_params;in float v_cutoff_opacity;\\n#endif\\nvec4 textureLodCustom(sampler2D image,vec2 pos,vec2 lod_coord) {vec2 size=vec2(textureSize(image,0));vec2 dx=dFdx(lod_coord.xy*size);vec2 dy=dFdy(lod_coord.xy*size);float delta_max_sqr=max(dot(dx,dx),dot(dy,dy));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);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}\",pt=\"\\n#define EXTENT 8192.0\\n#define RAD_TO_DEG 180.0/PI\\n#define DEG_TO_RAD PI/180.0\\n#define GLOBE_RADIUS EXTENT/PI/2.0\\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\\n#ifndef PROJECTED_POS_ON_VIEWPORT\\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\\n#else\\nreturn vec3(0.0);\\n#endif\\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\\n#endif\\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(PI/4.0+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}\\n#ifdef RENDER_CUTOFF\\nuniform vec4 u_cutoff_params;out float v_cutoff_opacity;\\n#endif\\nconst vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\",ft=\"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;}\",mt=\"\\n#define ELEVATION_SCALE 7.0\\n#define ELEVATION_OFFSET 450.0\\n#ifdef PROJECTION_GLOBE_VIEW\\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\\n#else\\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\\n#endif\\n#ifdef TERRAIN\\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform highp sampler2D u_depth;uniform vec2 u_depth_size_inv;uniform vec2 u_depth_range_unpack;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\\n#ifdef TERRAIN_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(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(vec4 frag) {vec3 coord=frag.xyz/frag.w;\\n#ifdef TERRAIN_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 > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;\\n#ifdef TERRAIN_DEPTH_D24\\nvec4 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\\nvec4 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 dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {float tl=texture(u_dem,pos).r;float tr=texture(u_dem,pos+vec2(off.x,0.0)).r;float bl=texture(u_dem,pos+vec2(0.0,off.y)).r;float br=texture(u_dem,pos+off).r;return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\\n#else\\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\\n#endif\",gt=\"#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\",vt=\"highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}\\n#ifdef FOG\\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump vec2 u_fog_vertical_limit;uniform mediump float u_fog_temporal_offset;in vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos,float opacity_limit) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,min(opacity,opacity_limit));}vec3 fog_apply(vec3 color,vec3 pos) {return fog_apply(color,pos,1.0);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec4 fog_apply_premultiplied(vec4 color,vec3 pos,float heightMeters) {float verticalProgress=(u_fog_vertical_limit.x > 0.0 || u_fog_vertical_limit.y > 0.0) ? smoothstep(u_fog_vertical_limit.x,u_fog_vertical_limit.y,heightMeters) : 0.0;float opacityLimit=1.0-smoothstep(0.9,1.0,fog_opacity(pos));return mix(fog_apply_premultiplied(color,pos),color,min(verticalProgress,opacityLimit));}vec3 fog_dither(vec3 color) {\\n#ifdef FOG_DITHERING\\nvec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);\\n#else\\nreturn color;\\n#endif\\n}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\\n#endif\",xt=\"#ifdef RASTER_ARRAY\\nuniform 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\",yt=\"#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;}\",bt=\"#ifdef RENDER_SHADOWS\\nuniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_normal_offset;vec3 shadow_normal_offset(vec3 normal) {float tileInMeters=u_shadow_normal_offset[0];vec3 n=vec3(-normal.xy,tileInMeters*normal.z);float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return n*dotScale;}vec3 shadow_normal_offset_model(vec3 normal) {float dotScale=min(1.0-dot(normal,u_shadow_direction),1.0)*0.5+0.5;return normal*dotScale;}float shadow_normal_offset_multiplier0() {return u_shadow_normal_offset[1];}float shadow_normal_offset_multiplier1() {return u_shadow_normal_offset[2];}\\n#endif//RENDER_SHADOWS\",wt=\"#ifdef RENDER_SHADOWS\\n#ifdef DEPTH_TEXTURE\\nuniform highp sampler2D u_shadowmap_0;uniform highp sampler2D u_shadowmap_1;\\n#else\\nuniform sampler2D u_shadowmap_0;uniform sampler2D u_shadowmap_1;\\n#endif\\nuniform float u_shadow_intensity;uniform float u_shadow_map_resolution;uniform float u_shadow_texel_size;uniform highp vec3 u_shadow_normal_offset;uniform vec2 u_fade_range;uniform mediump vec3 u_shadow_direction;uniform highp vec3 u_shadow_bias;highp float shadow_sample_1(highp vec2 uv,highp float compare) {highp float shadow_depth;\\n#ifdef DEPTH_TEXTURE\\nshadow_depth=texture(u_shadowmap_1,uv).r;\\n#else\\nshadow_depth=unpack_depth(texture(u_shadowmap_1,uv))*0.5+0.5;\\n#endif\\nreturn step(shadow_depth,compare);}highp float shadow_sample_0(highp vec2 uv,highp float compare) {highp float shadow_depth;\\n#ifdef DEPTH_TEXTURE\\nshadow_depth=texture(u_shadowmap_0,uv).r;\\n#else\\nshadow_depth=unpack_depth(texture(u_shadowmap_0,uv))*0.5+0.5;\\n#endif\\nreturn step(shadow_depth,compare);}float shadow_occlusion_1(highp vec4 pos,highp float bias) {highp vec2 uv=pos.xy;return shadow_sample_1(uv,pos.z-bias);}float shadow_occlusion_0(highp vec4 pos,highp float bias) {highp float compare0=pos.z-bias;\\n#ifdef NATIVE\\nhighp vec2 uv=pos.xy;highp vec4 samples=textureGather(u_shadowmap_0,uv,0);lowp vec4 stepSamples=step(samples,vec4(compare0));\\n#else\\nhighp vec2 uv00=pos.xy-vec2(0.5*u_shadow_texel_size);highp vec2 uv10=uv00+vec2(u_shadow_texel_size,0.0);highp vec2 uv01=uv00+vec2(0.0,u_shadow_texel_size);highp vec2 uv11=uv01+vec2(u_shadow_texel_size,0.0);lowp vec4 stepSamples=vec4(\\nshadow_sample_0(uv01,compare0),shadow_sample_0(uv11,compare0),shadow_sample_0(uv10,compare0),shadow_sample_0(uv00,compare0)\\n);\\n#endif\\nvec2 f=fract(pos.xy*u_shadow_map_resolution-vec2(0.5));lowp vec2 lerpx=mix(stepSamples.wx,stepSamples.zy,f.xx);return mix(lerpx.x,lerpx.y,f.y);}float shadow_occlusion(highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth,highp float bias) {\\n#ifdef SHADOWS_SINGLE_CASCADE\\nlight_view_pos0.xyz=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);\\n#else\\nlight_view_pos0.xyz/=light_view_pos0.w;light_view_pos1.xyz/=light_view_pos1.w;vec4 uv=vec4(light_view_pos0.xy,light_view_pos1.xy);vec4 abs_bounds=abs(uv);if (abs_bounds.x < 1.0 && abs_bounds.y < 1.0) {light_view_pos0.xyz=light_view_pos0.xyz*0.5+0.5;return shadow_occlusion_0(light_view_pos0,bias);}if (abs_bounds.z >=1.0 || abs_bounds.w >=1.0) {return 0.0;}light_view_pos1.xyz=light_view_pos1.xyz*0.5+0.5;float occlusion1=shadow_occlusion_1(light_view_pos1,bias);return mix(occlusion1,0.0,smoothstep(u_fade_range.x,u_fade_range.y,view_depth));\\n#endif\\n}highp float calculate_shadow_bias(float NDotL) {\\n#ifdef NORMAL_OFFSET\\nreturn 0.5*u_shadow_bias.x;\\n#else\\nreturn 0.5*(u_shadow_bias.x+clamp(u_shadow_bias.y*tan(acos(NDotL)),0.0,u_shadow_bias.z));\\n#endif\\n}float shadowed_light_factor_normal(vec3 N,highp vec4 light_view_pos0,highp vec4 light_view_pos1,float view_depth) {float NDotL=dot(N,u_shadow_direction);float bias=calculate_shadow_bias(NDotL);float occlusion=shadow_occlusion(light_view_pos0,light_view_pos1,view_depth,bias);return mix(0.0,(1.0-(u_shadow_intensity*occlusion))*NDotL,step(0.0,NDotL));}float shadowed_light_factor_normal_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));}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 Tt=[];Pt(ut,Tt),Pt(pt,Tt),Pt(dt,Tt);const Et={\"_prelude_fog.vertex.glsl\":gt,\"_prelude_terrain.vertex.glsl\":mt,\"_prelude_shadow.vertex.glsl\":bt,\"_prelude_fog.fragment.glsl\":vt,\"_prelude_shadow.fragment.glsl\":wt,\"_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\":xt,\"_prelude_raster_particle.glsl\":yt},Ct={};At(\"\",mt),At(vt,gt),At(wt,bt),At(xt,\"\"),At(yt,\"\");const St=At(dt,pt),It=ut;var Lt={background:At('#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:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform float u_emissive_strength;uniform sampler2D u_image;in vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=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 float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\\n#ifdef FOG\\nv_fog_pos=fog_position(a_pos);\\n#endif\\n}'),circle:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nin vec3 v_data;in float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nuniform float u_emissive_strength;void main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\\n#endif\\nglFragColor=out_color*(v_visibility*opacity_t);\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\n}','#include \"_prelude_fog.vertex.glsl\"\\n#include \"_prelude_terrain.vertex.glsl\"\\n#define NUM_VISIBILITY_RINGS 2\\n#define INV_SQRT2 0.70710678\\n#define ELEVATION_BIAS 0.0001\\n#define NUM_SAMPLES_PER_RING 16\\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;in vec2 a_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\\n#endif\\nout vec3 v_data;out float v_visibility;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define mediump float radius\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define highp vec4 stroke_color\\n#pragma mapbox: define mediump float stroke_width\\n#pragma mapbox: define lowp float stroke_opacity\\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\\n#if defined(TERRAIN)\\nreturn elevation(pos)+ELEVATION_BIAS;\\n#else\\nreturn 0.0;\\n#endif\\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\\n#ifdef PITCH_WITH_MAP\\n#ifdef PROJECTION_GLOBE_VIEW\\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\\n#else\\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\\n#endif\\n#else\\nreturn projected_center+vec4(sample_offset,0,0);\\n#endif\\n}float get_sample_step() {\\n#ifdef PITCH_WITH_MAP\\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\\n#else\\nreturn PI/float(NUM_SAMPLES_PER_RING);\\n#endif\\n}void main(void) {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize mediump float radius\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize highp vec4 stroke_color\\n#pragma mapbox: initialize mediump float stroke_width\\n#pragma mapbox: initialize lowp float stroke_opacity\\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\\n#else \\nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\\n#endif\\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\\n#ifdef PITCH_WITH_MAP\\n#ifdef SCALE_WITH_MAP\\nview_scale=1.0;\\n#else\\nview_scale=projected_center.w/u_camera_to_center_distance;\\n#endif\\n#else\\n#ifdef SCALE_WITH_MAP\\nview_scale=u_camera_to_center_distance;\\n#else\\nview_scale=projected_center.w;\\n#endif\\n#endif\\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\\n#ifdef TERRAIN\\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\\n#ifdef PITCH_WITH_MAP\\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\\n#else\\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\\n#endif\\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\\n#else\\nvisibility=1.0;\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nvisibility=1.0;\\n#endif\\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\\n#ifdef FOG\\nv_fog_pos=fog_position(world_center.xyz);\\n#endif\\n}'),clippingMask:At(\"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:At('#include \"_prelude_fog.fragment.glsl\"\\nuniform highp float u_intensity;in vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main() {\\n#pragma mapbox: initialize highp float weight\\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);glFragColor=vec4(val,1.0,1.0,1.0);\\n#ifdef FOG\\nif (u_is_globe==0) {glFragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\\n#endif\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_terrain.vertex.glsl\"\\n#include \"_prelude_fog.vertex.glsl\"\\nuniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;in vec2 a_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\\n#endif\\nout vec2 v_extrude;\\n#pragma mapbox: define highp float weight\\n#pragma mapbox: define mediump float radius\\nconst highp float ZERO=1.0/255.0/16.0;\\n#define GAUSS_COEF 0.3989422804014327\\nvoid main(void) {\\n#pragma mapbox: initialize highp float weight\\n#pragma mapbox: initialize mediump float radius\\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\\n#else\\npos=vec3(tilePos+extrude,elevation(tilePos));\\n#endif\\ngl_Position=u_matrix*vec4(pos,1);\\n#ifdef FOG\\nv_fog_pos=fog_position(pos);\\n#endif\\n}'),heatmapTexture:At(\"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:At(\"in float v_placed;in float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);glFragColor =mix(red,blue,step(0.5,v_placed))*0.5;glFragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}\",'#include \"_prelude_terrain.vertex.glsl\"\\nin vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 a_placed;in vec2 a_shift;in float a_size_scale;in vec2 a_padding;in float a_z_offset;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;out float v_placed;out float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*(a_z_offset+elevation(a_anchor_pos)),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:At(\"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:At(\"uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);glFragColor=mix(u_color,overlay_color,overlay_color.a);}\",'#include \"_prelude_terrain.vertex.glsl\"\\nin vec2 a_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_pos_3;\\n#endif\\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\\n#ifdef PROJECTION_GLOBE_VIEW\\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\\n#else\\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\\n#endif\\n}'),fill:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nuniform float u_emissive_strength;void main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\nvec4 out_color=color;\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\nglFragColor=out_color*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\nin vec2 a_pos;uniform mat4 u_matrix;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);\\n#ifdef FOG\\nv_fog_pos=fog_position(a_pos);\\n#endif\\n}'),fillOutline:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nin highp vec2 v_pos;uniform float u_emissive_strength;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\nglFragColor=out_color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\nin vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;out highp vec2 v_pos;\\n#pragma mapbox: define highp vec4 outline_color\\n#pragma mapbox: define lowp float opacity\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 outline_color\\n#pragma mapbox: initialize lowp float opacity\\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\\n#ifdef FOG\\nv_fog_pos=fog_position(a_pos);\\n#endif\\n}'),fillOutlinePattern:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_emissive_strength;in highp vec2 v_pos;in highp vec2 v_pos_world;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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 LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\nglFragColor=out_color*(alpha*opacity);\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\nuniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out 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#pragma mapbox: define lowp float pixel_ratio\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern\\n#pragma mapbox: initialize lowp float pixel_ratio\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\\n#ifdef FOG\\nv_fog_pos=fog_position(a_pos);\\n#endif\\n}'),fillPattern:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform vec2 u_texsize;uniform sampler2D u_image;in vec2 v_pos;uniform float u_emissive_strength;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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 LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\nglFragColor=out_color*opacity;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp vec4 pattern\\n#pragma mapbox: define lowp float pixel_ratio\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump vec4 pattern\\n#pragma mapbox: initialize lowp float pixel_ratio\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\\n#ifdef FOG\\nv_fog_pos=fog_position(a_pos);\\n#endif\\n}'),fillExtrusion:At('#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\\nuniform float u_emissive_strength;in float v_height;void main() {\\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\\nvec3 normal=normalize(v_normal);\\n#endif\\nfloat z;vec4 color=v_color;\\n#ifdef ZERO_ROOF_RADIUS\\nz=float(normal.z > 0.00001);\\n#ifdef LIGHTING_3D_MODE\\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\\n#else\\ncolor=mix(v_color,v_roof_color,z);\\n#endif\\n#endif\\nfloat h=max(0.0,v_height);float ao_shade=1.0;\\n#ifdef FAUX_AO\\nfloat intensity=u_ao[0];float h_floors=h/(u_ao[1]*u_vertical_scale);float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);ao_shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\\n#ifdef ZERO_ROOF_RADIUS\\nconcave*=(1.0-z);\\n#endif\\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);ao_shade*=mix(1.0,x_shade*x_shade*x_shade,concave);\\n#ifdef LIGHTING_3D_MODE\\n#ifdef FLOOD_LIGHT\\ncolor.rgb*=mix(ao_shade,1.0,v_has_floodlight);\\n#else\\ncolor.rgb*=ao_shade;\\n#endif\\n#else\\ncolor.rgb*=ao_shade;\\n#endif\\n#endif\\n#ifdef LIGHTING_3D_MODE\\nfloat flood_radiance=0.0;\\n#ifdef FLOOD_LIGHT\\nflood_radiance=(1.0-min(h/v_flood_radius,1.0))*u_flood_light_intensity*v_has_floodlight;\\n#endif\\n#ifdef RENDER_SHADOWS\\n#ifdef FLOOD_LIGHT\\nfloat ndotl_unclamped=dot(normal,u_shadow_direction);float ndotl=max(0.0,ndotl_unclamped);float occlusion=ndotl_unclamped < 0.0 ? 1.0 : shadow_occlusion(ndotl,v_pos_light_view_0,v_pos_light_view_1,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,u_emissive_strength);color*=u_opacity;\\n#endif\\n#ifdef FOG\\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos,h));\\n#endif\\n#ifdef INDICATOR_CUTOUT\\ncolor=applyCutout(color);\\n#endif\\nglFragColor=color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\n#include \"_prelude_terrain.vertex.glsl\"\\n#include \"_prelude_shadow.vertex.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\\n#endif\\nuniform highp float u_vertical_scale;out vec4 v_color;out vec4 v_flat;\\n#ifdef RENDER_SHADOWS\\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;out highp vec4 v_pos_light_view_0;out highp vec4 v_pos_light_view_1;\\n#endif\\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\\nout vec4 v_roof_color;\\n#endif\\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\\nout highp vec3 v_normal;\\n#endif\\n#ifdef FAUX_AO\\nuniform lowp vec2 u_ao;out vec2 v_ao;\\n#endif\\n#if defined(LIGHTING_3D_MODE) && defined(FLOOD_LIGHT)\\nout float v_flood_radius;out float v_has_floodlight;\\n#endif\\nout float v_height;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define highp float flood_light_wall_radius\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize highp float flood_light_wall_radius\\nbase*=u_vertical_scale;height*=u_vertical_scale;vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS) || defined(LIGHTING_3D_MODE)\\nv_normal=normal;\\n#endif\\nbase=max(0.0,base);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 flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\\n#else\\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\\n#endif\\nfloat 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);cutoff=cutoff_opacity(u_cutoff_params,ground.z);if (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));gl_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);v_flat=vec4(linearProduct(color.rgb,vec3(calculate_NdotL(normal))),1.0);\\n#else\\nv_color=vec4(0.0,0.0,0.0,1.0);v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\\n#endif\\n#if defined(ZERO_ROOF_RADIUS) && !defined(LIGHTING_3D_MODE)\\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color=vec4(0.0,0.0,0.0,1.0);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\\n#endif\\n#ifdef FOG\\nv_fog_pos=fog_position(pos);\\n#endif\\n}'),fillExtrusionDepth:At(\"in highp float v_depth;void main() {\\n#ifndef DEPTH_TEXTURE\\nglFragColor=pack_depth(v_depth);\\n#endif\\n}\",'#include \"_prelude_terrain.vertex.glsl\"\\nuniform mat4 u_matrix;uniform float u_edge_radius;uniform float u_vertical_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\nout highp float v_depth;void main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\nbase*=u_vertical_scale;height*=u_vertical_scale;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\\n#if defined(HAS_CENTROID) || defined(TERRAIN)\\ncentroid_pos=a_centroid_pos;\\n#endif\\nvec3 pos;\\n#ifdef TERRAIN\\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base);pos=vec3(pos_nx.xy,h);\\n#else\\npos=vec3(pos_nx.xy,t > 0.0 ? height : base);\\n#endif\\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform vec2 u_texsize;uniform sampler2D u_image;\\n#ifdef FAUX_AO\\nuniform lowp vec2 u_ao;in vec3 v_ao;\\n#endif\\n#ifdef LIGHTING_3D_MODE\\nin vec3 v_normal;\\n#endif\\nin vec2 v_pos;in vec4 v_lighting;uniform lowp float u_opacity;\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define mediump vec4 pattern\\n#pragma mapbox: define highp float pixel_ratio\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize mediump vec4 pattern\\n#pragma mapbox: initialize highp float pixel_ratio\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);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 LIGHTING_3D_MODE\\nout_color=apply_lighting(out_color,normalize(v_normal))*u_opacity;\\n#else\\nout_color=out_color*v_lighting;\\n#endif\\n#ifdef FAUX_AO\\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\n#ifdef INDICATOR_CUTOUT\\nout_color=applyCutout(out_color);\\n#endif\\nglFragColor=out_color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\n#include \"_prelude_terrain.vertex.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_pos_3;in vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\\n#endif\\nout vec2 v_pos;out vec4 v_lighting;\\n#ifdef FAUX_AO\\nuniform lowp vec2 u_ao;out vec3 v_ao;\\n#endif\\n#ifdef LIGHTING_3D_MODE\\nout vec3 v_normal;\\n#endif\\n#pragma mapbox: define highp float base\\n#pragma mapbox: define highp float height\\n#pragma mapbox: define mediump vec4 pattern\\n#pragma mapbox: define highp float pixel_ratio\\nvoid main() {\\n#pragma mapbox: initialize highp float base\\n#pragma mapbox: initialize highp float height\\n#pragma mapbox: initialize mediump vec4 pattern\\n#pragma mapbox: initialize highp float pixel_ratio\\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\\n#if defined(HAS_CENTROID) || defined(TERRAIN)\\ncentroid_pos=a_centroid_pos;\\n#endif\\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\\n#ifdef TERRAIN\\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\\n#else\\np=vec3(pos_nx.xy,z);\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\\n#endif\\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\\n? pos_nx.xy\\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\\n#ifdef LIGHTING_3D_MODE\\nNdotL=calculate_NdotL(normal);\\n#else\\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\\n#endif\\nif (normal.y !=0.0) {float r=0.84;\\n#ifndef LIGHTING_3D_MODE\\nr=mix(0.7,0.98,1.0-u_lightintensity);\\n#endif\\nNdotL*=(\\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\\n#ifdef FAUX_AO\\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\\n#ifdef TERRAIN\\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\\n#endif\\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\\n#ifdef PROJECTION_GLOBE_VIEW\\ntop_height+=u_height_lift;\\n#endif\\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\\n#endif\\n#ifdef LIGHTING_3D_MODE\\nv_normal=normal;\\n#else\\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\\n#endif \\n#ifdef FOG\\nv_fog_pos=fog_position(p);\\n#endif\\n}'),groundShadow:At('#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(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)).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:At(\"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 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(1.0,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:At(\"precision highp float;uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;float getElevation(vec2 coord) {return texture(u_image,coord).r/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\\n)/pow(2.0,exaggeration+(19.2562-u_zoom));glFragColor=clamp(vec4(\\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);}\",\"uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}\"),hillshade:At('#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:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform lowp 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 vec4 v_uv;\\n#ifdef RENDER_LINE_DASH\\nuniform sampler2D u_dash_image;in vec2 v_tex;\\n#endif\\n#ifdef RENDER_LINE_GRADIENT\\nuniform sampler2D u_gradient_image;\\n#endif\\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float floorwidth\\n#pragma mapbox: define lowp vec4 dash\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float border_width\\n#pragma mapbox: define lowp vec4 border_color\\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float floorwidth\\n#pragma mapbox: initialize lowp vec4 dash\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float border_width\\n#pragma mapbox: initialize lowp vec4 border_color\\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\\n#ifdef RENDER_LINE_DASH\\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\\n#endif\\nhighp vec4 out_color;\\n#ifdef RENDER_LINE_GRADIENT\\nout_color=texture(u_gradient_image,v_uv.xy);\\n#else\\nout_color=color;\\n#endif\\nfloat trim_alpha=1.0;\\n#ifdef RENDER_LINE_TRIM_OFFSET\\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {float start_transition=max(0.0,min(1.0,(line_progress-trim_start)/clamp(u_trim_fade_range[0],1e-4,1.0)));float end_transition=max(0.0,min(1.0,(trim_end-line_progress)/clamp(u_trim_fade_range[1],1e-4,1.0)));float transition_factor=min(start_transition,end_transition);out_color=mix(out_color,u_trim_color,transition_factor);trim_alpha=out_color.a;}\\n#endif\\nif (u_alpha_discard_threshold !=0.0) {if (alpha < u_alpha_discard_threshold) {discard;}}\\n#ifdef RENDER_LINE_BORDER\\nfloat edgeBlur=(border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {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.rgb=mix(border_color.rgb*border_color.a*trim_alpha,out_color.rgb,smoothAlpha);}}\\n#endif\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,u_emissive_strength);\\n#endif\\n#ifdef FOG\\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\\n#endif\\nout_color*=(alpha*opacity);\\n#ifdef INDICATOR_CUTOUT\\nout_color=applyCutout(out_color);\\n#endif\\nglFragColor=out_color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_fog.vertex.glsl\"\\n#include \"_prelude_terrain.vertex.glsl\"\\n#define EXTRUDE_SCALE 0.015873016\\nin vec2 a_pos_normal;in vec4 a_data;\\n#if defined(ELEVATED)\\nin float a_z_offset;\\n#endif\\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\\nin highp vec4 a_packed;\\n#endif\\n#ifdef RENDER_LINE_DASH\\nin float a_linesofar;\\n#endif\\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec4 v_uv;\\n#ifdef RENDER_LINE_DASH\\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\\n#endif\\n#ifdef RENDER_LINE_GRADIENT\\nuniform float u_image_height;\\n#endif\\n#pragma mapbox: define highp vec4 color\\n#pragma mapbox: define lowp float floorwidth\\n#pragma mapbox: define lowp vec4 dash\\n#pragma mapbox: define lowp float blur\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define mediump float gapwidth\\n#pragma mapbox: define lowp float offset\\n#pragma mapbox: define mediump float width\\n#pragma mapbox: define lowp float border_width\\n#pragma mapbox: define lowp vec4 border_color\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 color\\n#pragma mapbox: initialize lowp float floorwidth\\n#pragma mapbox: initialize lowp vec4 dash\\n#pragma mapbox: initialize lowp float blur\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize mediump float gapwidth\\n#pragma mapbox: initialize lowp float offset\\n#pragma mapbox: initialize mediump float width\\n#pragma mapbox: initialize lowp float border_width\\n#pragma mapbox: initialize lowp vec4 border_color\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\\n#if defined(ELEVATED)\\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);\\n#else\\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\\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=extrude_length_without_perspective/extrude_length_with_perspective;\\n#else\\nv_gamma_scale=1.0;\\n#endif\\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\\n#ifdef RENDER_LINE_GRADIENT\\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\\n#else\\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\\n#endif\\n#endif\\n#ifdef RENDER_LINE_DASH\\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\\n#endif\\nv_width2=vec2(outset,inset);\\n#ifdef FOG\\nv_fog_pos=fog_position(pos);\\n#endif\\n}'),linePattern:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform highp float u_device_pixel_ratio;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 sampler2D u_image;in 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 vec4 v_uv;\\n#endif\\n#ifdef LINE_JOIN_NONE\\nin vec2 v_pattern_data;\\n#endif\\n#pragma mapbox: define mediump vec4 pattern\\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#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;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=(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;float x=mod(pattern_x,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));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 RENDER_LINE_TRIM_OFFSET\\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {color=vec4(0,0,0,0);}}\\n#endif\\n#ifdef LINE_JOIN_NONE\\nfloat pattern_len=pattern_size/aspect;float segment_phase=pattern_len-mod(v_linesofar-v_pattern_data.x+pattern_len,pattern_len);float visible_start=segment_phase-step(pattern_len*0.5,segment_phase)*pattern_len;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_ground(color);\\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);\\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#define scale 0.015873016\\nin vec2 a_pos_normal;in vec4 a_data;\\n#if defined(ELEVATED)\\nin float a_z_offset;\\n#endif\\n#ifdef RENDER_LINE_TRIM_OFFSET\\nin highp vec4 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\\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;out 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 vec4 v_uv;\\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#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#pragma mapbox: initialize mediump float pixel_ratio\\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);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);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);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);\\n#if defined(ELEVATED)\\nvec2 offsetTile=offset2*u_pixels_to_tile_units;vec2 halfCellProgress=normal.yx*32.0;float ele0=elevation(pos);float ele_line=max(ele0,max(elevation(pos+halfCellProgress),elevation(pos-halfCellProgress)));float ele1=elevation(pos+offsetTile);float ele2=elevation(pos-offsetTile);float ele_max=max(ele_line,0.5*(ele1+ele2));float ele=ele_max-ele0+ele1+a_z_offset ;gl_Position=u_matrix*vec4(pos+offsetTile,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)*0.1*u_exaggeration);gl_Position.z-=(gl_Position.w*zbias);\\n#else\\ngl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\\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=extrude_length_without_perspective/extrude_length_with_perspective;\\n#else\\nv_gamma_scale=1.0;\\n#endif\\n#ifdef RENDER_LINE_TRIM_OFFSET\\nfloat a_uv_x=a_packed[0];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\\n#endif\\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\\n#ifdef LINE_JOIN_NONE\\nv_width=floorwidth+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}'),raster:At('#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 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:At('#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),0.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:At(\"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:At(\"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:At('#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);}\"),symbolIcon:At('#include \"_prelude_lighting.glsl\"\\nuniform sampler2D u_texture;\\n#ifdef ICON_TRANSITION\\nuniform float u_icon_transition;\\n#endif\\nin float v_fade_opacity;in vec2 v_tex_a;\\n#ifdef ICON_TRANSITION\\nin vec2 v_tex_b;\\n#endif\\n#ifdef COLOR_ADJUSTMENT\\nuniform mat4 u_color_adj_mat;\\n#endif\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float emissive_strength\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float emissive_strength\\nlowp float alpha=opacity*v_fade_opacity;vec4 out_color;\\n#ifdef ICON_TRANSITION\\nvec4 a=texture(u_texture,v_tex_a)*(1.0-u_icon_transition);vec4 b=texture(u_texture,v_tex_b)*u_icon_transition;out_color=(a+b);\\n#else\\nout_color=texture(u_texture,v_tex_a);\\n#endif\\n#ifdef COLOR_ADJUSTMENT\\nout_color=u_color_adj_mat*out_color;\\n#endif\\nout_color*=alpha;\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\\n#endif\\nglFragColor=out_color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_terrain.vertex.glsl\"\\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\\n#ifdef OCCLUSION_QUERIES\\nin float a_occlusion_query_opacity;\\n#endif\\n#ifdef Z_OFFSET\\nin float a_z_offset;\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\\n#endif\\n#ifdef ICON_TRANSITION\\nin vec2 a_texb;\\n#endif\\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\\n#ifdef PROJECTION_GLOBE_VIEW\\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\\n#endif\\nout vec2 v_tex_a;\\n#ifdef ICON_TRANSITION\\nout vec2 v_tex_b;\\n#endif\\nout float v_fade_opacity;\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float emissive_strength\\n#pragma mapbox: define lowp float occlusion_opacity\\nvoid main() {\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float emissive_strength\\n#pragma mapbox: initialize lowp float occlusion_opacity\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\\n#ifdef Z_OFFSET\\ne+=a_z_offset;\\n#endif\\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;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\\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\\n#else\\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\\n#endif\\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\\n#ifdef TERRAIN\\n#ifdef PITCH_WITH_MAP_TERRAIN\\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\\n#endif\\n#endif\\nfloat occlusion_fade=globe_occlusion_fade;\\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\\nocclusion_fade*=occlusionFade(projected_point);\\n#endif\\nfloat projection_transition_fade=1.0;\\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\\n#endif\\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float out_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;float alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\\n#else\\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\\n#endif\\nv_tex_a=a_tex/u_texsize;\\n#ifdef ICON_TRANSITION\\nv_tex_b=a_texb/u_texsize;\\n#endif\\nv_fade_opacity=out_fade_opacity;\\n#ifdef OCCLUSION_QUERIES\\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);v_fade_opacity*=occludedFadeMultiplier;\\n#endif\\n}'),symbolSDF:At('#include \"_prelude_lighting.glsl\"\\n#define SDF_PX 8.0\\nuniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;in float v_draw_halo;in vec2 v_data0;in vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\n#pragma mapbox: define lowp float emissive_strength\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\n#pragma mapbox: initialize lowp float emissive_strength\\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\\n#endif\\nglFragColor=out_color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_terrain.vertex.glsl\"\\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\\n#ifdef Z_OFFSET\\nin float a_z_offset;\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\\n#endif\\n#ifdef OCCLUSION_QUERIES\\nin float a_occlusion_query_opacity;\\n#endif\\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform bool u_is_halo;\\n#ifdef PROJECTION_GLOBE_VIEW\\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\\n#endif\\nout float v_draw_halo;out vec2 v_data0;out vec3 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\n#pragma mapbox: define lowp float emissive_strength\\n#pragma mapbox: define lowp float occlusion_opacity\\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\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\\n#ifdef Z_OFFSET\\ne+=a_z_offset;\\n#endif\\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;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 fontScale=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\\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\\n#else\\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\\n#endif\\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\\n#ifdef TERRAIN\\n#ifdef PITCH_WITH_MAP_TERRAIN\\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\\n#endif\\n#endif\\nfloat occlusion_fade=globe_occlusion_fade;\\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\\nocclusion_fade*=occlusionFade(projected_point);\\n#endif\\nfloat projection_transition_fade=1.0;\\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\\n#endif\\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\\n#ifdef OCCLUSION_QUERIES\\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\\n#endif\\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\\n#else\\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\\n#endif\\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,out_fade_opacity);}'),symbolTextAndIcon:At('#include \"_prelude_lighting.glsl\"\\n#define SDF_PX 8.0\\n#define SDF 1.0\\n#define ICON 0.0\\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_halo;in float v_draw_halo;in vec4 v_data0;in vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\n#pragma mapbox: define lowp float emissive_strength\\nvoid main() {\\n#pragma mapbox: initialize highp vec4 fill_color\\n#pragma mapbox: initialize highp vec4 halo_color\\n#pragma mapbox: initialize lowp float opacity\\n#pragma mapbox: initialize lowp float halo_width\\n#pragma mapbox: initialize lowp float halo_blur\\n#pragma mapbox: initialize lowp float emissive_strength\\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;bool draw_halo=v_draw_halo > 0.0;if (draw_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).r;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);vec4 out_color=color*(alpha*opacity*fade_opacity);\\n#ifdef LIGHTING_3D_MODE\\nout_color=apply_lighting_with_emission_ground(out_color,emissive_strength);\\n#endif\\nglFragColor=out_color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\nHANDLE_WIREFRAME_DEBUG;}','#include \"_prelude_terrain.vertex.glsl\"\\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_projected_pos;in float a_fade_opacity;\\n#ifdef OCCLUSION_QUERIES\\nin float a_occlusion_query_opacity;\\n#endif\\n#ifdef Z_OFFSET\\nin float a_z_offset;\\n#endif\\n#ifdef PROJECTION_GLOBE_VIEW\\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\\n#endif\\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform bool u_is_halo;\\n#ifdef PROJECTION_GLOBE_VIEW\\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\\n#endif\\nout float v_draw_halo;out vec4 v_data0;out vec4 v_data1;\\n#pragma mapbox: define highp vec4 fill_color\\n#pragma mapbox: define highp vec4 halo_color\\n#pragma mapbox: define lowp float opacity\\n#pragma mapbox: define lowp float halo_width\\n#pragma mapbox: define lowp float halo_blur\\n#pragma mapbox: define lowp float emissive_strength\\n#pragma mapbox: define lowp float occlusion_opacity\\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\\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;float e=elevation(tile_anchor);\\n#ifdef Z_OFFSET\\ne+=a_z_offset;\\n#endif\\nvec3 h=elevationVector(tile_anchor)*e;float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\\n#else\\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\\n#endif\\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\\ncamera_to_anchor_distance/u_camera_to_center_distance :\\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\\n#else\\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\\n#endif\\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\\n#ifdef TERRAIN\\n#ifdef PITCH_WITH_MAP_TERRAIN\\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\\n#endif\\n#endif\\nfloat occlusion_fade=globe_occlusion_fade;\\n#ifdef SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\\nocclusion_fade*=occlusionFade(projected_point);\\n#endif\\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\\n#endif\\nfloat out_fade_opacity=interpolated_fade_opacity*projection_transition_fade;\\n#ifdef OCCLUSION_QUERIES\\nfloat occludedFadeMultiplier=mix(occlusion_opacity,1.0,a_occlusion_query_opacity);out_fade_opacity*=occludedFadeMultiplier;\\n#endif\\nfloat alpha=opacity*out_fade_opacity;float hidden=float(alpha==0.0 || projected_point.w <=0.0 || occlusion_fade==0.0);\\n#ifdef PROJECTION_GLOBE_VIEW\\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+ xAxis*offset.x+yAxis*offset.y,1.0),AWAY,hidden);\\n#else\\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,hidden);\\n#endif\\nfloat gamma_scale=gl_Position.w;v_draw_halo=(u_is_halo && float(gl_InstanceID)==0.0) ? 1.0 : 0.0;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,out_fade_opacity,is_sdf);}'),terrainRaster:At('#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;out float v_depth;\\n#endif\\nvoid main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\\n#ifdef FOG\\n#ifdef ZERO_EXAGGERATION\\nv_fog_pos=fog_position(decodedPos);\\n#else\\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\\n#endif\\n#endif\\n#ifdef RENDER_SHADOWS\\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);\\n#endif\\n}'),terrainDepth:At(\"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:At('#include \"_prelude_fog.fragment.glsl\"\\nin lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=texture(u_cubemap,uv).rgb;\\n#ifdef FOG\\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\\n#endif\\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);glFragColor=vec4(sky_color*u_opacity,u_opacity);\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\n}',ft),skyboxGradient:At('#include \"_prelude_fog.fragment.glsl\"\\nin highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture(u_color_ramp,vec2(progress,0.5));\\n#ifdef FOG\\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\\n#endif\\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);glFragColor=color;\\n#ifdef OVERDRAW_INSPECTOR\\nglFragColor=vec4(1.0);\\n#endif\\n}',ft),skyboxCapture:At(\"\\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:At('#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\\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture(u_image0,v_pos0);\\n#ifdef LIGHTING_3D_MODE\\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\\nraster=apply_lighting_with_emission_ground(raster,raster.a);color=vec4(raster.rgb*antialias,antialias);\\n#else\\nraster=apply_lighting_ground(raster);color=vec4(raster.rgb*antialias,raster.a*antialias);\\n#endif\\n#else\\ncolor=vec4(raster.rgb*antialias,raster.a*antialias);\\n#endif\\n#else\\ncolor=texture(u_image0,v_pos0);\\n#ifdef LIGHTING_3D_MODE\\n#ifdef LIGHTING_3D_ALPHA_EMISSIVENESS\\ncolor=apply_lighting_with_emission_ground(color,color.a);color.a=1.0;\\n#else\\ncolor=apply_lighting_ground(color);\\n#endif\\n#endif\\n#endif\\n#ifdef FOG\\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\\n#endif\\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:At('#include \"_prelude_fog.fragment.glsl\"\\nuniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec4 u_color;uniform vec4 u_high_color;uniform vec4 u_space_color;uniform float u_horizon_angle;in highp vec3 v_ray_dir;in highp vec3 v_horizon_dir;void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\\n#ifdef PROJECTION_GLOBE_VIEW\\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {\\n#ifdef ALPHA_PASS\\nglFragColor=vec4(0,0,0,0);return;\\n#else\\n#ifdef NATIVE\\nglFragColor=vec4(1,1,1,1);\\n#else\\nglFragColor=vec4(0,0,0,1);\\n#endif\\nreturn;\\n#endif\\n}\\n#endif\\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\\n0.0 : max(acos(clamp(dot(dir,horizon_dir),-1.0,1.0)),0.0);float horizon_angle;\\n#ifdef PROJECTION_GLOBE_VIEW\\nhighp vec3 closest_point=globe_pos_dot_dir*dir;highp float closest_point_to_center=length(closest_point-u_globe_pos);highp float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\\n#else\\nhorizon_angle=horizon_angle_mercator;\\n#endif\\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;\\n#ifdef ALPHA_PASS\\nfloat a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);glFragColor=vec4(1.0,1.0,1.0,a);\\n#else\\nvec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c=c2;\\n#ifndef NATIVE\\nc=dither(c,gl_FragCoord.xy+u_temporal_offset);\\n#endif\\nglFragColor=vec4(c*t,t);\\n#endif\\n}',\"in vec3 a_pos;in vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;out highp vec3 v_ray_dir;out highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}\"),model:At('#include \"_prelude_fog.fragment.glsl\"\\n#include \"_prelude_shadow.fragment.glsl\"\\n#include \"_prelude_lighting.glsl\"\\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform vec4 u_baseColorFactor;uniform vec4 u_emissiveFactor;uniform float u_metallicFactor;uniform float u_roughnessFactor;uniform float u_emissive_strength;in highp vec4 v_position_height;in lowp vec4 v_color_mix;\\n#ifdef RENDER_SHADOWS\\nin vec4 v_pos_light_view_0;in vec4 v_pos_light_view_1;in float v_depth_shadows;\\n#endif\\n#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 vec2 u_inv_depth_size;uniform vec2 u_depth_range_unpack;\\n#ifdef TERRAIN_DEPTH_D24\\nfloat unpack_depth(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() {vec2 coord=gl_FragCoord.xy*u_inv_depth_size;\\n#ifdef TERRAIN_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;highp float lengthT=dot(T,T);highp float lengthB=dot(B,B);highp float maxLength=max(lengthT,lengthB);highp float invmax=inversesqrt( maxLength );highp mat3 res=mat3( T*invmax,B*invmax,N );return res;\\n#else\\nreturn mat3(1.0);\\n#endif\\n}highp vec3 getNormal(){highp vec3 n;\\n#ifdef HAS_ATTRIBUTE_a_normal_3f\\nn=normalize(normal_3f);\\n#else\\nhighp vec3 fdx=vec3(dFdx(v_position_height.x),dFdx(v_position_height.y),dFdx(v_position_height.z));highp vec3 fdy=vec3(dFdy(v_position_height.x),dFdy(v_position_height.y),dFdy(v_position_height.z));n=normalize(cross(fdx,fdy))*-1.0;\\n#endif\\n#if defined(HAS_TEXTURE_u_normalTexture) && defined(HAS_ATTRIBUTE_a_uv_2f)\\nvec3 nMap=texture( u_normalTexture,uv_2f).xyz;nMap=normalize(2.0*nMap-vec3(1.0));highp vec3 v=normalize(-v_position_height.xyz);highp mat3 TBN=cotangentFrame(n,v,uv_2f);n=normalize(TBN*nMap);\\n#endif\\nreturn n;}struct Material {float perceptualRoughness;float alphaRoughness;float metallic;vec3 f90;vec4 baseColor;vec3 diffuseColor;vec3 specularColor;highp vec3 normal;};Material getPBRMaterial() {Material mat;mat.baseColor=getBaseColor();mat.perceptualRoughness=u_roughnessFactor;mat.metallic=u_metallicFactor;\\n#ifdef HAS_ATTRIBUTE_a_pbr\\nmat.perceptualRoughness=v_roughness_metallic_emissive_alpha.x;mat.metallic=v_roughness_metallic_emissive_alpha.y;mat.baseColor.w*=v_roughness_metallic_emissive_alpha.w;\\n#endif\\n#if defined(HAS_TEXTURE_u_metallicRoughnessTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) \\nvec4 mrSample=texture(u_metallicRoughnessTexture,uv_2f);mat.perceptualRoughness*=mrSample.g;mat.metallic*=mrSample.b;\\n#endif\\nconst float c_minRoughness=0.04;mat.perceptualRoughness=clamp(mat.perceptualRoughness,c_minRoughness,1.0);mat.metallic=saturate(mat.metallic);mat.alphaRoughness=mat.perceptualRoughness*mat.perceptualRoughness;const vec3 f0=vec3(0.04);mat.diffuseColor=mat.baseColor.rgb*(vec3(1.0)-f0);mat.diffuseColor*=1.0-mat.metallic;mat.specularColor=mix(f0,mat.baseColor.rgb,mat.metallic);highp float reflectance=max(max(mat.specularColor.r,mat.specularColor.g),mat.specularColor.b);highp float reflectance90=saturate(reflectance*25.0);mat.f90=vec3(reflectance90);mat.normal=getNormal();return mat;}float V_GGX(float NdotL,float NdotV,float roughness)\\n{float a2=roughness*roughness;float GGXV=NdotL*sqrt(NdotV*NdotV*(1.0-a2)+a2);float GGXL=NdotV*sqrt(NdotL*NdotL*(1.0-a2)+a2);return 0.5/(GGXV+GGXL);}float V_GGXFast(float NdotL,float NdotV,float roughness) {float a=roughness;float GGXV=NdotL*(NdotV*(1.0-a)+a);float GGXL=NdotV*(NdotL*(1.0-a)+a);return 0.5/(GGXV+GGXL);}vec3 F_Schlick(vec3 specularColor,vec3 f90,float VdotH)\\n{return specularColor+(f90-specularColor)*pow(clamp(1.0-VdotH,0.0,1.0),5.0);}vec3 F_SchlickFast(vec3 specularColor,float VdotH)\\n{float x=1.0-VdotH;float x4=x*x*x*x;return specularColor+(1.0-specularColor)*x4*x;}float D_GGX(highp float NdotH,float alphaRoughness)\\n{highp float a4=alphaRoughness*alphaRoughness;highp float f=(NdotH*a4-NdotH)*NdotH+1.0;return a4/(PI*f*f);}vec3 diffuseBurley(Material mat,float LdotH,float NdotL,float NdotV)\\n{float f90=2.0*LdotH*LdotH*mat.alphaRoughness-0.5;return (mat.diffuseColor/PI)*(1.0+f90*pow((1.0-NdotL),5.0))*(1.0+f90*pow((1.0-NdotV),5.0));}vec3 diffuseLambertian(Material mat)\\n{\\n#ifdef LIGHTING_3D_MODE\\nreturn mat.diffuseColor;\\n#else\\nreturn mat.diffuseColor/PI;\\n#endif\\n}vec3 EnvBRDFApprox(vec3 specularColor,float roughness,highp float NdotV)\\n{vec4 c0=vec4(-1,-0.0275,-0.572,0.022);vec4 c1=vec4(1,0.0425,1.04,-0.04);highp vec4 r=roughness*c0+c1;highp float a004=min(r.x*r.x,exp2(-9.28*NdotV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}vec3 computeIndirectLightContribution(Material mat,float NdotV,vec3 normal)\\n{vec3 env_light=vec3(0.65,0.65,0.65);\\n#ifdef LIGHTING_3D_MODE\\nfloat ambient_factor=calculate_ambient_directional_factor(normal);env_light=u_lighting_ambient_color*ambient_factor;\\n#endif\\nvec3 envBRDF=EnvBRDFApprox(mat.specularColor,mat.perceptualRoughness,NdotV);vec3 indirectSpecular= envBRDF*env_light;vec3 indirectDiffuse=mat.diffuseColor*env_light;return indirectSpecular+indirectDiffuse;}vec3 computeLightContribution(Material mat,vec3 lightPosition,vec3 lightColor)\\n{highp vec3 n=mat.normal;highp vec3 v=normalize(-v_position_height.xyz);highp vec3 l=normalize(lightPosition);highp vec3 h=normalize(v+l);float NdotV=clamp(abs(dot(n,v)),0.001,1.0);float NdotL=saturate(dot(n,l));highp float NdotH=saturate(dot(n,h));float VdotH=saturate(dot(v,h));vec3 f=F_SchlickFast(mat.specularColor,VdotH);float g=V_GGXFast(NdotL,NdotV,mat.alphaRoughness);float d=D_GGX(NdotH,mat.alphaRoughness);vec3 diffuseTerm=(1.0-f)*diffuseLambertian(mat);vec3 specularTerm=f*g*d;vec3 transformed_normal=vec3(-n.xy,n.z);float lighting_factor;\\n#ifdef RENDER_SHADOWS\\nlighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\\n#else\\nlighting_factor=NdotL;\\n#endif\\nvec3 directLightColor=(specularTerm+diffuseTerm)*lighting_factor*lightColor;vec3 indirectLightColor=computeIndirectLightContribution(mat,NdotV,transformed_normal);vec3 color=(saturate(directLightColor)+indirectLightColor);float intensityFactor=1.0;\\n#if !defined(LIGHTING_3D_MODE)\\nconst vec3 luminosityFactor=vec3(0.2126,0.7152,0.0722);float luminance=dot(diffuseTerm,luminosityFactor);intensityFactor=mix((1.0-u_lightintensity),max((1.0-luminance+u_lightintensity),1.0),NdotL);\\n#endif\\ncolor*=intensityFactor;return color;}void main() {\\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\\nif (isOccluded()) {discard;}\\n#endif\\nvec3 lightDir=u_lightpos;vec3 lightColor=u_lightcolor;\\n#ifdef LIGHTING_3D_MODE\\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\\n#endif\\nvec4 finalColor;\\n#ifdef DIFFUSE_SHADED\\nvec3 N=getNormal();vec3 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);\\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 vec4 v_pos_light_view_0;out vec4 v_pos_light_view_1;out float v_depth_shadows;\\n#endif\\nout vec4 v_position_height;out lowp vec4 v_color_mix;\\n#ifdef TERRAIN_FRAGMENT_OCCLUSION\\nout highp float v_depth;\\n#endif\\n#ifdef HAS_ATTRIBUTE_a_pbr\\nout lowp vec4 v_roughness_metallic_emissive_alpha;out mediump vec4 v_height_based_emission_params;\\n#endif\\nvec3 sRGBToLinear(vec3 srgbIn) {return pow(srgbIn,vec3(2.2));}void main() {\\n#pragma mapbox: initialize-attribute highp vec3 normal_3f\\n#pragma mapbox: initialize-attribute highp vec2 uv_2f\\n#pragma mapbox: initialize-attribute highp vec3 color_3f\\n#pragma mapbox: initialize-attribute highp vec4 color_4f\\n#pragma mapbox: initialize-attribute-custom highp vec4 pbr\\n#pragma mapbox: initialize-attribute-custom highp vec3 heightBasedEmissiveStrength\\nhighp mat4 normal_matrix;\\n#ifdef INSTANCED_ARRAYS\\nnormal_matrix=mat4(a_normal_matrix0,a_normal_matrix1,a_normal_matrix2,a_normal_matrix3);\\n#else\\nnormal_matrix=u_normal_matrix;\\n#endif\\nvec3 local_pos;mat3 rs;\\n#ifdef MODEL_POSITION_ON_GPU\\nvec3 pos_color=normal_matrix[0].xyz;vec4 translate=normal_matrix[1];vec3 pos_a=floor(pos_color);vec3 rgb=1.05*(pos_color-pos_a);float 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#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(normalize(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:At(\"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:At(\"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);}\"),occlusion:At(\"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 Pt(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 At(e,t){const i=/#include\\s+\"([^\"]+)\"/g,o=/#pragma mapbox: ([\\w\\-]+) ([\\w]+) ([\\w]+) ([\\w]+)/g;let r=t.match(/(attribute(\\S*)|(^\\s*|;)in) (highp |mediump |lowp )?([\\w]+) ([\\w]+)/gm);r&&(r=r.map((e=>{const t=e.split(\" \");return t[t.length-1]})),r=[...new Set(r)]);const a={},n=[],s=[];if(e=e.replace(i,((e,t)=>(s.push(t),\"\"))),(t=t.replace(i,((e,t)=>(n.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 l=[...Tt];Pt(e,l),Pt(t,l);for(const e of [...n,...s])Et[e]||console.error(`Undefined include: ${e}`),Ct[e]||(Ct[e]=[],Pt(Et[e],Ct[e])),l=[...l,...Ct[e]];return {fragmentSource:e=e.replace(o,((e,t,i,o,r)=>(a[r]=!0,\"define\"===t?`\\n#ifndef HAS_UNIFORM_u_${r}\\nin ${i} ${o} ${r};\\n#else\\nuniform ${i} ${o} u_${r};\\n#endif\\n`:\"initialize\"===t?`\\n#ifdef HAS_UNIFORM_u_${r}\\n ${i} ${o} ${r} = u_${r};\\n#endif\\n`:\"define-attribute\"===t?`\\n#ifdef HAS_ATTRIBUTE_a_${r}\\n in ${i} ${o} ${r};\\n#endif\\n`:\"initialize-attribute\"===t?\"\":void 0))),vertexSource:t=t.replace(o,((e,t,i,o,r)=>{const n=\"float\"===o?\"vec2\":o,s=r.match(/color/)?\"color\":n;return \"define-attribute-vertex-shader-only\"===t?`\\n#ifdef HAS_ATTRIBUTE_a_${r}\\nin ${i} ${o} a_${r};\\n#endif\\n`:a[r]?\"define\"===t?`\\n#ifndef HAS_UNIFORM_u_${r}\\nuniform lowp float u_${r}_t;\\nin ${i} ${n} a_${r};\\nout ${i} ${o} ${r};\\n#else\\nuniform ${i} ${o} u_${r};\\n#endif\\n`:\"initialize\"===t?\"vec4\"===s?`\\n#ifndef HAS_UNIFORM_u_${r}\\n ${r} = a_${r};\\n#else\\n ${i} ${o} ${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} ${o} ${r} = u_${r};\\n#endif\\n`:\"define-attribute\"===t?`\\n#ifdef HAS_ATTRIBUTE_a_${r}\\n in ${i} ${o} a_${r};\\n out ${i} ${o} ${r};\\n#endif\\n`:\"initialize-attribute\"===t?`\\n#ifdef HAS_ATTRIBUTE_a_${r}\\n ${r} = a_${r};\\n#endif\\n`:void 0:\"define\"===t?`\\n#ifndef HAS_UNIFORM_u_${r}\\nuniform lowp float u_${r}_t;\\nin ${i} ${n} a_${r};\\n#else\\nuniform ${i} ${o} u_${r};\\n#endif\\n`:\"define-instanced\"===t?\"mat4\"===s?`\\n#ifdef INSTANCED_ARRAYS\\nin vec4 a_${r}0;\\nin vec4 a_${r}1;\\nin vec4 a_${r}2;\\nin vec4 a_${r}3;\\n#else\\nuniform ${i} ${o} u_${r};\\n#endif\\n`:`\\n#ifdef INSTANCED_ARRAYS\\nin ${i} ${n} a_${r};\\n#else\\nuniform ${i} ${o} u_${r};\\n#endif\\n`:\"initialize-attribute-custom\"===t?`\\n#ifdef HAS_ATTRIBUTE_a_${r}\\n ${i} ${o} ${r} = a_${r};\\n#endif\\n`:\"vec4\"===s?`\\n#ifndef HAS_UNIFORM_u_${r}\\n ${i} ${o} ${r} = a_${r};\\n#else\\n ${i} ${o} ${r} = u_${r};\\n#endif\\n`:`\\n#ifndef HAS_UNIFORM_u_${r}\\n ${i} ${o} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\\n#else\\n ${i} ${o} ${r} = u_${r};\\n#endif\\n`})),staticAttributes:r,usedDefines:l,vertexIncludes:n,fragmentIncludes:s}}class Rt{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null;}bind(e,t,i,o,r,a,n,s){this.context=e;let l=this.boundPaintVertexBuffers.length!==o.length;for(let e=0;!l&&e{const a=o.paint.get(\"hillshade-shadow-color\"),n=o.paint.get(\"hillshade-highlight-color\"),s=o.paint.get(\"hillshade-accent-color\"),l=o.paint.get(\"hillshade-emissive-strength\");let c=e.ab(o.paint.get(\"hillshade-illumination-direction\"));if(\"viewport\"===o.paint.get(\"hillshade-illumination-anchor\"))c-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get(\"direction\"),o=e.ac(i.x,i.y,i.z);c=e.ab(o[1]);}const h=!t.options.moving;return {u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),h),u_image:0,u_latrange:Dt(0,i.tileID),u_light:[o.paint.get(\"hillshade-exaggeration\"),c],u_shadow:a.toRenderColor(o.lut),u_highlight:n.toRenderColor(o.lut),u_emissive_strength:l,u_accent:s.toRenderColor(o.lut)}})(t,o,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,u,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(o);u.draw(t,c.TRIANGLES,a,n,s,e.af.disabled,d,r.id,p,f,m);}function zt(t,i,o){if(!i.needsDEMTextureUpload)return;const r=t.context,a=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(o.stride);const n=o.getPixels();i.demTexture?i.demTexture.update(n,{premultiply:!1}):i.demTexture=new e.T(r,n,a.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1;}function Ot(t,i,o){const r=t.context,a=r.gl;if(!i.dem)return;const n=i.dem;if(r.activeTexture.set(a.TEXTURE1),zt(t,i,n),!i.demTexture)return;i.demTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE);const s=n.dim;r.activeTexture.set(a.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(r,{width:s,height:s,data:null},a.RGBA);t.bind(a.LINEAR,a.CLAMP_TO_EDGE),l=i.hillshadeFBO=r.createFramebuffer(s,s,!0,\"renderbuffer\"),l.colorAttachment.set(t.texture);}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,s,s]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:h,tileBoundsSegments:_}=t.getMercatorTileBoundsBuffers(),u=[];t.linearFloatFilteringSupported()&&u.push(\"TERRAIN_DEM_FLOAT_FORMAT\"),t.getOrCreateProgram(\"hillshadePrepare\",{defines:u}).draw(t,a.TRIANGLES,e.ae.disabled,e.ag.disabled,e.a.unblended,e.af.disabled,((t,i)=>{const o=i.stride,r=e.ad.create();return e.ad.ortho(r,0,e.a3,-e.a3,0,0,1),e.ad.translate(r,r,[0,-e.a3,0]),{u_matrix:r,u_image:1,u_dimension:[o,o],u_zoom:t.overscaledZ}})(i.tileID,n),o.id,c,h,_),i.needsHillshadePrepare=!1;}function Ft(t,i,o,r,a){const n=function(o,r){if(o)return a(o);if(r){if(t.url&&r.tiles&&t.tiles&&delete t.tiles,r.variants){if(!Array.isArray(r.variants))return a(new Error(\"variants must be an array\"));for(const t of r.variants){if(null==t||\"object\"!=typeof t||t.constructor!==Object)return a(new Error(\"variant must be an object\"));if(!Array.isArray(t.capabilities))return a(new Error(\"capabilities must be an array\"));if(1===t.capabilities.length&&\"meshopt\"===t.capabilities[0]){r=e.W(r,t);break}}}const o=e.ah(e.W(r,t),[\"tilejson\",\"tiles\",\"minzoom\",\"maxzoom\",\"attribution\",\"mapbox_logo\",\"bounds\",\"scheme\",\"tileSize\",\"encoding\"]);r.vector_layers&&(o.vectorLayers=r.vector_layers,o.vectorLayerIds=o.vectorLayers.map((e=>e.id))),r.raster_layers&&(o.rasterLayers=r.raster_layers,o.rasterLayerIds=o.rasterLayers.map((e=>e.id))),o.tiles=i.canonicalizeTileset(o,t.url),a(null,o);}};return t.url?e.g(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.R.Source),n):e.e.frame((()=>n(null,t)))}class Bt{constructor(t,i,o){this.bounds=e.ai.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||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(t){const i=Math.pow(2,t.z),o=Math.floor(e.aj(this.bounds.getWest())*i),r=Math.floor(e.ak(this.bounds.getNorth())*i),a=Math.ceil(e.aj(this.bounds.getEast())*i),n=Math.ceil(e.ak(this.bounds.getSouth())*i);return t.x>=o&&t.x=r&&t.y{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.d(i)):o&&(e.W(this,o),o.bounds&&(this.tileBounds=new Bt(o.bounds,this.minzoom,this.maxzoom)),e.an(o.tiles),this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.f(\"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.al(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 e.W({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.e.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.h(this.map._requestManager.transformRequest(r,e.R.Tile),((o,r,a,n)=>(delete t.request,t.aborted?(t.state=\"unloaded\",i(null)):o?(t.state=\"errored\",i(o)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:n}),t.setTexture(r,this.map.painter),t.state=\"loaded\",e.am(this.dispatcher),void i(null)):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);}}class Nt extends e.E{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type=\"vector\",this.minzoom=0,this.maxzoom=22,this.scheme=\"xyz\",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.W(this,e.ah(i,[\"url\",\"scheme\",\"tileSize\",\"promoteId\"])),this._options=e.W({type:\"vector\"},i),this._collectResourceTiming=!!i.collectResourceTiming,512!==this.tileSize)throw new Error(\"vector tile sources must have a tileSize of 512\");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.ao;}load(t){this._loaded=!1,this.fire(new e.f(\"dataloading\",{dataType:\"source\"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=Ft(this._options,this.map._requestManager,i,o,((r,a)=>{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}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.d(r))):a&&(e.W(this,a),a.bounds&&(this.tileBounds=new Bt(a.bounds,this.minzoom,this.maxzoom)),e.an(a.tiles,this.map._requestManager._customAccessToken),this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.f(\"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.al(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 e.W({},this._options)}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r=this.map._requestManager.transformRequest(o,e.R.Tile),a=this.map.style?this.map.style.getLut(this.scope):null,n={request:r,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,lut:a?{image:a.image.clone()}:null,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.e.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};if(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&\"expired\"!==t.state)\"loading\"===t.state?t.reloadCallback=i:t.request=t.actor.send(\"reloadTile\",n,s.bind(this));else if(t.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send(\"loadTile\",n,s.bind(this),void 0,!0);else {const i=e.ap.call({deduped:this._deduped},n,((e,i)=>{e||!i?s.call(this,e):(n.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send(\"loadTile\",n,s.bind(this),void 0,!0));}),!0);t.request={cancel:i};}function s(o,r){return delete t.request,t.aborted?i(null):o&&404!==o.status?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.am(this.dispatcher),i(null),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);}}const Ut=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Gt=(e,t,i,o,r,a,n,s,l,c,h,_,u,d,p,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(o),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:a,u_image0:0,u_frustum_tl:n,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:h,u_globe_radius:_,u_viewport:u,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:d,u_far_z_cutoff:p});class jt{constructor(e=0,t=0,i=0,o=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(o)||o<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=o;}interpolate(t,i,o){return null!=i.top&&null!=t.top&&(this.top=e.a2(t.top,i.top,o)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.a2(t.bottom,i.bottom,o)),null!=i.left&&null!=t.left&&(this.left=e.a2(t.left,i.left,o)),null!=i.right&&null!=t.right&&(this.right=e.a2(t.right,i.right,o)),this}getCenter(t,i){const o=e.at((this.left+t-this.right)/2,0,t),r=e.at((this.top+i-this.bottom)/2,0,i);return new e.P(o,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new jt(this.top,this.bottom,this.left,this.right)}toJSON(){return {top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Vt(t,i){const o=e.aw(t,3);e.ad.fromQuat(t,i),e.az(t,3,o);}function Wt(t,i){const o=e.av.identity([]);return e.av.rotateZ(o,o,-i),e.av.rotateX(o,o,-t),o}function Zt(t,i){const o=[t[0],t[1],0],r=[i[0],i[1],0];if(e._.length(o)>=1e-15){const t=e._.normalize([],o);e._.scale(r,t,e._.dot(r,t)),i[0]=r[0],i[1]=r[1];}const a=e._.cross([],i,t);if(e._.len(a)<1e-15)return null;const n=Math.atan2(-a[1],a[0]);return Wt(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),n)}class qt{constructor(e,t){this.position=e,this.orientation=t;}get position(){return this._position}set position(t){if(t){const i=t instanceof e.Y?t:new e.Y(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.au(i.x,0,1)),this._position=i;}else this._position=null;}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const o=this.position,r=this._elevation?this._elevation.getAtPointOrZero(e.Y.fromLngLat(t)):0,a=e.Y.fromLngLat(t,r),n=[a.x-o.x,a.y-o.y,a.z-o.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Zt(n,i);}setPitchBearing(t,i){this.orientation=Wt(e.ab(t),e.ab(-i));}}class Ht{constructor(t,i){this._transform=e.ad.identity([]),this.orientation=i,this.position=t;}get mercatorPosition(){const t=this.position;return new e.Y(t[0],t[1],t[2])}get position(){const t=e.aw(this._transform,3);return [t[0],t[1],t[2]]}set position(t){var i;t&&e.az(this._transform,3,[(i=t)[0],i[1],i[2],1]);}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.av.identity([]),t&&Vt(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=Wt(e,t),Vt(this._transform,this._orientation);}forward(){const t=e.aw(this._transform,2);return [-t[0],-t[1],-t[2]]}up(){const t=e.aw(this._transform,1);return [-t[0],-t[1],-t[2]]}right(){const t=e.aw(this._transform,0);return [t[0],t[1],t[2]]}getCameraToWorld(t,i){const o=new Float64Array(16);return e.ad.invert(o,this.getWorldToCamera(t,i)),o}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,o){const r=this.position;e._.scale(r,r,-t);const a=new Float64Array(16);return e.ad.fromScaling(a,[o,o,o]),e.ad.translate(a,a,r),a[10]*=i,a}getWorldToCamera(t,i){const o=new Float64Array(16),r=new Float64Array(4),a=this.position;return e.av.conjugate(r,this._orientation),e._.scale(a,a,-t),e.ad.fromQuat(o,r),e.ad.translate(o,o,a),o[1]*=-1,o[5]*=-1,o[9]*=-1,o[13]*=-1,o[8]*=i,o[9]*=i,o[10]*=i,o[11]*=i,o}getCameraToClipPerspective(t,i,o,r){const a=new Float64Array(16);return e.ad.perspective(a,t,i,o,r),a}getCameraToClipOrthographic(t,i,o,r,a,n){const s=new Float64Array(16);return e.ad.ortho(s,t,i,o,r,a,n),s}getDistanceToElevation(t,i=!1){const o=0===t?0:e.ax(t,i?e.ay(this.position[1]):this.position[1]),r=this.forward();return (o-this.position[2])/r[2]}clone(){return new Ht([...this.position],[...this.orientation])}}const $t={unknown:0,flipRequired:1,flipNotRequired:2},Xt=Math.tan(85*Math.PI/180);function Yt(t,i,o,r,a,n,s){const l=e.ad.create();if(o)if(\"globe\"===n.name){const t=e.aB(a,i);e.ad.multiply(l,l,t);}else {const t=e.aC.invert([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.ad.rotateZ(l,l,a.angle);}else e.ad.multiply(l,a.labelPlaneMatrix,t);return l}function Kt(e,t,i,o,r,a,n){const s=Yt(e,t,i,o,r,a,n);return \"globe\"===a.name&&i||(s[2]=s[6]=s[10]=s[14]=0),s}function Qt(t,i,o,r,a,n,s){if(o){if(\"globe\"===n.name){const l=Yt(t,i,o,r,a,n,s);return e.ad.invert(l,l),e.ad.multiply(l,t,l),l}{const i=e.ad.clone(t),o=e.ad.identity([]);return o[0]=s[0],o[1]=s[1],o[4]=s[2],o[5]=s[3],e.ad.multiply(i,i,o),r||e.ad.rotateZ(i,i,-a.angle),i}}return a.glCoordMatrix}function Jt(t,i,o,r){const a=[t,i,o,1];o?e.aA.transformMat4(a,a,r):hi(a,a,r);const n=a[3];return a[0]/=n,a[1]/=n,a[2]/=n,a}function ei(e,t){return Math.min(.5+e/t*.5,1.5)}function ti(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function ii(t,i,o,r,a,n,s,l,c,h){const _=o.transform,u=r?t.textSizeData:t.iconSizeData,d=e.aD(u,o.transform.zoom),p=\"globe\"===_.projection.name,f=[256/o.width*2+1,256/o.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let g=null;p&&(g=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b,w=!1;for(let r=0;rMath.abs(o)?{useVertical:!0}:t===e.aE.vertical?r>0?{needsFlipping:!0}:null:i!==$t.unknown&&function(e,t){return 0===e||Math.abs(t/e)>Xt}(o,r)?i===$t.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function ai(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:S,writingMode:I,flipState:L}=t,P=T+t.lineLength,A=t=>{if(_){const[i,o,r]=t.up,a=h.length;e.aG(_,a+0,i,o,r),e.aG(_,a+1,i,o,r),e.aG(_,a+2,i,o,r),e.aG(_,a+3,i,o,r);}const[i,o,r]=t.point;e.aH(h,i,o,r,t.angle);};if(C>1){const e=oi(y,l,b,w,o,u,d,t,c,n,p,m,!1,g,v,x);if(!e)return {notEnoughRoom:!0};if(r&&!o){let[i,o,r]=e.first.point,[a,n,l]=e.last.point;[i,o]=Jt(i,o,r,s),[a,n]=Jt(a,n,l,s);const c=ri(I,L,(a-i)*f,n-o);if(t.flipState=c&&c.needsFlipping?$t.flipRequired:$t.flipNotRequired,c)return c}A(e.first);for(let e=E+1;e0?n:si(d,r,i,1,a,void 0,g,v.canonical),l=ri(I,L,(s[0]-i[0])*f,s[1]-i[1]);if(t.flipState=l&&l.needsFlipping?$t.flipRequired:$t.flipNotRequired,l)return l}const i=li(y*l.getoffsetX(E),b,w,o,u,d,S,T,P,c,n,p,m,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};A(i);}return {}}function ni(e,t,i,o,r){const{x:a,y:n,z:s}=o.projectTilePoint(e.x,e.y,t);if(!r)return Jt(a,n,s,i);const[l,c,h]=r(e);return Jt(a+l,n+c,s+h,i)}function si(t,i,o,r,a,n,s,l){const c=ni(t.sub(i)._unit()._add(t),l,a,s,n);return e._.sub(c,o,c),e._.normalize(c,c),e._.scaleAndAdd(c,o,c,r)}function li(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g,v){const x=r?t-i:t+i;let y=x>0?1:-1,b=0;r&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=l+s+(y>0?0:1)|0,T=a,E=a,C=0,S=0;const I=Math.abs(x),L=[],P=[];let A=n,R=A;const D=()=>si(R,A,E,I-C+1,_,d,m,g.canonical);for(;C+S<=I;){if(w+=y,w=c)return null;if(E=T,R=A,L.push(E),p&&P.push(R),A=new e.P(h.getx(w),h.gety(w)),T=u[w],!T){const e=ni(A,g.canonical,_,m,d);T=e[3]>0?u[w]=e:D();}C+=S,S=e._.distance(E,T);}f&&d&&(u[w]&&(T=D(),S=e._.distance(E,T)),u[w]=T);const M=(I-C)/S,z=A.sub(R)._mult(M)._add(R),O=e._.sub([],T,E),F=e._.scaleAndAdd([],E,O,M);let B=[0,0,1],k=O[0],N=O[1];if(v&&(B=m.upVector(g.canonical,z.x,z.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],i=e._.cross([],B,t);e._.normalize(t,t),e._.normalize(i,i),k=e._.dot(O,t),N=e._.dot(O,i);}if(o){const t=e._.cross([],B,O);e._.normalize(t,t),e._.scaleAndAdd(F,F,t,o*y);}const U=b+Math.atan2(N,k);return L.push(F),p&&P.push(z),{point:F,angle:U,path:L,tilePath:P,up:B}}function ci(e,t){const i=t.length,o=i+4*e;t.resize(o),t.float32.fill(-1/0,4*i,4*o);}function hi(e,t,i){const o=t[0],r=t[1];return e[0]=i[0]*o+i[4]*r+i[12],e[1]=i[1]*o+i[5]*r+i[13],e[3]=i[3]*o+i[7]*r+i[15],e}const _i=(e,t,i)=>(1-i)*e+i*t,ui=e=>e*e*e*e*e;class di{constructor(t,i,o,r,a,n,s){this.tileSize=512,this._renderWorldCopies=void 0===a||a,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=o??0,this._maxPitch=r??60,this.setProjection(n),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.aI(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 jt,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new Ht,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;}clone(){const e=new di(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._orthographicProjectionAtLowPitch=this._orthographicProjectionAtLowPitch,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get isOrthographic(){return \"globe\"!==this.projection.name&&this._orthographicProjectionAtLowPitch&&this.pitch<15}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices());}get depthOcclusionForSymbolsAndCircles(){return \"globe\"!==this.projection.name&&!this.isOrthographic}updateElevation(e,t=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(e||i)&&this._constrainCamera(t),this._calcMatrices();}getProjection(){return e.ah(this.projection,[\"name\",\"center\",\"parallels\"])}setProjection(i){this.projectionOptions=i||{name:\"mercator\"};const o=this.projection?this.getProjection():void 0;this.projection=e.aJ(this.projectionOptions);const r=!t(o,this.getProjection());return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setOrthographicProjectionAtLowPitch(e){return this._orthographicProjectionAtLowPitch!==e&&(this._orthographicProjectionAtLowPitch=e,this._calcMatrices(),!0)}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:\"mercator\"},this.projection=e.aJ({name:\"mercator\"});const i=t!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e));}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e));}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e));}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e));}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e;}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.ax(1,this.center.lat)*this.cameraWorldSizeForFog}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return e.au(this.rotation,-180,180)}set bearing(e){this.rotation=e;}get rotation(){return -this.angle/Math.PI*180}set rotation(t){const i=-t*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=e.aC.create(),e.aC.rotate(this.rotationMatrix,this.rotationMatrix,this.angle));}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.at(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices());}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.ab(t),this._calcMatrices());}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={};}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices());}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom;}get tileCoverLift(){return this._tileCoverLift}set tileCoverLift(e){this._tileCoverLift!==e&&(this._tileCoverLift=e);}_updateCameraOnTerrain(){const e=this.elevation?this.elevation.getAtPoint(this.locationCoordinate(this.center),Number.NEGATIVE_INFINITY):Number.NEGATIVE_INFINITY,t=this.elevation&&e===Number.NEGATIVE_INFINITY&&this.elevation.visibleDemTiles.length>0&&this.elevation.exaggeration()>0&&this._centerAltitudeValidForExaggeration;if(!this._elevation||e===Number.NEGATIVE_INFINITY&&(!t||!this._centerAltitude))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const i=this._elevation;t||this._centerAltitude&&this._centerAltitudeValidForExaggeration&&i.exaggeration()&&this._centerAltitudeValidForExaggeration!==i.exaggeration()?(this._centerAltitude=this._centerAltitude/this._centerAltitudeValidForExaggeration*i.exaggeration(),this._centerAltitudeValidForExaggeration=i.exaggeration()):(this._centerAltitude=e||0,this._centerAltitudeValidForExaggeration=i.exaggeration()),this._updateSeaLevelZoom();}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize));}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],o=this.horizonLineFromTop();let r=0,a=0;for(let n=0;n0,h=t.y+10,u=o.wrap-(c?0:1),d=o.wrap+(l?0:1),p=c?t.x-1:s-1,f=l?t.x+1:0;i[0]<0?(r.push(new e.aL(a,d,t.z,f,t.y)),i[1]<0&&h&&(r.push(new e.aL(a,n,t.z,t.x,t.y+1)),r.push(new e.aL(a,d,t.z,f,t.y+1))),i[1]>0&&_&&(r.push(new e.aL(a,n,t.z,t.x,t.y-1)),r.push(new e.aL(a,d,t.z,f,t.y-1)))):i[0]>0?(r.push(new e.aL(a,u,t.z,p,t.y)),i[1]<0&&h&&(r.push(new e.aL(a,n,t.z,t.x,t.y+1)),r.push(new e.aL(a,u,t.z,p,t.y+1))),i[1]>0&&_&&(r.push(new e.aL(a,n,t.z,t.x,t.y-1)),r.push(new e.aL(a,u,t.z,p,t.y-1)))):i[1]<0&&h?r.push(new e.aL(a,n,t.z,t.x,t.y+1)):_&&r.push(new e.aL(a,n,t.z,t.x,t.y-1));}if(r.length>1){r.sort(((e,t)=>e.overscaledZ-t.overscaledZ||e.wrap-t.wrap||e.canonical.z-t.canonical.z||e.canonical.x-t.canonical.x||e.canonical.y-t.canonical.y));let e=0,t=0;for(;te.isChildOf(t)))||a.push(e);return r=a.filter((e=>!t.some((t=>!!(e.overscaledZt.maxzoom&&(i=t.maxzoom);const s=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,o=new e.Y(t.x+i,t.y,t.z),r=new e.Y(t.x,t.y+i,t.z),a=t.toLngLat(),n=o.toLngLat(),s=r.toLngLat(),l=this.locationCoordinate(a),c=this.locationCoordinate(n),h=this.locationCoordinate(s),_=Math.hypot(c.x-l.x,c.y-l.y),u=Math.hypot(h.x-l.x,h.y-l.y);return Math.sqrt(_*u)*T/i},C=t=>{const i=b,o=w;return {aabb:e.aQ(this,c,0,0,0,t,o,i,this.projection),zoom:0,x:0,y:0,minZ:o,maxZ:i,wrap:t,fullyVisible:!1}},S=[];let I=[];const L=i,P=t.reparseOverscaled?o:i,A=(m-this._centerAltitude)*f,R=e=>{if(!this._elevation||!e.tileID||!n)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=M(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude));},D=(e,t)=>{if(.707*t{if(t.zoom=.9)return !0}else if(a&&(s=t.aabb.distanceZ(g)*f),this.projection.isReprojectedInTileSpace&&o<=5){const i=Math.pow(2,t.zoom),o=E(new e.Y((t.x+.5)/i,(t.y+.5)/i));c=o>.85?1:o;}if(!n){const e=Math.sqrt(i*i+r*r+s*s);let o=(1<0;){const o=S.pop(),r=o.x,s=o.y;let l=o.fullyVisible;const u=()=>\"globe\"===this.projection.name&&(0===o.y||o.y===(1<>1),u={aabb:n?o.aabb.quadrant(t):e.aQ(this,c,o.zoom+1,i,h,o.wrap,o.minZ,o.maxZ,this.projection),zoom:o.zoom+1,x:i,y:h,wrap:o.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:o.minZ,maxZ:o.maxZ};a&&!_&&(u.tileID=new e.aL(o.zoom+1===L?P:o.zoom+1,o.wrap,o.zoom+1,i,h),R(u)),S.push(u);}else {const a=o.zoom===L?P:o.zoom;if(t.minzoom&&t.minzoom>a)continue;if(!l){let t=v?o.aabb.intersectsPrecise(d):o.aabb.intersectsPreciseFlat(d);if(0===t&&u()){const i=new e.aO(o.zoom,r,s);t=e.aP(this,c,i,!0).intersectsPrecise(d);}if(0===t)continue}const n=h[0]-(.5+r+(o.wrap<{const a=[0,0,0,1],n=[e.a3,e.a3,0,1],s=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aA.transformMat4(a,a,s),e.aA.transformMat4(n,n,s);const l=e.aA.min([],a,n),c=e.aA.max([],a,n),h=e.aR(l,c);if(0===h)return !0;let _=!1;const u=this._elevation;if(u&&h>i&&0!==o){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let a;t.isTerrainDEM||(a=u.getMinMaxForTile(r.tileID)),a||(a={min:w,max:b});const n=e.b2(this.rotation),s=[n[0]*e.a3,n[1]*e.a3,a.max];e._.transformMat4(s,s,i),_=(1-s[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.log(e)/Math.LN2}project(t){const i=e.at(t.lat,-e.aS,e.aS),o=this.projection.project(t.lng,i);return new e.P(o.x*this.worldSize,o.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.ax(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let o,r;const a=this.centerPoint;if(\"globe\"===this.projection.name){const e=this.worldSize;o=(i.x-a.x)/e,r=(i.y-a.y)/e;}else {const e=this.pointCoordinate(i),t=this.pointCoordinate(a);o=e.x-t.x,r=e.y-t.y;}const n=this.locationCoordinate(t);this.setLocation(new e.Y(n.x-o,n.y-r));}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap());}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const o=i?e.ax(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.Y(r.x,r.y,o)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const o=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],a=[t.x,t.y,1,1];e.aA.transformMat4(r,r,this.pixelMatrixInverse),e.aA.transformMat4(a,a,this.pixelMatrixInverse);const n=a[3];e.aA.scale(r,r,1/r[3]),e.aA.scale(a,a,1/n);const s=r[2],l=a[2];return {p0:r,p1:a,t:s===l?0:(o-s)/(l-s)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];return e.aA.transformMat4(i,i,this.pixelMatrixInverse),e.aA.transformMat4(o,o,this.pixelMatrixInverse),e.aA.scale(i,i,1/i[3]),e.aA.scale(o,o,1/o[3]),i[2]=e.ax(i[2],this._center.lat)*this.worldSize,o[2]=e.ax(o[2],this._center.lat)*this.worldSize,e.aA.scale(i,i,1/this.worldSize),e.aA.scale(o,o,1/this.worldSize),new e.aT([i[0],i[1],i[2]],e._.normalize([],e._.sub([],o,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:o,t:r}=t,a=e.ax(i[2],this._center.lat),n=e.ax(o[2],this._center.lat);return new e.Y(e.a2(i[0],o[0],r)/this.worldSize,e.a2(i[1],o[1],r)/this.worldSize,e.a2(a,n,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let i=this.projection.pointCoordinate3D(this,t.x,t.y);if(i)return new e.Y(i[0],i[1],i[2]);let o=0,r=this.horizonLineFromTop();if(t.y>r)return this.pointCoordinate(t);const a=.02*r,n=t.clone();for(let t=0;t<10&&r-o>a;t++){n.y=e.a2(o,r,.66);const t=this.projection.pointCoordinate3D(this,n.x,n.y);t?(r=n.y,i=t):o=n.y;}return i?new e.Y(i[0],i[1],i[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.aU)return !this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const o=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,o+t.toAltitude(),1];return e.aA.transformMat4(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,o=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,a=this.pointLocation3D(new e.P(i,t)),n=this.pointLocation3D(new e.P(r,t)),s=this.pointLocation3D(new e.P(r,o)),l=this.pointLocation3D(new e.P(i,o));let c=Math.min(a.lng,n.lng,s.lng,l.lng),h=Math.max(a.lng,n.lng,s.lng,l.lng),_=Math.min(a.lat,n.lat,s.lat,l.lat),u=Math.max(a.lat,n.lat,s.lat,l.lat);const d=Math.pow(2,-this.zoom)/16*270,p=\"globe\"===this.projection.name?1:4,f=(t,i,o,r,a)=>{const n=(t+o)/2,s=(i+r)/2,l=new e.P(n,s),{lng:m,lat:g}=this.pointLocation3D(l),v=Math.max(0,c-m,_-g,m-h,g-u);c=Math.min(c,m),h=Math.max(h,m),_=Math.min(_,g),u=Math.max(u,g),(ad)&&(f(t,i,n,s,a+1),f(n,s,o,r,a+1));};if(f(i,t,r,t,1),f(r,t,r,o,1),f(r,o,i,o,1),f(i,o,i,t,1),\"globe\"===this.projection.name){const[t,i]=e.aV(this);t?(u=90,h=180,c=-180):i&&(_=-90,h=180,c=-180);}return new e.ai(new e.aI(c,_),new e.aI(h,u))}_getBoundsRectangular(t,i){const{top:o,left:r}=this._edgeInsets,a=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,s=new e.P(r,o),l=new e.P(n,o),c=new e.P(n,a),h=new e.P(r,a);let _=this.pointCoordinate(s,t),u=this.pointCoordinate(l,t);const d=this.pointCoordinate(c,i),p=this.pointCoordinate(h,i),f=(e,t)=>(t.y-e.y)/(t.x-e.x);return _.y>1&&u.y>=0?_=new e.Y((1-p.y)/f(p,_)+p.x,1):_.y<0&&u.y<=1&&(_=new e.Y(-p.y/f(p,_)+p.x,0)),u.y>1&&_.y>=0?u=new e.Y((1-d.y)/f(d,u)+d.x,1):u.y<0&&_.y<=1&&(u=new e.Y(-d.y/f(d,u)+d.x,0)),(new e.ai).extend(this.coordinateLocation(_)).extend(this.coordinateLocation(u)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBoundsRectangular(0,0);const t=e.visibleDemTiles.reduce(((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0]);}return e}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return \"mercator\"===this.projection.name||\"equirectangular\"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))-this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.aS,this.maxLat=e.aS,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLng_&&(s=_-c),_-ht&&(n=t-l),t-e{for(let r=0;r<16;r++)e[r]=_i(t[r],i[r],o);})(s,s,l,ui(this.pitch>=15?1:this.pitch/15));}else s=l;const c=e.ad.mul([],l,n);let h=e.ad.mul([],s,n);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.ad.identity([]);e.ad.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.ad.multiply(i,i,e.aY(this)),e.ad.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.ad.multiply(h,h,i),e.ad.multiply(c,c,i),this.inverseAdjustmentMatrix=e.aZ(this);}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.ad.scale([],h,[this.worldSize,this.worldSize,this.worldSize/a,1]),this.projMatrix=h,this.invProjMatrix=e.ad.invert(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.ad.mul([],i,n);}else this.expandedFarZProjMatrix=this.projMatrix;const _=e.ad.invert([],s);this.frustumCorners=e.a_.fromInvProjectionMatrix(_,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.aM.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const u=new Float32Array(16);e.ad.identity(u),e.ad.scale(u,u,[1,-1,1]),e.ad.rotateX(u,u,this._pitch),e.ad.rotateZ(u,u,this.angle);const d=e.ad.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.ad.clone(d);const p=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;d[8]=2*-t.x/this.width,d[9]=2*(t.y+p)/this.height,this.skyboxMatrix=e.ad.multiply(u,d,u);const f=this.point,m=f.x,g=f.y,v=this.width%2/2,x=this.height%2/2,y=Math.cos(this.angle),b=Math.sin(this.angle),w=m-Math.round(m)+y*v+b*x,T=g-Math.round(g)+y*x+b*v,E=new Float64Array(h);if(e.ad.translate(E,E,[w>.5?w-1:w,T>.5?T-1:T,0]),this.alignedProjMatrix=E,h=e.ad.create(),e.ad.scale(h,h,[this.width/2,-this.height/2,1]),e.ad.translate(h,h,[1,-1,0]),this.labelPlaneMatrix=h,h=e.ad.create(),e.ad.scale(h,h,[1,-1,1]),e.ad.translate(h,h,[-1,-1,0]),e.ad.scale(h,h,[2/this.width,2/this.height,1]),this.glCoordMatrix=h,this.pixelMatrix=e.ad.multiply(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},h=e.ad.invert(new Float64Array(16),this.pixelMatrix),!h)throw new Error(\"failed to invert matrix\");if(this.pixelMatrixInverse=h,\"globe\"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.a$(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e._.transformMat4(t,t,n),this.globeRadius=this.worldSize/2/Math.PI-1;}else this.globeMatrix=h;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={};}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,o=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,a=[t,t,i];e._.scale(a,a,r),e._.scale(o,o,-1),e._.multiply(o,o,a);const n=e.ad.create();e.ad.translate(n,n,o),e.ad.scale(n,n,a),this.mercatorFogMatrix=n,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r);}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),o=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return [o.x/this.worldSize-i[0]*r,o.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),o=this._camera.position[2],r=t[2];let a=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(a=Math.min((i-o)/r,1)),this._camera.position=e._.scaleAndAdd([],this._camera.position,t,a),this._updateStateFromCamera();}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:o,bearing:r}=this._camera.getPitchBearing(),a=e.ax(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,n=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.ab(this._maxPitch)),s=Math.max((t[2]-a)/Math.cos(o),n),l=this._zoomFromMercatorZ(s);e._.scaleAndAdd(t,t,i,s),this._pitch=e.at(o,e.ab(this.minPitch),e.ab(this.maxPitch)),this.angle=e.au(r,-Math.PI,Math.PI),this._setZoom(e.at(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.Y(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/(e*this.tileSize))}zoomFromMercatorZAdjusted(t){let i=0,o=e.aU,r=0,a=1/0;for(;o-i>1e-6&&o>i;){const e=i+.5*(o-i),n=this.tileSize*Math.pow(2,e),s=this.getCameraToCenterDistance(this.projection,e,n),l=this.scaleZoom(s/(t*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return !0}return !1}isHorizonVisible(){return this.pitch+e.b0(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const o=e._.length(e._.sub([],this._camera.position,t)),r=this._zoomFromMercatorZ(o)+i;return o-this._mercatorZfromZoom(r)}getCameraPoint(){if(\"globe\"===this.projection.name){const t=function([t,i,o],r){const a=[t,i,o,1];e.aA.transformMat4(a,a,r);const n=a[3]=Math.max(a[3],1e-6);return a[0]/=n,a[1]/=n,a[2]/=n,a}([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,o=this.worldSize){const r=e.aX(t,i,this.width,this.height,1024),a=t.pixelSpaceConversion(this.center.lat,o,r);let n=.5/Math.tan(.5*this._fov)*this.height*a;return this.isOrthographic&&(n=_i(1,n,ui(this.pitch>=15?1:this.pitch/15))),n}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,\"meters\"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return \"globe\"===this.projection.name&&e.ad.multiply(t,t,this.globeMatrix),t}getFrustum(t){return e.aM.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,\"meters\"===this.projection.zAxisUnit)}}const pi={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11},fi=(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 o=t.transform,r=Math.max(Math.abs(o._zoom-(t.minCutoffZoom-1)),1),a=o.isLODDisabled(!1)?e.$(60,45,o.pitch):e.$(30,15,o.pitch),n=o._farZ-o._nearZ,s=i*o.height,l=((1-(c=a))*o.cameraToCenterDistance+c*(o._farZ+s))*r;var c;return {shouldRenderCutoff:a<1,uniformValues:{u_cutoff_params:[o._nearZ,o._farZ,(l-o._nearZ)/n,(l-s-o._nearZ)/n]}}},mi={cascadeCount:2,shadowMapResolution:2048};class gi{constructor(e,t){this.aabb=e,this.lastCascade=t;}}class vi{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 gi(t,null);}clear(){this.receivers={};}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,o){const r=e.b6.fromPoints(t.points);let a=0;for(const t in this.receivers){const n=this.receivers[t];if(!n)continue;if(!r.intersectsAabb(n.aabb))continue;n.aabb.min=r.closestPoint(n.aabb.min),n.aabb.max=r.closestPoint(n.aabb.max);const s=n.aabb.getCorners();for(let t=0;t1||n[1]<-1||n[1]>1){r=!1;break}}if(n.lastCascade=t,a=Math.max(a,t),r)break}}return a+1}}class xi{constructor(t){this.painter=t,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new vi,this._depthMode=new e.ae(t.context.gl.LEQUAL,e.ae.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,t.tp.registerParameter(this,[\"Shadows\"],\"_forceDisable\",{label:\"forceDisable\"},(()=>{this.painter.style.map.triggerRepaint();})),t.tp.registerParameter(mi,[\"Shadows\"],\"cascadeCount\",{min:1,max:2,step:1}),t.tp.registerParameter(mi,[\"Shadows\"],\"shadowMapResolution\",{min:32,max:2048,step:32}),t.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 o=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=o.style.order.reduce(((e,i)=>{const r=o.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)}),0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const a=o.context,n=mi.shadowMapResolution,s=mi.shadowMapResolution;if(0===this._cascades.length||mi.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,h=3*c,_=new Float64Array(16);for(let i=0;i=0)return {};const a=function(t,i,o){const r=o/(1<0&&(e._.add(a[1],a[1],[r[0]*n,0,0]),e._.add(a[2],a[2],[r[0]*n,0,0])),r[1]<0?(e._.add(a[0],a[0],[0,r[1]*n,0]),e._.add(a[1],a[1],[0,r[1]*n,0])):r[1]>0&&(e._.add(a[2],a[2],[0,r[1]*n,0]),e._.add(a[3],a[3],[0,r[1]*n,0]));const s={};return s.vertices=a,s.planes=[yi(a[1],a[0],a[4]),yi(a[2],a[1],a[5]),yi(a[3],a[2],a[6]),yi(a[0],a[3],a[7])],s}addShadowReceiver(t,i,o){this._receivers.add(t,e.b6.fromTileIdAndHeight(t,i,o));}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function yi(t,i,o){const r=e._.sub([],o,i),a=e._.sub([],t,i),n=e._.cross([],r,a),s=e._.length(n);return 0===s?[0,0,1,0]:(e._.scale(n,n,1/s),[n[0],n[1],n[2],-e._.dot(n,i)])}function bi(t){const i=t.properties.get(\"direction\"),o=e.ac(i.x,i.y,i.z);o[2]=e.at(o[2],0,75);const r=e.b7([o[0],o[1],o[2]]);return e._.fromValues(r.x,r.y,r.z)}function wi(t,i,o){const r=i.properties.get(\"color\"),a=i.properties.get(\"intensity\"),n=i.properties.get(\"direction\"),s=[n.x,n.y,n.z],l=o.properties.get(\"color\"),c=o.properties.get(\"intensity\"),h=Math.max(e._.dot([0,0,1],s),0),_=[0,0,0];e._.scale(_,l.toRenderColor(t.getLut(i.scope)).toArray01Linear().slice(0,3),c);const u=[0,0,0];return e._.scale(u,r.toRenderColor(t.getLut(o.scope)).toArray01Linear().slice(0,3),h*a),e.b8([_[0]>0?_[0]/(_[0]+u[0]):0,_[1]>0?_[1]/(_[1]+u[1]):0,_[2]>0?_[2]/(_[2]+u[2]):0])}function Ti(t,i,o,r,a,n){const s=t.zoom,l=t.scale,c=t.worldSize,h=1/c,_=t.aspect,u=Math.sqrt(1+_*_)*Math.tan(.5*t.fovX),d=u*u,p=r-o,f=r+o;let m,g;d>p/f?(m=r,g=r*u):(m=.5*f*(1+d),g=.5*Math.sqrt(p*p+2*(r*r+o*o)*d+f*f*d*d));const v=t.projection.pixelsPerMeter(t.center.lat,c),x=t._camera.getCameraToWorldMercator(),y=[0,0,-m*h];e._.transformMat4(y,y,x);let b=g*h;const w=t._edgeInsets;if(!(0===w.left&&0===w.top&&0===w.right&&0===w.bottom||w.left===w.right&&w.top===w.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,\"meters\"===t.projection.zAxisUnit?v:1),a=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,o,r);a[8]=2*-t.centerOffset.x/t.width,a[9]=2*t.centerOffset.y/t.height;const n=new Float64Array(16);e.ad.mul(n,a,i);const h=new Float64Array(16);e.ad.invert(h,n);const _=e.aM.fromInvProjectionMatrix(h,c,s,!0);for(const i of _.points){const o=((T=i)[0]/=l,T[1]/=l,T[2]=e.ax(T[2],t._center.lat),T);b=Math.max(b,e._.len(e._.subtract([],y,o)));}}var T;b*=a/(a-1);const E=Math.acos(i[2]),C=Math.atan2(-i[0],-i[1]),S=new Ht;S.position=y,S.setPitchBearing(E,C);const I=S.getWorldToCamera(c,v),L=b*c,P=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*L),A=S.getCameraToClipOrthographic(-L,L,-L,L,P,(L+n*v)/i[2]),R=new Float64Array(16);e.ad.multiply(R,A,I);const D=e._.fromValues(Math.floor(1e6*y[0])/1e6*c,Math.floor(1e6*y[1])/1e6*c,0),M=.5*a,z=[0,0,0];e._.transformMat4(z,D,R),e._.scale(z,z,M);const O=[Math.floor(z[0]),Math.floor(z[1]),Math.floor(z[2])],F=[0,0,0];e._.sub(F,z,O),e._.scale(F,F,-1/M);const B=new Float64Array(16);return e.ad.identity(B),e.ad.translate(B,B,F),e.ad.multiply(R,B,R),[R,L]}function Ei(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Ci=new class{constructor(){this.operations={};}newMorphing(e,t,i,o,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:o,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()}},Si={0:null,1:\"TERRAIN_VERTEX_MORPHING\"};function Ii(e,t,i){if(0===t)return 0;const o=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*o}function Li(e,t){const i=1<({u_matrix:e});function Ai(t,i,o,r,a){if(a>0){const n=e.e.now(),s=(n-t.timeAdded)/a,l=i?(n-i.timeAdded)/a:-1,c=o.getSource(),h=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),_=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),u=_&&t.refreshedUponExpiration?1:e.at(_?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-u}:{opacity:u,mix:0}}return {opacity:1,mix:0}}class Ri extends kt{constructor(t,i,o,r){super(t,i,o,r),this.type=\"raster-array\",this.maxzoom=22,this._options=e.W({type:\"raster-array\"},i);}triggerRepaint(e){const t=this.map.painter._terrain,i=this.map.style.getSourceCache(this.id);t&&t.enabled&&i&&t._clearRenderCacheForTile(i.id,e.tileID),this.map.triggerRepaint();}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(o,e.R.Tile);t.requestParams=r,t.actor||(t.actor=this.dispatcher.getActor()),t.request=t.fetchHeader(void 0,((e,o,r,a)=>{if(delete t.request,t.aborted)return t.state=\"unloaded\",i(null);if(e){if(20===e.code)return;return t.state=\"errored\",i(e)}this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:r,expires:a}),t.state=\"empty\",i(null);}));}unloadTile(t,i){const o=t.texture;o&&o instanceof e.T?(t.destroy(!0),this.map.painter.saveTileTexture(o)):(t.destroy(),t.flushQueues(),t._isHeaderLoaded=!1,delete t._mrt,delete t.textureDescriptor),t.fbo&&(t.fbo.destroy(),delete t.fbo),delete t.request,delete t.requestParams,delete t.neighboringTiles,t.state=\"unloaded\";}prepareTile(t,i,o){t._isHeaderLoaded&&(\"empty\"!==t.state&&(t.state=\"reloading\"),t.fetchBand(i,o,((i,o)=>{if(i)return t.state=\"errored\",this.fire(new e.d(i)),void this.triggerRepaint(t);o&&(t.setTexture(o,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,o=i&&i.bands&&i.bands;return o?o[0]:0}getTextureDescriptor(t,i,o){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let a=null;i instanceof e.bk?a=i.paint.get(\"raster-array-band\"):i instanceof e.bl&&(a=i.paint.get(\"raster-particle-array-band\"));const n=a||this.getInitialBand(r);if(null!=n)if(t.textureDescriptor){if(!t.updateNeeded(r,n)||o)return Object.assign({},t.textureDescriptor,{texture:t.texture})}else this.prepareTile(t,r,n);}}const Di={vector:Nt,raster:kt,\"raster-dem\":class extends kt{constructor(t,i,o,r){super(t,i,o,r),this.type=\"raster-dem\",this.maxzoom=22,this._options=e.W({type:\"raster-dem\"},i),this.encoding=i.encoding||\"mapbox\";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,o){e&&(t.state=\"errored\",i(e)),o&&(t.dem=o,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state=\"loaded\",i(null));}t.request=e.h(this.map._requestManager.transformRequest(o,e.R.Tile),function(o,a,n,s){if(delete t.request,t.aborted)t.state=\"unloaded\",i(null);else if(o)t.state=\"errored\",i(o);else if(a){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:s});const i=ImageBitmap&&a instanceof ImageBitmap&&e.bi(),o=1-(a.width-e.bj(a.width))/2;o<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?a:e.e.getImageData(a,o),c={uid:t.uid,coord:t.tileID,source:this.id,scope:this.scope,rawImageData:l,encoding:this.encoding,padding:o};t.actor&&\"expired\"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send(\"loadDEMTile\",c,r.bind(this),void 0,!0));}}.bind(this));}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,a=0===i.x?t.wrap-1:t.wrap,n=(i.x+1+o)%o,s=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.aL(t.overscaledZ,a,i.z,r,i.y).key]={backfilled:!1},l[new e.aL(t.overscaledZ,s,i.z,n,i.y).key]={backfilled:!1},i.y>0&&(l[new e.aL(t.overscaledZ,a,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aL(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aL(t.overscaledZ,s,i.z,n,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.d(i));else {const i={dataType:\"source\",sourceDataType:this._metadataFired?\"content\":\"metadata\"};this._collectResourceTiming&&o&&o.resourceTiming&&o.resourceTiming[this.id]&&(i.resourceTiming=o.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.f(\"data\",i)),this._partialReload=!1,this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(t,i){const o=t.actor?\"reloadTile\":\"loadTile\";t.actor=this.actor;const r=this.map.style?this.map.style.getLut(this.scope):null,a=this._partialReload,n={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:r?{image:r.image.clone()}:null,scope:this.scope,pixelRatio:e.e.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,partial:a};t.request=this.actor.send(o,n,((e,r)=>a&&!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\"===o),i(null)))),void 0,\"loadTile\"===o);}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 e.W({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends e.bm{constructor(e,t,i,o){super(e,t,i,o),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.bn(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.d(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.d(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.RGBA),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.bm,model:class extends e.E{constructor(e,t,i,o){super(),this.id=e,this.type=\"model\",this.models=[],this._loaded=!1,this._options=t;}load(){const t=[];for(const i in this._options.models){const o=this._options.models[i],r=e.l(this.map._requestManager.transformRequest(o.uri,e.R.Model).url).then((t=>{if(!t)return;const r=e.c(t),a=new e.M(i,o.position,o.orientation,r);a.computeBoundsAndApplyParent(),this.models.push(a);})).catch((t=>{this.fire(new e.d(new Error(`Could not load model ${i} from ${o.uri}: ${t.message}`)));}));t.push(r);}return Promise.allSettled(t).then((()=>{this._loaded=!0,this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"}));})).catch((t=>{this.fire(new e.d(new Error(`Could not load models: ${t.message}`)));}))}onAdd(e){this.map=e,this.load();}hasTransition(){return !1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return {type:\"model\"}}},\"batched-model\":class extends e.E{constructor(e,t,i,o){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(o);}onAdd(e){this.map=e,this.load();}load(t){this._loaded=!1,this.fire(new e.f(\"dataloading\",{dataType:\"source\"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,o=this.map._worldview;this._tileJSONRequest=Ft(this._options,this.map._requestManager,i,o,((r,a)=>{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}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.d(r))):a&&(e.W(this,a),a.bounds&&(this.tileBounds=new Bt(a.bounds,this.minzoom,this.maxzoom)),e.an(a.tiles,this.map._requestManager._customAccessToken),this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.f(\"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 o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,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};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,a.bind(this));}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send(\"loadTile\",r,a.bind(this),void 0,!0);function a(e,o){return t.aborted?i(null):e&&404!==e.status?i(e):(o&&(o.resourceTiming&&(t.resourceTiming=o.resourceTiming),this.map._refreshExpiredTiles&&t.setExpiryData(o),t.buckets={...t.buckets,...o.buckets},o.featureIndex&&(t.latestFeatureIndex=o.featureIndex)),t.state=\"loaded\",void i(null))}}serialize(){return e.W({},this._options)}},canvas:class extends e.bm{constructor(t,i,o,r){super(t,i,o,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.d(new e.V(`sources.${t}`,null,'\"coordinates\" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.d(new e.V(`sources.${t}`,null,'missing required property \"coordinates\"'))),i.animate&&\"boolean\"!=typeof i.animate&&this.fire(new e.d(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.d(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.d(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.d(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.bo||this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.T(i,this.canvas,i.gl.RGBA,{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,o,r){super(),this.id=t,this.type=\"custom\",this._dataType=\"raster\",this._dispatcher=o,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.d(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.d(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Bt(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),e.W(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.f(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.f(\"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:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:o,z:r}=e.tileID.canonical,a=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:o,z:r},{signal:a.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=>{20!==i.code&&(e.state=\"errored\",t(i));})),e.request.cancel=()=>a.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:o}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:o});}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.al(this.id,this.scope);this.map.style.clearSource(t);}_update(){this.fire(new e.f(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}}},Mi=function(t,i,o,r){const a=new Di[i.type](t,i,o,r);if(a.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${a.id}`);return e.bp([\"load\",\"abort\",\"unload\",\"serialize\",\"prepare\"],a),a};class zi extends e.bv{constructor(t){const i={type:\"raster-dem\",maxzoom:t.transform.maxZoom},o=new e.bw(e.bx(),null),r=Mi(\"mock-dem\",i,o,t.style);super(\"mock-dem\",r,!1),r.setEventedParent(this),this._sourceLoaded=!0;}_loadTile(e,t){e.state=\"loaded\",t(null);}}class Oi extends e.bv{constructor(t){const i=Mi(\"proxy\",{type:\"geojson\",maxzoom:t.transform.maxZoom},new e.bw(e.bx(),null),t.style);super(\"proxy\",i,!1),i.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}update(t,i,o){if(t.freezeTileCoverage)return;this.transform=t;const r=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,o)=>{if(i[o.key]=\"\",!this._tiles[o.key]){const i=new e.by(o,this._source.tileSize*o.overscaleFactor(),t.tileZoom);i.state=\"loaded\",this._tiles[o.key]=i;}return i}),{});for(const e in this._tiles)e in r||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e]);}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e];}}deallocRenderCache(){this.renderCache.forEach((e=>e.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={};}}class Fi extends e.aL{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 Bi extends e.bq{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[o,r,a]=function(t){const i=new e.bt,o=new e.bu,r=131;i.reserve(17161),o.reserve(33800);const a=e.a3/128,n=e.a3+a/2,s=n+a;for(let t=-a;tn||t<0||t>n?24575:0,a=e.at(Math.round(o),0,e.a3),s=e.at(Math.round(t),0,e.a3);i.emplaceBack(a+r,s);}const l=(e,t)=>{const i=t*r+e;o.emplaceBack(i+1,i,i+r),o.emplaceBack(i+r,i+r+1,i+1);};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return [0,129].forEach((e=>{for(let t=0;t<130;t++)l(t,e),l(e,t);})),[i,o,32768]}(),n=t.context;this.gridBuffer=n.createVertexBuffer(o,e.br.members),this.gridIndexBuffer=n.createIndexBuffer(r),this.gridSegments=e.b.simpleSegment(0,0,o.length,r.length),this.gridNoSkirtSegments=e.b.simpleSegment(0,0,o.length,a),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Oi(i.map),this.orthoMatrix=e.ad.create(),e.ad.ortho(this.orthoMatrix,\"globe\"===this.painter.transform.projection.name?.015:0,e.a3,0,e.a3,0,1);const s=n.gl;this._overlapStencilMode=new e.ag({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new zi(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,o){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,a=0===t.terrain.drapeRenderMode,n=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.e.now();const s=t.terrain&&t.terrain.scope,l=r.get(\"source\"),c=a?this._mockSourceCache:t.getSourceCache(l,s);if(!c)return void e.w(`Couldn't find terrain source \"${l}\".`);if(this.sourceCache=c,this._exaggeration=n?this.calculateExaggeration(i):r.get(\"exaggeration\"),!i.projection.requiresDraping&&n&&0===this._exaggeration)return void this._disable();this.enabled=!0;const h=()=>{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,h(),this._initializing=!0),h(),i.updateElevation(!0,o),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0,this._previousZoom=i.zoom;}else this._disable();}calculateExaggeration(t){const i=this._previousCameraAltitude,o=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=o;const r=null!=i?o-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const a=t.zoom,n=this._style.terrain;if(!this._previousUpdateTimestamp)return n.getExaggeration(a);let s=a-this._previousZoom;const l=this._previousUpdateTimestamp;let c=a;null!=this._evaluationZoom&&(c=this._evaluationZoom,Math.abs(a-c)>.5&&(s=.5*(a-c+s)),s*r<0&&(c+=s)),this._evaluationZoom=c;const h=n.getExaggeration(c),_=h===n.getExaggeration(Math.max(0,c-.1));if(_&&Math.abs(h-this._exaggeration)<.01)return h;let u=Math.min(.1,.00375*(this._updateTimestamp-l));return (_||h<.1||Math.abs(s)<1e-4)&&(u=Math.min(.2,4*u)),e.a2(this._exaggeration,h,u)}resetTileLookupCache(e){this._findCoveringTileCache[e]={};}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_onStyleDataEvent(e){e.coord&&\"source\"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):\"style\"===e.dataType&&(this.invalidateRenderCache=!0,this._evaluationZoom=void 0,this._previousUpdateTimestamp=void 0,this._previousCameraAltitude=void 0);}_disable(){if(this.enabled&&(this.enabled=!1,this._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._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((e=>e.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),this.framebufferCopyTexture&&this.framebufferCopyTexture.destroy();}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this.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,o=this.painter.transform;this._initializing&&(this._initializing=0===o._centerAltitude&&-1===this.getAtPointOrZero(e.Y.fromLngLat(o.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=o.calculateProjMatrix(t.toUnwrapped()),t}));!function(t,i){const o=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(o.x,o.y);t.sort(((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const o=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={};})),this.terrainTileForTile={};const n=this._style._mergedSourceCaches;for(const e in n){const i=n[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],a),i.usedForTerrain)continue;const o=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(o);}this.proxiedCoords[i.id]=r.map((e=>new Fi(e,e.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(a),this.renderingToTexture=!1;const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in s||(this._visibleDemTiles.push(t),s[i]=i);}}_assignTerrainTiles(e){this._initializing||e.forEach((e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t);}));}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const i in this.terrainTileForTile){const o=this.terrainTileForTile[i],r=o.dem;!r||o.demTexture&&!o.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),zt(this.painter,o,r));}}_prepareDemTileUniforms(e,t,i,o){if(!t||null==t.demTexture)return !1;const r=e.tileID.canonical,a=Math.pow(2,t.tileID.canonical.z-r.z),n=o||\"\";return i[`u_dem_tl${n}`]=[r.x*a%1,r.y*a%1],i[`u_dem_scale${n}`]=a,!0}get emptyDEMTexture(){return !this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const o=new e.i({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.T(t,o,i.RGBA,{premultiply:!1});}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){if(!this.enabled)return 0;let e=0;const t=this._visibleDemTiles.reduce(((t,i)=>{if(!i.dem)return t;const o=i.dem.tree.minimums[0];return o>0&&e++,t+o}),0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const o=this._getLoadedAreaMinimum(),[r,a]=(()=>{const t=new e.bz({width:1,height:1},new Float32Array([o]));return [i.R32F,t]})();this._emptyDEMTextureDirty=!1;let n=this._emptyDEMTexture;return n?n.update(a,{premultiply:!1}):n=this._emptyDEMTexture=new e.T(t,a,r,{premultiply:!1}),n}setupElevationDraw(t,i,o){const r=this.painter.context,a=r.gl,n={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:[2,0],u_exaggeration:0};n.u_exaggeration=this.exaggeration();let s=null,l=null,c=1;if(o&&o.morphing&&this._useVertexMorphing){const e=o.morphing.srcDemTile,i=o.morphing.dstDemTile;c=o.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,n,\"_prev\")&&(l=e),this._prepareDemTileUniforms(t,i,n)&&(s=i));}const h=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?a.LINEAR:a.NEAREST;let _=null;var u,d;if(this.enabled?l&&s?(_=s.demTexture,r.activeTexture.set(a.TEXTURE4),l.demTexture.bind(h(l),a.CLAMP_TO_EDGE),n.u_dem_lerp=c):(s=this.terrainTileForTile[t.tileID.key],_=this._prepareDemTileUniforms(t,s,n)?s.demTexture:this.emptyDEMTexture):_=this.emptyDEMTexture,r.activeTexture.set(a.TEXTURE2),_&&(n.u_dem_size=1===(u=_).size[0]?1:u.size[0]-2,_.bind(h(s),a.CLAMP_TO_EDGE)),r.activeTexture.set(a.TEXTURE3),o&&o.useDepthForOcclusion&&this.painter.terrainDepthTexture&&this.painter.terrainDepthFBO?(this.painter.terrainDepthTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),n.u_depth_size_inv=[1/this.painter.terrainDepthFBO.width,1/this.painter.terrainDepthFBO.height],n.u_depth_range_unpack=[2/((d=this.painter.depthRangeFor3D)[1]-d[0]),-1-2*d[0]/(d[1]-d[0])]):(this.emptyDepthBufferTexture.bind(a.NEAREST,a.CLAMP_TO_EDGE),n.u_depth_range_unpack=[2,0]),r.activeTexture.set(a.TEXTURE0),o&&o.useMeterToDem&&s){const t=(1<{if(c===i)return;const o=[Si[i],\"PROJECTION_GLOBE_VIEW\"];_&&o.push(\"CUSTOM_ANTIALIASING\");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram(\"globeRaster\",{defines:o,overrideFog:r}),c=i;},d=t.colorModeForRenderPass(),p=new e.ae(s.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);Ci.update(a);const f=e.bb(h),m=[e.aj(h.center.lng),e.ak(h.center.lat)],g=t.globeSharedBuffers,v=[h.width*e.e.devicePixelRatio,h.height*e.e.devicePixelRatio],x=Float32Array.from(h.globeMatrix),y={useDenormalizedUpVectorScale:!0};{const h=t.transform,_=Ii(h.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const b=s.TRIANGLES;for(const c of r){const r=o.getTile(c),w=e.ag.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];Ei(T,E)&&Ci.newMorphing(c.key,T,E,a,250),n.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const C=Ci.getMorphValuesForProxy(c.key),S=C?1:0;C&&e.o(y,{morphing:{srcDemTile:C.from,dstDemTile:C.to,phase:e.b9(C.phase)}});const I=e.bc(c.canonical),L=e.bd(I.getCenter().lat),P=e.be(c.canonical,I,L,h.worldSize/h._pixelsPerMercatorPixel),A=e.bf(e.bg(c.canonical)),R=Gt(h.expandedFarZProjMatrix,x,f,A,e.a1(h.zoom),m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,_,h._farZ,P);if(u(c,S),l&&(i.setupElevationDraw(r,l,y),t.uploadCommonUniforms(n,l,c.toUnwrapped()),g)){const[i,o,r]=g.getGridBuffers(L,0!==_);l.draw(t,b,p,w,d,e.af.backCCW,R,\"globe_raster\",i,o,r);}}}if(g&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const a=[\"GLOBE_POLES\",\"PROJECTION_GLOBE_VIEW\"];_&&a.push(\"CUSTOM_ANTIALIASING\"),l=t.getOrCreateProgram(\"globeRaster\",{defines:a});for(const a of r){const{x:r,y:c,z:_}=a.canonical,u=0===c,f=c===(1<<_)-1,[x,b,w,T]=g.getPoleBuffers(_,!1);if(T&&(u||f)){const c=o.getTile(a);n.activeTexture.set(s.TEXTURE0),c.texture&&c.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);let g=e.bh(_,r,h);const E=e.bf(e.bg(a.canonical)),C=(i,o)=>i.draw(t,s.TRIANGLES,p,e.ag.disabled,d,e.af.disabled,Gt(h.expandedFarZProjMatrix,g,g,E,0,m,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,v,0,h._farZ),\"globe_pole_raster\",o,w,T);i.setupElevationDraw(c,l,y),t.uploadCommonUniforms(n,l,a.toUnwrapped()),u&&t.renderDefaultNorthPole&&C(l,x),f&&t.renderDefaultSouthPole&&(g=e.ad.scale(e.ad.create(),g,[1,-1,1]),C(l,b));}}}}(t,i,o,r,a);else {const n=t.context,s=n.gl;let l,c;const h=t.shadowRenderer,_=fi(t,t.longestCutoffRange),u=e=>{if(c===e)return;const i=[];i.push(Si[e]),_.shouldRenderCutoff&&i.push(\"RENDER_CUTOFF\"),l=t.getOrCreateProgram(\"terrainRaster\",{defines:i}),c=e;},d=t.colorModeForRenderPass(),p=new e.ae(s.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);Ci.update(a);const f=t.transform,m=Ii(f.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let g=[0,0,0];if(h){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(g=wi(t.style,e,i));}{c=-1;const v=s.TRIANGLES,[x,y]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=o.getTile(c),b=e.ag.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Ei(w,T)&&Ci.newMorphing(c.key,w,T,a,250),n.activeTexture.set(s.TEXTURE0),r.texture&&r.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const E=Ci.getMorphValuesForProxy(c.key),C=E?1:0;let S;E&&(S={morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.b9(E.phase)}});const I=Ut(c.projMatrix,Li(c.canonical,f.renderWorldCopies)?m/10:m,g);if(u(C),!l)continue;i.setupElevationDraw(r,l,S);const L=c.toUnwrapped();h&&h.setupShadows(L,l),t.uploadCommonUniforms(n,l,L,null,_),l.draw(t,v,p,b,d,e.af.backCCW,I,\"terrain_raster\",i.gridBuffer,x,y);}}}}(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,o=this.painter.context,r=this.proxySourceCache,a=this.proxiedCoords[r.id],n=this._drapedRenderBatches.shift(),s=i.style.order,l=[];let c=0;for(const h of a){const a=r.getTileByID(h.proxyTileKey),_=r.proxyCachedFBO[h.key]?r.proxyCachedFBO[h.key][t]:void 0,u=void 0!==_?r.renderCache[_]:this.pool[c++],d=void 0!==_;if(a.texture=u.tex,d&&!u.dirty){l.push(a.tileID);continue}let p;o.bindFramebuffer.set(u.fb.framebuffer),this.renderedToTile=!1,u.dirty&&(o.clear({color:e.C.transparent,stencil:0}),u.dirty=!1);for(let e=n.start;e<=n.end;++e){const t=i.style._mergedLayers[s[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),a=r?this.proxyToSource[h.key][r.id]:[h];if(!a)continue;const n=a;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,a,t,r),p=r?r.id:null),i.renderLayer(i,r,t,n);}if(0===this._drapedRenderBatches.length)for(const e of this._pendingGroundEffectLayers){const t=i.style._mergedLayers[s[e]];if(t.isHidden(i.transform.zoom))continue;const r=i.style.getLayerSourceCache(t),a=r?this.proxyToSource[h.key][r.id]:[h];if(!a)continue;const n=a;o.viewport.set([0,0,u.fb.width,u.fb.height]),p!==(r?r.id:null)&&(this._setupStencil(u,a,t,r),p=r?r.id:null),i.renderLayer(i,r,t,n);}this.renderedToTile?(u.dirty=!0,l.push(a.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(l));}return this.renderToBackBuffer(l),this.renderingToTexture=!1,o.bindFramebuffer.set(null),o.viewport.set([0,0,i.width,i.height]),n.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,o=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 o=this._visibleDemTiles.filter((e=>e.dem)).map((o=>{const r=o.tileID,a=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)));for(const r of o){if(null==r.t)return null;const o=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=o)return o}return null}_createFBO(){const t=this.painter.context,i=t.gl,o=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:o[0],height:o[1],data:null},i.RGBA);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const a=t.createFramebuffer(o[0],o[1],!0,null);return a.colorAttachment.set(r.texture),a.depthAttachment=new oe(t,a.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,o[0],o[1]),this._stencilRef=0,a.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):a.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:a,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._mergedLayers[e],i=t.isHidden(this.painter.transform.zoom);return \"custom\"===t.type?!i&&t.shouldRedrape():!i&&t.hasTransition()}))}_clearLineLayersFromRenderCache(){let t=!1;for(const e of this._style.getSources())if(e instanceof Nt){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=o;}_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 a=i[r];if(t.getTileByID(a.key),void 0!==t.proxyCachedFBO[a.key]){const i=e[a.key],r=this.proxyToSource[a.key];let n=0;for(const e in r){const t=r[e],a=i[e];if(!a||a.length!==t.length||t.some(((t,i)=>t!==a[i]||o[e]&&o[e].hasOwnProperty(t.key)))){n=-1;break}++n;}for(const e in t.proxyCachedFBO[a.key])t.renderCache[t.proxyCachedFBO[a.key][e]].dirty=n<0||n!==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 o of i){if(t.proxyCachedFBO[o.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[o.key]={},t.proxyCachedFBO[o.key][e.start]=i,t.renderCache[i].dirty=!0);}this._tilesDirty={};}_setupStencil(e,t,i,o){if(!o||!this._sourceTilesOverlap[o.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,a=r.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let n;if(i.isTileClipped())n=t.length,this._overlapStencilMode.test={func:a.EQUAL,mask:255},this._overlapStencilType=\"Clip\";else {if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);n=1,this._overlapStencilMode.test={func:a.GREATER,mask:255},this._overlapStencilType=\"Mask\";}this._stencilRef+n>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=n,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref);}clipOrMaskOverlapStencilType(){return \"Clip\"===this._overlapStencilType||\"Mask\"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?(\"Clip\"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.ag.disabled}_renderTileClippingMasks(t,i){const o=this.painter,r=this.painter.context,a=r.gl;o._tileClippingMaskIDs={},r.setColorMode(e.a.disabled),r.setDepthMode(e.ae.disabled);const n=o.getOrCreateProgram(\"clippingMask\");for(const r of t){const t=o._tileClippingMaskIDs[r.key]=--i;n.draw(o,a.TRIANGLES,e.ae.disabled,new e.ag({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),e.a.disabled,e.af.disabled,Pi(r.projMatrix),\"$clipping\",o.tileExtentBuffer,o.quadTriangleIndexBuffer,o.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 o=[t.x,t.y,1,1];e.aA.transformMat4(o,o,i.pixelMatrixInverse),e.aA.scale(o,o,1/o[3]),o[0]/=i.worldSize,o[1]/=i.worldSize;const r=i._camera.position,a=e.ax(1,i.center.lat),n=[r[0],r[1],r[2]/a,0],s=e._.subtract([],o.slice(0,3),n);e._.normalize(s,s);const l=this.raycast(n,s,this._exaggeration);return null!==l&&l?(e._.scaleAndAdd(n,n,s,l),n[3]=n[2],n[2]*=a,n):null}_setupProxiedCoordsForOrtho(t,i,o){if(t.getSource()instanceof e.bm)return this._setupProxiedCoordsForImageSource(t,i,o);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],a=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ));}_setupProxiedCoordsForImageSource(t,i,o){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],a=this.proxyCoords,n=t.getSource(),s=n.tileID;if(!s)return;const l=new e.P(s.x,s.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)}),h=(t,i)=>{const o=t.wrap+t.canonical.x/(1<n+c.max.x||r+as+c.max.y};for(let e=0;ee.key===i.tileID.key));if(e)return e}if(i.tileID.key!==t.key){const o=t.canonical.z-i.tileID.canonical.z;let a,n,s;r=e.ad.create();const l=i.tileID.wrap-t.wrap<0?(a=e.a3>>o,n=a*((i.tileID.canonical.x<=r){const o=t.canonical.z-r;i.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,i.transform.tileZoom),n=new e.aL(s,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o)):0!==o&&(s=r,n=new e.aL(s,t.wrap,r,t.canonical.x>>o,t.canonical.y>>o));}n.key!==t.key&&(c.push(n.key),o=i.getTile(n));}const h=e=>{c.forEach((t=>{r[t]=e;})),c.length=0;};for(s-=1;s>=l&&(!o||!o.hasData());s--){o&&h(o.tileID.key);const e=n.calculateScaledKey(s);if(o=i.getTileByID(e),o&&o.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):o=i.getTileByID(t);}return h(o?o.tileID.key:null),o&&o.hasData()?o: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 ki(t,i,o){const r=function(t,i,o){const r=e._.dot(i,t),a=e._.dot(o,[.2126,.7152,.0722]),n=(e,t,i)=>(1-i)*e+i*t,s=n(1-.3*Math.min(a,1),1,Math.min(r+1,1));return n(.92,1,Math.asin(e.at(i[2],-1,1))/Math.PI+.5)*s}(t,[0,0,1],i),a=[0,0,0];e._.scale(a,o.slice(0,3),r);const n=[0,0,0];e._.scale(n,i.slice(0,3),t[2]);const s=[0,0,0];return e._.add(s,a,n),e.b8(s)}const Ni=[\"fill\",\"fillOutline\",\"fillPattern\",\"line\",\"linePattern\",\"background\",\"backgroundPattern\",\"hillshade\",\"raster\"],Ui=[\"stars\",\"fillExtrusion\",\"fillExtrusionGroundEffect\",\"model\",\"symbolSDF\",\"symbolIcon\",\"symbolTextAndIcon\"];class Gi{static cacheKey(e,t,i,o){let r=`${t}${o?o.cacheKey:\"\"}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,o,r,a,n){const s=t.gl;this.program=s.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...n];const l=r?r.getBinderAttributes():[],c=(o.staticAttributes||[]).concat(l);let h=r?r.defines():[];h=h.concat(n.map((e=>`#define ${e}`)));const _=\"#version 300 es\\n\";let u=_+h.concat(\"precision mediump float;\",It,St.fragmentSource).join(\"\\n\");for(const e of o.fragmentIncludes)u+=`\\n${Et[e]}`;u+=`\\n${o.fragmentSource}`;let d=_+h.concat(\"precision highp float;\",It,St.vertexSource).join(\"\\n\");for(const e of o.vertexIncludes)d+=`\\n${Et[e]}`;d+=`\\n${o.vertexSource}`;const p=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(p,u),s.compileShader(p),s.attachShader(this.program,p);const f=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else {s.shaderSource(f,d),s.compileShader(f),s.attachShader(this.program,f),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.a7(t),u_dem_prev:new e.a7(t),u_dem_tl:new e.a8(t),u_dem_scale:new e.aa(t),u_dem_tl_prev:new e.a8(t),u_dem_scale_prev:new e.aa(t),u_dem_size:new e.aa(t),u_dem_lerp:new e.aa(t),u_exaggeration:new e.aa(t),u_depth:new e.a7(t),u_depth_size_inv:new e.a8(t),u_depth_range_unpack:new e.a8(t),u_meter_to_dem:new e.aa(t),u_label_plane_matrix_inv:new e.a6(t)}))(t)),n.includes(\"GLOBE\")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.aq(t),u_tile_tr_up:new e.aq(t),u_tile_br_up:new e.aq(t),u_tile_bl_up:new e.aq(t),u_tile_up_scale:new e.aa(t)}))(t)),n.includes(\"FOG\")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.a6(t),u_fog_range:new e.a8(t),u_fog_color:new e.as(t),u_fog_horizon_blend:new e.aa(t),u_fog_vertical_limit:new e.a8(t),u_fog_temporal_offset:new e.aa(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.aa(t),u_globe_transition:new e.aa(t),u_is_globe:new e.a7(t),u_viewport:new e.a8(t)}))(t)),n.includes(\"RENDER_CUTOFF\")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.as(t)}))(t)),n.includes(\"LIGHTING_3D_MODE\")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.aq(t),u_lighting_directional_dir:new e.aq(t),u_lighting_directional_color:new e.aq(t),u_ground_radiance:new e.aq(t)}))(t)),n.includes(\"RENDER_SHADOWS\")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.a6(t),u_light_matrix_1:new e.a6(t),u_fade_range:new e.a8(t),u_shadow_normal_offset:new e.aq(t),u_shadow_intensity:new e.aa(t),u_shadow_texel_size:new e.aa(t),u_shadow_map_resolution:new e.aa(t),u_shadow_direction:new e.aq(t),u_shadow_bias:new e.aq(t),u_shadowmap_0:new e.a7(t),u_shadowmap_1:new e.a7(t)}))(t));}}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,o,r,a,n,s,l,c,h){const _=t.options.wireframe;if(!1===_.terrain&&!1===_.layers2D&&!1===_.layers3D)return;const u=t.context;if(!(()=>!(!_.terrain||\"terrainRaster\"!==this.name&&\"globeRaster\"!==this.name)||!(!_.layers2D||t._terrain&&t._terrain.renderingToTexture||!Ni.includes(this.name))||!(!_.layers3D||!Ui.includes(this.name)))())return;const d=u.gl,p=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,a,u);if(!p)return;const f=[...this.fixedDefines];f.push(\"DEBUG_WIREFRAME\");const m=t.getOrCreateProgram(this.name,{config:this.configuration,defines:f});u.program.set(m.program);const g=(e,t,i)=>{if(t[e]&&i[e])for(const o in t[e])i[e][o]&&i[e][o].set(i.program,o,t[e][o].current);};c&&c.setUniforms(m.program,u,m.binderUniforms,s,{zoom:l}),g(\"fixedUniforms\",this,m),g(\"terrainUniforms\",this,m),g(\"globeUniforms\",this,m),g(\"fogUniforms\",this,m),g(\"lightsUniforms\",this,m),g(\"shadowUniforms\",this,m),p.bind(),u.setColorMode(new e.a([d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE],e.C.transparent,[!0,!0,!0,!1])),u.setDepthMode(new e.ae(i.func===d.LESS?d.LEQUAL:i.func,e.ae.ReadOnly,i.range)),u.setStencilMode(e.ag.disabled);const v=3*n.primitiveLength*2,x=3*n.primitiveOffset*2*2;h&&h>1?d.drawElementsInstanced(d.LINES,v,d.UNSIGNED_SHORT,x,h):d.drawElements(d.LINES,v,d.UNSIGNED_SHORT,x),a.bind(),u.program.set(this.program),u.setDepthMode(i),u.setStencilMode(o),u.setColorMode(r);}draw(e,t,i,o,r,a,n,s,l,c,h,_,u,d,p,f){const m=e.context,g=m.gl;if(this.failedToCreate)return;m.program.set(this.program),m.setDepthMode(i),m.setStencilMode(o),m.setColorMode(r),m.setCullFace(a);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,n[e]);d&&d.setUniforms(this.program,m,this.binderUniforms,_,{zoom:u});const v={[g.POINTS]:1,[g.LINES]:2,[g.TRIANGLES]:3,[g.LINE_STRIP]:1}[t],x=f&&f>0?1:void 0;for(const a of h.get()){const n=a.vaos||(a.vaos={});(n[s]||(n[s]=new Rt)).bind(m,this,l,d?d.getPaintVertexBuffers():[],c,a.vertexOffset,p||[],x),f&&f>1?g.drawElementsInstanced(t,a.primitiveLength*v,g.UNSIGNED_SHORT,a.primitiveOffset*v*2,f):c?g.drawElements(t,a.primitiveLength*v,g.UNSIGNED_SHORT,a.primitiveOffset*v*2):g.drawArrays(t,a.vertexOffset,a.vertexLength),t===g.TRIANGLES&&c&&this._drawDebugWireframe(e,i,o,r,c,a,_,u,d,f);}}}function ji(t,i){const o=Math.pow(2,i.tileID.overscaledZ),r=i.tileSize*Math.pow(2,t.transform.tileZoom)/o,a=r*(i.tileID.canonical.x+i.tileID.wrap*o),n=r*i.tileID.canonical.y;return {u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.bB(i,1,t.transform.tileZoom),u_pixel_coord_upper:[a>>16,n>>16],u_pixel_coord_lower:[65535&a,65535&n]}}const Vi=e.ad.create(),Wi=(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m)=>{const g=i.style.light,v=g.properties.get(\"position\"),x=[v.x,v.y,v.z],y=e.bC.create();\"viewport\"===g.properties.get(\"anchor\")&&(e.bC.fromRotation(y,-i.transform.angle),e._.transformMat3(x,x,y));const b=g.properties.get(\"color\"),w=i.transform,T={u_matrix:t,u_lightpos:x,u_lightintensity:g.properties.get(\"intensity\"),u_lightcolor:[b.r,b.g,b.b],u_vertical_gradient:+o,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Vi,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:a,u_edge_radius:n,u_flood_light_color:u,u_vertical_scale:d,u_flood_light_intensity:p,u_ground_shadow_factor:f,u_emissive_strength:m};return \"globe\"===w.projection.name&&(T.u_tile_id=[s.canonical.x,s.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_vertical_scale:i}),qi=(t,i,o,r,a,n,s,l,c,h,_,u,d,p)=>{const f=Wi(t,i,o,r,a,n,s,c,h,_,u,d,p,1,[0,0,0],0),m={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return e.W(f,ji(i,l),m)},Hi=(e,t)=>({u_matrix:e,u_emissive_strength:t}),$i=(t,i,o,r)=>e.W(Hi(t,i),ji(o,r)),Xi=(e,t,i)=>({u_matrix:e,u_world:i,u_emissive_strength:t}),Yi=(t,i,o,r,a)=>e.W($i(t,i,o,r),{u_world:a}),Ki=(t,i,o,r)=>{const a=e.a3/o.tileSize;return {u_matrix:t,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/a,i.pixelsToGLUnits[1]/a]}},Qi=(e,t,i=1)=>({u_matrix:e,u_color:t.toRenderColor(null),u_overlay:0,u_overlay_scale:i}),Ji=e.ad.create(),eo=(t,i,o,r,a,n,s)=>{const l=t.transform,c=\"globe\"===l.projection.name,h=c?e.bD(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.bB(o,1,n),_={u_matrix:i.projMatrix,u_extrude_scale:h,u_intensity:s,u_inv_rot_matrix:Ji,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){_.u_inv_rot_matrix=r,_.u_merc_center=a,_.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:o,u_merc_matrix:r,u_grid_matrix:a,u_tl_parent:n,u_scale_parent:h,u_fade_t:_.mix,u_opacity:_.opacity*u.paint.get(\"raster-opacity\"),u_image0:0,u_image1:1,u_brightness_low:u.paint.get(\"raster-brightness-min\"),u_brightness_high:u.paint.get(\"raster-brightness-max\"),u_saturation_factor:e.bE(u.paint.get(\"raster-saturation\")),u_contrast_factor:e.bF(u.paint.get(\"raster-contrast\")),u_spin_weights:ro(u.paint.get(\"raster-hue-rotate\")),u_perspective_transform:d,u_raster_elevation:p,u_zoom_transition:s,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:to(e.bG,m,v),u_colorization_offset:io(e.bG,g,v),u_color_ramp:f,u_texture_offset:[y/(x+2*y),x/(x+2*y)],u_texture_res:[x+2*y,x+2*y],u_emissive_strength:b});function ro(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 ao=.05,no=(e,t,i,o,r,a,n,s,l,c,h,_)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:o,u_grid_matrix:r,u_tl_parent:a,u_scale_parent:c,u_fade_t:h.mix,u_opacity:h.opacity,u_image0:0,u_image1:1,u_raster_elevation:_,u_zoom_transition:n,u_merc_center:s,u_cutoff_params:l}),so=(e,t,i,o,r,a,n,s,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:o,u_color_ramp:a,u_velocity_res:r,u_max_speed:n,u_uv_offset:s,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[ao,ao]}),lo=(e,t,i,o,r,a,n,s,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:o,u_max_speed:r,u_speed_factor:a,u_reset_rate:n,u_rand_seed:Math.random(),u_uv_offset:s,u_data_scale:[255*l[0],255*l[1]],u_data_offset:c,u_particle_pos_scale:1.1,u_particle_pos_offset:[ao,ao]}),co=e.ad.create(),ho=(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g,v)=>{const x=a.transform,y={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:x.getCameraToCenterDistance(m),u_rotate_symbol:+o,u_aspect_ratio:x.width/x.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_matrix:n,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+r,u_texsize:h,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:co,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:co,u_up_vector:[0,-1,0],u_color_adj_mat:g,u_icon_transition:v||0};return \"globe\"===m.name&&(y.u_tile_id=[_.canonical.x,_.canonical.y,1<<_.canonical.z],y.u_zoom_transition=u,y.u_inv_rot_matrix=p,y.u_merc_center=d,y.u_camera_forward=x._camera.forward(),y.u_ecef_origin=e.bH(x.globeMatrix,_.toUnwrapped()),y.u_tile_matrix=Float32Array.from(x.globeMatrix),y.u_up_vector=f),y},_o=(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g)=>e.W(ho(t,i,o,r,a,n,s,l,c,h,u,d,p,f,m,g),{u_gamma_scale:r?a.transform.getCameraToCenterDistance(g)*Math.cos(a.terrain?0:a.transform._pitch):1,u_device_pixel_ratio:e.e.devicePixelRatio,u_is_halo:+_,undefined:void 0}),uo=(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m)=>e.W(_o(t,i,o,r,a,n,s,l,!0,c,!0,_,u,d,p,f,m),{u_texsize_icon:h,u_texture_icon:1}),po=(e,t,i,o)=>({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:o}),fo=(t,i,o,r,a,n,s,l)=>e.W(function(t,i,o,r,a){const{width:n,height:s}=r.imageManager.getPixelSize(i),l=Math.pow(2,a.tileID.overscaledZ),c=a.tileSize*Math.pow(2,r.transform.tileZoom)/l,h=c*(a.tileID.canonical.x+a.tileID.wrap*l),_=c*a.tileID.canonical.y;return {u_image:0,u_pattern_tl:o.tl,u_pattern_br:o.br,u_texsize:[n,s],u_pattern_size:o.displaySize,u_tile_units_to_pixels:1/e.bB(a,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,_>>16],u_pixel_coord_lower:[65535&h,65535&_]}}(0,n,s,r,l),{u_matrix:t,u_emissive_strength:i,u_opacity:o}),mo=new Float32Array(e.ad.identity([])),go=(t,i,o,r,a,n,s,l,c,h,_,u,d,p=[0,0,0],f)=>{const m=a.style.light,g=m.properties.get(\"position\"),v=[-g.x,-g.y,g.z],x=e.bC.create();\"viewport\"===m.properties.get(\"anchor\")&&(e.bC.fromRotation(x,-a.transform.angle),e._.transformMat3(v,v,x));const y=\"MASK\"===_.alphaMode,b=m.properties.get(\"color\").toRenderColor(null),w=d.paint.get(\"model-ambient-occlusion-intensity\"),T=d.paint.get(\"model-color\").constantOr(e.C.white).toRenderColor(null),E=d.paint.get(\"model-color-mix-intensity\").constantOr(0);return {u_matrix:t,u_lighting_matrix:i,u_normal_matrix:o,u_node_matrix:r||mo,u_lightpos:v,u_lightintensity:m.properties.get(\"intensity\"),u_lightcolor:[b.r,b.g,b.b],u_camera_pos:p,u_opacity:n,u_baseTextureIsAlpha:0,u_alphaMask:+y,u_alphaCutoff:_.alphaCutoff,u_baseColorFactor:[s.r,s.g,s.b,s.a],u_emissiveFactor:[l[0],l[1],l[2],1],u_metallicFactor:c,u_roughnessFactor:h,u_baseColorTexture:pi.BaseColor,u_metallicRoughnessTexture:pi.MetallicRoughness,u_normalTexture:pi.Normal,u_occlusionTexture:pi.Occlusion,u_emissionTexture:pi.Emission,u_lutTexture:pi.LUT,u_color_mix:[T.r,T.g,T.b,E],u_aoIntensity:w,u_emissive_strength:u,u_occlusionTextureTransform:f||[0,0,0,0]}},vo=(e,t=mo,i=mo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),xo=(e,t,i,o,r)=>({u_matrix:Float32Array.from(e),u_anchorPos:t,u_screenSizePx:i,u_occluderSizePx:o,u_color:r}),yo={fillExtrusion:t=>({u_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.aa(t),u_opacity:new e.aa(t),u_edge_radius:new e.aa(t),u_ao:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_up_dir:new e.aq(t),u_height_lift:new e.aa(t),u_flood_light_color:new e.aq(t),u_vertical_scale:new e.aa(t),u_flood_light_intensity:new e.aa(t),u_ground_shadow_factor:new e.aq(t),u_emissive_strength:new e.aa(t)}),fillExtrusionDepth:t=>({u_matrix:new e.a6(t),u_edge_radius:new e.aa(t),u_vertical_scale:new e.aa(t)}),fillExtrusionPattern:t=>({u_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_vertical_gradient:new e.aa(t),u_height_factor:new e.aa(t),u_edge_radius:new e.aa(t),u_ao:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_up_dir:new e.aq(t),u_height_lift:new e.aa(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t),u_opacity:new e.aa(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.a6(t),u_opacity:new e.aa(t),u_ao_pass:new e.aa(t),u_meter_to_tile:new e.aa(t),u_ao:new e.a8(t),u_flood_light_intensity:new e.aa(t),u_flood_light_color:new e.aq(t),u_attenuation:new e.aa(t),u_edge_radius:new e.aa(t),u_fb:new e.a7(t),u_fb_size:new e.aa(t)}),fill:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t)}),fillPattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),fillOutline:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_world:new e.a8(t)}),fillOutlinePattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_world:new e.a8(t),u_image:new e.a7(t),u_texsize:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),circle:e.bI,collisionBox:t=>({u_matrix:new e.a6(t),u_camera_to_center_distance:new e.aa(t),u_extrude_scale:new e.a8(t)}),collisionCircle:t=>({u_matrix:new e.a6(t),u_inv_matrix:new e.a6(t),u_camera_to_center_distance:new e.aa(t),u_viewport_size:new e.a8(t)}),debug:t=>({u_color:new e.a9(t),u_matrix:new e.a6(t),u_overlay:new e.a7(t),u_overlay_scale:new e.aa(t)}),clippingMask:t=>({u_matrix:new e.a6(t)}),heatmap:t=>({u_extrude_scale:new e.aa(t),u_intensity:new e.aa(t),u_matrix:new e.a6(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_up_dir:new e.aq(t)}),heatmapTexture:t=>({u_image:new e.a7(t),u_color_ramp:new e.a7(t),u_opacity:new e.aa(t)}),hillshade:t=>({u_matrix:new e.a6(t),u_image:new e.a7(t),u_latrange:new e.a8(t),u_light:new e.a8(t),u_shadow:new e.a9(t),u_highlight:new e.a9(t),u_emissive_strength:new e.aa(t),u_accent:new e.a9(t)}),hillshadePrepare:t=>({u_matrix:new e.a6(t),u_image:new e.a7(t),u_dimension:new e.a8(t),u_zoom:new e.aa(t)}),line:e.bJ,linePattern:e.bK,raster:t=>({u_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_grid_matrix:new e.ar(t),u_tl_parent:new e.a8(t),u_scale_parent:new e.aa(t),u_fade_t:new e.aa(t),u_opacity:new e.aa(t),u_image0:new e.a7(t),u_image1:new e.a7(t),u_brightness_low:new e.aa(t),u_brightness_high:new e.aa(t),u_saturation_factor:new e.aa(t),u_contrast_factor:new e.aa(t),u_spin_weights:new e.aq(t),u_perspective_transform:new e.a8(t),u_raster_elevation:new e.aa(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_cutoff_params:new e.as(t),u_colorization_mix:new e.as(t),u_colorization_offset:new e.aa(t),u_color_ramp:new e.a7(t),u_texture_offset:new e.a8(t),u_texture_res:new e.a8(t),u_emissive_strength:new e.aa(t)}),rasterParticle:t=>({u_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_grid_matrix:new e.ar(t),u_tl_parent:new e.a8(t),u_scale_parent:new e.aa(t),u_fade_t:new e.aa(t),u_opacity:new e.aa(t),u_image0:new e.a7(t),u_image1:new e.a7(t),u_raster_elevation:new e.aa(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_cutoff_params:new e.as(t)}),rasterParticleTexture:t=>({u_texture:new e.a7(t),u_opacity:new e.aa(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.a7(t),u_particle_texture_side_len:new e.aa(t),u_tile_offset:new e.a8(t),u_velocity:new e.a7(t),u_color_ramp:new e.a7(t),u_velocity_res:new e.a8(t),u_max_speed:new e.aa(t),u_uv_offset:new e.a8(t),u_data_scale:new e.a8(t),u_data_offset:new e.aa(t),u_particle_pos_scale:new e.aa(t),u_particle_pos_offset:new e.a8(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.a7(t),u_particle_texture_side_len:new e.aa(t),u_velocity:new e.a7(t),u_velocity_res:new e.a8(t),u_max_speed:new e.aa(t),u_speed_factor:new e.aa(t),u_reset_rate:new e.aa(t),u_rand_seed:new e.aa(t),u_uv_offset:new e.a8(t),u_data_scale:new e.a8(t),u_data_offset:new e.aa(t),u_particle_pos_scale:new e.aa(t),u_particle_pos_offset:new e.a8(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_camera_forward:new e.aq(t),u_tile_matrix:new e.a6(t),u_up_vector:new e.aq(t),u_ecef_origin:new e.aq(t),u_texture:new e.a7(t),u_icon_transition:new e.aa(t),u_color_adj_mat:new e.a6(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_texture:new e.a7(t),u_gamma_scale:new e.aa(t),u_device_pixel_ratio:new e.aa(t),u_tile_id:new e.aq(t),u_zoom_transition:new e.aa(t),u_inv_rot_matrix:new e.a6(t),u_merc_center:new e.a8(t),u_camera_forward:new e.aq(t),u_tile_matrix:new e.a6(t),u_up_vector:new e.aq(t),u_ecef_origin:new e.aq(t),u_is_halo:new e.a7(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.a7(t),u_is_size_feature_constant:new e.a7(t),u_size_t:new e.aa(t),u_size:new e.aa(t),u_camera_to_center_distance:new e.aa(t),u_rotate_symbol:new e.a7(t),u_aspect_ratio:new e.aa(t),u_fade_change:new e.aa(t),u_matrix:new e.a6(t),u_label_plane_matrix:new e.a6(t),u_coord_matrix:new e.a6(t),u_is_text:new e.a7(t),u_pitch_with_map:new e.a7(t),u_texsize:new e.a8(t),u_texsize_icon:new e.a8(t),u_texture:new e.a7(t),u_texture_icon:new e.a7(t),u_gamma_scale:new e.aa(t),u_device_pixel_ratio:new e.aa(t),u_is_halo:new e.a7(t)}),background:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_opacity:new e.aa(t),u_color:new e.a9(t)}),backgroundPattern:t=>({u_matrix:new e.a6(t),u_emissive_strength:new e.aa(t),u_opacity:new e.aa(t),u_image:new e.a7(t),u_pattern_tl:new e.a8(t),u_pattern_br:new e.a8(t),u_texsize:new e.a8(t),u_pattern_size:new e.a8(t),u_pixel_coord_upper:new e.a8(t),u_pixel_coord_lower:new e.a8(t),u_tile_units_to_pixels:new e.aa(t)}),terrainRaster:t=>({u_matrix:new e.a6(t),u_image0:new e.a7(t),u_skirt_height:new e.aa(t),u_ground_shadow_factor:new e.aq(t)}),skybox:t=>({u_matrix:new e.a6(t),u_sun_direction:new e.aq(t),u_cubemap:new e.a7(t),u_opacity:new e.aa(t),u_temporal_offset:new e.aa(t)}),skyboxGradient:t=>({u_matrix:new e.a6(t),u_color_ramp:new e.a7(t),u_center_direction:new e.aq(t),u_radius:new e.aa(t),u_opacity:new e.aa(t),u_temporal_offset:new e.aa(t)}),skyboxCapture:t=>({u_matrix_3f:new e.ar(t),u_sun_direction:new e.aq(t),u_sun_intensity:new e.aa(t),u_color_tint_r:new e.as(t),u_color_tint_m:new e.as(t),u_luminance:new e.aa(t)}),globeRaster:t=>({u_proj_matrix:new e.a6(t),u_globe_matrix:new e.a6(t),u_normalize_matrix:new e.a6(t),u_merc_matrix:new e.a6(t),u_zoom_transition:new e.aa(t),u_merc_center:new e.a8(t),u_image0:new e.a7(t),u_grid_matrix:new e.ar(t),u_skirt_height:new e.aa(t),u_far_z_cutoff:new e.aa(t),u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_globe_pos:new e.aq(t),u_globe_radius:new e.aa(t),u_viewport:new e.a8(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.aq(t),u_frustum_tr:new e.aq(t),u_frustum_br:new e.aq(t),u_frustum_bl:new e.aq(t),u_horizon:new e.aa(t),u_transition:new e.aa(t),u_fadeout_range:new e.aa(t),u_color:new e.as(t),u_high_color:new e.as(t),u_space_color:new e.as(t),u_temporal_offset:new e.aa(t),u_horizon_angle:new e.aa(t)}),model:t=>({u_matrix:new e.a6(t),u_lighting_matrix:new e.a6(t),u_normal_matrix:new e.a6(t),u_node_matrix:new e.a6(t),u_lightpos:new e.aq(t),u_lightintensity:new e.aa(t),u_lightcolor:new e.aq(t),u_camera_pos:new e.aq(t),u_opacity:new e.aa(t),u_baseColorFactor:new e.as(t),u_emissiveFactor:new e.as(t),u_metallicFactor:new e.aa(t),u_roughnessFactor:new e.aa(t),u_baseTextureIsAlpha:new e.a7(t),u_alphaMask:new e.a7(t),u_alphaCutoff:new e.aa(t),u_baseColorTexture:new e.a7(t),u_metallicRoughnessTexture:new e.a7(t),u_normalTexture:new e.a7(t),u_occlusionTexture:new e.a7(t),u_emissionTexture:new e.a7(t),u_lutTexture:new e.a7(t),u_color_mix:new e.as(t),u_aoIntensity:new e.aa(t),u_emissive_strength:new e.aa(t),u_occlusionTextureTransform:new e.as(t)}),modelDepth:t=>({u_matrix:new e.a6(t),u_instance:new e.a6(t),u_node_matrix:new e.a6(t)}),groundShadow:t=>({u_matrix:new e.a6(t),u_ground_shadow_factor:new e.aq(t)}),stars:t=>({u_matrix:new e.a6(t),u_up:new e.aq(t),u_right:new e.aq(t),u_intensity_multiplier:new e.aa(t)}),occlusion:t=>({u_matrix:new e.a6(t),u_anchorPos:new e.aq(t),u_screenSizePx:new e.a8(t),u_occluderSizePx:new e.a8(t),u_color:new e.as(t)})};function bo(t,i,o){const r=i.createTileMatrix(t,t.worldSize,o.toUnwrapped());return e.ad.multiply(new Float32Array(16),t.projMatrix,r)}function wo(e,t,i){if(t.projection.name===i.projection.name)return e.projMatrix;const o=i.clone();return o.setProjection(t.projection),bo(o,t.getProjection(),e)}function To(e,t,i){return t.name===i.projection.name?e.projMatrix:bo(i,t,e)}let Eo;function Co(t,i,o,r,a,n,s){const l=t.context,c=l.gl,h=t.transform,_=t.getOrCreateProgram(\"collisionBox\"),u=[];let d=0,p=0;for(let l=0;l0){const t=e.ad.create(),i=x;e.ad.mul(t,g.placementInvProjMatrix,h.glCoordMatrix),e.ad.mul(t,t,g.placementViewportMatrix),u.push({circleArray:b,circleOffset:p,transform:i,invTransform:t,projection:g.getProjection()}),d+=b.length/4,p=d;}y&&(t.terrain&&t.terrain.setupElevationDraw(m,_),_.draw(t,c.LINES,e.ae.disabled,e.ag.disabled,t.colorModeForRenderPass(),e.af.disabled,Ki(x,h,m,g.getProjection()),o.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,h.zoom,null,[y.collisionVertexBuffer,y.collisionVertexBufferExt]));}if(!s||!u.length)return;const f=t.getOrCreateProgram(\"collisionCircle\"),m=new e.bL;m.resize(4*d),m._trim();let g=0;for(const e of u)for(let t=0;t=0&&(f[y.associatedIconIndex]={x:C,y:S,z:I,angle:D});}else ci(T,d);}if(_){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{const i=I&&\"point\"!==o.layout.get(\"symbol-placement\"),s=[];o.hasInitialOcclusionOpacityProperties&&R&&t.symbolParams.useOcclusionQueries&&!u&&!k&&s.push(\"OCCLUSION_QUERIES\"),o.hasInitialOcclusionOpacityProperties||s.push(\"SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\");const c=i||T,_=o.paint.get(\"icon-image-cross-fade\").constantOr(0);t.terrainRenderModeElevated()&&P&&s.push(\"PITCH_WITH_MAP_TERRAIN\"),u&&(s.push(\"PROJECTION_GLOBE_VIEW\"),c&&s.push(\"PROJECTED_POS_ON_VIEWPORT\")),_>0&&s.push(\"ICON_TRANSITION\"),n.icon.zOffsetVertexBuffer&&s.push(\"Z_OFFSET\"),s.push(\"TERRAIN_DEPTH_D24\"),0===v&&0===x&&0===y&&1===b||s.push(\"COLOR_ADJUSTMENT\");const g=n.icon.programConfigurations.get(o.id),w=t.getOrCreateProgram(n.sdfIcons?\"symbolSDF\":\"symbolIcon\",{config:g,defines:s});let L;const A=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],D=n.iconSizeData,M=e.aD(D,S.zoom),z=P||0!==S.pitch,O=Yt(p,r.tileID.canonical,P,I,S,n.getProjection(),f),B=Qt(p,r.tileID.canonical,P,I,S,n.getProjection(),f),N=t.translatePosMatrix(B,r,l,h,!0),G=t.translatePosMatrix(p,r,l,h),j=c?So:O,V=I&&!P&&!i;let W=U;!k&&!S.mercatorFromTransition||I||(W=Io(S));const Z=u?W:U;if(n.sdfIcons&&!n.iconsInText)L=_o(D.kind,M,V,P,t,G,j,N,!1,A,!0,a,d,F,E,Z,n.getProjection());else {const e=o.getColorAdjustmentMatrix(v,x,y,b);L=ho(D.kind,M,V,P,t,G,j,N,!1,A,a,d,F,E,Z,n.getProjection(),e,_);}const q=r.imageAtlasTexture?r.imageAtlasTexture:null,H=1!==o.layout.get(\"icon-size\").constantOr(0)||n.iconsNeedLinear,$=n.sdfIcons||t.options.rotating||t.options.zooming||H||z?C.LINEAR:C.NEAREST,X=n.sdfIcons&&0!==o.paint.get(\"icon-halo-width\").constantOr(1),Y=t.terrain&&P&&i?e.ad.invert(e.ad.create(),O):So;if(i&&n.icon){const e=S.elevation,i=e?e.getAtTileOffsetFunc(a,S.center.lat,S.worldSize,n.getProjection()):null,o=Kt(p,r.tileID.canonical,P,I,S,n.getProjection(),f);ii(n,p,t,!1,o,B,P,m,i,a);}return {program:w,buffers:n.icon,uniformValues:L,atlasTexture:q,atlasTextureIcon:null,atlasInterpolation:$,atlasInterpolationIcon:null,isSDF:n.sdfIcons,hasHalo:X,tile:r,labelPlaneMatrixInv:Y}},G=()=>{const i=L&&\"point\"!==o.layout.get(\"symbol-placement\"),s=[],l=i||B||T;o.hasInitialOcclusionOpacityProperties&&D&&t.symbolParams.useOcclusionQueries&&!u&&!k&&s.push(\"OCCLUSION_QUERIES\"),o.hasInitialOcclusionOpacityProperties||s.push(\"SYMBOL_OCCLUSION_BY_TERRAIN_DEPTH\"),t.terrainRenderModeElevated()&&A&&s.push(\"PITCH_WITH_MAP_TERRAIN\"),u&&(s.push(\"PROJECTION_GLOBE_VIEW\"),l&&s.push(\"PROJECTED_POS_ON_VIEWPORT\")),n.text.zOffsetVertexBuffer&&s.push(\"Z_OFFSET\"),s.push(\"TERRAIN_DEPTH_D24\");const h=n.text.programConfigurations.get(o.id),m=t.getOrCreateProgram(n.iconsInText?\"symbolTextAndIcon\":\"symbolSDF\",{config:h,defines:s});let v,x=[0,0],y=null;const b=n.textSizeData;n.iconsInText&&(x=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],y=r.imageAtlasTexture?r.imageAtlasTexture:null,v=A||0!==S.pitch||t.options.rotating||t.options.zooming||\"composite\"===b.kind||\"camera\"===b.kind?C.LINEAR:C.NEAREST);const w=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],I=e.aD(b,S.zoom),P=Yt(p,r.tileID.canonical,A,L,S,n.getProjection(),f),R=Qt(p,r.tileID.canonical,A,L,S,n.getProjection(),f),M=t.translatePosMatrix(R,r,c,_,!0),z=t.translatePosMatrix(p,r,c,_),O=l?So:P,N=L&&!A&&!i;let G=U;!k&&!S.mercatorFromTransition||L||(G=Io(S));const j=u?G:U;let V;V=n.iconsInText?uo(b.kind,I,N,A,t,z,O,M,w,x,a,d,F,E,j,n.getProjection()):_o(b.kind,I,N,A,t,z,O,M,!0,w,!0,a,d,F,E,j,n.getProjection());const W=r.glyphAtlasTexture?r.glyphAtlasTexture:null,Z=C.LINEAR,q=0!==o.paint.get(\"text-halo-width\").constantOr(1),H=t.terrain&&A&&i?e.ad.invert(e.ad.create(),P):So;if(i&&n.text){const e=S.elevation,i=e?e.getAtTileOffsetFunc(a,S.center.lat,S.worldSize,n.getProjection()):null,o=Kt(p,r.tileID.canonical,A,L,S,n.getProjection(),f);ii(n,p,t,!0,o,R,A,g,i,a);}return {program:m,buffers:n.text,uniformValues:V,atlasTexture:W,atlasTextureIcon:y,atlasInterpolation:Z,atlasInterpolationIcon:v,isSDF:!0,hasHalo:q,tile:r,labelPlaneMatrixInv:H}},j=n.icon.segments.get().length,V=n.text.segments.get().length,W=j&&!s.onlyText?O():null,Z=V&&!s.onlyIcons?G():null,q=o.paint.get(\"icon-opacity\").constantOr(1),H=o.paint.get(\"text-opacity\").constantOr(1);if(M&&n.canOverlap){z=!0;const t=q&&!s.onlyText?n.icon.segments.get():[],i=H&&!s.onlyIcons?n.text.segments.get():[];for(const i of t)N.push({segments:new e.b([i]),sortKey:i.sortKey,state:W});for(const t of i)N.push({segments:new e.b([t]),sortKey:t.sortKey,state:Z});}else s.onlyText||N.push({segments:q?n.icon.segments:new e.b([]),sortKey:0,state:W}),s.onlyIcons||N.push({segments:H?n.text.segments:new e.b([]),sortKey:0,state:Z});}z&&N.sort(((e,t)=>e.sortKey-t.sortKey));for(const e of N){const i=e.state;if(i)if(t.terrain&&t.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!o.hasInitialOcclusionOpacityProperties&&S.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),E.activeTexture.set(C.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,C.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(E.activeTexture.set(C.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,C.CLAMP_TO_EDGE,!0)),t.uploadCommonLightUniforms(t.context,i.program),i.hasHalo){const r=i.uniformValues;r.u_is_halo=1,Ro(i.buffers,e.segments,o,t,i.program,O,a,n,r,2),r.u_is_halo=0;}else {if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Ro(i.buffers,e.segments,o,t,i.program,O,a,n,r,1)),r.u_is_halo=0;}Ro(i.buffers,e.segments,o,t,i.program,O,a,n,i.uniformValues,1);}}}function Ro(t,i,o,r,a,n,s,l,c,h){const _=r.context.gl,u=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.iconTransitioningVertexBuffer,t.globeExtVertexBuffer,t.zOffsetVertexBuffer];t.occlusionQueryOpacityVertexBuffer.length>0&&u.push(t.occlusionQueryOpacityVertexBuffer),a.draw(r,_.TRIANGLES,n,s,l,e.af.disabled,c,o.id,t.layoutVertexBuffer,t.indexBuffer,i,o.paint,r.transform.zoom,t.programConfigurations.get(o.id),u,h);}function Do(t,i,o,r,a,n,s){const l=t.context.gl,c=o.paint.get(\"fill-pattern\"),h=c&&c.constantOr(1);let _,u,d,p,f;s?(u=h&&!o.getPaintProperty(\"fill-outline-color\")?\"fillOutlinePattern\":\"fillOutline\",_=l.LINES):(u=h?\"fillPattern\":\"fill\",_=l.TRIANGLES);for(const m of r){const r=i.getTile(m);if(h&&!r.patternsLoaded())continue;const g=r.getBucket(o);if(!g)continue;t.prepareDrawTile();const v=g.programConfigurations.get(o.id),x=t.isTileAffectedByFog(m),y=t.getOrCreateProgram(u,{config:v,overrideFog:x});h&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers());const b=c.constantOr(null);if(b&&r.imageAtlas){const e=r.imageAtlas.patternPositions[b.toString()];e&&v.setConstantPatternPositions(e);}const w=t.translatePosMatrix(m.projMatrix,r,o.paint.get(\"fill-translate\"),o.paint.get(\"fill-translate-anchor\")),T=o.paint.get(\"fill-emissive-strength\");if(s){p=g.indexBuffer2,f=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];d=\"fillOutlinePattern\"===u&&h?Yi(w,T,t,r,e):Xi(w,T,e);}else p=g.indexBuffer,f=g.segments,d=h?$i(w,T,t,r):Hi(w,T);t.uploadCommonUniforms(t.context,y,m.toUnwrapped()),y.draw(t,_,a,t.stencilModeForClipping(m),n,e.af.disabled,d,o.id,g.layoutVertexBuffer,p,f,o.paint,t.transform.zoom,v,void 0);}}function Mo(t,i,o,r,a,n,s,l){o.resetLayerRenderingStats(t);const c=t.context,h=c.gl,_=t.transform,u=o.paint.get(\"fill-extrusion-pattern\"),d=u.constantOr(1),p=o.paint.get(\"fill-extrusion-opacity\"),f=t.style.enable3dLights(),m=o.paint.get(f&&!d?\"fill-extrusion-ambient-occlusion-wall-radius\":\"fill-extrusion-ambient-occlusion-radius\"),g=[o.paint.get(\"fill-extrusion-ambient-occlusion-intensity\"),m],v=o.layout.get(\"fill-extrusion-edge-radius\"),x=v>0&&!o.paint.get(\"fill-extrusion-rounded-roof\"),y=x?0:v,b=\"globe\"===_.projection.name?e.bY():0,w=\"globe\"===_.projection.name,T=w?e.a1(_.zoom):0,E=[e.aj(_.center.lng),e.ak(_.center.lat)],C=o.paint.get(\"fill-extrusion-flood-light-color\").toRenderColor(o.lut).toArray01().slice(0,3),S=o.paint.get(\"fill-extrusion-flood-light-intensity\"),I=o.paint.get(\"fill-extrusion-vertical-scale\"),L=fi(t,o.paint.get(\"fill-extrusion-cutoff-fade-range\")),P=o.paint.get(\"fill-extrusion-emissive-strength\"),A=[];let R;w&&A.push(\"PROJECTION_GLOBE_VIEW\"),g[0]>0&&A.push(\"FAUX_AO\"),x&&A.push(\"ZERO_ROOF_RADIUS\"),l&&A.push(\"HAS_CENTROID\"),S>0&&A.push(\"FLOOD_LIGHT\"),L.shouldRenderCutoff&&A.push(\"RENDER_CUTOFF\");const D=\"shadow\"===t.renderPass,M=t.shadowRenderer,z=D&&!!M;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let O=[0,0,0];if(M){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(O=wi(t.style,e,i)),R=A.concat([\"SHADOWS_SINGLE_CASCADE\"]);}const F=z?\"fillExtrusionDepth\":d?\"fillExtrusionPattern\":\"fillExtrusion\",B=o.getLayerRenderingStats();for(const f of r){const r=i.getTile(f),m=r.getBucket(o);if(!m||m.projection.name!==_.projection.name)continue;let v=!1;M&&(v=0===M.getMaxCascadeForTile(f.toUnwrapped()));const x=t.isTileAffectedByFog(f),z=m.programConfigurations.get(o.id),k=t.getOrCreateProgram(F,{config:z,defines:v?R:A,overrideFog:x});if(t.terrain&&t.terrain.setupElevationDraw(r,k,{useMeterToDem:!0}),!m.centroidVertexBuffer){const e=k.attributes.a_centroid_pos;void 0!==e&&h.vertexAttrib2f(e,0,0);}!D&&M&&M.setupShadows(r.tileID.toUnwrapped(),k,\"vector-tile\",r.tileID.overscaledZ),d&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),z.updatePaintBuffers());const N=u.constantOr(null);if(N&&r.imageAtlas){const e=r.imageAtlas.patternPositions[N.toString()];e&&z.setConstantPatternPositions(e);}const U=o.paint.get(\"fill-extrusion-vertical-gradient\");let G;if(D&&M){if(No(r.tileID,m,t))continue;const e=M.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());G=Zi(e,y,I);}else {const e=t.translatePosMatrix(f.expandedProjMatrix,r,o.paint.get(\"fill-extrusion-translate\"),o.paint.get(\"fill-extrusion-translate-anchor\")),i=_.projection.createInversionMatrix(_,f.canonical);G=d?qi(e,t,U,p,g,y,f,r,b,T,E,i,C,I):Wi(e,t,U,p,g,y,f,b,T,E,i,C,I,S,O,P);}t.uploadCommonUniforms(c,k,f.toUnwrapped(),null,L);let j=m.segments;if(\"mercator\"===_.projection.name&&!D&&(j=m.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!j.get().length))continue;if(B)if(D)for(const e of j.get())B.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of j.get())B.numRenderedVerticesInTransparentPass+=e.primitiveLength;const V=[];(t.terrain||l)&&V.push(m.centroidVertexBuffer),w&&V.push(m.layoutVertexExtBuffer),k.draw(t,c.gl.TRIANGLES,a,n,s,e.af.backCCW,G,o.id,m.layoutVertexBuffer,m.indexBuffer,j,o.paint,t.transform.zoom,z,V);}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1);}function zo(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g,v,x){const y=t.context,b=y.gl,w=t.transform,T=t.transform.zoom,E=[],C=fi(t,o.paint.get(\"fill-extrusion-cutoff-fade-range\"));\"clear\"===h?(E.push(\"CLEAR_SUBPASS\"),x&&(E.push(\"CLEAR_FROM_TEXTURE\"),y.activeTexture.set(b.TEXTURE0),x.bind(b.LINEAR,b.CLAMP_TO_EDGE))):\"sdf\"===h&&E.push(\"SDF_SUBPASS\"),g&&E.push(\"HAS_CENTROID\"),C.shouldRenderCutoff&&E.push(\"RENDER_CUTOFF\");const S=o.layout.get(\"fill-extrusion-edge-radius\"),I=(e,i,r,h,v)=>{const b=i.programConfigurations.get(o.id),w=t.isTileAffectedByFog(e),I=t.getOrCreateProgram(\"fillExtrusionGroundEffect\",{config:b,defines:E,overrideFog:w}),L=((e,t,i,o,r,a,n,s,l,c,h)=>({u_matrix:t,u_opacity:i,u_ao_pass:o?1:0,u_meter_to_tile:r,u_ao:a,u_flood_light_intensity:n,u_flood_light_color:s,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:h}))(0,h,_,c,v,[u,d*v],p,f,m,T>=17?0:S*v,x?x.size[0]:0),P=[];g&&P.push(i.hiddenByLandmarkVertexBuffer),t.uploadCommonUniforms(y,I,e.toUnwrapped(),null,C),I.draw(t,y.gl.TRIANGLES,a,n,s,l,L,o.id,i.vertexBuffer,i.indexBuffer,r,o.paint,T,b,P);};for(const a of r){const r=i.getTile(a),n=r.getBucket(o);if(!n||n.projection.name!==w.projection.name||!n.groundEffect||n.groundEffect&&!n.groundEffect.hasData())continue;const s=n.groundEffect,l=1/n.tileToMeter;{const e=t.translatePosMatrix(a.projMatrix,r,o.paint.get(\"fill-extrusion-translate\"),o.paint.get(\"fill-extrusion-translate-anchor\")),i=s.getDefaultSegment();I(a,s,i,e,l);}if(v)for(let n=0;n<4;n++){const s=e.bZ[n](a),c=i.getTile(s);if(!c)continue;const h=c.getBucket(o);if(!h||h.projection.name!==w.projection.name||!h.groundEffect||h.groundEffect&&!h.groundEffect.hasData())continue;const _=h.groundEffect;let u,d;0===n?(u=[-e.a3,0,0],d=1):1===n?(u=[e.a3,0,0],d=0):2===n?(u=[0,-e.a3,0],d=3):(u=[0,e.a3,0],d=2);const p=_.regionSegments[d];if(!p)continue;const f=new Float32Array(16);e.ad.translate(f,a.projMatrix,u),I(a,_,p,t.translatePosMatrix(f,r,o.paint.get(\"fill-extrusion-translate\"),o.paint.get(\"fill-extrusion-translate-anchor\")),l);}}}function Oo(t,i,o,r,a,n,s){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=n?n.findDEMTileFor(o):null;if(!(l&&l.dem||s))return;const c=t=>new e.P(Math.ceil((t+e.c0)*e.c1),0),h=e=>{const t=i.getSource().minzoom,o=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(a)},r=[0,-1,1];for(const i of r){if(e.overscaledZ+i(_[0]=Math.min(t.min.y,i.min.y),_[1]=Math.max(t.max.y,i.max.y),_[2]=e.a3-i.min.x>t.max.x?i.min.x-e.a3:t.max.x,_),d=(t,i)=>(_[0]=Math.min(t.min.x,i.min.x),_[1]=Math.max(t.max.x,i.max.x),_[2]=e.a3-i.min.y>t.max.y?i.min.y-e.a3:t.max.y,_),p=[(e,t)=>u(e,t),(e,t)=>u(t,e),(e,t)=>d(e,t),(e,t)=>d(t,e)],f=(t,i,r,a,s,c,h)=>{if(!n)return 0;const _=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],u=h<0?e.a3+h:h,d=[c?u:(t+i)/2,c?(t+i)/2:u,0];return 0===r&&h<0||0!==r&&h>0?n.getForTilePoints(s,[d],!0,a):_.push(d),n.getForTilePoints(o,_,!0,l),Math.max(_[0][2],_[1][2],d[2])/n.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const a=e.bZ[t](o),l=h(a);if(!(l&&l instanceof e.b_))continue;if(r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const _=n?n.findDEMTileFor(a):null;if(!(_&&_.dem||s))continue;const u=(t<2?1:5)-t,d=l.borderDoneWithNeighborZ[u]!==r.canonical.z,v=l.borderFeatureIndices[u];let x=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(d)for(const e of v)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[u]=r.canonical.z;}for(const o of i){const i=r.featuresOnBorder[o],n=r.centroidData[i.centroidDataIndex],h=i.borders[t];let d;for(;xh[0]+3||e[0]>h[0]-3)break;l.showCentroid(d),x++;}if(d&&xh[1]-3)&&(y++,++x!==v.length);)d=l.featuresOnBorder[v[x]];if(d=l.featuresOnBorder[v[o]],y>1){const e=d.borders[u];Math.abs(h[0]-e[0])<3&&Math.abs(h[1]-e[1])<3&&(y=1,x=o+1);}else if(0===y){r.showCentroid(i);continue}const b=l.centroidData[d.centroidDataIndex];s&&1===y&&(((m=n).flags|(g=b).flags)&e.b$?(m.flags|=e.b$,g.flags|=e.b$):(m.flags&=~e.b$,g.flags&=~e.b$));const w=i.intersectsCount()>1||d.intersectsCount()>1;if(y>1)x=o,n.centroidXY=b.centroidXY=new e.P(0,0);else if(_&&_.dem&&!w){const i=p[t](n,b),o=t%2?e.a3-1:0,r=f(i[0],Math.min(e.a3-1,i[1]),o,_,a,t<2,i[2]);n.centroidXY=b.centroidXY=c(r);}else w?n.centroidXY=b.centroidXY=new e.P(0,0):(n.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(d));r.writeCentroidToBuffer(n),l.writeCentroidToBuffer(b);}else r.showCentroid(i);}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[u]=r.canonical.z;}var m,g;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t);}const Fo=[1,0,0],Bo=[0,1,0],ko=[0,0,1];function No(t,i,o){const r=o.transform,a=o.shadowRenderer;if(!a)return !0;const n=t.toUnwrapped(),s=r.tileSize*a._cascades[o.currentShadowCascade].scale;let l=i.maxHeight;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max);}const c=[...a.shadowDirection];c[2]=-c[2];const h=a.computeSimplifiedTileShadowVolume(n,l,s,c);if(!h)return !1;const _=[Fo,Bo,ko,c,[c[0],0,c[2]],[0,c[1],c[2]]],u=\"globe\"===r.projection.name,d=r.scaleZoom(s),p=e.aM.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,d,!u),f=a.getCurrentCascadeFrustum();return 0===p.intersectsPrecise(h.vertices,h.planes,_)||0===f.intersectsPrecise(h.vertices,h.planes,_)}function Uo(t){return [t[0]*e.c2,t[1]*e.c2,t[2]*e.c2,0]}function Go(t,i,o,r,a,n,s,l,c){const h=r.getSource(),_=o.globeSharedBuffers;if(!_)return;let u,d,p;if(i&&(u=r.getTile(i)),h instanceof e.bm?(d=h.texture,p=e.bh(0,0,o.transform)):u&&i&&(d=u.texture,p=e.bh(i.canonical.z,i.canonical.x,o.transform)),!d||!p)return;t||(p=e.ad.scale(e.ad.create(),p,[1,-1,1]));const f=o.context,m=f.gl,g=\"nearest\"===a.paint.get(\"raster-resampling\")?m.NEAREST:m.LINEAR,v=o.colorModeForDrapableLayerRenderPass(n),x=s.defines;x.push(\"GLOBE_POLES\");const y=new e.ae(m.LEQUAL,e.ae.ReadWrite,o.depthRangeFor3D),b=Float32Array.from(o.transform.expandedFarZProjMatrix),w=Float32Array.from(e.bf(e.bg(new e.aO(0,0,0))));o.terrain&&o.terrain.prepareDrawTile(),f.activeTexture.set(m.TEXTURE0),d.bind(g,m.CLAMP_TO_EDGE),f.activeTexture.set(m.TEXTURE1),d.bind(g,m.CLAMP_TO_EDGE),d.useMipmap&&f.extTextureFilterAnisotropic&&o.transform.pitch>20&&m.texParameterf(m.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const[T,E,C,S]=i?_.getPoleBuffers(i.canonical.z,!1):_.getPoleBuffers(0,!0),I=a.paint.get(\"raster-elevation\");let L;t?(L=T,o.renderDefaultNorthPole=0!==I):(L=E,o.renderDefaultSouthPole=0!==I);const P=Uo(s.mix),A=((e,t,i,o,r,a,n,s,l,c,h,_,u)=>oo(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],o,[0,0],[0,0,0,0],1,{opacity:1,mix:0},a,[0,0]||[0,0],s,2,c,h,_,1,0,u))(b,w,p,e.a1(o.transform.zoom),0,a,0,I,0,P,s.offset,s.range,n),R=o.getOrCreateProgram(\"raster\",{defines:x});o.uploadCommonUniforms(f,R,null),R.draw(o,m.TRIANGLES,y,c,v,l,A,a.id,L,C,S);}function jo(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,a=t+r;return [t,i,(a-r-t)/o,(a-t)/o]}function Vo(t,i,o,r){if(t)return i instanceof Ri&&t instanceof e.c3?i.getTextureDescriptor(t,o,!0):{texture:t.texture,mix:Uo(r.mix),offset:r.offset,buffer:0,tileSize:1}}function Wo(t,i,o){if(!t)return null;const r=i.getTextureDescriptor(t,o,!0);if(!r)return null;let{texture:a,mix:n,offset:s,tileSize:l,buffer:c,format:h}=r;if(!a||!h)return null;let _=!1;return \"uint32\"===h&&(_=!0,n[3]=0,n=to(e.c4,n,[0,o.paint.get(\"raster-particle-max-speed\")]),s=io(e.c4,s,[0,o.paint.get(\"raster-particle-max-speed\")])),{texture:a,textureOffset:[c/(l+2*c),l/(l+2*c)],tileSize:l,scalarData:_,scale:n,offset:s,defines:[\"RASTER_ARRAY\",{uint8:\"DATA_FORMAT_UINT8\",uint16:\"DATA_FORMAT_UINT16\",uint32:\"DATA_FORMAT_UINT32\"}[h]]}}function Zo(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),o=i-t,r=.2*e.height,a=t+r;return [t,i,(a-r-t)/o,(a-t)/o]}const qo=new e.C(1,0,0,1),Ho=new e.C(0,1,0,1),$o=new e.C(0,0,1,1),Xo=new e.C(1,0,1,1),Yo=new e.C(0,1,1,1);function Ko(t,i,o,r,a,n,s){const l=t.context,c=t.transform,h=l.gl,_=\"globe\"===c.projection.name,u=_?[\"PROJECTION_GLOBE_VIEW\"]:[];let d=e.ad.clone(o.projMatrix);if(_&&e.a1(c.zoom)>0){const t=e.c5(o.canonical,c),i=e.c6(t);d=e.ad.multiply(new Float32Array(16),c.globeMatrix,i),e.ad.multiply(d,c.projMatrix,d);}const p=e.ad.create();p[12]+=2*a/(e.e.devicePixelRatio*c.width),p[13]+=2*n/(e.e.devicePixelRatio*c.height),e.ad.multiply(d,p,d);const f=t.getOrCreateProgram(\"debug\",{defines:u}),m=i.getTileByID(o.key);t.terrain&&t.terrain.setupElevationDraw(m,f);const g=e.ae.disabled,v=e.ag.disabled,x=t.colorModeForRenderPass(),y=\"$debug\";l.activeTexture.set(h.TEXTURE0),t.emptyTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),_?m._makeGlobeTileDebugBuffers(t.context,c):m._makeDebugTileBoundsBuffers(t.context,c.projection);const b=m._tileDebugBuffer||t.debugBuffer,w=m._tileDebugIndexBuffer||t.debugIndexBuffer,T=m._tileDebugSegments||t.debugSegments;if(f.draw(t,h.LINE_STRIP,g,v,x,e.af.disabled,Qi(d,r),y,b,w,T,null,null,null,[m._globeTileDebugBorderBuffer]),s){const e=m.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(r+=` => ${o.overscaledZ}`),r+=` ${m.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,o=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(o.LINEAR,o.CLAMP_TO_EDGE);}(t,r);}const E=i.getTile(o).tileSize,C=512/Math.min(E,512)*(o.overscaledZ/c.zoom)*.5,S=m._tileDebugTextBuffer||t.debugBuffer,I=m._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,L=m._tileDebugTextSegments||t.debugSegments;f.draw(t,h.TRIANGLES,g,v,e.a.alphaBlended,e.af.disabled,Qi(d,e.C.transparent,C),y,S,I,L,null,null,null,[m._globeTileDebugTextBuffer]);}function Qo(e,t,i,o){er(e,0,t+i/2,e.transform.width,i,o);}function Jo(e,t,i,o){er(e,t-i/2,0,i,e.transform.height,o);}function er(t,i,o,r,a,n){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.e.devicePixelRatio,o*e.e.devicePixelRatio,r*e.e.devicePixelRatio,a*e.e.devicePixelRatio),s.clear({color:n}),l.disable(l.SCISSOR_TEST);}const tr=e.c7([{name:\"a_pos_3f\",components:3,type:\"Float32\"}]),{members:ir}=tr;function or(e,t,i,o){e.emplaceBack(t,i,o);}class rr{constructor(t){this.vertexArray=new e.c8,this.indices=new e.bu,or(this.vertexArray,-1,-1,1),or(this.vertexArray,1,-1,1),or(this.vertexArray,-1,1,1),or(this.vertexArray,1,1,1),or(this.vertexArray,-1,-1,-1),or(this.vertexArray,1,-1,-1),or(this.vertexArray,-1,1,-1),or(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,ir),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.b.simpleSegment(0,0,36,12);}}function ar(t,i,o,r,a,n){const s=t.context.gl,l=i.paint.get(\"sky-atmosphere-color\"),c=i.paint.get(\"sky-atmosphere-halo-color\"),h=i.paint.get(\"sky-atmosphere-sun-intensity\"),_=((e,t,i,o,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[o.r,o.g,o.b,o.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.bC.fromMat4(e.bC.create(),r),a,h,l,c);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+n,i.skyboxTexture,0),o.draw(t,s.TRIANGLES,e.ae.disabled,e.ag.disabled,e.a.unblended,e.af.frontCW,_,\"skyboxCapture\",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}const nr=e.c7([{type:\"Float32\",name:\"a_pos\",components:3},{type:\"Float32\",name:\"a_uv\",components:2}]);class sr{constructor(t){const i=new e.c9;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 o=new e.bu;o.emplaceBack(0,1,2),o.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,nr.members),this.indexBuffer=t.createIndexBuffer(o),this.segments=e.b.simpleSegment(0,0,4,2);}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy();}}const lr=e.c7([{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 cr{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200;}}class hr{constructor(t){this.colorModeAlphaBlendedWriteRGB=new e.a([e.ca,e.cb,e.ca,e.cb],e.C.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new e.a([e.ca,e.cc,e.ca,e.cc],e.C.transparent,[!1,!1,!1,!0]),this.params=new cr,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 sr(i);const t=this.params.sizeRange,o=this.params.intensityRange,r=function(t){const i=e.cf(30),o=[];for(let r=0;r{const l=\"globe\"===a.projection.name?[\"PROJECTION_GLOBE_VIEW\",\"FOG\"]:[\"FOG\"];i&&l.push(\"ALPHA_PASS\");const u=t.getOrCreateProgram(\"globeAtmosphere\",{defines:l}),p=((e,t,i,o,r,a,n,s,l,c,h,_)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:o,u_horizon:r,u_transition:a,u_fadeout_range:n,u_color:s,u_high_color:l,u_space_color:c,u_temporal_offset:h,u_horizon_angle:_}))(a.frustumCorners.TL,a.frustumCorners.TR,a.frustumCorners.BR,a.frustumCorners.BL,a.frustumCorners.horizon,s,d,c,h,_,f,v);t.uploadCommonUniforms(o,u);const m=this.atmosphereBuffer;m&&u.draw(t,r.TRIANGLES,n,e.ag.disabled,i?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,e.af.backCW,p,i?\"atmosphere_glow_alpha\":\"atmosphere_glow\",m.vertexBuffer,m.indexBuffer,m.segments);};x(!1),x(!0);}drawStars(t,i){const o=e.at(i.properties.get(\"star-intensity\"),0,1);if(0===o)return;const r=t.context,a=r.gl,n=t.transform,s=t.getOrCreateProgram(\"stars\"),l=e.av.identity([]);e.av.rotateX(l,l,-n._pitch),e.av.rotateZ(l,l,-n.angle),e.av.rotateX(l,l,e.ab(n._center.lat)),e.av.rotateY(l,l,-e.ab(n._center.lng));const c=e.ad.fromQuat(new Float32Array(16),l),h=e.ad.multiply([],n.starsProjMatrix,c),_=e.bC.fromMat4([],c),u=e.bC.invert([],_),d=[0,1,0];e._.transformMat3(d,d,u),e._.scale(d,d,this.params.sizeMultiplier);const p=[1,0,0];e._.transformMat3(p,p,u),e._.scale(p,p,this.params.sizeMultiplier);const f=(m=d,g=p,v=o,{u_matrix:Float32Array.from(h),u_up:m,u_right:g,u_intensity_multiplier:v});var m,g,v;t.uploadCommonUniforms(r,s),this.starsVx&&this.starsIdx&&s.draw(t,a.TRIANGLES,e.ae.disabled,e.ag.disabled,this.colorModeAlphaBlendedWriteRGB,e.af.disabled,f,\"atmosphere_stars\",this.starsVx,this.starsIdx,this.starsSegments);}}function _r(t,i){const o=[...t],r=i.cameraWorldSizeForFog/i.worldSize,a=e.ad.identity([]);return e.ad.scale(a,a,[r,r,1]),e.ad.multiply(o,a,o),e.ad.multiply(o,i.worldToFogMatrix,o),o}function ur(t,i,o,r,a){const n=o.material,s=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=n.pbrMetallicRoughness,{normalTexture:h,occlusionTexture:_,emissionTexture:u}=n;function d(e,i,o){if(e&&(t.push(i),s.activeTexture.set(s.gl.TEXTURE0+o),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:o,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,o,r);}}d(l,\"HAS_TEXTURE_u_baseColorTexture\",pi.BaseColor),d(c,\"HAS_TEXTURE_u_metallicRoughnessTexture\",pi.MetallicRoughness),d(h,\"HAS_TEXTURE_u_normalTexture\",pi.Normal),d(_,\"HAS_TEXTURE_u_occlusionTexture\",pi.Occlusion),d(u,\"HAS_TEXTURE_u_emissionTexture\",pi.Emission),a&&(a.texture||(a.texture=new e.ch(r.context,a.image,[a.image.height,a.image.height,a.image.height],s.gl.RGBA)),s.activeTexture.set(s.gl.TEXTURE0+pi.LUT),a.texture&&a.texture.bind(s.gl.LINEAR,s.gl.CLAMP_TO_EDGE),t.push(\"APPLY_LUT_ON_GPU\")),o.texcoordBuffer&&(t.push(\"HAS_ATTRIBUTE_a_uv_2f\"),i.push(o.texcoordBuffer)),o.colorBuffer&&(t.push(12===o.colorBuffer.itemSize?\"HAS_ATTRIBUTE_a_color_3f\":\"HAS_ATTRIBUTE_a_color_4f\"),i.push(o.colorBuffer)),o.normalBuffer&&(t.push(\"HAS_ATTRIBUTE_a_normal_3f\"),i.push(o.normalBuffer)),o.pbrBuffer&&(t.push(\"HAS_ATTRIBUTE_a_pbr\"),t.push(\"HAS_ATTRIBUTE_a_heightBasedEmissiveStrength\"),i.push(o.pbrBuffer)),\"OPAQUE\"!==n.alphaMode&&\"MASK\"!==n.alphaMode||t.push(\"UNPREMULT_TEXTURE_IN_SHADER\"),n.defined||t.push(\"DIFFUSE_SHADED\"),t.push(\"USE_STANDARD_DERIVATIVES\");}function dr(t,i,o,r,a,n){const s=o.paint.get(\"model-opacity\"),l=i.context,c=new e.ae(i.context.gl.LEQUAL,e.ae.ReadWrite,i.depthRangeFor3D),h=i.transform,_=t.mesh,u=_.material,d=u.pbrMetallicRoughness,p=i.style.fog;let f;f=\"pixels\"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.ad.multiply([],r.zScaleMatrix,t.nodeModelMatrix),e.ad.multiply(f,r.negCameraPosMatrix,f);const m=e.ad.invert([],f);e.ad.transpose(m,m);const g=o.paint.get(\"model-emissive-strength\").constantOr(0),v=go(new Float32Array(t.worldViewProjection),new Float32Array(f),new Float32Array(m),null,i,s,d.baseColorFactor.toRenderColor(null),u.emissiveFactor,d.metallicFactor,d.roughnessFactor,u,g,o),x={defines:[]},y=[];ur(x.defines,y,_,i,o.lut);const b=i.shadowRenderer;b&&(b.useNormalOffset=!1);let w=null;if(p){const e=_r(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),\"globe\"!==h.projection.name){const t=_.aabb.min,i=_.aabb.max,[o,r]=p.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);x.overrideFog=o>=it||r>=it;}}const T=fi(i,o.paint.get(\"model-cutoff-fade-range\"));T.shouldRenderCutoff&&x.defines.push(\"RENDER_CUTOFF\");const E=i.getOrCreateProgram(\"model\",x);i.uploadCommonUniforms(l,E,null,w,T),\"shadow\"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,a,n,_.material.doubleSided?e.af.disabled:e.af.backCCW,v,o.id,_.vertexBuffer,_.indexBuffer,_.segments,o.paint,i.transform.zoom,void 0,y);}function pr(t,i,o,r,a,n,s){let l;l=\"globe\"===t.projection.name?e.ci(o,t):[...o],e.ad.multiply(l,l,i.matrix);const c=e.ad.multiply([],r,l);if(i.meshes)for(const t of i.meshes){if(\"BLEND\"!==t.material.alphaMode){s.push({mesh:t,depth:0,modelIndex:a,worldViewProjection:c,nodeModelMatrix:l});continue}const i=e._.transformMat4([],t.centroid,c);i[2]>0&&n.push({mesh:t,depth:i[2],modelIndex:a,worldViewProjection:c,nodeModelMatrix:l});}if(i.children)for(const e of i.children)pr(t,e,o,r,a,n,s);}function fr(t,i,o,r){const a=o.shadowRenderer;if(!a)return;const n=a.getShadowPassDepthMode(),s=a.getShadowPassColorMode(),l=a.calculateShadowPassMatrixFromMatrix(i),c=vo(l);o.getOrCreateProgram(\"modelDepth\",{defines:o._shadowMapDebug?[]:[\"DEPTH_TEXTURE\"]}).draw(o,o.context.gl.TRIANGLES,n,e.ag.disabled,s,e.af.backCCW,c,r.id,t.vertexBuffer,t.indexBuffer,t.segments,r.paint,o.transform.zoom,void 0,void 0);}function mr(t,i,o){const r=i.updateZoomBasedPaintProperties(),a=function(t,i,o){let r,a,n,s=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&s>0){const i=t.terrain,a=i.findDEMTileFor(o);a&&a.dem?r=e.ck.create(i,o,a):s=0;}if(0===s&&(i.terrainElevationMin=0,i.terrainElevationMax=0),s===i.validForExaggeration&&(0===s||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;eh&&(h=e.max);}const _=e.at(r.x,n,s)-r.x,u=e.at(r.y,l,c)-r.y,d=e.ax(h,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(_*_+u*u+d*d))}function xr(t,i,o,r,a,n,s){const l=t.context,c=\"shadow\"===t.renderPass,h=t.shadowRenderer,_=c&&h?h.getShadowPassDepthMode():new e.ae(l.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),u=t.isTileAffectedByFog(n);if(o.meshes)for(const d of o.meshes){const p=[\"MODEL_POSITION_ON_GPU\"],f=[];let m,g,v;r.instancedDataArray.length>20&&p.push(\"INSTANCED_ARRAYS\");const x=fi(t,i.paint.get(\"model-cutoff-fade-range\"));if(x.shouldRenderCutoff&&p.push(\"RENDER_CUTOFF\"),c&&h)m=t.getOrCreateProgram(\"modelDepth\",{defines:p}),g=vo(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(o.matrix)),v=h.getShadowPassColorMode();else {ur(p,f,d,t,i.lut),m=t.getOrCreateProgram(\"model\",{defines:p,overrideFog:u});const r=d.material,c=r.pbrMetallicRoughness,_=i.paint.get(\"model-opacity\"),y=i.paint.get(\"model-emissive-strength\").constantOr(0);g=go(n.expandedProjMatrix,Float32Array.from(o.matrix),new Float32Array(16),null,t,_,c.baseColorFactor.toRenderColor(null),r.emissiveFactor,c.metallicFactor,c.roughnessFactor,r,y,i,a),h&&(s.shadowUniformsInitialized?m.setShadowUniformValues(l,h.getShadowUniformValues()):(h.setupShadows(n.toUnwrapped(),m,\"model-tile\",n.overscaledZ),s.shadowUniformsInitialized=!0)),v=x.shouldRenderCutoff||_<1||\"OPAQUE\"!==r.alphaMode?e.a.alphaBlended:e.a.unblended;}t.uploadCommonUniforms(l,m,n.toUnwrapped(),null,x);const y=d.material.doubleSided?e.af.disabled:e.af.backCCW;if(r.instancedDataArray.length>20)f.push(r.instancedDataBuffer),m.draw(t,l.gl.TRIANGLES,_,e.ag.disabled,v,y,g,i.id,d.vertexBuffer,d.indexBuffer,d.segments,i.paint,t.transform.zoom,void 0,f,r.instancedDataArray.length);else {const o=c?\"u_instance\":\"u_normal_matrix\";for(let a=0;ah[1]?l:h,s[0]=o.max[0],l=e.aA.transformMat4([],s,n),c=l[1]h[1]?l:h,s[1]=o.min[1],l=e.aA.transformMat4([],s,n),c=l[1]h[1]?l:h;const _=e.at(r[0],0,1),u=100*i.pixelsPerMeter*e.at(r[1],0,1),d=e.at(r[2],0,1),p=e._.lerp([],c,h,_),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===u)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/u,v=(e,t,i)=>(1-i)*e+i*t,x=e.at(v(1,d,g),d,1);return v(1,x,e.at((i.pitch-20)/20,0,1))}class Er{}class Cr{constructor(){this._storage=new Map;}getLinesFromTrianglesBuffer(t,i,o){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=o.gl,a=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),n=new ArrayBuffer(a),s=new Int16Array(n);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(n));const l=new e.cm;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);}}const Sr=e.c7([{type:\"Float32\",name:\"a_offset_xy\",components:2}]);class Ir{constructor(t){const i=new e.cn,o=new e.bu;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),o.emplaceBack(0,1,2),o.emplaceBack(0,2,3),this.segments=e.b.simpleSegment(0,0,i.length,o.length),this.vx=t.createVertexBuffer(i,Sr.members),this.idx=t.createIndexBuffer(o);}destroy(){this.vx.destroy(),this.idx.destroy();}}const Lr={symbol:function(t,i,o,r,a){if(\"translucent\"!==t.renderPass)return;const n=e.ag.disabled,s=t.colorModeForRenderPass();o.layout.get(\"text-variable-anchor\")&&function(t,i,o,r,a,n,s){const l=i.transform,c=\"map\"===a,h=\"map\"===n;for(const i of t){const t=r.getTile(i),a=t.getBucket(o);if(!a||!a.text||!a.text.segments.get().length)continue;const n=e.aD(a.textSizeData,l.zoom),_=To(i,a.getProjection(),l),u=l.calculatePixelsToTileUnitsMatrix(t),d=Yt(_,t.tileID.canonical,h,c,l,a.getProjection(),u),p=a.hasIconTextFit()&&a.hasIconData();if(n){const o=Math.pow(2,l.zoom-t.tileID.overscaledZ);Po(a,c,h,s,e.bO,l,d,i,o,n,p);}}}(r,t,o,i,o.layout.get(\"text-rotation-alignment\"),o.layout.get(\"text-pitch-alignment\"),a);const l=0!==o.paint.get(\"icon-opacity\").constantOr(1),c=0!==o.paint.get(\"text-opacity\").constantOr(1);void 0!==o.layout.get(\"symbol-sort-key\").constantOr(1)&&(l||c)?Ao(t,i,o,r,n,s):(l&&Ao(t,i,o,r,n,s,{onlyIcons:!0}),c&&Ao(t,i,o,r,n,s,{onlyText:!0}),function(t,i,o,r){if(!t.symbolParams.useOcclusionQueries)return;const a=t.context.gl,n=t.transform,s=o.paint,l=s.get(\"icon-occlusion-opacity\").constantOr(0),c=s.get(\"text-occlusion-opacity\").constantOr(0);if(!o.hasInitialOcclusionOpacityProperties||1===l&&1===c)return;const h=\"globe\"===n.projection.name;for(const s of r){const r=i.getTile(s),l=r.getBucket(o);if(!l)continue;if(\"mercator\"===l.projection.name&&h)continue;if(l.fullyClipped)continue;if(\"globe\"===l.projection.name){e.w(`Occlusion not supported for globe mode. Layer: ${o.type}`);continue}const c=To(s,l.getProjection(),n),_=e.ad.fromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,t.symbolParams.depthOffset,1),u=e.ad.multiply([],_,c),d=\"none\"!==t.symbolParams.visualizeOcclusions?1:t.symbolParams.occlusionQueryFrameWindow;for(let i=0;ie.sortKey-t.sortKey));const x={useDepthForOcclusion:u.depthOcclusionForSymbolsAndCircles};for(const i of v){const{programConfiguration:r,program:a,layoutVertexBuffer:n,globeExtVertexBuffer:s,indexBuffer:l,uniformValues:c,tile:m}=i.state,g=i.segments;t.terrain&&t.terrain.setupElevationDraw(m,a,x),t.uploadCommonUniforms(h,a,m.tileID.toUnwrapped()),a.draw(t,_.TRIANGLES,d,p,f,e.af.disabled,c,o.id,n,l,g,o.paint,u.zoom,r,[s]);}},heatmap:function(t,i,o,r){if(0!==o.paint.get(\"heatmap-opacity\"))if(\"offscreen\"===t.renderPass){const a=t.context,n=a.gl,s=e.ag.disabled,l=new e.a([n.ONE,n.ONE,n.ONE,n.ONE],e.C.transparent,[!0,!0,!0,!0]);!function(e,t,i,o){const r=e.gl,a=t.width*o,n=t.height*o;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,a,n]);let s=i.heatmapFbo;if(!s||s&&(s.width!==a||s.height!==n)){s&&s.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),s=i.heatmapFbo=e.createFramebuffer(a,n,!0,null),function(e,t,i,o,r,a){const n=e.gl;n.texImage2D(n.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?n.RGBA16F:n.RGBA,r,a,0,n.RGBA,e.extRenderToTextureHalfFloat?n.HALF_FLOAT:n.UNSIGNED_BYTE,null),o.colorAttachment.set(i);}(e,0,t,s,a,n);}else r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer);}(a,t,o,\"globe\"===t.transform.projection.name?.5:.25),a.clear({color:e.C.transparent});const c=t.transform,h=\"globe\"===c.projection.name,_=h?[\"PROJECTION_GLOBE_VIEW\"]:[],u=h?e.af.frontCCW:e.af.disabled,d=[e.aj(c.center.lng),e.ak(c.center.lat)];for(let p=0;p({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,o));},line:function(t,i,o,r){if(\"translucent\"!==t.renderPass)return;const a=o.paint.get(\"line-opacity\"),n=o.paint.get(\"line-width\");if(0===a.constantOr(1)||0===n.constantOr(1))return;const s=o.paint.get(\"line-emissive-strength\"),l=o.paint.get(\"line-occlusion-opacity\"),c=t.context,h=c.gl,_=o.layout.get(\"line-z-offset\"),u=!_.isConstant()||!!_.constantOr(0),d=u?new e.ae(t.depthOcclusion?h.GREATER:h.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D):t.depthModeForSublayer(0,e.ae.ReadOnly),p=t.colorModeForDrapableLayerRenderPass(s),f=t.terrain&&t.terrain.renderingToTexture,m=f?1:e.e.devicePixelRatio,g=o.paint.get(\"line-dasharray\"),v=g.constantOr(1),x=o.layout.get(\"line-cap\"),y=g.constantOr(null),b=x.constantOr(null),w=o.paint.get(\"line-pattern\"),T=w.constantOr(1),E=w.constantOr(null),C=o.paint.get(\"line-opacity\").constantOr(1);let S=!T&&1!==C||t.depthOcclusion&&l>0&&l<1;const I=o.paint.get(\"line-gradient\"),L=T?\"linePattern\":\"line\",P=e.bT(o);let A;if(f&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(S=!1),0!==l&&t.depthOcclusion){const t=o.paint._values[\"line-opacity\"];t&&t.value&&\"constant\"===t.value.kind?A=t.value:e.w(`Occlusion opacity for layer ${o.id} is supported only when line-opacity isn't data-driven.`);}if(u&&(t.forceTerrainMode=!0),!u&&0!==l&&t.terrain&&!f)return void e.w(`Occlusion opacity for layer ${o.id} is supported on terrain only if the layer has non-zero line-z-offset.`);const R=S&&u?t.stencilModeFor3D():e.ag.disabled;for(const a of r){const r=i.getTile(a);if(T&&!r.patternsLoaded())continue;const n=r.getBucket(o);if(!n)continue;t.prepareDrawTile();const s=n.programConfigurations.get(o.id),_=t.isTileAffectedByFog(a),g=t.getOrCreateProgram(L,{config:s,defines:u?[...P,\"ELEVATED\"]:P,overrideFog:_});if(E&&r.imageAtlas){const e=r.imageAtlas.patternPositions[E.toString()];e&&s.setConstantPatternPositions(e);}if(!T&&y&&b&&r.lineAtlas){const e=r.lineAtlas.getDash(y,b);e&&s.setConstantPatternPositions(e);}let[x,w]=o.paint.get(\"line-trim-offset\");if(\"round\"===b||\"square\"===b){const e=1;x!==w&&(0===x&&(x-=e),1===w&&(w+=e));}const D=f?a.projMatrix:null,M=T?e.bU(t,r,o,D,m,[x,w]):e.bV(t,r,o,D,n.lineClipsArray.length,m,[x,w]);if(I){const r=n.gradients[o.id];let s=r.texture;if(o.gradientVersion!==r.version){let l=256;if(o.stepInterpolant){const o=i.getSource().maxzoom,r=a.canonical.z===o?Math.ceil(1<{null!=A&&(A.value=C*l),g.draw(t,h.TRIANGLES,d,i,p,e.af.disabled,M,o.id,n.layoutVertexBuffer,n.indexBuffer,n.segments,o.paint,t.transform.zoom,s,[n.layoutVertexBuffer2,n.patternVertexBuffer,n.zOffsetVertexBuffer]),null!=A&&(A.value=C);};if(S&&!u){const i=t.stencilModeForClipping(a).ref;0===i&&f&&c.clear({stencil:0});const o={func:h.EQUAL,mask:255};M.u_alpha_discard_threshold=.8,z(new e.ag(o,i,255,h.KEEP,h.KEEP,h.INVERT)),M.u_alpha_discard_threshold=0,z(new e.ag(o,i,255,h.KEEP,h.KEEP,h.KEEP));}else S&&u&&(M.u_alpha_discard_threshold=.001),z(u?R:t.stencilModeForClipping(a));}S&&(t.resetStencilClippingMasks(),f&&c.clear({stencil:0})),0===l||t.depthOcclusion||f||t.layersWithOcclusionOpacity.push(t.currentLayer),u&&(t.forceTerrainMode=!1);},fill:function(t,i,o,r){const a=o.paint.get(\"fill-color\"),n=o.paint.get(\"fill-opacity\");if(0===n.constantOr(1))return;const s=o.paint.get(\"fill-emissive-strength\"),l=t.colorModeForDrapableLayerRenderPass(s),c=o.paint.get(\"fill-pattern\"),h=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===a.constantOr(e.C.transparent).a&&1===n.constantOr(0)?\"opaque\":\"translucent\";if(t.renderPass===h){const a=t.depthModeForSublayer(1,\"opaque\"===t.renderPass?e.ae.ReadWrite:e.ae.ReadOnly);Do(t,i,o,r,a,l,!1);}if(\"translucent\"===t.renderPass&&o.paint.get(\"fill-antialias\")){const a=t.depthModeForSublayer(o.getPaintProperty(\"fill-outline-color\")?2:0,e.ae.ReadOnly);Do(t,i,o,r,a,l,!0);}},\"fill-extrusion\":function(t,i,o,r){const a=o.paint.get(\"fill-extrusion-opacity\"),n=t.context,s=n.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===a)return;const h=t.conflationActive&&t.style.isLayerClipped(o,i.getSource()),_=t.style.order.indexOf(o.fqid);if(h&&function(e,t,i,o,r){for(const a of o){const o=t.getTile(a).getBucket(i);o&&(o.updateReplacement(a,e.replacementSource,r),o.uploadCentroid(e.context));}}(t,i,o,r,_),l||h)for(const e of r){const r=i.getTile(e).getBucket(o);r&&Oo(t.context,i,e,r,o,l,h);}if(\"shadow\"===t.renderPass&&t.shadowRenderer){const n=t.shadowRenderer;if(l&&a<.65&&o._transitionablePaint._values[\"fill-extrusion-opacity\"].value.expression instanceof e.Z)return;const s=n.getShadowPassDepthMode(),c=n.getShadowPassColorMode();Mo(t,i,o,r,s,e.ag.disabled,c,h);}else if(\"translucent\"===t.renderPass){const _=!o.paint.get(\"fill-extrusion-pattern\").constantOr(1),u=o.paint.get(\"fill-extrusion-color\").constantOr(e.C.white);if(!c&&0!==u.a){const n=new e.ae(t.context.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D);1===a&&_?Mo(t,i,o,r,n,e.ag.disabled,e.a.unblended,h):(Mo(t,i,o,r,n,e.ag.disabled,e.a.disabled,h),Mo(t,i,o,r,n,t.stencilModeFor3D(),t.colorModeForRenderPass(),h),t.resetStencilClippingMasks());}if(t.style.enable3dLights()&&_&&(!l&&\"globe\"!==t.transform.projection.name||c)){const a=o.paint.get(\"fill-extrusion-opacity\"),_=o.paint.get(\"fill-extrusion-ambient-occlusion-intensity\"),u=o.paint.get(\"fill-extrusion-ambient-occlusion-ground-radius\"),d=o.paint.get(\"fill-extrusion-flood-light-intensity\"),p=o.paint.get(\"fill-extrusion-flood-light-color\").toRenderColor(o.lut).toArray01().slice(0,3),f=_>0&&u>0,m=d>0,g=(e,t,i)=>(1-i)*e+i*t,v=n=>{const l=t.depthModeForSublayer(1,e.ae.ReadOnly,s.LEQUAL,!0),c=o.paint.get(n?\"fill-extrusion-ambient-occlusion-ground-attenuation\":\"fill-extrusion-flood-light-ground-attenuation\"),f=g(.1,3,c),m=t._showOverdrawInspector;if(!m){const c=new e.ag({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new e.a([s.ONE,s.ONE,s.ONE,s.ONE],e.C.transparent,[!1,!1,!1,!0],s.MIN);zo(t,i,o,r,l,c,m,e.af.disabled,n,\"sdf\",a,_,u,d,p,f,h,!1);}{const c=m?e.ag.disabled:new e.ag({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),g=m?t.colorModeForRenderPass():new e.a([s.ONE_MINUS_DST_ALPHA,s.DST_ALPHA,s.ONE,s.ONE],e.C.transparent,[!0,!0,!0,!0]);zo(t,i,o,r,l,c,g,e.af.disabled,n,\"color\",a,_,u,d,p,f,h,!1);}};if(c){const c=(n,l,c)=>{const f=t.depthModeForSublayer(1,e.ae.ReadOnly,s.LEQUAL,!1),m=o.paint.get(n?\"fill-extrusion-ambient-occlusion-ground-attenuation\":\"fill-extrusion-flood-light-ground-attenuation\"),v=g(.1,3,m);{const c=new e.a([s.ONE,s.ONE,s.ONE,s.ONE],e.C.transparent,[!1,!1,!1,!0]);zo(t,i,o,r,f,e.ag.disabled,c,e.af.disabled,n,\"clear\",a,_,u,d,p,v,h,l);}{const c=new e.ag({func:s.ALWAYS,mask:255},255,255,s.KEEP,s.KEEP,s.REPLACE),m=new e.a([s.ONE,s.ONE,s.ONE,s.ONE],e.C.transparent,[!1,!1,!1,!0],s.MIN);zo(t,i,o,r,f,c,m,e.af.disabled,n,\"sdf\",a,_,u,d,p,v,h,l);}{const c=n?s.ZERO:s.ONE_MINUS_DST_ALPHA,m=new e.ag({func:s.EQUAL,mask:255},255,255,s.KEEP,s.DECR,s.DECR),g=new e.a([c,s.DST_ALPHA,s.ONE_MINUS_DST_ALPHA,s.ZERO],e.C.transparent,[!0,!0,!0,!0]);zo(t,i,o,r,f,m,g,e.af.disabled,n,\"color\",a,_,u,d,p,v,h,l);}{const m=new e.a([s.ONE,s.ONE,s.ONE,n?s.ZERO:s.ONE],e.C.transparent,[!1,!1,!1,!0],n?s.FUNC_ADD:s.MAX);zo(t,i,o,r,f,e.ag.disabled,m,e.af.disabled,n,\"clear\",a,_,u,d,p,v,h,l,c);}};if(f||m){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],o=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===o)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(n,new e.i({width:t,height:o}),s.RGBA)),i.bind(s.LINEAR,s.CLAMP_TO_EDGE),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGBA,0,0,t,o,0);}f&&c(!0,!1,i),m&&c(!1,!0,i);}}else f&&v(!0),m&&v(!1);}}},hillshade:function(t,i,o,r){if(\"offscreen\"!==t.renderPass&&\"translucent\"!==t.renderPass)return;if(t.style.disableElevatedTerrain)return;const a=t.context,n=t.terrain&&t.terrain.renderingToTexture,[s,l]=\"translucent\"!==t.renderPass||n?[{},r]:t.stencilConfigForOverlap(r);for(const r of l){const a=i.getTile(r);if(a.needsHillshadePrepare&&\"offscreen\"===t.renderPass)Ot(t,a,o);else if(\"translucent\"===t.renderPass){const i=t.depthModeForSublayer(0,e.ae.ReadOnly),l=o.paint.get(\"hillshade-emissive-strength\"),c=t.colorModeForDrapableLayerRenderPass(l),h=n&&t.terrain?t.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];Mt(t,r,a,o,i,h,c);}}a.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks();},raster:function(t,i,o,r,a,n){if(\"translucent\"!==t.renderPass)return;if(0===o.paint.get(\"raster-opacity\"))return;const s=\"globe\"===t.transform.projection.name,l=0!==o.paint.get(\"raster-elevation\"),c=l&&s;if(t.renderElevatedRasterBackface&&!c)return;const h=t.context,_=h.gl,u=i.getSource(),d=function(t,i,o,r){const a=i.paint.get(\"raster-color\"),n=\"raster-array\"===t.type,s=[],l=i.paint.get(\"raster-resampling\"),c=i.paint.get(\"raster-color-mix\");let h=i.paint.get(\"raster-color-range\");const _=[c[0],c[1],c[2],0],u=c[3];let d=\"nearest\"===l?r.NEAREST:r.LINEAR;if(n&&(s.push(\"RASTER_ARRAY\"),a||s.push(\"RASTER_COLOR\"),\"linear\"===l&&s.push(\"RASTER_ARRAY_LINEAR\"),d=r.NEAREST,!h&&t.rasterLayers)){const e=t.rasterLayers.find((({id:e})=>e===i.sourceLayer));e&&e.fields&&e.fields.range&&(h=e.fields.range);}if(h=h||[0,1],a){s.push(\"RASTER_COLOR\"),o.activeTexture.set(r.TEXTURE2),i.updateColorRamp(h);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(o,i.colorRamp,r.RGBA)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE);}return {mix:_,range:h,offset:u,defines:s,resampling:d}}(u,o,h,_);if(u instanceof e.bm&&!r.length&&!s)return;const p=o.paint.get(\"raster-emissive-strength\"),f=t.colorModeForDrapableLayerRenderPass(p),m=t.terrain&&t.terrain.renderingToTexture,g=!t.options.moving,v=\"nearest\"===o.paint.get(\"raster-resampling\")?_.NEAREST:_.LINEAR;if(u instanceof e.bm&&!r.length&&(u.onNorthPole||u.onSouthPole)){const r=l?t.stencilModeFor3D():e.ag.disabled;return void Go(!!u.onNorthPole,null,t,i,o,p,d,e.af.disabled,r)}if(!r.length)return;const[x,y]=u instanceof e.bm||m?[{},r]:t.stencilConfigForOverlap(r),b=y[y.length-1].overscaledZ;c&&d.defines.push(\"PROJECTION_GLOBE_VIEW\"),l&&d.defines.push(\"RENDER_CUTOFF\");const w=(r,a,y)=>{for(const w of r){const r=w.toUnwrapped(),T=i.getTile(w);if(m&&(!T||!T.hasData()))continue;h.activeTexture.set(_.TEXTURE0);const E=Vo(T,u,o,d);if(!E||!E.texture)continue;const{texture:C,mix:S,offset:I,tileSize:L,buffer:P}=E;let A,R;m?(A=e.ae.disabled,R=w.projMatrix):l?(A=new e.ae(_.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),R=s?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,g)):(A=t.depthModeForSublayer(w.overscaledZ-b,1===o.paint.get(\"raster-opacity\")?e.ae.ReadWrite:e.ae.ReadOnly,_.LESS),R=t.transform.calculateProjMatrix(r,g));const D=t.terrain&&m?t.terrain.stencilModeForRTTOverlap(w):x[w.overscaledZ],M=n?0:o.paint.get(\"raster-fade-duration\");T.registerFadeDuration(M);const z=i.findLoadedParent(w,0),O=Ai(T,z,i,t.transform,M);let F,B;t.terrain&&t.terrain.prepareDrawTile(),h.activeTexture.set(_.TEXTURE0),C.bind(v,_.CLAMP_TO_EDGE),h.activeTexture.set(_.TEXTURE1),z?(z.texture&&z.texture.bind(v,_.CLAMP_TO_EDGE),F=Math.pow(2,z.tileID.overscaledZ-T.tileID.overscaledZ),B=[T.tileID.canonical.x*F%1,T.tileID.canonical.y*F%1]):C.bind(v,_.CLAMP_TO_EDGE),C.useMipmap&&h.extTextureFilterAnisotropic&&t.transform.pitch>20&&_.texParameterf(_.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const k=t.transform;let N;const U=l?jo(k):[0,0,0,0];let G,j,V,W,Z,q=0;if(c&&u instanceof e.bm&&u.coordinates.length>3)G=Float32Array.from(e.bf(e.bg(new e.aO(0,0,0)))),j=Float32Array.from(k.globeMatrix),V=Float32Array.from(e.bb(k)),W=[e.aj(k.center.lng),e.ak(k.center.lat)],N=u.elevatedGlobePerspectiveTransform,Z=u.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.bc(w.canonical);q=e.bd(t.getCenter().lat),G=Float32Array.from(e.bf(e.bg(w.canonical))),j=Float32Array.from(k.globeMatrix),V=Float32Array.from(e.bb(k)),W=[e.aj(k.center.lng),e.ak(k.center.lat)],N=[0,0],Z=Float32Array.from(e.be(w.canonical,t,q,k.worldSize/k._pixelsPerMercatorPixel));}else N=u instanceof e.bm?u.perspectiveTransform:[0,0],G=new Float32Array(16),j=new Float32Array(9),V=new Float32Array(16),W=[0,0],Z=new Float32Array(9);const H=oo(R,G,j,V,Z,B||[0,0],e.a1(t.transform.zoom),W,U,F||1,O,o,N,l?o.paint.get(\"raster-elevation\"):0,2,S,I,d.range,L,P,p),$=t.isTileAffectedByFog(w),X=t.getOrCreateProgram(\"raster\",{defines:d.defines,overrideFog:$});if(t.uploadCommonUniforms(h,X,r),u instanceof e.bm){const i=u.elevatedGlobeVertexBuffer,r=u.elevatedGlobeIndexBuffer;if(m||!s)u.boundsBuffer&&u.boundsSegments&&X.draw(t,_.TRIANGLES,A,e.ag.disabled,f,e.af.disabled,H,o.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else if(i&&r){const n=k.zoom<=e.b1?u.elevatedGlobeSegments:u.getSegmentsForLongitude(k.center.lng);n&&X.draw(t,_.TRIANGLES,A,e.ag.disabled,f,a,H,o.id,i,r,n);}}else if(c){A=new e.ae(_.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D);const i=t.globeSharedBuffers;if(i){const[e,r,n]=i.getGridBuffers(q,!1);X.draw(t,_.TRIANGLES,A,y||D,t.colorModeForRenderPass(),a,H,o.id,e,r,n);}}else {const{tileBoundsBuffer:i,tileBoundsIndexBuffer:r,tileBoundsSegments:a}=t.getTileBoundsBuffers(T);X.draw(t,_.TRIANGLES,A,D,f,e.af.disabled,H,o.id,i,r,a);}}if(!(u instanceof e.bm)&&c)for(const n of r){const r=n.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},r=1/1.1;for(let e=0;ee.bZ[t](r)));p.push(r);const f=r.canonical.x,m=r.canonical.y;for(const a of p){const s=i.getTile(l?a.wrapped():a);if(!s)continue;const h=s.rasterParticleState;if(!h)continue;const u=a.canonical.x+(1<e.tileID))),u&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context,o.scope));for(const p of y){const y=t.isTileAffectedByFog(p),b=t.getOrCreateProgram(v,{overrideFog:y}),w=p.toUnwrapped(),T=r?p.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(p):x?x[p.key]:new e.by(p,_,h.zoom,t),C=u?fo(T,s,n,t,0,o.scope,d,{tileID:p,tileSize:_}):po(T,s,n,a.toRenderColor(o.lut));t.uploadCommonUniforms(l,b,w);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:I,tileBoundsSegments:L}=t.getTileBoundsBuffers(E);b.draw(t,c.TRIANGLES,m,f,g,e.af.disabled,C,o.id,S,I,L);}},sky:function(t,i,o){const r=t._atmosphere?e.a1(t.transform.zoom):1,a=o.paint.get(\"sky-opacity\")*r;if(0===a)return;const n=t.context,s=o.paint.get(\"sky-type\"),l=new e.ae(n.gl.LEQUAL,e.ae.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;\"atmosphere\"===s?\"offscreen\"===t.renderPass?o.needsSkyboxCapture(t)&&(function(t,i,o,r){const a=t.context,n=a.gl;let s=i.skyboxFbo;if(!s){s=i.skyboxFbo=a.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new rr(a),i.skyboxTexture=a.gl.createTexture(),n.bindTexture(n.TEXTURE_CUBE_MAP,i.skyboxTexture),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,n.LINEAR);for(let e=0;e<6;++e)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,n.RGBA,32,32,0,n.RGBA,n.UNSIGNED_BYTE,null);}a.bindFramebuffer.set(s.framebuffer),a.viewport.set([0,0,32,32]);const l=i.getCenter(t,!0),c=t.getOrCreateProgram(\"skyboxCapture\"),h=new Float64Array(16);e.ad.identity(h),e.ad.rotateY(h,h,.5*-Math.PI),ar(t,i,c,h,l,0),e.ad.identity(h),e.ad.rotateY(h,h,.5*Math.PI),ar(t,i,c,h,l,1),e.ad.identity(h),e.ad.rotateX(h,h,.5*-Math.PI),ar(t,i,c,h,l,2),e.ad.identity(h),e.ad.rotateX(h,h,.5*Math.PI),ar(t,i,c,h,l,3),e.ad.identity(h),ar(t,i,c,h,l,4),e.ad.identity(h),e.ad.rotateY(h,h,Math.PI),ar(t,i,c,h,l,5),a.viewport.set([0,0,t.width,t.height]);}(t,o),o.markSkyboxValid(t)):\"sky\"===t.renderPass&&function(t,i,o,r,a){const n=t.context,s=n.gl,l=t.transform,c=t.getOrCreateProgram(\"skybox\");n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture);const h=((e,t,i,o,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:o,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(t,!1),0,r,a);t.uploadCommonUniforms(n,c),c.draw(t,s.TRIANGLES,o,e.ag.disabled,t.colorModeForRenderPass(),e.af.backCW,h,\"skybox\",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,a,c):\"gradient\"===s&&\"sky\"===t.renderPass&&function(t,i,o,r,a){const n=t.context,s=n.gl,l=t.transform,c=t.getOrCreateProgram(\"skyboxGradient\");i.skyboxGeometry||(i.skyboxGeometry=new rr(n)),n.activeTexture.set(s.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.T(n,i.colorRamp,s.RGBA)),h.bind(s.LINEAR,s.CLAMP_TO_EDGE);const _=((t,i,o,r,a)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.ab(o),u_opacity:r,u_temporal_offset:a}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get(\"sky-gradient-radius\"),r,a);t.uploadCommonUniforms(n,c),c.draw(t,s.TRIANGLES,o,e.ag.disabled,t.colorModeForRenderPass(),e.af.backCW,_,\"skyboxGradient\",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment);}(t,o,l,a,c);},debug:function(t,i,o,r,a,n){for(let s=0;s{s&&(s.useNormalOffset=!0,l||(s.enabled=!0));},h=i.getSource();if(\"light-beam\"===t.renderPass&&\"batched-model\"!==h.type)return;if(\"vector\"===h.type||\"geojson\"===h.type)return function(t,i,o,r,a){const n=t.transform;if(\"mercator\"!==n.projection.name)return void e.w(`Drawing 3D models for ${n.projection.name} projection is not yet implemented`);const s=n.getFreeCameraOptions().position;if(!t.modelManager)return;const l=t.modelManager;o.modelManager=l;const c=t.shadowRenderer;if(!o._unevaluatedLayout._values.hasOwnProperty(\"model-id\"))return;const h=o._unevaluatedLayout._values[\"model-id\"],_={...o.layout.get(\"model-id\").parameters},u=t.style.order.indexOf(o.fqid);for(const d of r){const r=i.getTile(d).getBucket(o);if(!r||r.projection.name!==n.projection.name)continue;const p=r.getModelUris();p&&!r.modelsRequested&&(l.addModelsFromBucket(p,a),r.modelsRequested=!0);const f=vr(d,n);_.zoom=f;const m=h.possiblyEvaluate(_);if(mr(t,r,d),gr.shadowUniformsInitialized=!1,gr.useSingleShadowCascade=!!c&&0===c.getMaxCascadeForTile(d.toUnwrapped()),\"shadow\"===t.renderPass&&c){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=n.calculatePosMatrix(d.toUnwrapped(),n.worldSize);if(gr.tileMatrix.set(i),gr.shadowTileMatrix=Float32Array.from(c.calculateShadowPassMatrixFromMatrix(i)),gr.aabb.min.fill(0),gr.aabb.max[0]=gr.aabb.max[1]=e.a3,gr.aabb.max[2]=0,br(r,gr,t,o.scope))continue}const g=1<0&&t.style.isLayerClipped(o,i.getSource())&&r.updateReplacement(d,t.replacementSource,u)&&(r.uploaded=!1,r.upload(t.context));for(let e in r.instancesPerModel){const i=r.instancesPerModel[e];i.features.length>0&&(e=m.evaluate(i.features[0].feature,{}));const n=l.getModel(e,a);if(n&&n.uploaded)for(const e of n.nodes)xr(t,o,e,i,v,d,gr);}}}(t,i,o,r,\"vector\"===h.type?o.scope:\"\"),void c();if(!h.loaded())return;if(\"batched-model\"===h.type)return function(t,i,o,r){o.resetLayerRenderingStats(t);const a=t.context,n=t.transform,s=t.style.fog,l=t.shadowRenderer;if(\"mercator\"!==n.projection.name)return void e.w(`Drawing 3D landmark models for ${n.projection.name} projection is not yet implemented`);const c=t.transform.getFreeCameraOptions().position,h=e._.scale([],[c.x,c.y,c.z],t.transform.worldSize);e._.negate(h,h);const _=e.ad.identity([]),u=e.cg(n.center.lat,n.zoom),d=e.ad.fromScaling([],[1,1,1/u]);e.ad.translate(_,_,h);const p=o.paint.get(\"model-opacity\"),f=new e.ae(a.gl.LEQUAL,e.ae.ReadWrite,t.depthRangeFor3D),m=new e.ae(a.gl.LEQUAL,e.ae.ReadOnly,t.depthRangeFor3D),g=new e.b6([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),v=\"shadow\"===t.renderPass,x=v&&l?l.getCurrentCascadeFrustum():n.getFrustum(n.scaleZoom(n.worldSize)),y=o.paint.get(\"model-front-cutoff\"),b=y[2]<1,w=fi(t,o.paint.get(\"model-cutoff-fade-range\")),T=o.getLayerRenderingStats();((function(e,t,i,o){const r=e.terrain?e.terrain.exaggeration():0,a=e.transform.zoom;for(const n of o){const o=t.getTile(n).getBucket(i);o&&(e.conflationActive&&o.updateReplacement(n,e.replacementSource),o.evaluateScale(e,i),e.terrain&&r>0&&o.elevationUpdate(e.terrain,r,n,i.source),o.needsReEvaluation(e,a,i)&&o.evaluate(i));}}))(t,i,o,r),function(){let c,h,u;b?(c=r.length-1,h=-1,u=-1):(c=0,h=r.length,u=1);for(let E=c;E!==h;E+=u){const c=r[E],h=i.getTile(c).getBucket(o);if(!h||!h.uploaded)continue;let u=!1;l&&(u=0===l.getMaxCascadeForTile(c.toUnwrapped()));const C=n.calculatePosMatrix(c.toUnwrapped(),n.worldSize),S=h.modelTraits,I=[];for(const i of h.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const o=i.node;let r=0;t.terrain&&o.elevation&&(r=o.elevation*t.terrain.exaggeration());const a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===(()=>{const t=i.aabb;return g.min=[...t.min],g.max=[...t.max],g.min[2]+=r,g.max[2]+=r,e._.transformMat4(g.min,g.min,C),e._.transformMat4(g.max,g.max,C),g})().intersects(x))continue;const s=[...C],l=o.anchor?o.anchor[0]:0,c=o.anchor?o.anchor[1]:0;e.ad.translate(s,s,[l*(a[0]-1),c*(a[1]-1),r]),e._.exactEquals(a,e.cj)||e.ad.scale(s,s,a);const h=e.ad.multiply([],s,o.matrix),_=e.ad.multiply([],n.expandedFarZProjMatrix,h),u=e.ad.multiply([],n.expandedFarZProjMatrix,s),d=e.aA.transformMat4([],[l,c,r,1],_)[2];o.hidden=!1;let f=p;v||(b&&(f*=Tr(s,n,i.aabb,y)),f*=wr(w,d)),0!==f?I.push({nodeInfo:i,depth:d,opacity:f,wvpForNode:_,wvpForTile:u,nodeModelMatrix:h,tileModelMatrix:s}):o.hidden=!0;}v||I.sort(((e,t)=>!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1));for(const i of I){const r=i.nodeInfo,c=r.node;let h=e.ad.multiply([],d,i.tileModelMatrix);e.ad.multiply(h,_,h);const p=e.ad.invert([],h);e.ad.transpose(p,p),e.ad.scale(p,p,yr),h=e.ad.multiply(h,h,c.matrix);const g=\"light-beam\"===t.renderPass,x=S&e.cl.HasMapboxMeshFeatures,y=x?0:r.evaluatedRMEA[0][2];for(let _=0;_=it||r>=it;}}const I=d.material;let L;I.occlusionTexture&&I.occlusionTexture.offsetScale&&(L=I.occlusionTexture.offsetScale,E.defines.push(\"OCCLUSION_TEXTURE_TRANSFORM\")),!v&&l&&(l.useNormalOffset=!!d.normalBuffer);const P=t.getOrCreateProgram(\"model\",E);!v&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,P,l.useNormalOffset),t.uploadCommonUniforms(a,P,null,S);const A=I.pbrMetallicRoughness;A.metallicFactor=.9,A.roughnessFactor=.5;const R=go(new Float32Array(w),new Float32Array(h),new Float32Array(p),new Float32Array(c.matrix),t,i.opacity,A.baseColorFactor.toRenderColor(null),I.emissiveFactor,A.metallicFactor,A.roughnessFactor,I,y,o,[0,0,0],L);!b&&(r.hasTranslucentParts||i.opacity<1)&&P.draw(t,a.gl.TRIANGLES,f,e.ag.disabled,e.a.disabled,e.af.backCCW,R,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,C),P.draw(t,a.gl.TRIANGLES,b?m:f,e.ag.disabled,b||i.opacity<1||r.hasTranslucentParts?e.a.alphaBlended:e.a.unblended,e.af.backCCW,R,o.id,d.vertexBuffer,d.indexBuffer,d.segments,o.paint,t.transform.zoom,void 0,C);}}}}();}(t,i,o,r),void c();if(\"model\"!==h.type)return;const _=h.getModels(),u=[],d=t.transform.getFreeCameraOptions().position,p=e._.scale([],[d.x,d.y,d.z],t.transform.worldSize);e._.negate(p,p);const f=[],m=[];let g=0;for(const i of _){const r=o.paint.get(\"model-rotation\").constantOr(null),a=o.paint.get(\"model-scale\").constantOr(null),n=o.paint.get(\"model-translation\").constantOr(null);i.computeModelMatrix(t,r,a,n,!0,!0,!1);const s=e.ad.identity([]),l=e.cg(i.position.lat,t.transform.zoom),c=e.ad.fromScaling([],[1,1,1/l]);e.ad.translate(s,s,p),u.push({zScaleMatrix:c,negCameraPosMatrix:s});for(const e of i.nodes)pr(t.transform,e,i.matrix,t.transform.expandedFarZProjMatrix,g,f,m);g++;}if(f.sort(((e,t)=>t.depth-e.depth)),\"shadow\"!==t.renderPass){if(1===a)for(const i of m)dr(i,t,o,u[i.modelIndex],e.ag.disabled,t.colorModeForRenderPass());else {for(const i of m)dr(i,t,o,u[i.modelIndex],e.ag.disabled,e.a.disabled);for(const e of m)dr(e,t,o,u[e.modelIndex],t.stencilModeFor3D(),t.colorModeForRenderPass());t.resetStencilClippingMasks();}for(const i of f)dr(i,t,o,u[i.modelIndex],e.ag.disabled,t.colorModeForRenderPass());c();}else {for(const e of m)fr(e.mesh,e.nodeModelMatrix,t,o);for(const e of f)fr(e.mesh,e.nodeModelMatrix,t,o);c();}}},Pr={model:function(e,t,i){const o=t.getSource();if(!o.loaded())return;if(\"vector\"===o.type||\"geojson\"===o.type)return void(i.modelManager&&i.modelManager.upload(i,\"vector\"===o.type?e.scope:\"\"));if(\"batched-model\"===o.type)return;if(\"model\"!==o.type)return;const r=o.getModels();for(const e of r)e.upload(i.context);},raster:function(e,t,i){const o=t.getSource();if(!(o instanceof Ri&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const a=e.paint.get(\"raster-array-band\")||o.getInitialBand(r);if(null==a)return;const n=t.getIds().map((e=>t.getTileByID(e)));for(const e of n)e.updateNeeded(r,a)&&o.prepareTile(e,r,a);},\"raster-particle\":function(e,t,i){const o=t.getSource();if(!(o instanceof Ri&&o.loaded()))return;const r=e.sourceLayer||o.rasterLayerIds&&o.rasterLayerIds[0];if(!r)return;const a=e.paint.get(\"raster-particle-array-band\")||o.getInitialBand(r);if(null==a)return;const n=t.getIds().map((e=>t.getTileByID(e)));for(const e of n)e.updateNeeded(r,a)&&o.prepareTile(e,r,a);}};class Ar{constructor(t,i,o,r){this.context=new ae(t,i),this.occlusionBuffers=new Ir(this.context),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=r,this._timeStamp=e.e.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=[\"fill\",\"line\",\"symbol\",\"circle\",\"heatmap\",\"fill-extrusion\",\"raster\",\"raster-particle\",\"hillshade\",\"model\",\"background\",\"sky\"];for(const e of a)this._debugParams.enabledLayers[e]=!0;r.registerParameter(this._debugParams,[\"Terrain\"],\"showTerrainProxyTiles\",{},(()=>{this.style.map.triggerRepaint();})),r.registerParameter(this._debugParams,[\"FPS\"],\"fpsWindow\",{min:1,max:100,step:1}),r.registerBinding(this._debugParams,[\"FPS\"],\"continousRedraw\",{readonly:!0,label:\"continuous redraw\"}),r.registerBinding(this,[\"FPS\"],\"_averageFPS\",{readonly:!0,label:\"value\"}),r.registerBinding(this,[\"FPS\"],\"_averageFPS\",{readonly:!0,label:\"graph\",view:\"graph\",min:0,max:200});for(const e of a)r.registerParameter(this._debugParams.enabledLayers,[\"Debug\",\"Layers\"],e);this.symbolParams=new se(r),this.setup(),this.numSublayers=e.bv.maxUnderzooming+e.bv.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.co,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new xi(this),this._wireframeDebugCache=new Cr,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];}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 Bi(this,e));const o=this._terrain;this.transform.elevation=i?o:null,o.update(e,this.transform,t),this.transform.elevation&&!o.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,o]=t.getFovAdjustedRange(this.transform._fov);if(i>o)return void(this.transform.fogCullDistSq=null);const r=i+.78*(o-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 Bi(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.e.devicePixelRatio,this.height=i*e.e.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.bt;i.emplaceBack(0,0),i.emplaceBack(e.a3,0),i.emplaceBack(0,e.a3),i.emplaceBack(e.a3,e.a3),this.tileExtentBuffer=t.createVertexBuffer(i,e.br.members),this.tileExtentSegments=e.b.simpleSegment(0,0,4,2);const o=new e.bt;o.emplaceBack(0,0),o.emplaceBack(e.a3,0),o.emplaceBack(0,e.a3),o.emplaceBack(e.a3,e.a3),this.debugBuffer=t.createVertexBuffer(o,e.br.members),this.debugSegments=e.b.simpleSegment(0,0,4,5);const r=new e.bt;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(r,e.br.members),this.viewportSegments=e.b.simpleSegment(0,0,4,2);const a=new e.cp;a.emplaceBack(0,0,0,0),a.emplaceBack(e.a3,0,e.a3,0),a.emplaceBack(0,e.a3,0,e.a3),a.emplaceBack(e.a3,e.a3,e.a3,e.a3),this.mercatorBoundsBuffer=t.createVertexBuffer(a,e.cq.members),this.mercatorBoundsSegments=e.b.simpleSegment(0,0,4,2);const n=new e.bu;n.emplaceBack(0,1,2),n.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(n);const s=new e.cr;for(const e of [0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.T(t,new e.i({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.ad.create();const l=this.context.gl;this.stencilClearMode=new e.ag({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 t=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram(\"clippingMask\").draw(this,t.TRIANGLES,e.ae.disabled,this.stencilClearMode,e.a.disabled,e.af.disabled,Pi(this.identityMat),\"$clipping\",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments);}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={});}_renderTileClippingMasks(t,i,o){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!o||0===o.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of o)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const r=this.context,a=r.gl;this.nextStencilID+o.length>256&&this.clearStencil(),r.setColorMode(e.a.disabled),r.setDepthMode(e.ae.disabled);const n=this.getOrCreateProgram(\"clippingMask\");this._tileClippingMaskIDs={};for(const t of o){const o=i.getTile(t),r=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:l,tileBoundsSegments:c}=this.getTileBoundsBuffers(o);n.draw(this,a.TRIANGLES,e.ae.disabled,new e.ag({func:a.ALWAYS,mask:0},r,255,a.KEEP,a.KEEP,a.REPLACE),e.a.disabled,e.af.disabled,Pi(t.projMatrix),\"$clipping\",s,l,c);}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e.ag({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e.ag({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,o=t.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=o[o.length-1].overscaledZ,a=o[0].overscaledZ-r+1;if(a>1){this.currentStencilSource=void 0,this.nextStencilID+a>256&&this.clearStencil();const t={};for(let o=0;othis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&\"translucent\"===this.renderPass?new e.a([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.C(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(t,i,o,r=!1){if(this.depthOcclusion)return new e.ae(this.context.gl.GREATER,e.ae.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!r)return e.ae.disabled;const a=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.ae(o||this.context.gl.LEQUAL,i,[a,a])}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 o=e.e.now();this._dt=o-this._timeStamp,this._timeStamp=o,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,a=this.style.order.filter((e=>{const t=r[e];return !(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]})),n=a.map((e=>r[e])),s=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.e.now()),this.imageManager.beginFrame();let l=0,c=!1;for(const e in s){const t=s[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++l);}let h=!1;for(const e of n)e.isHidden(this.transform.zoom)||(\"clip\"===e.type&&(h=!0),this.prepareLayer(e));const _={},u={},d={},p={},f={};for(const e in s){const t=s[e];_[e]=t.getVisibleCoordinates(),u[e]=_[e].slice().reverse(),d[e]=t.getVisibleCoordinates(!0).reverse(),p[e]=t.getShadowCasterCoordinates(),f[e]=t.sortCoordinatesByDistance(_[e]);}const m=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(l||h){const t=[],i=[];let o=0;for(const e of n)this.isSourceForClippingOrConflation(e,m(e))&&(t.push(e),i.push(o)),o++;if(t&&(h||t.length>1)){const o=[];for(let r=0;r0){const e=m(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom));}t.is3D()&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e);}const g=this.style&&this.style.fog;g?(this._fogVisible=0!==g.getOpacity(this.transform.pitch),this._fogVisible&&\"globe\"!==this.transform.projection.name&&(this._fogVisible=g.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(d),this.opaquePassCutoff=0);const v=this._shadowRenderer;if(v){v.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in s)for(const t of _[e]){let e={min:0,max:0};this.terrain&&(e=this.terrain.getMinMaxForTile(t)||e),v.addShadowReceiver(t.toUnwrapped(),e.min,e.max);}}if(\"globe\"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.cs(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new hr(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),!e.ct(this.context.gl))return;this.renderPass=\"offscreen\";for(const e of n){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const o=i?u[i.id]:void 0;(\"custom\"===e.type||\"raster\"===e.type||\"raster-particle\"===e.type||e.isSky()||o&&o.length)&&this.renderLayer(this,i,e,o);}this.depthRangeFor3D=[0,1-(n.length+2)*this.numSublayers*this.depthEpsilon],this._shadowRenderer&&(this.renderPass=\"shadow\",this._shadowRenderer.drawShadowPass(this.style,p)),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);const x=\"globe\"===this.transform.projection.name||this.transform.isHorizonVisible(),y=(()=>{if(i.showOverdrawInspector)return e.C.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!x){const o=t.properties.get(\"color\").toRenderColor(i).toArray01();return new e.C(...o)}if(x){const o=t.properties.get(\"space-color\").toRenderColor(i).toArray01();return new e.C(...o)}}return e.C.transparent})();if(this.context.clear({color:y,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass=\"opaque\",this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&x&&this._atmosphere.drawStars(this,this.style.fog),!this.terrain)for(this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=n[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const o=i?(e.is3D()?f:u)[i.id]:void 0;this._renderTileClippingMasks(e,i,o),this.renderLayer(this,i,e,o);}if(this.style.fog&&this.transform.projection.supportsFog&&this._atmosphere&&!this._showOverdrawInspector&&x&&this._atmosphere.drawAtmosphereGlow(this,this.style.fog),this.renderPass=\"sky\",(!this._atmosphere||e.a1(this.transform.zoom)>0)&&(\"globe\"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--w&&(v.drawGroundShadows(),this.firstLightBeamLayer<=this.currentLayer)){const e=this.currentLayer;for(this.renderPass=\"light-beam\",this.currentLayer=this.firstLightBeamLayer;this.currentLayer<=e;this.currentLayer++){const e=n[this.currentLayer];if(!e.hasLightBeamPass())continue;const i=t.getLayerSourceCache(e);this.renderLayer(this,i,e,i?u[i.id]:void 0);}this.currentLayer=e,this.renderPass=\"translucent\";}if(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=n[this.currentLayer],o=t.getLayerSourceCache(i),r=o?u[o.id]:void 0;i.is3D()||this.terrain||this._renderTileClippingMasks(i,o,o?_[o.id]:void 0),this.renderLayer(this,o,i,r);}this.depthOcclusion=!1,this.currentLayer=e,this.renderPass=\"translucent\",this.layersWithOcclusionOpacity=[];}++this.currentLayer;}}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let i=null;n.forEach((e=>{const o=t.getLayerSourceCache(e);o&&!e.isHidden(this.transform.zoom)&&o.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 o=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\")):o||r.push(\"LIGHTING_3D_MODE\")),\"shadow\"===this.renderPass?this._shadowMapDebug||r.push(\"DEPTH_TEXTURE\"):this.shadowRenderer&&(this.shadowRenderer.useNormalOffset?r.push(\"RENDER_SHADOWS\",\"DEPTH_TEXTURE\",\"NORMAL_OFFSET\"):r.push(\"RENDER_SHADOWS\",\"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||o||void 0!==t&&!t||r.push(\"FOG\",\"FOG_DITHERING\"),o&&r.push(\"RENDER_TO_TEXTURE\"),this._showOverdrawInspector&&r.push(\"OVERDRAW_INSPECTOR\"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],o=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),a=Gi.cacheKey(Lt[e],e,r,o);return this.cache[a]||(this.cache[a]=new Gi(this.context,e,Lt[e],o,yo[e],r)),this.cache[a]}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.RGBA));}destroy(){this._terrain&&this._terrain.destroy(),this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this._wireframeDebugCache.destroy(),this.terrainDepthFBO&&(this.terrainDepthFBO.destroy(),this.terrainDepthFBO=void 0,this.terrainDepthTexture=void 0);}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile();}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const o=this.style.directionalLight,r=this.style.ambientLight;if(o&&r){const a=((t,i,o)=>{const r=t.properties.get(\"direction\"),a=t.properties.get(\"color\").toRenderColor(o.getLut(t.scope)).toArray01(),n=t.properties.get(\"intensity\"),s=i.properties.get(\"color\").toRenderColor(o.getLut(i.scope)).toArray01(),l=i.properties.get(\"intensity\"),c=[r.x,r.y,r.z],h=e.bA(s,l),_=e.bA(a,n);return {u_lighting_ambient_color:h,u_lighting_directional_dir:c,u_lighting_directional_color:_,u_ground_radiance:ki(c,_,h)}})(o,r,this.style);i.setLightsUniformValues(t,a);}}}uploadCommonUniforms(t,i,o,r,a){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const n=this.style.fog;if(n){const a=n.getOpacity(this.transform.pitch),s=((t,i,o,r,a,n,s,l,c,h,_,u)=>{const d=t.transform,p=i.properties.get(\"color\").toRenderColor(t.style.getLut(i.scope)).toArray01();p[3]=r;const f=t.frameCounter/1e3%1,[m,g]=i.properties.get(\"vertical-range\");return {u_fog_matrix:o?d.calculateFogTileMatrix(o):u||t.identityMat,u_fog_range:i.getFovAdjustedRange(d._fov),u_fog_color:p,u_fog_horizon_blend:i.properties.get(\"horizon-blend\"),u_fog_vertical_limit:[Math.min(m,g),g],u_fog_temporal_offset:f,u_frustum_tl:a,u_frustum_tr:n,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:h,u_viewport:_,u_globe_transition:e.a1(d.zoom),u_is_globe:+(\"globe\"===d.projection.name)}})(this,n,o,a,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.e.devicePixelRatio,this.transform.height*e.e.devicePixelRatio],r);i.setFogUniformValues(t,s);}a&&i.setCutoffUniformValues(t,a.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 t=this._backgroundTiles,i=this._backgroundTiles={},o=this.transform.coveringTiles({tileSize:512});for(const r of o)i[r.key]=t[r.key]||new e.by(r,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={};}isSourceForClippingOrConflation(e,t){return !(!e.is3D()||e.minzoom&&e.minzoom>this.transform.zoom||(this.style._clipLayerIndices.length||\"building\"!==e.sourceLayer)&&\"clip\"!==e.type&&(!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]>=it||t[1]>=it}}class Rr{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.P||\"number\"==typeof t[0]){const a=e.P.convert(t);o=[a],r=i.isPointAboveHorizon(a);}else {const a=e.P.convert(t[0]),n=e.P.convert(t[1]);o=[a,n],r=e.cv(a,n).every((e=>i.isPointAboveHorizon(e)));}return new Rr(o,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.cv(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.cv(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.cw(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.cv(i,o,t),a=this.cameraPoint.clone();switch(3*((a.y>i.y)+(a.y>o.y))+((a.x>i.x)+(a.x>o.x))){case 0:r[0]=a,r[4]=a.clone();break;case 1:r.splice(1,0,a);break;case 2:r[1]=a;break;case 3:r.splice(4,0,a);break;case 5:r.splice(2,0,a);break;case 6:r[3]=a;break;case 7:r.splice(3,0,a);break;case 8:r[2]=a;}return r}containsTile(t,i,o,r=0){const a=t.queryPadding/i._pixelsPerMercatorPixel+1,n=o?this._bufferedCameraMercator(a,i):this._bufferedScreenMercator(a,i);let s=t.tileID.wrap+(n.unwrapped?r:0);const l=n.polygon.map((i=>e.cx(t.tileTransform,i,s)));if(!e.cy(l,0,0,e.a3,e.a3))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.cz(t.tileTransform,i,s))),h=c.map((t=>new e.P(t[0],t[1]))),_=i.getFreeCameraOptions().position||new e.Y(0,0,0),u=e.cz(t.tileTransform,_,s),d=c.map((t=>{const i=e._.sub(t,t,u);return e._.normalize(i,i),new e.aT(u,i)})),p=e.bB(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(f=e.cA(l),f.min.x=e.at(f.min.x,0,e.a3),f.min.y=e.at(f.min.y,0,e.a3),f.max.x=e.at(f.max.x,0,e.a3),f.max.y=e.at(f.max.y,0,e.a3),f),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var f;}_bufferedScreenMercator(e,t){const i=zr(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=zr(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.ad.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.cD,0,1],a=[0,e.cD,0,1],n=[0,0,0,1];e.aA.transformMat4(r,r,o),e.aA.transformMat4(a,a,o),e.aA.transformMat4(n,n,o);const s=new e.P(r[0]/r[3],r[1]/r[3]),l=new e.P(a[0]/a[3],a[1]/a[3]),c=e.cB(t,s)&&r[3]1?Dr(t.slice(0,u),i):[],f=unew e.P(Mr(t.x),t.y))),f=f.map((t=>new e.P(Mr(t.x),t.y)));const m=[...p];0===m.length&&m.push(f[f.length-1]);const g=e.a2(m[m.length-1].y,(0===f.length?p[0]:f[0]).y,d);let v;return v=c?[new e.P(0,g),new e.P(0,0),new e.P(1,0),new e.P(1,g)]:[new e.P(1,g),new e.P(1,1),new e.P(0,1),new e.P(0,g)],m.push(...v),0===f.length?m.push(p[0]):m.push(...f),{polygon:m.map((t=>new e.Y(t.x,t.y))),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,a=0;for(let e=0;er&&(r=t[e].x,a=e);for(let e=0;e.5&&(r.x{e.x-=1;})),{polygon:t,unwrapped:o}}(Dr(t,i).map((t=>new e.P(Mr(t.x),t.y))),i);return {polygon:r.polygon.map((t=>new e.Y(t.x,t.y))),unwrapped:r.unwrapped}}}function Dr(t,i){return e.cC(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function Mr(e){return e<0?1+e%1:e%1}function zr(e){return 100*e|0}function Or(t,i){const o=e.ad.identity([]);return e.ad.scale(o,o,[.5*t.width,.5*-t.height,1]),e.ad.translate(o,o,[1,-1,0]),e.ad.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function Fr(e,t,i,o,r,a,n,s=!1){const l=e.tilesIn(o,n,s);l.sort(kr);const c=[];for(const o of l)c.push({wrappedTileID:o.tile.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e._state,o,r,a,Or(e.transform,o.tile.tileID),s)});const h=function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,a=i[r]=i[r]||{};for(const i in e){const o=e[i],r=a[i]=a[i]||{},n=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,n.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,o=i.layer;o&&\"background\"!==o.type&&\"sky\"!==o.type&&\"slot\"!==o.type&&(i.source=o.source,o[\"source-layer\"]&&(i.sourceLayer=o[\"source-layer\"]),i.state=void 0!==i.id?e.getFeatureState(o[\"source-layer\"],i.id):{});}));return h}function Br(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],r={};for(let e=0;e0:\"model\"===i.type&&(o=!i.isHidden(e)&&i.paint.get(\"model-opacity\")>0),this.layersGotHidden=this.layersGotHidden||!o&&t.visible,t.visible=o;}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,o=this.style.getLayerSourceCache(i);let r=1;\"fill-extrusion\"===i.type&&(r=e.visible?i.paint.get(\"fill-extrusion-vertical-scale\"):0);let a=o?o.getTile(t):null;if(!a&&o&&t.canonical.z>o.getSource().minzoom){let e=t.scaledTo(Math.min(o.getSource().maxzoom,t.overscaledZ-1));for(;e.overscaledZ>=o.getSource().minzoom&&(a=o.getTile(e),!a&&0!==e.overscaledZ);)e=e.scaledTo(e.overscaledZ-1);}this.currentBuildingBuckets.push({bucket:a?a.getBucket(i):null,tileID:a?a.tileID:t,verticalScale:r});}e.hasAnyZOffset=!1;let i=!1;for(let o=0;o{e in i&&(o[e]=i[e]);})),o}function Gr(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-n)/s:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}class Kr{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !r&&[];const n=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e0:n}_queryCircle(e,t,i,o,r){const a=e-i,n=e+i,s=t-i,l=t+i;if(n<0||a>this.width||l<0||s>this.height)return !o&&[];const c=[];return this._forEachCell(a,s,n,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,a,n,s){const l=n.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!s||s(this.boxKeys[h]))){if(n.hitTest)return a.push(!0),!0;a.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!s||s(this.circleKeys[c]))){if(n.hitTest)return a.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];a.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,a,n,s){const l=n.circle,c=n.seenUids,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;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!s||s(this.boxKeys[t])))return a.push(!0),!0}}const _=this.circleCells[r];if(null!==_){const e=this.circles;for(const t of _)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)&&(!s||s(this.circleKeys[t])))return a.push(!0),!0}}}_forEachCell(e,t,i,o,r,a,n,s){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),_=this._convertToYCellCoord(o);for(let u=l;u<=h;u++)for(let l=c;l<=_;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+u,a,n,s))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,o,r,a){const n=o-e,s=r-t,l=i+a;return l*l>n*n+s*s}_circleAndRectCollide(e,t,i,o,r,a,n){const s=(a-o)/2,l=Math.abs(e-(o+s));if(l>s+i)return !1;const c=(n-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=s||h<=c)return !0;const _=l-s,u=h-c;return _*_+u*u<=i*i}}const Qr=100;class Jr{constructor(e,t,i=new Kr(e.width+200,e.height+200,25),o=new Kr(e.width+200,e.height+200,25)){this.transform=e,this.grid=i,this.ignoredGrid=o,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+Qr,this.screenBottomBoundary=e.height+Qr,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t;}placeCollisionBox(e,t,i,o,r,a,n,s){let l=i.projectedAnchorX,c=i.projectedAnchorY,h=i.projectedAnchorZ;const _=i.elevation,u=i.tileID,d=e.getProjection();if(_&&u){const[e,t,o]=d.upVector(u.canonical,i.tileAnchorX,i.tileAnchorY),r=d.upVectorScale(u.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*_*r,c+=t*_*r,h+=o*_*r;}const p=this.projectAndGetPerspectiveRatio(n,l,c,h,i.tileID,\"globe\"===d.name||!!_||this.transform.pitch>0,d),f=a*p.perspectiveRatio,m=(i.x1*t+o.x-i.padding)*f+p.point.x,g=(i.y1*t+o.y-i.padding)*f+p.point.y,v=(i.x2*t+o.x+i.padding)*f+p.point.x,x=(i.y2*t+o.y+i.padding)*f+p.point.y,y=p.perspectiveRatio<=.55||p.occluded;return !this.isInsideGrid(m,g,v,x)||!r&&this.grid.hitTest(m,g,v,x,s)||y?{box:[],offscreen:!1,occluded:p.occluded}:{box:[m,g,v,x],offscreen:this.isOffscreen(m,g,v,x),occluded:!1}}placeCollisionCircles(t,i,o,r,a,n,s,l,c,h,_,u,d,p,f){const m=[],g=this.transform.elevation,v=t.getProjection(),x=g?g.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,v):null,y=new e.P(o.tileAnchorX,o.tileAnchorY);let{x:b,y:w,z:T}=v.projectTilePoint(y.x,y.y,f.canonical);if(x){const[e,t,i]=x(y);b+=e,w+=t,T+=i;}const E=\"globe\"===v.name,C=this.projectAndGetPerspectiveRatio(s,b,w,T,f,E||!!g||this.transform.pitch>0,v),{perspectiveRatio:S}=C,I=(_?n/S:n*S)/e.bN,L=Jt(b,w,T,l),P=C.signedDistanceFromCamera>0?oi(I,a,o.lineOffsetX*I,o.lineOffsetY*I,!1,L,y,o,r,l,{},g&&!_?x:null,_&&!!g,v,f,_):null;let A=!1,R=!1,D=!0;if(P&&!C.occluded){const t=.5*d*S+p,o=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),a=new Yr,{first:n,last:s}=P,l=n.path.length;let _=[];for(let e=l-1;e>=1;e--)_.push(n.path[e]);for(let e=1;e(x&&!E&&(i=x(oe[3]<=0))&&(_=[]));let g=[];if(_.length>0){let t=1/0,i=-1/0,a=1/0,n=-1/0;for(const e of _)t=Math.min(t,e[0]),a=Math.min(a,e[1]),i=Math.max(i,e[0]),n=Math.max(n,e[1]);i>=o.x&&t<=r.x&&n>=o.y&&a<=r.y&&(g=[_.map((t=>new e.P(t[0],t[1])))],(tr.x||ar.y)&&(g=e.cF(g,o.x,o.y,r.x,r.y)));}for(const e of g){a.reset(e,.25*t);let o=0;o=a.length<=.5*t?1:Math.ceil(a.paddedLength/f)+1;for(let e=0;e0){if(e.aA.transformMat4(l,l,t),this.fogState&&a&&\"globe\"!==s.name){const t=function(t,i,o,r,a,n){const s=n.calculateFogTileMatrix(a),l=[i,o,r];return e._.transformMat4(l,l,s),ot(t,e._.length(l),n.pitch,n._fov)}(this.fogState,i,o,r,a.toUnwrapped(),this.transform);c=t>.9;}}else hi(l,l,t);const h=l[3];return {point:new e.P((l[0]/h+1)/2*this.transform.width+Qr,(-l[1]/h+1)/2*this.transform.height+Qr),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/h*.5,1.5),signedDistanceFromCamera:h,occluded:n&&l[2]>h||c}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function na(t,i,o,r,a){const{horizontalAlign:n,verticalAlign:s}=e.bQ(t),l=-(n-.5)*i,c=-(s-.5)*o,h=e.bP(t,r);return new e.P(l+h[0]*a,c+h[1]*a)}function sa(t,i,o,r,a){const n=new e.P(t,i);return o&&n._rotate(r?a:-a),n}class la{constructor(e,t,i,o,r,a){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new Jr(this.transform,r),this.buildingIndex=a,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new aa(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,r){const a=o.getBucket(i),n=o.latestFeatureIndex;if(!a||!n||i.fqid!==a.layerIds[0])return;const s=a.layers[0].layout,l=o.collisionBoxArray,c=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),h=o.tileSize/e.a3,_=o.tileID.toUnwrapped();this.transform.setProjection(a.projection);const u=(d=o.tileID,p=a.getProjection(),f=this.transform,p.name===this.projection?f.calculateProjMatrix(d.toUnwrapped()):bo(f,p,d));var d,p,f;const m=\"map\"===s.get(\"text-pitch-alignment\"),g=\"map\"===s.get(\"text-rotation-alignment\");i.compileFilter();const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),y=this.transform.calculatePixelsToTileUnitsMatrix(o),b=Kt(u,o.tileID.canonical,m,g,this.transform,a.getProjection(),y);let w=null;if(m){const t=Qt(u,o.tileID.canonical,m,g,this.transform,a.getProjection(),y);w=e.ad.multiply([],this.transform.labelPlaneMatrix,t);}let T=null;v&&o.latestFeatureIndex&&(T={unwrappedTileID:_,dynamicFilter:v,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[a.bucketInstanceId]=new ra(a.bucketInstanceId,n,a.sourceLayerIndex,a.index,o.tileID);const E={bucket:a,layout:s,posMatrix:u,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:h,holdingForFade:o.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.aD(a.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.aD(a.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(r)for(const e of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:E});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:E});}attemptAnchorPlacement(e,t,i,o,r,a,n,s,l,c,h,_,u,d,p,f,m,g){const{textOffset0:v,textOffset1:x,crossTileID:y}=_,b=[v,x],w=na(e,i,o,b,r),T=this.collisionIndex.placeCollisionBox(d,r,t,sa(w.x,w.y,a,n,this.transform.angle),h,s,l,c.predicate);if(f){const e=d.getSymbolInstanceIconSize(g,this.transform.zoom,_.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,e,f,sa(w.x,w.y,a,n,this.transform.angle),h,s,l,c.predicate).box.length)return}if(T.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[y]&&this.prevPlacement.placements[y]&&this.prevPlacement.placements[y].text&&(t=this.prevPlacement.variableOffsets[y].anchor),this.variableOffsets[y]={textOffset:b,width:i,height:o,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(d,e,_,p),d.allowVerticalPlacement&&(this.markUsedOrientation(d,p,_),this.placedOrientations[y]=p),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(t,i,o,r){const{bucket:a,layout:n,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:_,holdingForFade:u,collisionBoxArray:d,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:f,collisionGroup:m}=t.parameters,g=n.get(\"text-optional\"),v=n.get(\"icon-optional\"),x=n.get(\"text-allow-overlap\"),y=n.get(\"icon-allow-overlap\"),b=\"map\"===n.get(\"text-rotation-alignment\"),w=\"map\"===n.get(\"text-pitch-alignment\"),T=\"viewport-y\"===n.get(\"symbol-z-order\"),E=n.get(\"symbol-z-elevate\");this.transform.setProjection(a.projection);let C=x&&(y||!a.hasIconData()||v),S=y&&(x||!a.hasTextData()||g);!a.collisionArrays&&d&&a.deserializeCollisionBoxes(d),o&&r&&a.updateCollisionDebugBuffers(this.transform.zoom,d);const I=(t,r,d)=>{const{crossTileID:T,numVerticalGlyphVertices:E}=t;if(h){const o={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[a.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0,h.dynamicFilter)(o,r,this.retainedQueryData[a.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[T]=new ia(!1,!1,!1,!0),void i.add(T)}if(i.has(T))return;if(u)return void(this.placements[T]=new ia(!1,!1,!1));let I=!1,L=!1,P=!0,A=!1,R=!1,D=null,M={box:null,offscreen:null,occluded:null},z={box:null,offscreen:null,occluded:null},O=null,F=null,B=null,k=0,N=0,U=0;d.textFeatureIndex?k=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(k=t.featureIndex),d.verticalTextFeatureIndex&&(N=d.verticalTextFeatureIndex);const G=e=>{e.tileID=this.retainedQueryData[a.bucketInstanceId].tileID;const i=this.transform.elevation;e.elevation=t.zOffset+(i?i.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0);},j=d.textBox;if(j){G(j);const i=i=>{let o=e.aE.horizontal;if(a.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,o=e,this.markUsedOrientation(a,o,t));}return o},o=(t,i)=>{if(a.allowVerticalPlacement&&E>0&&d.verticalTextBox){for(const o of a.writingModes)if(o===e.aE.vertical?(M=i(),z=M):M=t(),M&&M.box&&M.box.length)break}else M=t();};if(n.get(\"text-variable-anchor\")){let l=n.get(\"text-variable-anchor\");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor));}const c=(e,i,o)=>{const n=a.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),c=(e.x2-e.x1)*n+2*e.padding,h=(e.y2-e.y1)*n+2*e.padding,u=t.hasIconTextFit&&!y?i:null;u&&G(u);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,r,a,o,u,p,f);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){I=!0,D=g.shift;break}}return d};o((()=>c(j,d.iconBox,e.aE.horizontal)),(()=>{const t=d.verticalTextBox;return t&&G(t),a.allowVerticalPlacement&&!(M&&M.box&&M.box.length)&&E>0&&t?c(t,d.verticalIconBox,e.aE.vertical):{box:null,offscreen:null,occluded:null}})),M&&(I=M.box,P=M.offscreen,A=M.occluded);const h=i(!(!M||!M.box));if(!I&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(a,e.anchor,t,h));}}else {const n=(i,o)=>{const n=a.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(a,n,i,new e.P(0,0),x,_,s,m.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(a,o,t),this.placedOrientations[T]=o),l};o((()=>n(j,e.aE.horizontal)),(()=>{const t=d.verticalTextBox;return a.allowVerticalPlacement&&E>0&&t?(G(t),n(t,e.aE.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(M&&M.box&&M.box.length));}}if(O=M,I=O&&O.box&&O.box.length>0,P=O&&O.offscreen,A=O&&O.occluded,t.useRuntimeCollisionCircles){const i=a.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.aF(a.textSizeData,p,i),h=n.get(\"text-padding\");F=this.collisionIndex.placeCollisionCircles(a,x,i,a.lineVertexArray,a.glyphOffsetArray,r,s,l,c,o,w,m.predicate,t.collisionCircleDiameter*r/e.bN,h,this.retainedQueryData[a.bucketInstanceId].tileID),I=x||F.circles.length>0&&!F.collisionDetected,P=P&&F.offscreen,A=F.occluded;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const i=i=>{G(i);const o=t.hasIconTextFit&&D?sa(D.x,D.y,b,w,this.transform.angle):new e.P(0,0),r=a.getSymbolInstanceIconSize(f,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(a,r,i,o,y,_,s,m.predicate)};z&&z.box&&z.box.length&&d.verticalIconBox?(B=i(d.verticalIconBox),L=B.box.length>0):(B=i(d.iconBox),L=B.box.length>0),P=P&&B.offscreen,R=B.occluded;}const V=g||0===t.numHorizontalGlyphVertices&&0===E,W=v||0===t.numIconVertices;if(V||W?W?V||(L=L&&I):I=L&&I:L=I=L&&I,I&&O&&O.box&&this.collisionIndex.insertCollisionBox(O.box,n.get(\"text-ignore-placement\"),a.bucketInstanceId,z&&z.box&&N?N:k,m.ID),L&&B&&this.collisionIndex.insertCollisionBox(B.box,n.get(\"icon-ignore-placement\"),a.bucketInstanceId,U,m.ID),F&&(I&&this.collisionIndex.insertCollisionCircles(F.circles,n.get(\"text-ignore-placement\"),a.bucketInstanceId,k,m.ID),o)){const e=a.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new oa);for(let e=0;e=0;--e){const i=t[e];I(a.symbolInstances.get(i),i,a.collisionArrays[i]);}a.hasAnyZOffset&&e.w(`${a.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`);}else if(a.hasAnyZOffset){const e=a.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(a).crossTileID=_>=0&&a!==_?0:c),n>=0&&(t.text.placedSymbolArray.get(n).crossTileID=_>=0&&n!==_?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=_>=0&&s!==_?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=_>=0&&l!==_?0:c);}markUsedOrientation(t,i,o){const r=i===e.aE.horizontal||i===e.aE.horizontalOnly?i:0,a=i===e.aE.vertical?i:0,{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=o,h=t.text.placedSymbolArray;n>=0&&(h.get(n).placedOrientation=r),s>=0&&(h.get(s).placedOrientation=r),l>=0&&(h.get(l).placedOrientation=r),c>=0&&(h.get(c).placedOrientation=a);}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 o=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},a=t?t.variableOffsets:{},n=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],a=r[e];a?(this.opacities[e]=new ta(a,o,t.text,t.icon,null,t.clipped),i=i||t.text!==a.text.placed||t.icon!==a.icon.placed):(this.opacities[e]=new ta(null,o,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 ta(t,o,!1,!1);r.isHidden()||(this.opacities[e]=r,i=i||t.text.placed||t.icon.placed);}}for(const e in a)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=a[e]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);i?this.lastPlacementChangeTime=e:\"number\"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e);}updateLayerOpacities(e,t,i,o){const r=new Set;for(const a of t){const t=a.getBucket(e);t&&a.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,a.collisionBoxArray,i,o,a.tileID),t.layers[0].layout.get(\"symbol-z-elevate\")&&this.buildingIndex&&(this.buildingIndex.updateZOffset(t,a.tileID),t.updateZOffset()));}}updateBucketOpacities(t,i,o,r,a,n){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 s=t.layers[0].layout,l=!!t.layers[0].dynamicFilter(),c=new ta(null,0,!1,!1,!0),h=s.get(\"text-allow-overlap\"),_=s.get(\"icon-allow-overlap\"),u=s.get(\"text-variable-anchor\"),d=\"map\"===s.get(\"text-rotation-alignment\"),p=\"map\"===s.get(\"text-pitch-alignment\"),f=new ta(null,0,h&&(_||!t.hasIconData()||s.get(\"icon-optional\")),_&&(h||!t.hasTextData()||s.get(\"text-optional\")),!0);!t.collisionArrays&&o&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(o);const m=(e,t,i)=>{for(let o=0;o0||_>0,C=x>0,S=this.placedOrientations[v],I=S===e.aE.vertical,L=S===e.aE.horizontal||S===e.aE.horizontalOnly;!E&&!C||T.isHidden()||g++;let P=!1;if((E||C)&&a)for(const i of t.activeReplacements){if(i.ordery||y>i.max.x||i.min.y>b||b>i.max.y)continue;const t=e.cH(y,b,n.canonical,i.footprintTileId.canonical);if(P=e.cI(t,i),P)break}if(E){const e=P?va:ga(T.text);m(t.text,h,I?va:e),m(t.text,_,L?va:e);const i=T.text.isHidden(),{leftJustifiedTextSymbolIndex:o,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:n}=s,l=t.text.placedSymbolArray,c=i||I?1:0;o>=0&&(l.get(o).hidden=c),r>=0&&(l.get(r).hidden=c),a>=0&&(l.get(a).hidden=c),n>=0&&(l.get(n).hidden=i||L?1:0);const u=this.variableOffsets[v];u&&this.markUsedJustification(t,u.anchor,s,S);const d=this.placedOrientations[v];d&&(this.markUsedJustification(t,\"left\",s,d),this.markUsedOrientation(t,d,s));}if(C){const e=P?va:ga(T.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:o}=s,r=t.icon.placedSymbolArray,a=T.icon.isHidden()?1:0;i>=0&&(m(t.icon,x,I?va:e),r.get(i).hidden=a),o>=0&&(m(t.icon,s.numVerticalIconVertices,L?va:e),r.get(o).hidden=a);}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[o];if(i){let o=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(u){const e=this.variableOffsets[v];e?(o=na(e.anchor,e.width,e.height,e.textOffset,e.textScale),d&&o._rotate(p?this.transform.angle:-this.transform.angle)):r=!1;}l&&(r=!T.clipped),i.textBox&&ca(t.textCollisionBox.collisionVertexArray,T.text.placed,!r||I,o.x,o.y),i.verticalTextBox&&ca(t.textCollisionBox.collisionVertexArray,T.text.placed,!r||L,o.x,o.y);}const a=r&&Boolean(!L&&i.verticalIconBox);i.iconBox&&ca(t.iconCollisionBox.collisionVertexArray,T.icon.placed,a,s.hasIconTextFit?o.x:0,s.hasIconTextFit?o.y:0),i.verticalIconBox&&ca(t.iconCollisionBox.collisionVertexArray,T.icon.placed,!a,s.hasIconTextFit?o.x:0,s.hasIconTextFit?o.y:0);}}}if(t.fullyClipped=0===g,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 ca(e,t,i,o,r){e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0),e.emplaceBack(t?1:0,i?1:0,o||0,r||0);}const ha=Math.pow(2,25),_a=Math.pow(2,24),ua=Math.pow(2,17),da=Math.pow(2,16),pa=Math.pow(2,9),fa=Math.pow(2,8),ma=Math.pow(2,1);function ga(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*ha+t*_a+i*ua+t*da+i*pa+t*fa+i*ma+t}const va=0;class xa{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,o,r){const a=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey)));this._currentPartIndex{const t=e.e.now()-a;return !this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const a=i[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(\"symbol\"===a.type&&(!a.minzoom||a.minzoom<=s)&&(!a.maxzoom||a.maxzoom>s)){const t=a,i=t.layout.get(\"symbol-z-elevate\"),s=this._inProgressLayer=this._inProgressLayer||new xa(t),l=e.al(a.source,a.scope);if(s.continuePlacement(i?r[l]:o[l],this.placement,this._showCollisionBoxes,a,n))return;delete this._inProgressLayer;}this._currentPlacementIndex--;}this._done=!0;}commit(e){return this.placement.commit(e),this.placement}}const ba=512/e.a3/2;class wa{constructor(t,i,o){this.tileID=t,this.bucketInstanceId=o,this.index=new e.cK(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.a3,a=t.canonical.y*e.a3;for(let e=0;ee.overscaledZ)for(const i in r){const a=r[i];a.tileID.isChildOf(e)&&a.findMatches(t.symbolInstances,e,o);}else {const a=r[e.scaledTo(Number(i)).key];a&&a.findMatches(t.symbolInstances,e,o);}}for(let e=0;e{t[e]=!0;}));for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e];}}const Sa=new e.N({data:new e.O(e.L.colorTheme.data)}),Ia=(e,t)=>Xe(e,t&&t.filter((e=>\"source.canvas\"!==e.identifier))),La=e.ah(jr,[\"addLayer\",\"removeLayer\",\"setLights\",\"setPaintProperty\",\"setLayoutProperty\",\"setSlot\",\"setFilter\",\"addSource\",\"removeSource\",\"setLayerZoomRange\",\"setLight\",\"setTransition\",\"setGeoJSONSourceData\",\"setTerrain\",\"setFog\",\"setProjection\",\"setCamera\",\"addImport\",\"removeImport\",\"updateImport\"]),Pa=e.ah(jr,[\"setCenter\",\"setZoom\",\"setBearing\",\"setPitch\"]),Aa={version:8,layers:[],sources:{}},Ra={duration:300,delay:0};class Da 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=e.W({},Ra),this._buildingIndex=new Nr(this),this.crossTileSymbolIndex=new Ca,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerIndices=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._changes=i.styleChanges||new v,this.dispatcher=i.dispatcher?i.dispatcher:new e.bw(e.bx(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new _e,this.imageManager.setEventedParent(this)),this.imageManager.createScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.cM(t._requestManager,i.localFontFamily?e.cN.all:i.localIdeographFontFamily?e.cN.ideographs:e.cN.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new ce(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._order=[],this._markersNeedUpdate=!1,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null},this._styleColorThemeForScope={},this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._config=i.config,this._initialConfig=i.initialConfig,this.dispatcher.broadcast(\"setReferrer\",e.cO());const o=this;this._rtlTextPluginCallback=Da.registerForPluginStateChange((t=>{o.dispatcher.broadcast(\"syncRTLPluginState\",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},((t,i)=>{if(e.cP(t),i&&i.every((e=>e)))for(const e in o._sourceCaches){const t=o._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.cQ(t))return t;const i=e.cR(t);if(!i.startsWith(\"http\"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return `json://${e.cS(JSON.stringify(t))}`}_diffStyle(t,i,o){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,o));}catch(e){t(e,!1);}};if(\"string\"==typeof t){const o=this.map._requestManager.normalizeStyleURL(t),a=this.map._requestManager.transformRequest(o,e.R.Style);e.g(a,((t,o)=>{t?this.fire(new e.d(t)):o&&r(o,i);}));}else \"object\"==typeof t&&r(t,i);}loadURL(t,i={}){this.fire(new e.f(\"dataloading\",{dataType:\"style\"}));const o=\"boolean\"==typeof i.validate?i.validate:!e.cQ(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,o);const a=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.g(a,((i,r)=>{if(this._request=null,i)this.fire(new e.d(i));else if(r)return this.importsCache.set(t,r),this._load(r,o)}));}loadJSON(t,i={}){this.fire(new e.f(\"dataloading\",{dataType:\"style\"})),this.globalId=this._getGlobalId(t),this._request=e.e.frame((()=>{this._request=null,this._load(t,!1!==i.validate);}));}loadEmpty(){this.fire(new e.f(\"dataloading\",{dataType:\"style\"})),this._load(Aa,!1);}_loadImports(t,i,o){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),a=new Promise((e=>{t.once(\"style.import.load\",e),t.once(\"error\",e);})).then((()=>this.mergeAll()));if(r.push(a),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const n=e.data||this.importsCache.get(e.url);n?(t.loadJSON(n,{validate:i}),this._isInternalStyle(n)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const s={style:t,id:e.id,config:e.config};if(o){const e=this.fragments.findIndex((({id:e})=>e===o));this.fragments=this.fragments.slice(0,e).concat(s).concat(this.fragments.slice(e));}else this.fragments.push(s);}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.al(t.id,this.scope):t.id;let o;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(o=e.W({},t.config,r));const a=new Da(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:o,configOptions:this.options,configDependentLayers:this._configDependentLayers});return a.setEventedParent(this.map,{style:a}),a}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast(\"setLayers\",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.isRootStyle();}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){const o=t.schema;if(this._isInternalStyle(t)){const o=e.W({},Aa,{imports:[{id:\"basemap\",data:t,url:\"\"}]});return void this._load(o,i)}if(this.updateConfig(this._config,o),i&&Ia(this,Be(t)))return;this._loaded=!0,this.stylesheet=e.cT(t);const r=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast(\"spriteLoaded\",{scope:this.scope,isLoaded:!0})),this.glyphManager.setURL(t.glyphs,this.scope);const o=Gr(this.stylesheet.layers);if(this._order=o.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 Ke(e.properties,e.id);}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Ke(this.stylesheet.light)),this._layers={},this._serializedLayers={};for(const t of o){const i=e.cY(t,this.scope,this._styleColorTheme.lut,this.options);i.isConfigDependent&&this._configDependentLayers.add(i.fqid),i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize();const o=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();o&&i.canCastShadows()&&r&&(o.castsShadows=!0);}this.stylesheet.models&&this.modelManager.addModels(this.stylesheet.models,this.scope);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.terrainSetForDrapingOnly()||this._createTerrain(r,1)),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this.stylesheet.transition&&this.setTransition(this.stylesheet.transition),this.fire(new e.f(\"data\",{dataType:\"style\"}));const a=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then((()=>{this._reloadImports(),this.fire(new e.f(a?\"style.load\":\"style.import.load\"));})):(this._reloadImports(),this.fire(new e.f(a?\"style.load\":\"style.import.load\")));},a=this.stylesheet[\"color-theme\"];if(this._styleColorTheme.colorTheme=a,a){const t=this._evaluateColorThemeData(a);this._loadColorTheme(t).then((()=>{r();})).catch((t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),r();}));}else this._styleColorTheme.lut=null,r();}isRootStyle(){return 0===this.importDepth}mergeAll(){let t,i,o,r,a,n,s,l;const c={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle((e=>{if(e.stylesheet){if(null!=e.light&&(t=e.light),e.stylesheet.lights)for(const t of e.stylesheet.lights)\"ambient\"===t.type&&null!=e.ambientLight&&(i=e.ambientLight),\"directional\"===t.type&&null!=e.directionalLight&&(o=e.directionalLight);r=this._prioritizeTerrain(r,e.terrain,e.stylesheet.terrain),e.stylesheet.fog&&null!=e.fog&&(a=e.fog),null!=e.stylesheet.camera&&(l=e.stylesheet.camera),null!=e.stylesheet.projection&&(n=e.stylesheet.projection),null!=e.stylesheet.transition&&(s=e.stylesheet.transition),c[e.scope]=e._styleColorTheme;}})),this.light=t,this.ambientLight=i,this.directionalLight=o,this.fog=a,this._styleColorThemeForScope=c,null===r?delete this.terrain:this.terrain=r,this.camera=l||{\"camera-projection\":\"perspective\"},this.projection=n||{name:\"mercator\"},this.transition=e.W({},Ra,s),this.mergeSources(),this.mergeLayers();}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i);};t(this);}_prioritizeTerrain(e,t,i){const o=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:o?e:null:null!=t&&(!e||o||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={},o={};this.forEachFragmentStyle((r=>{for(const i in r._sourceCaches){const o=e.al(i,r.scope);t[o]=r._sourceCaches[i];}for(const t in r._otherSourceCaches){const o=e.al(t,r.scope);i[o]=r._otherSourceCaches[t];}for(const t in r._symbolSourceCaches){const i=e.al(t,r.scope);o[i]=r._symbolSourceCaches[t];}})),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=o;}mergeLayers(){const t={},i=[],o={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle((o=>{for(const r of o._order){const a=o._layers[r];if(\"slot\"===a.type){const i=e.cU(r);if(t[i])continue;t[i]=[];}a.slot&&t[a.slot]?t[a.slot].push(a):i.push(a);}})),this._mergedOrder=[],this._clipLayerIndices=[];let r=0;const a=(i=[])=>{for(const n of i)if(\"slot\"===n.type){const i=e.cU(n.id);t[i]&&a(t[i]),this._mergedSlots.push(i);}else {const t=e.al(n.id,n.scope);this._mergedOrder.push(t),o[t]=n,n.is3D()&&(this._has3DLayers=!0),\"circle\"===n.type&&(this._hasCircleLayers=!0),\"symbol\"===n.type&&(this._hasSymbolLayers=!0),\"clip\"===n.type&&this._clipLayerIndices.push(r),r++;}};a(i),this._mergedLayers=o,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged();}terrainSetForDrapingOnly(){return !!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(t){return this.stylesheet.camera=e.W({},this.stylesheet.camera,t),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,o){const r=e.W({},i);for(const t of Object.keys(e.L.colorTheme))void 0===r[t]&&(r[t]=e.L.colorTheme[t].default);const a=new e.U(Sa,t,new Map(o));return a.setTransitionOrValue(r,o),a.untransitioned().possiblyEvaluate(new e.X(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(((o,r)=>{const a=\"data:image/png;base64,\";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void o();let n=t;n.startsWith(a)||(n=a+n);const s=\"mapbox-reserved-lut\",l=new Image;l.src=n,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error(\"Failed to load image data\"));},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void o();this._styleColorTheme.lutLoading=!1;const{width:a,height:n,data:c}=e.e.getImageData(l);if(n>32)return void r(new Error(\"The height of the image must be less than or equal to 32 pixels.\"));if(a!==n*n)return void r(new Error(\"The width of the image must be equal to the height squared.\"));this.getImage(s)&&this.removeImage(s),this.addImage(s,{data:new e.i({width:a,height:n},c),pixelRatio:1,sdf:!1,version:0});const h=this.imageManager.getImage(s,this.scope);h?(this._styleColorTheme.lut={image:h.data,data:t},o()):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,o){let r,a,n;const s=e.e.devicePixelRatio>1?\"@2x\":\"\";let l=e.g(i.transformRequest(i.normalizeSpriteURL(t,s,\".json\"),e.R.SpriteJSON),((e,t)=>{l=null,n||(n=e,r=t,h());})),c=e.h(i.transformRequest(i.normalizeSpriteURL(t,s,\".png\"),e.R.SpriteImage),((e,t)=>{c=null,n||(n=e,a=t,h());}));function h(){if(n)o(n);else if(r&&a){const t=e.e.getImageData(a),i={};for(const o in r){const{width:a,height:n,x:s,y:l,sdf:c,pixelRatio:h,stretchX:_,stretchY:u,content:d}=r[o],p=new e.i({width:a,height:n});e.i.copy(t,p,{x:s,y:l},{x:0,y:0},{width:a,height:n},null),i[o]={data:p,pixelRatio:h,sdf:c,stretchX:_,stretchY:u,content:d};}o(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.d(t));else if(i)for(const e in i)this.imageManager.addImage(e,this.scope,i[e]);this.imageManager.setLoaded(!0,this.scope),this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast(\"setImages\",{scope:this.scope,images:this._availableImages}),this.dispatcher.broadcast(\"spriteLoaded\",{scope:this.scope,isLoaded:!0}),this.fire(new e.f(\"data\",{dataType:\"style\"}));}));}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const o=t.sourceLayer;o&&(\"geojson\"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(o))&&this.fire(new e.d(new Error(`Source layer \"${o}\" 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.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()}hasTransitions(){if(this.hasLightTransitions())return !0;if(this.hasFogTransition())return !0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return !0;for(const e in this._layers)if(this._layers[e].hasTransition())return !0;return !1}get order(){return this.terrain?this._drapedFirstOrder:this._mergedOrder}isLayerDraped(e){return !!this.terrain&&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.d(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.d(new Error(`The source '${t}' does not exist in the map's style.`)));}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));const o=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:o}=e[t];(i||o)&&(this._updateWorkerLayers(t,i,o),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._changes.reset();}const a={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];a[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()));}if(!this._precompileDone&&this._shouldPrecompile)for(let e=i.minzoom||0;e<(i.maxzoom||25.5);e++){const e=this.map.painter;if(e){const o=i.getProgramIds();if(!o)continue;for(const r of o){const o=i.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);o&&(e.style=this,this.fog&&(e._fogVisible=!0,o.overrideFog=!0,e.getOrCreateProgram(r,o)),e._fogVisible=!1,o.overrideFog=!1,e.getOrCreateProgram(r,o),(this.stylesheet.terrain||this.stylesheet.projection&&\"globe\"===this.stylesheet.projection.name)&&(o.overrideRtt=!0,e.getOrCreateProgram(r,o)));}}}}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&r&&this.mergeLayers();for(const t in a){const i=this._mergedSourceCaches[t];a[t]!==i.used&&i.getSource().fire(new e.f(\"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.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new e.f(\"data\",{dataType:\"style\"}));}_updateTilesForChangedImages(){const e=this._changes.getUpdatedImages();if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies([\"icons\",\"patterns\"],e);this._changes.resetUpdatedImages();}}_updateWorkerLayers(e,t,i){const o=this.getFragmentStyle(e);o&&this.dispatcher.broadcast(\"updateLayers\",{layers:t?o._serializeLayers(t):[],scope:e,removedIds:i||[],options:o.options});}setState(i,o){if(this._checkLoaded(),Ia(this,Be(i)))return !1;(i=e.cT(i)).layers=Gr(i.layers);const r=function(e,i){if(!e)return [{command:jr.setStyle,args:[i]}];let o=[];try{if(!t(e.version,i.version))return [{command:jr.setStyle,args:[i]}];if(t(e.center,i.center)||o.push({command:jr.setCenter,args:[i.center]}),t(e.zoom,i.zoom)||o.push({command:jr.setZoom,args:[i.zoom]}),t(e.bearing,i.bearing)||o.push({command:jr.setBearing,args:[i.bearing]}),t(e.pitch,i.pitch)||o.push({command:jr.setPitch,args:[i.pitch]}),t(e.sprite,i.sprite)||o.push({command:jr.setSprite,args:[i.sprite]}),t(e.glyphs,i.glyphs)||o.push({command:jr.setGlyphs,args:[i.glyphs]}),t(e.imports,i.imports)||function(e=[],i=[],o){i=i||[];const r=(e=e||[]).map($r),a=i.map($r),n=e.reduce(Xr,{}),s=i.reduce(Xr,{}),l=r.slice();let c,h,_,u;for(c=0,h=0;c{e.source&&r[e.source]?o.push({command:jr.removeLayer,args:[e.id]}):n.push(e);}));let s=e.terrain;s&&r[s.source]&&(o.push({command:jr.setTerrain,args:[void 0]}),s=void 0),o=o.concat(a),t(s,i.terrain)||o.push({command:jr.setTerrain,args:[i.terrain]}),function(e,i,o){i=i||[];const r=(e=e||[]).map($r),a=i.map($r),n=e.reduce(Xr,{}),s=i.reduce(Xr,{}),l=r.slice(),c=Object.create(null);let h,_,u,d,p,f,m;for(h=0,_=0;h!(e.command in Pa)));if(0===r.length)return !1;const a=r.filter((e=>!(e.command in La)));if(a.length>0)throw new Error(`Unimplemented: ${a.map((e=>e.command)).join(\", \")}.`);const n=[];return r.forEach((e=>{n.push(this[e.command].apply(this,e.args));})),o&&Promise.all(n).then(o),this.stylesheet=i,this.mergeAll(),this.dispatcher.broadcast(\"setLayers\",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),!0}addImage(t,i){return this.getImage(t)?this.fire(new e.d(new Error(\"An image with this name already exists.\"))):(this.imageManager.addImage(t,this.scope,i),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,this.scope,t);}getImage(e){return this.imageManager.getImage(e,this.scope)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t,this.scope),this._afterImageUpdated(t),this):this.fire(new e.d(new Error(\"No image with this name exists.\")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(this.scope),this._changes.updateImage(t),this.dispatcher.broadcast(\"setImages\",{scope:this.scope,images:this._availableImages}),this.fire(new e.f(\"data\",{dataType:\"style\"}));}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModel(e,t,i={}){return this._checkLoaded(),this._validate(He,`models.${e}`,t,null,i)||(this.modelManager.addModel(e,t,this.scope),this._changes.setDirty()),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope),this):this.fire(new e.d(new Error(\"No model with this ID exists.\")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,o={}){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(ke,`sources.${t}`,i,null,o))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Mi(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id})));const a=t=>{const i=(t?\"symbol:\":\"other:\")+r.id,o=e.al(i,this.scope),a=this._sourceCaches[i]=new e.bv(o,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=a,a.onAdd(this.map);};a(!1),\"vector\"!==i.type&&\"geojson\"!==i.type||a(!0),r.onAdd&&r.onAdd(this.map),o.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.d(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.d(new Error(`Source \"${t}\" cannot be removed while terrain is using it.`)));const o=this.getOwnSourceCaches(t);for(const t of o){const i=e.cU(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.f(\"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 e of t){if(this._validate(Ue,\"lights\",e))return;switch(e.type){case\"ambient\":if(this.ambientLight){const t=this.ambientLight;t.set(e),t.updateTransitions(i);}else this.ambientLight=new ct(e,ht,this.scope,this.options);break;case\"directional\":if(this.directionalLight){const t=this.directionalLight;t.set(e),t.updateTransitions(i);}else this.directionalLight=new ct(e,_t,this.scope,this.options);}}const o=new e.X(this.z||0,i);this.ambientLight&&this.ambientLight.recalculate(o),this.directionalLight&&this.directionalLight.recalculate(o),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast(\"setBrightness\",this._brightness);}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const o=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\").toRenderColor(null).toArray01(),a=t.properties.get(\"intensity\"),n=t.properties.get(\"direction\"),s=1-e.ac(n.x,n.y,n.z)[2]/90,l=o(r)*a*s,c=i.properties.get(\"color\").toRenderColor(null).toArray01(),h=i.properties.get(\"intensity\");return (l+o(c)*h)/2}getBrightness(){return this._brightness}getLights(){if(!this.enable3dLights())return null;const e=[];return this.directionalLight&&e.push(this.directionalLight.get()),this.ambientLight&&e.push(this.ambientLight.get()),e}enable3dLights(){return !!this.ambientLight&&!!this.directionalLight}getFragmentStyle(t){if(!t)return this;if(e.cV(t)){const i=e.cW(t),o=this.fragments.find((({id:e})=>e===i));if(!o)throw new Error(`Style import not found: ${t}`);const r=e.cU(t);return o.style.getFragmentStyle(r)}{const e=this.fragments.find((({id:e})=>e===t));if(!e)throw new Error(`Style import not found: ${t}`);return e.style}}getConfigProperty(t,i){const o=this.getFragmentStyle(t);if(!o)return null;const r=e.al(i,o.scope),a=o.options.get(r),n=a?a.value||a.default:null;return n?n.serialize():null}setConfigProperty(t,i,o){const r=this.getFragmentStyle(t);if(!r)return;const a=r.stylesheet.schema;if(!a||!a[i])return;const n=e.y(o);if(\"success\"!==n.result)return void Ia(this,n.value);const s=n.value.expression,l=e.al(i,r.scope),c=r.options.get(l);if(!c)return;let h;const{minValue:_,maxValue:u,stepValue:d,type:p,values:f}=a[i],m=e.y(a[i].default);\"success\"===m.result&&(h=m.value.expression),h?(this.options.set(l,{...c,value:s,default:h,minValue:_,maxValue:u,stepValue:d,type:p,values:f}),this.updateConfigDependencies()):this.fire(new e.d(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 o=i.stylesheet.schema;if(!o)return null;const r={};for(const t in o){const o=e.al(t,i.scope),a=i.options.get(o),n=a?a.value||a.default:null;r[t]=n?n.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 o in i){let r,a;const n=e.y(i[o].default);if(\"success\"===n.result&&(r=n.value.expression),t&&void 0!==t[o]){const i=e.y(t[o]);\"success\"===i.result&&(a=i.value.expression);}const{minValue:s,maxValue:l,stepValue:c,type:h,values:_}=i[o];if(r){const t=e.al(o,this.scope);this.options.set(t,{default:r,value:a,minValue:s,maxValue:l,stepValue:c,type:h,values:_});}else this.fire(new e.d(new Error(`No schema defined for config option \"${o}\".`)));}else this.fire(new e.d(new Error(\"Attempting to set config for a style without schema.\")));}updateConfigDependencies(){for(const e of this._configDependentLayers){const t=this.getLayer(e);t&&(t.possiblyEvaluateVisibility(),this._updateLayer(t));}this.ambientLight&&this.ambientLight.updateConfig(this.options),this.directionalLight&&this.directionalLight.updateConfig(this.options),this.fog&&this.fog.updateConfig(this.options),this.forEachFragmentStyle((e=>{if(e._styleColorTheme.colorTheme){const t=e._evaluateColorThemeData(e._styleColorTheme.colorTheme);(!e._styleColorTheme.lut||e._styleColorTheme.lut&&t!==e._styleColorTheme.lut.data)&&e.setColorTheme(e._styleColorTheme.colorTheme);}})),this._changes.setDirty();}addLayer(t,i,o={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.d(new Error(`Layer with id \"${r}\" already exists on this map`)));let a;if(\"custom\"===t.type){if(Ia(this,e.cX(t)))return;a=e.cY(t,this.scope,this._styleColorTheme.lut,this.options);}else {if(\"object\"==typeof t.source&&(this.addSource(r,t.source),t=e.cT(t),t=e.W(t,{source:r})),this._validate(Ve,`layers.${r}`,t,{arrayIndex:-1},o))return;a=e.cY(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(a),a.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[a.id]=a.serialize();}a.isConfigDependent&&this._configDependentLayers.add(a.fqid);let n=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.d(new Error(`Layer with id \"${i}\" does not exist on this map.`)));a.slot===this._layers[i].slot?n=t:e.w(`Layer with id \"${i}\" has a different slot. Layers can only be rearranged within the same slot.`);}this._order.splice(n,0,r),this._layerOrderChanged=!0,this._layers[r]=a;const s=this.getOwnLayerSourceCache(a),l=!!this.directionalLight&&this.directionalLight.shadowsEnabled();s&&a.canCastShadows()&&l&&(s.castsShadows=!0);const c=this._changes.getRemovedLayer(a);if(c&&a.source&&s&&\"custom\"!==a.type){this._changes.discardLayerRemoval(a);const t=e.al(a.source,a.scope);c.type!==a.type?this._changes.updateSourceCache(t,\"clear\"):(this._changes.updateSourceCache(t,\"reload\"),s.pause());}this._updateLayer(a),a.onAdd&&a.onAdd(this.map),a.scope=this.scope,this.mergeLayers();}moveLayer(t,i){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.d(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,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],delete this._serializedLayers[e],this._changes.setDirty(),this._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const o=this.getOwnLayerSourceCache(t);if(o&&o.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}o.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 o=this._checkLayer(e);o&&(o.minzoom===t&&o.maxzoom===i||(null!=t&&(o.minzoom=t),null!=i&&(o.maxzoom=i),this._updateLayer(o)));}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(i,o,r={}){this._checkLoaded();const a=this._checkLayer(i);if(a&&!t(a.filter,o))return null==o?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(We,`layers.${a.id}.filter`,o,{layerType:a.type},r)||(a.filter=e.cT(o),this._updateLayer(a)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.cT(i.filter)}setLayoutProperty(i,o,r,a={}){this._checkLoaded();const n=this._checkLayer(i);if(n&&!t(n.getLayoutProperty(o),r)){if(null!=r&&(!a||!1!==a.validate)&&Ia(n,qe.call(Be,{key:`layers.${i}.layout.${o}`,layerType:n.type,objectKey:o,value:r,styleSpec:e.L,style:{glyphs:!0,sprite:!0}})))return;n.setLayoutProperty(o,r),n.isConfigDependent&&this._configDependentLayers.add(n.fqid),this._updateLayer(n);}}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(i,o,r,a={}){this._checkLoaded();const n=this._checkLayer(i);if(!n)return;if(t(n.getPaintProperty(o),r))return;if(null!=r&&(!a||!1!==a.validate)&&Ia(n,Ze.call(Be,{key:`layers.${i}.paint.${o}`,layerType:n.type,objectKey:o,value:r,styleSpec:e.L})))return;const s=n.setPaintProperty(o,r);n.isConfigDependent&&this._configDependentLayers.add(n.fqid),s&&this._updateLayer(n),this._changes.updatePaintProperties(n);}getPaintProperty(e,t){const i=this._checkLayer(e);if(i)return i.getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const o=t.source,r=t.sourceLayer,a=this._checkSource(o);if(!a)return;const n=a.type;if(\"geojson\"===n&&r)return void this.fire(new e.d(new Error(\"GeoJSON sources cannot have a sourceLayer parameter.\")));if(\"vector\"===n&&!r)return void this.fire(new e.d(new Error(\"The sourceLayer parameter must be provided for vector source types.\")));void 0===t.id&&this.fire(new e.d(new Error(\"The feature id parameter must be provided.\")));const s=this.getOwnSourceCaches(o);for(const e of s)e.setFeatureState(r,t.id,i);}removeFeatureState(t,i){this._checkLoaded();const o=t.source,r=this._checkSource(o);if(!r)return;const a=r.type,n=\"vector\"===a?t.sourceLayer:void 0;if(\"vector\"===a&&!n)return void this.fire(new e.d(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.d(new Error(\"A feature id is required to remove its specific state property.\")));const s=this.getOwnSourceCaches(o);for(const e of s)e.removeFeatureState(n,t.id,i);}getFeatureState(t){this._checkLoaded();const i=t.source,o=t.sourceLayer,r=this._checkSource(i);if(r){if(\"vector\"!==r.type||o)return void 0===t.id&&this.fire(new e.d(new Error(\"The feature id parameter must be provided.\"))),this.getOwnSourceCaches(i)[0].getFeatureState(o,t.id);this.fire(new e.d(new Error(\"The sourceLayer parameter must be provided for vector source types.\")));}}setTransition(t){return this.stylesheet.transition=e.W({},this.stylesheet.transition,t),this.transition=this.stylesheet.transition,this}getTransition(){return e.W({},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.cZ({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,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,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))}_updateLayer(t){this._changes.updateLayer(t);const i=this.getLayerSourceCache(t),o=e.al(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[o]&&i&&\"raster\"!==i.getSource().type&&(this._changes.updateSourceCache(o,\"reload\"),i.pause()),t.invalidateCompiledFilter();}_flattenAndSortRenderedFeatures(e){const t=e=>\"fill-extrusion\"===this._mergedLayers[e].type||\"model\"===this._mergedLayers[e].type,i=this.order,o={},r=[];for(let a=i.length-1;a>=0;a--){const n=i[a];if(t(n)){o[n]=a;for(const t of e){const e=t[n];if(e)for(const t of e)r.push(t);}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));const a=[];for(let n=i.length-1;n>=0;n--){const s=i[n];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&o[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()})):this.has3DLayers(),l=Rr.createFromScreenPoints(t,o);for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e].getSource();if(!t||t.scope!==i.scope)continue;const c=this._mergedSourceCaches[e].getSource().id;i.layers&&!r[c]||a.push(Fr(this._mergedSourceCaches[e],this._mergedLayers,n,l,i,o,s,!!this.map._showQueryGeometry));}return this.placement&&a.push(function(e,t,i,o,r,a,n){const s={},l=a.queryRenderedSymbols(o),c=[];for(const e of Object.keys(l).map(Number))c.push(n[e]);c.sort(kr);for(const i of c){const o=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,e);for(const e in o){const t=s[e]=s[e]||[],r=o[e];r.sort(((e,t)=>{const o=i.featureSortOrder;if(o){const i=o.indexOf(e.featureIndex);return o.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex}));for(const e of r)t.push(e);}}for(const t in s)s[t].forEach((o=>{const r=o.feature,a=i(e[t]);if(!a)return;const n=a.getFeatureState(r.layer[\"source-layer\"],r.id);r.source=r.layer.source,r.layer[\"source-layer\"]&&(r.sourceLayer=r.layer[\"source-layer\"]),r.state=n;}));return s}(this._mergedLayers,n,this.getLayerSourceCache.bind(this),l.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,t){t&&t.filter&&this._validate(We,\"querySourceFeatures.filter\",t.filter,null,t);const i=this.getOwnSourceCaches(e);let o=[];for(const e of i)o=o.concat(Br(e,t));return o}addSourceType(e,t,i){return Da.getSourceType(e)?i(new Error(`A source type called \"${e}\" already exists.`)):(Da.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast(\"loadWorkerSource\",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(e,i,o={}){this._checkLoaded();const r=this.light.getLight();let a=!1;for(const i in e)if(!t(e[i],r[i])){a=!0;break}if(!a)return;const n=this._getTransitionParameters();this.light.setLight(e,i,o),this.light.updateTransitions(n);}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.e.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(i,o=1){if(this._checkLoaded(),!i)return this.terrainSetForDrapingOnly()&&0!==o||delete this.terrain,null===i?this.stylesheet.terrain=null:delete this.stylesheet.terrain,this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);this.checkCanvasFingerprintNoise();let r=i;const a=null==i.source;if(1===o){if(this.disableElevatedTerrain)return;if(\"object\"==typeof r.source){const t=\"terrain-dem-src\";this.addSource(t,r.source),r=e.cT(r),r=e.W(r,{source:t});}const t=e.W({},r),i={};if(this.terrain&&a){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize());}if(this._validate(Ge,\"terrain\",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!a||this.terrain&&o!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,o),this.fire(new e.f(\"data\",{dataType:\"style\"}));}else {const o=this.terrain,a=o.get();for(const t of Object.keys(e.L.terrain))!r.hasOwnProperty(t)&&e.L.terrain[t].default&&(r[t]=e.L.terrain[t].default);for(const r in i)if(!t(i[r],a[r])){o.set(i,this.options),this.stylesheet.terrain=i;const t=this._getTransitionParameters({duration:0});o.updateTransitions(t),this.fire(new e.f(\"data\",{dataType:\"style\"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0;}_createFog(e){const t=this.fog=new lt(e,this.map.transform,this.scope,this.options);this.stylesheet.fog=t.get();const i=this._getTransitionParameters({duration:0});t.updateTransitions(i);}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const e of this.map._markers)e._evaluateOpacity();}));}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!t(i.get(),e)){i.set(e,this.options),this.stylesheet.fog=i.get();const t=this._getTransitionParameters({duration:0});i.updateTransitions(t);}}else this._createFog(e);this._markersNeedUpdate=!0;}setColorTheme(t){this._checkLoaded();const i=()=>{for(const e in this._layers)this._layers[e].lut=this._styleColorTheme.lut;for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles();};if(this._styleColorTheme.colorTheme=t,!t)return this._styleColorTheme.lut=null,void i();const o=this._evaluateColorThemeData(t);this._loadColorTheme(o).then((()=>{this.fire(new e.f(\"colorthemeset\")),i();})).catch((t=>{e.w(`Couldn't set color theme: ${t}`);}));}_getTransitionParameters(t){return {now:e.e.now(),transition:e.W(this.transition,t)}}updateDrapeFirstLayers(){if(!this.terrain)return;const e=[],t=[];for(const i in this._mergedLayers)this.isLayerDraped(this._mergedLayers[i])?e.push(i):t.push(i);this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t);}_createTerrain(e,t){const i=this.terrain=new Je(e,t,this.scope,this.options);1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const o=this._getTransitionParameters({duration:0});i.updateTransitions(o);}_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,o,r,a={}){if(a&&!1===a.validate)return !1;const n=e.W({},this.serialize());return Ia(this,t.call(Be,e.W({key:i,style:n,value:o,styleSpec:e.L},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.c_.off(\"pluginStateChange\",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.setEventedParent(null),delete this.fog,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.modelManager.setEventedParent(null),this.dispatcher.remove());}clearSource(e){const t=this.getSourceCaches(e);for(const e of t)e.clearTiles();}clearSources(){for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles();}reloadSource(e){const t=this.getSourceCaches(e);for(const e of t)e.resume(),e.reload();}reloadSources(){for(const e of this.getSources())e.reload&&e.reload();}updateSources(e){let t;this.directionalLight&&(t=bi(this.directionalLight));for(const i in this._mergedSourceCaches)this._mergedSourceCaches[i].update(e,void 0,void 0,t);}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload();}}_updatePlacement(t,i,o,r,a,n,s=!1){let l=!1,c=!1;const h={},_={};for(const t of this._mergedOrder){const o=this._mergedLayers[t];if(\"symbol\"!==o.type)continue;const r=e.al(o.source,o.scope);let a=h[r];if(!a){const e=this.getLayerSourceCache(o);if(!e)continue;const t=e.getRenderableIds(!0).map((t=>e.getTileByID(t)));_[r]=t.slice(),a=h[r]=t.sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)));}const n=this.crossTileSymbolIndex.addLayer(o,a,i.center.lng,i.projection);l=l||n;}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),s=s||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.f(\"neworder\")),(s||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.e.now(),i.zoom))&&(this.pauseablePlacement=new ya(i,this._mergedOrder,s,o,r,a,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,h,_),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.e.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;tte===t.id)))return void this.fire(new e.d(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return o.push(t),this._loadImports([t],!0);const r=o.findIndex((({id:e})=>e===i));return -1===r&&this.fire(new e.d(new Error(`Import with id \"${i}\" does not exist on this map.`))),this.stylesheet.imports=o.slice(0,r).concat(t).concat(o.slice(r)),this._loadImports([t],!0,i)}updateImport(e,i){this._checkLoaded();const o=this.stylesheet.imports||[],r=this.getImportIndex(e);return -1===r?this:\"string\"==typeof i?(this.setImportUrl(e,i),this):(i.url&&i.url!==o[r].url&&this.setImportUrl(e,i.url),t(i.config,o[r].config)||this.setImportConfig(e,i.config),t(i.data,o[r].data)||this.setImportData(e,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const o=this.getImportIndex(e);if(-1===o)return this;const r=this.getImportIndex(t);if(-1===r)return this;const a=i[o],n=this.fragments[o];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(a).concat(i.slice(r)),this.fragments=this.fragments.slice(0,r).concat(n).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],o=this.getImportIndex(e);if(-1===o)return this;i[o].url=t;const r=this.fragments[o];return r.style=this._createFragmentStyle(i[o]),r.style.on(\"style.import.load\",(()=>this.mergeAll())),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];return -1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete o[i].data,this.setImportUrl(e,o[i].url))}setImportConfig(e,t){this._checkLoaded();const i=this.getImportIndex(e),o=this.stylesheet.imports||[];if(-1===i)return this;t?o[i].config=t:delete o[i].config;const r=this.fragments[i],a=r.style.stylesheet&&r.style.stylesheet.schema;return r.config=t,r.style.updateConfig(t,a),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.d(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 o=e.al(t,i);return this._mergedOtherSourceCaches[o]}getLayerSourceCache(t){const i=e.al(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);}}getImages(e,t,i){this.imageManager.getImages(t.icons,t.scope,i),this._updateTilesForChangedImages();const o=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons);};o(this._otherSourceCaches[t.source]),o(this._symbolSourceCaches[t.source]);}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,t.scope,i);}getResource(t,i,o){return e.c$(i,o)}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.d(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(t,i){if(0===this._clipLayerIndices.length&&\"fill-extrusion\"!==t.type)return !1;const o=\"fill-extrusion\"===t.type&&\"building\"===t.sourceLayer;let r=0;if(t.is3D()){if(o||i&&\"batched-model\"===i.type)return !0;\"model\"===t.type&&(r=e.cu.Model);}else \"symbol\"===t.type&&(r=e.cu.Symbol);for(const t of this._clipLayerIndices){const i=this._mergedLayers[this._mergedOrder[t]];if(!i)continue;const o=[];for(const t of i.layout.get(\"clip-layer-types\"))o.push(\"model\"===t?e.cu.Model:\"symbol\"===t?e.cu.Symbol:e.cu.FillExtrusion);for(const e of o)if(r&e)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);}}function Ma(e,t){let i=!1,o=null;const r=()=>{o=null,i&&(e(),o=setTimeout(r,t),i=!1);};return ()=>(i=!0,o||r(),o)}Da.getSourceType=function(e){return Di[e]},Da.setSourceType=function(e,t){Di[e]=t;},Da.registerForPluginStateChange=e.cL;class za{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bp([\"_getCurrentHash\",\"_onHashChange\",\"_updateHash\"],this),this._updateHash=Ma(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=Oa(e);if(this._hashName){const e=this._hashName;let i=!1;const o=location.hash.slice(1).split(\"&\").map((o=>{const r=o.split(\"=\")[0];return r===e?(i=!0,`${r}=${t}`):o})).filter((e=>e));return i||o.push(`${e}=${t}`),`#${o.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(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 Oa(e,t){const i=e.getCenter(),o=Math.round(100*e.getZoom())/100,r=Math.ceil((o*Math.LN2+Math.log(512/360/.5))/Math.LN10),a=Math.pow(10,r),n=Math.round(i.lng*a)/a,s=Math.round(i.lat*a)/a,l=e.getBearing(),c=e.getPitch();let h=t?`/${n}/${s}/${o}`:`${o}/${s}/${n}`;return (l||c)&&(h+=\"/\"+Math.round(10*l)/10),c&&(h+=`/${Math.round(c)}`),h}const Fa={linearity:.3,easing:e.d0(0,0,.3,1)},Ba=e.W({deceleration:2500,maxSpeed:1400},Fa),ka=e.W({deceleration:20,maxSpeed:1400},Fa),Na=e.W({deceleration:1e3,maxSpeed:360},Fa),Ua=e.W({deceleration:1e3,maxSpeed:90},Fa);class Ga{constructor(e){this._map=e,this.clear();}clear(){this._inertiaBuffer=[];}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.e.now(),settings:t});}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.e.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 o=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const a=Va(i.pan.mag(),o,e.W({},Ba,t||{}));r.offset=i.pan.mult(a.amount/i.pan.mag()),r.center=this._map.transform.center,ja(r,a);}if(i.zoom){const e=Va(i.zoom,o,ka);r.zoom=this._map.transform.zoom+e.amount,ja(r,e);}if(i.bearing){const t=Va(i.bearing,o,Na);r.bearing=this._map.transform.bearing+e.at(t.amount,-179,179),ja(r,t);}if(i.pitch){const e=Va(i.pitch,o,Ua);r.pitch=this._map.transform.pitch+e.amount,ja(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 ja(e,t){(!e.duration||e.durationi.unproject(e))),s=a.reduce(((e,t,i,o)=>e.add(t.div(o.length))),new e.P(0,0));super(t,{points:a,point:s,lngLats:n,lngLat:i.unproject(s),originalEvent:o}),this._defaultPrevented=!1;}}class qa extends e.f{preventDefault(){this._defaultPrevented=!0;}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super(\"wheel\",{originalEvent:t}),this._defaultPrevented=!1;}}class Ha{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance;}reset(){this._mousedownPos=void 0;}wheel(e){return this._firePreventable(new qa(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Wa(e.type,this._map,e))}mouseup(e){this._map.fire(new Wa(e.type,this._map,e));}preclick(t){const i=e.W({},t);i.type=\"preclick\",this._map.fire(new Wa(i.type,this._map,i));}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Wa(e.type,this._map,e)));}dblclick(e){return this._firePreventable(new Wa(e.type,this._map,e))}mouseover(e){this._map.fire(new Wa(e.type,this._map,e));}mouseout(e){this._map.fire(new Wa(e.type,this._map,e));}touchstart(e){return this._firePreventable(new Za(e.type,this._map,e))}touchmove(e){this._map.fire(new Za(e.type,this._map,e));}touchend(e){this._map.fire(new Za(e.type,this._map,e));}touchcancel(e){this._map.fire(new Za(e.type,this._map,e));}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return {}}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class $a{constructor(e){this._map=e;}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0;}mousemove(e){this._map.fire(new Wa(e.type,this._map,e));}mousedown(){this._delayContextMenu=!0;}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Wa(\"contextmenu\",this._map,this._contextMenuEvent)),delete this._contextMenuEvent);}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Wa(e.type,this._map,e)),this._map.listens(\"contextmenu\")&&e.preventDefault();}isEnabled(){return !0}isActive(){return !1}enable(){}disable(){}}class Xa{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&&(h(),this._startPos=this._lastPos=t,this._active=!0);}mousemoveWindow(e,t){if(!this._active)return;const i=t,o=this._startPos,r=this._lastPos;if(!o||!r||r.equals(i)||!this._box&&i.dist(o){this._box&&(this._box.style.transform=`translate(${n}px,${l}px)`,this._box.style.width=s-n+\"px\",this._box.style.height=c-l+\"px\");}));}mouseupWindow(t,i){if(!this._active)return;const o=this._startPos,r=i;if(o&&0===t.button){if(this.reset(),d(),o.x!==r.x||o.y!==r.y)return this._map.fire(new e.f(\"boxzoomend\",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(o,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),_(),delete this._startPos,delete this._lastPos;}_fireEvent(t,i){return this._map.fire(new e.f(t,{originalEvent:i}))}}function Ya(e,t){const i={};for(let o=0;othis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),o.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=Ya(o,i)));}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const o=Ya(i,t);for(const e in this.touches){const t=o[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 Qa{constructor(e){this.singleTap=new Ka(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 o=this.singleTap.touchend(e,t,i);if(o){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(o)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Ja{constructor(){this._zoomIn=new Qa({numTouches:1,numTaps:2}),this._zoomOut=new Qa({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 o=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return o?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(o)},{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 en={0:1,2:2};class tn{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=m(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=en[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=Ya(o,i),a=new e.P(0,0),n=new e.P(0,0);let s=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(a._add(t),n._add(t.sub(i)),s++,r[e]=t);}if(this._touches=r,s{this._alertContainer.classList.remove(\"mapboxgl-touch-pan-blocker-show\"),this._alertContainer.removeAttribute(\"role\");}),500);}}class sn{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 o=this._firstTwoTouches;if(!o)return;e.preventDefault();const[r,a]=o,n=ln(i,t,r),s=ln(i,t,a);if(!n||!s)return;const l=this._aroundCenter?null:n.add(s).div(2);return this._move([n,s],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[o,r]=this._firstTwoTouches,a=ln(i,t,o),n=ln(i,t,r);a&&n||(this._active&&d(),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 ln(e,t,i){for(let o=0;oMath.abs(e.x)}class pn extends sn{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,dn(e[0].sub(e[1]))&&(this._valid=!1);}_move(t,i,o){const r=this._lastPoints;if(!r)return;const a=t[0].sub(r[0]),n=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.d1()&&o.touches.length<3||(this._valid=this.gestureBeginsVertically(a,n,o.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(a.y+n.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const o=e.mag()>=2,r=t.mag()>=2;if(!o&&!r)return;if(!o||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=e.y>0==t.y>0;return dn(e)&&dn(t)&&a}}const fn={panStep:100,bearingStep:15,pitchStep:10};class mn{constructor(){const e=fn;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,o=0,r=0,a=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?o=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,o=0),{cameraAnimation:n=>{const s=n.getZoom();n.easeTo({duration:300,easeId:\"keyboardHandler\",easing:gn,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:n.getBearing()+i*this._bearingStep,pitch:n.getPitch()+o*this._pitchStep,offset:[-r*this._panStep,-a*this._panStep],center:n.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 gn(e){return e*(2-e)}const vn=4.000244140625,xn=1/450;class yn{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=xn,e.bp([\"_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.d1()))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 o=e.e.now(),r=o-(this._lastWheelEventTime||0);this._lastWheelEventTime=o,0!==i&&i%vn==0?this._type=\"wheel\":0!==i&&Math.abs(i)<4?this._type=\"trackpad\":r>400?(this._type=null,this._lastValue=i,this._timeout=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=p(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)>vn?this._wheelZoomRate:this._defaultZoomRate;let o=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==o&&(o=1/o);const r=i(),a=Math.pow(2,r),n=\"number\"==typeof this._targetZoom?t.zoomScale(this._targetZoom):a;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*o))),\"wheel\"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0;}const o=\"number\"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,a=this._easing;let n,s=!1;if(\"wheel\"===this._type&&r&&a){const t=Math.min((e.e.now()-this._lastWheelEventTime)/200,1),i=a(t);n=e.a2(r,o,i),t<1?this._frameId||(this._frameId=!0):s=!0;}else n=o,s=!0;this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout;}),200));let l=n-i();return l*this._lastDelta<0&&(l=0),{noInertia:!0,needsRenderFrame:!s,zoomDelta:l,around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.d2;if(this._prevEase){const t=this._prevEase,o=(e.e.now()-t.start)/t.duration,r=t.easing(o+.01)-t.easing(o),a=.27/Math.sqrt(r*r+1e-4)*.01,n=Math.sqrt(.0729-a*a);i=e.d0(a,n,.25,1);}return this._prevEase={start:e.e.now(),duration:t,easing:i},i}blur(){this.reset();}reset(){this._active=!1;}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=a(\"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=setTimeout((()=>{this._alertContainer.classList.remove(\"mapboxgl-scroll-zoom-blocker-show\"),this._alertContainer.removeAttribute(\"role\");}),200);}}class bn{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 wn{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 Tn{constructor(){this._tap=new Qa({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 o=t[0],r=o.y-this._swipePoint.y;return this._swipePoint=o,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 En{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 Cn{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 Sn{constructor(e,t,i,o){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=o,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 In=e=>e.zoom||e.drag||e.pitch||e.rotate;class Ln extends e.f{}class Pn{constructor(){this.constants=[1,1,.01],this.radius=0;}setup(t,i){const o=e._.sub([],i,t);this.radius=e._.length(o[2]<0?e._.div([],o,this.constants):[o[0],o[1],0]);}projectRay(t){e._.div(t,t,this.constants),e._.normalize(t,t),e._.mul(t,t,this.constants);const i=e._.scale([],t,this.radius);if(i[2]>0){const t=e._.scale([],[0,0,1],e._.dot(i,[0,0,1])),o=e._.scale([],e._.normalize([],[i[0],i[1],0]),this.radius),r=e._.add([],i,e._.scale([],e._.sub([],e._.add([],o,t),i),2));i[0]=r[0],i[1]=r[1];}return i}}function An(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Rn{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ga(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Pn,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bp([\"handleEvent\",\"handleWindowEvent\"],this);const o=this._el;this._listeners=[[o,\"touchstart\",{passive:!0}],[o,\"touchmove\",{passive:!1}],[o,\"touchend\",void 0],[o,\"touchcancel\",void 0],[o,\"mousedown\",void 0],[o,\"mousemove\",void 0],[o,\"mouseup\",void 0],[document,\"mousemove\",{capture:!0}],[document,\"mouseup\",void 0],[o,\"mouseover\",void 0],[o,\"mouseout\",void 0],[o,\"dblclick\",void 0],[o,\"click\",void 0],[o,\"keydown\",{capture:!1}],[o,\"keyup\",void 0],[o,\"wheel\",{passive:!1}],[o,\"contextmenu\",void 0],[window,\"blur\",void 0]];for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,o,i);}}destroy(){for(const[e,t,i]of this._listeners){const o=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,o,i);}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add(\"mapEvent\",new Ha(t,e));const o=t.boxZoom=new Xa(t,e);this._add(\"boxZoom\",o);const r=new Ja,a=new wn;t.doubleClickZoom=new bn(a,r),this._add(\"tapZoom\",r),this._add(\"clickZoom\",a);const n=new Tn;this._add(\"tapDragZoom\",n);const s=t.touchPitch=new pn(t);this._add(\"touchPitch\",s);const l=new rn(e),c=new an(e);t.dragRotate=new Cn(e,l,c),this._add(\"mouseRotate\",l,[\"mousePitch\"]),this._add(\"mousePitch\",c,[\"mouseRotate\"]);const h=new on(e),_=new nn(t,e);t.dragPan=new En(i,h,_),this._add(\"mousePan\",h),this._add(\"touchPan\",_,[\"touchZoom\",\"touchRotate\"]);const u=new un,d=new hn;t.touchZoomRotate=new Sn(i,d,u,n),this._add(\"touchRotate\",u,[\"touchPan\",\"touchZoom\"]),this._add(\"touchZoom\",d,[\"touchPan\",\"touchRotate\"]),this._add(\"blockableMapEvent\",new $a(t));const p=t.scrollZoom=new yn(t,this);this._add(\"scrollZoom\",p,[\"mousePan\"]);const f=t.keyboard=new mn;this._add(\"keyboard\",f);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 !!In(this._eventsInProgress)||this.isZooming()}_isDragging(){return !!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const o in e)if(o!==i&&(!t||t.indexOf(o)<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,o=i?void 0:e,r={needsRenderFrame:!1},a={},n={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?f(this._el,s):i?void 0:p(this._el,e);for(const{handlerName:i,handler:c,allowed:h}of this._handlers){if(!c.isEnabled())continue;let _;this._blockedByActive(n,h,i)?c.reset():c[t||e.type]&&(_=c[t||e.type](e,l,s),this.mergeHandlerResult(r,a,_,i,o),_&&_.needsRenderFrame&&this._triggerRenderFrame()),(_||c.isActive())&&(n[i]=c);}const c={};for(const e in this._previousActiveHandlers)n[e]||(c[e]=o);this._previousActiveHandlers=n,(Object.keys(c).length||An(r))&&(this._changes.push([r,a,c]),this._triggerRenderFrame()),(Object.keys(n).length||An(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=r;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map));}mergeHandlerResult(t,i,o,r,a){if(!o)return;e.W(t,o);const n={handlerName:r,originalEvent:o.originalEvent||a};void 0!==o.zoomDelta&&(i.zoom=n),void 0!==o.panDelta&&(i.drag=n),void 0!==o.pitchDelta&&(i.pitch=n),void 0!==o.bearingDelta&&(i.rotate=n);}_applyChanges(){const t={},i={},o={};for(const[r,a,n]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),e.W(i,a),e.W(o,n);this._updateMapTransform(t,i,o),this._changes=[];}_updateMapTransform(t,i,o){const r=this._map,a=r.transform,n=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!An(t)){const e=a.zoom;a.cameraElevationReference=\"sea\",null!=this._originalZoom&&a._orthographicProjectionAtLowPitch&&\"globe\"!==a.projection.name&&0===a.pitch?(a.cameraElevationReference=\"ground\",a.zoom=this._originalZoom):(a.recenterOnTerrain(),a.cameraElevationReference=\"ground\"),e!==a.zoom&&this._map._update(!0);}if(a._isCameraConstrained&&r._stop(!0),!An(t))return void this._fireEvents(i,o,!0);let{panDelta:s,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:_,aroundCoord:u,pinchAround:d}=t;a._isCameraConstrained&&(l>0&&(l=0),a._isCameraConstrained=!1),void 0!==d&&(_=d),(l||(e=>i[e]&&!this._eventsInProgress[e])(\"drag\"))&&_&&(this._dragOrigin=n(a.pointCoordinate3D(_)),this._originalZoom=a.zoom,this._trackingEllipsoid.setup(a._camera.position,this._dragOrigin)),a.cameraElevationReference=\"sea\",r._stop(!0),_=_||r.transform.centerPoint,c&&(a.bearing+=c),h&&(a.pitch+=h),a._updateCameraState();const p=[0,0,0];if(s)if(\"mercator\"===a.projection.name){const e=this._trackingEllipsoid.projectRay(a.screenPointToMercatorRay(_).dir),t=this._trackingEllipsoid.projectRay(a.screenPointToMercatorRay(_.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1];}else {const t=a.pointCoordinate(_);if(\"globe\"===a.projection.name){s=s.rotate(-a.angle);const i=a._pixelsPerMercatorPixel/a.worldSize;p[0]=-s.x*e.d3(e.ay(t.y))*i,p[1]=-s.y*e.d3(a.center.lat)*i;}else {const e=a.pointCoordinate(_.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y);}}const f=a.zoom,m=[0,0,0];if(l){const t=n(u||a.pointCoordinate3D(_)),i={dir:e._.normalize([],e._.sub([],t,a._camera.position))};if(i.dir[2]<0){const o=a.zoomDeltaToMovement(t,l);e._.scale(m,i.dir,o);}}const g=e._.add(p,p,m);a._translateCameraConstrained(g),l&&Math.abs(a.zoom-f)>1e-4&&a.recenterOnTerrain(),a.cameraElevationReference=\"ground\",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,o,!0);}_fireEvents(t,i,o){const r=In(this._eventsInProgress),a=In(t),n={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(n[`${e}start`]=i),this._eventsInProgress[e]=t[e];}!r&&a&&this._fireEvent(\"movestart\",a.originalEvent);for(const e in n)this._fireEvent(e,n[e]);a&&this._fireEvent(\"move\",a.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i);}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:o}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||o,s[`${e}end`]=l);}for(const e in s)this._fireEvent(e,s[e]);const c=In(this._eventsInProgress);if(o&&(r||a)&&!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 Ln(\"renderFrame\",{timeStamp:e})),this._applyChanges();}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame());}}const Dn=\"map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.\";class Mn 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.bp([\"_renderFrameCallback\"],this);}getCenter(){return new e.aI(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,o){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.W({offset:t},i),o)}panTo(t,i,o){return this.easeTo(e.W({center:t},i),o)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,o){return this.easeTo(e.W({zoom:t},i),o)}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(t,i,o){return this.easeTo(e.W({bearing:t},i),o)}resetNorth(t,i){return this.rotateTo(0,e.W({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.W({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):o/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,o,r,a,n){const s=t.clone(),l=this._extendCameraOptions(n);s.bearing=r,s.pitch=a;const c=e.aI.convert(i),h=e.aI.convert(o),_=.5*(c.lat+h.lat),u=.5*(c.lng+h.lng),d=e.d4(_,u),p=e._.normalize([],d),f=e._.normalize([],e._.cross([],p,[0,1,0])),m=e._.cross([],f,p),g=[f[0],f[1],f[2],0,m[0],m[1],m[2],0,p[0],p[1],p[2],0,0,0,0,1],v=[d,e.d4(c.lat,c.lng),e.d4(h.lat,c.lng),e.d4(h.lat,h.lng),e.d4(c.lat,h.lng),e.d4(_,c.lng),e.d4(_,h.lng),e.d4(c.lat,u),e.d4(h.lat,u)];let x=e.b6.fromPoints(v.map((t=>[e._.dot(f,t),e._.dot(m,t),e._.dot(p,t)])));const y=e._.transformMat4([],x.center,g);0===e._.squaredLength(y)&&e._.set(y,0,0,1),e._.normalize(y,y),e._.scale(y,y,e.cD),s.center=e.d5(y);const b=s.getWorldToCameraMatrix(),w=e.ad.invert(new Float64Array(16),b);x=e.b6.applyTransform(x,e.ad.multiply([],b,g));const T=this._extendAABB(x,s,l,r);if(!T)return void e.w(\"Map cannot fit within canvas with the given bounds, padding, and/or offset.\");x=T,e._.transformMat4(y,y,b);const E=.5*(x.max[2]-x.min[2]),C=this._minimumAABBFrustumDistance(s,x),S=e._.scale([],[0,0,1],E),I=e._.add(S,y,S),L=C+(0===s.pitch?0:e._.distance(y,I)),P=s.globeCenterInViewSpace,A=e._.sub([],y,[P[0],P[1],P[2]]);e._.normalize(A,A),e._.scale(A,A,L);const R=e._.add([],y,A);e._.transformMat4(R,R,w);const D=e.d7/e.cD,M=e._.length(R),z=e.ax(Math.max(M*D-e.d7,Number.EPSILON),0),O=Math.min(s.zoomFromMercatorZAdjusted(z),l.maxZoom);return O>.5*(e.b1+e.aU)?(s.setProjection({name:\"mercator\"}),s.zoom=O,this._cameraForBounds(s,i,o,r,a,n)):{center:s.center,zoom:O,bearing:r,pitch:a}}_extendAABB(t,i,o,r){const a=.5*((o.padding.left||0)+(o.padding.right||0)),n=.5*((o.padding.top||0)+(o.padding.bottom||0)),s=n,l=a,c=a,h=n,_=i.width-(l+c),u=i.height-(s+h),d=e._.sub([],t.max,t.min),p=Math.min(_/d[0],u/d[1]),f=Math.min(i.scaleZoom(i.scale*p),o.maxZoom);if(isNaN(f))return null;const m=i.scale/i.zoomScale(f),g=new e.b6([t.min[0]-l*m,t.min[1]-h*m,t.min[2]],[t.max[0]+c*m,t.max[1]+s*m,t.max[2]]),v=(\"number\"==typeof o.offset.x&&\"number\"==typeof o.offset.y?new e.P(o.offset.x,o.offset.y):e.P.convert(o.offset)).rotate(-e.ab(r));return g.center[0]-=v.x*m,g.center[1]+=v.y*m,g}queryTerrainElevation(t,i){const o=this.transform.elevation;return o?(i=e.W({},{exaggerated:!0},i),o.getAtPoint(e.Y.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,o,r,a,n){if(\"globe\"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,o,r,a,n);const s=t.clone(),l=this._extendCameraOptions(n);s.bearing=r,s.pitch=a;const c=e.aI.convert(i),h=e.aI.convert(o),_=new e.aI(c.lng,h.lat),u=new e.aI(h.lng,c.lat),d=s.project(c),p=s.project(h),f=this.queryTerrainElevation(c),m=this.queryTerrainElevation(h),g=this.queryTerrainElevation(_),v=this.queryTerrainElevation(u),x=[[d.x,d.y,Math.min(f||0,m||0,g||0,v||0)],[p.x,p.y,Math.max(f||0,m||0,g||0,v||0)]];let y=e.b6.fromPoints(x);const b=s.getWorldToCameraMatrix(),w=e.ad.invert(new Float64Array(16),b);y=e.b6.applyTransform(y,b);const T=this._extendAABB(y,s,l,r);if(!T)return void e.w(\"Map cannot fit within canvas with the given bounds, padding, and/or offset.\");y=T;const E=.5*e._.sub([],y.max,y.min)[2],C=this._minimumAABBFrustumDistance(s,y),S=[0,0,1,0];e.aA.transformMat4(S,S,b),e.aA.normalize(S,S);const I=e._.scale([],S,C+E),L=e._.add([],y.center,I);e._.transformMat4(y.center,y.center,w),e._.transformMat4(L,L,w);const P=[y.center[0],y.center[1],L[2]*s.pixelsPerMeter];e._.scale(P,P,1/s.worldSize);const A=e.d6(P[0]),R=e.ay(P[1]),D=Math.min(s._zoomFromMercatorZ(P[2]),l.maxZoom),M=new e.aI(A,R);return s.mercatorFromTransition&&D<.5*(e.b1+e.aU)?(s.setProjection({name:\"globe\"}),s.zoom=D,this._cameraForBounds(s,i,o,r,a,n)):{center:M,zoom:D,bearing:r,pitch:a}}fitBounds(e,t,i){const o=this.cameraForBounds(e,t);return this._fitInternal(o,t,i)}fitScreenCoordinates(t,i,o,r,a){const n=e.P.convert(t),s=e.P.convert(i),l=new e.P(Math.min(n.x,s.x),Math.min(n.y,s.y)),c=new e.P(Math.max(n.x,s.x),Math.max(n.y,s.y));if(\"mercator\"===this.transform.projection.name&&this.transform.anyCornerOffEdge(n,s))return this;const h=this.transform.pointLocation3D(l),_=this.transform.pointLocation3D(c),u=this.transform.pointLocation3D(new e.P(l.x,c.y)),d=this.transform.pointLocation3D(new e.P(c.x,l.y)),p=[Math.min(h.lng,_.lng,u.lng,d.lng),Math.min(h.lat,_.lat,u.lat,d.lat)],f=[Math.max(h.lng,_.lng,u.lng,d.lng),Math.max(h.lat,_.lat,u.lat,d.lat)],m=r&&r.pitch?r.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,f,o,m,r);return this._fitInternal(g,r,a)}_fitInternal(t,i,o){return t?(i=e.W(t,i)).linear?this.easeTo(i,o):this.flyTo(i,o):this}jumpTo(t,i){this.stop();const o=t.preloadOnly?this.transform.clone():this.transform;let r=!1,a=!1,n=!1;if(\"zoom\"in t&&o.zoom!==+t.zoom&&(r=!0,o.zoom=+t.zoom),void 0!==t.center&&(o.center=e.aI.convert(t.center)),\"bearing\"in t&&o.bearing!==+t.bearing&&(a=!0,o.bearing=+t.bearing),\"pitch\"in t&&o.pitch!==+t.pitch&&(n=!0,o.pitch=+t.pitch),null!=t.padding){const e=\"number\"==typeof t.padding?this._extendPadding(t.padding):t.padding;o.isPaddingEqual(e)||(o.padding=e);}return t.preloadOnly?(this._preloadTiles(o),this):(this.fire(new e.f(\"movestart\",i)).fire(new e.f(\"move\",i)),r&&this.fire(new e.f(\"zoomstart\",i)).fire(new e.f(\"zoom\",i)).fire(new e.f(\"zoomend\",i)),a&&this.fire(new e.f(\"rotatestart\",i)).fire(new e.f(\"rotate\",i)).fire(new e.f(\"rotateend\",i)),n&&this.fire(new e.f(\"pitchstart\",i)).fire(new e.f(\"pitch\",i)).fire(new e.f(\"pitchend\",i)),this.fire(new e.f(\"moveend\",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(Dn),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const o=this.transform;if(!o.projection.supportsFreeCamera)return e.w(Dn),this;this.stop();const r=o.zoom,a=o.pitch,n=o.bearing;o.setFreeCameraOptions(t);const s=r!==o.zoom,l=a!==o.pitch,c=n!==o.bearing;return this.fire(new e.f(\"movestart\",i)).fire(new e.f(\"move\",i)),s&&this.fire(new e.f(\"zoomstart\",i)).fire(new e.f(\"zoom\",i)).fire(new e.f(\"zoomend\",i)),c&&this.fire(new e.f(\"rotatestart\",i)).fire(new e.f(\"rotate\",i)).fire(new e.f(\"rotateend\",i)),l&&this.fire(new e.f(\"pitchstart\",i)).fire(new e.f(\"pitch\",i)).fire(new e.f(\"pitchend\",i)),this.fire(new e.f(\"moveend\",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.W({offset:[0,0],duration:500,easing:e.d2},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const o=this.transform,r=this.getZoom(),a=this.getBearing(),n=this.getPitch(),s=this.getPadding(),l=\"zoom\"in t?+t.zoom:r,c=\"bearing\"in t?this._normalizeBearing(t.bearing,a):a,h=\"pitch\"in t?+t.pitch:n,_=this._extendPadding(t.padding),u=e.P.convert(t.offset);let d,p,f;if(\"globe\"===o.projection.name){const i=e.Y.fromLngLat(o.center),r=u.rotate(-o.angle);i.x+=r.x/o.worldSize,i.y+=r.y/o.worldSize;const a=i.toLngLat(),n=e.aI.convert(t.center||a);this._normalizeCenter(n),d=o.centerPoint.add(r),p=new e.P(i.x,i.y).mult(o.worldSize),f=new e.P(e.aj(n.lng),e.ak(n.lat)).mult(o.worldSize).sub(p);}else {d=o.centerPoint.add(u);const i=o.pointLocation(d),r=e.aI.convert(t.center||i);this._normalizeCenter(r),p=o.project(i),f=o.project(r).sub(p);}const m=o.zoomScale(l-r);let g,v;t.around&&(g=e.aI.convert(t.around),v=o.locationPoint(g));const x=this._zooming||l!==r,y=this._rotating||a!==c,b=this._pitching||h!==n,w=!o.isPaddingEqual(_),T=o=>T=>{if(x&&(o.zoom=e.a2(r,l,T)),y&&(o.bearing=e.a2(a,c,T)),b&&(o.pitch=e.a2(n,h,T)),w&&(o.interpolatePadding(s,_,T),d=o.centerPoint.add(u)),g)o.setLocationAtPoint(g,v);else {const e=o.zoomScale(o.zoom-r),t=l>r?Math.min(2,m):Math.max(.5,m),i=Math.pow(t,1-T),a=o.unproject(p.add(f.mult(T*i)).mult(e));o.setLocationAtPoint(o.renderWorldCopies?a.wrap():a,d);}return t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(T,t.duration,o);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=x,this._rotating=y,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(o),(e=>{\"sea\"===o.cameraElevationReference&&o.recenterOnTerrain(),this._afterEase(i,e);}),t),this}_prepareEase(t,i,o={}){this._moving=!0,this.transform.cameraElevationReference=\"sea\",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&\"globe\"!==this.transform.projection.name&&(this.transform.cameraElevationReference=\"ground\"),i||o.moving||this.fire(new e.f(\"movestart\",t)),this._zooming&&!o.zooming&&this.fire(new e.f(\"zoomstart\",t)),this._rotating&&!o.rotating&&this.fire(new e.f(\"rotatestart\",t)),this._pitching&&!o.pitching&&this.fire(new e.f(\"pitchstart\",t));}_fireMoveEvents(t){this.fire(new e.f(\"move\",t)),this._zooming&&this.fire(new e.f(\"zoom\",t)),this._rotating&&this.fire(new e.f(\"rotate\",t)),this._pitching&&this.fire(new e.f(\"pitch\",t));}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference=\"ground\";const o=this._zooming,r=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,o&&this.fire(new e.f(\"zoomend\",t)),r&&this.fire(new e.f(\"rotateend\",t)),a&&this.fire(new e.f(\"pitchend\",t)),this.fire(new e.f(\"moveend\",t));}flyTo(t,i){if(this._prefersReducedMotion(t)){const o=e.ah(t,[\"center\",\"zoom\",\"bearing\",\"pitch\",\"around\",\"padding\"]);return this.jumpTo(o,i)}this.stop(),t=e.W({offset:[0,0],speed:1.2,curve:1.42,easing:e.d2},t);const o=this.transform,r=this.getZoom(),a=this.getBearing(),n=this.getPitch(),s=this.getPadding(),l=\"zoom\"in t?e.at(+t.zoom,o.minZoom,o.maxZoom):r,c=\"bearing\"in t?this._normalizeBearing(t.bearing,a):a,h=\"pitch\"in t?+t.pitch:n,_=this._extendPadding(t.padding),u=o.zoomScale(l-r),d=e.P.convert(t.offset);let p=o.centerPoint.add(d);const f=o.pointLocation(p),m=e.aI.convert(t.center||f);this._normalizeCenter(m);const g=o.project(f),v=o.project(m).sub(g);let x=t.curve;const y=Math.max(o.width,o.height),b=y/u,w=v.mag();if(\"minZoom\"in t){const i=e.at(Math.min(t.minZoom,r,l),o.minZoom,o.maxZoom),a=y/o.zoomScale(i-r);x=Math.sqrt(a/w*2);}const T=x*x;function E(e){const t=(b*b-y*y+(e?-1:1)*T*T*w*w)/(2*(e?b:y)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return (Math.exp(e)-Math.exp(-e))/2}function S(e){return (Math.exp(e)+Math.exp(-e))/2}const I=E(0);let L=function(e){return S(I)/S(I+x*e)},P=function(e){return y*((S(I)*(C(t=I+x*e)/S(t))-C(I))/T)/w;var t;},A=(E(1)-I)/x;if(Math.abs(w)<1e-6||!isFinite(A)){if(Math.abs(y-b)<1e-6)return this.easeTo(t,i);const e=bt.maxDuration&&(t.duration=0);const R=a!==c,D=h!==n,M=!o.isPaddingEqual(_),z=o=>u=>{const f=u*A,x=1/L(f);o.zoom=1===u?l:r+o.scaleZoom(x),R&&(o.bearing=e.a2(a,c,u)),D&&(o.pitch=e.a2(n,h,u)),M&&(o.interpolatePadding(s,_,u),p=o.centerPoint.add(d));const y=1===u?m:o.unproject(g.add(v.mult(P(f))).mult(x));return o.setLocationAtPoint(o.renderWorldCopies?y.wrap():y,p),o._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),o};if(t.preloadOnly){const e=this._emulate(z,t.duration,o);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=R,this._pitching=D,this._padding=M,this._prepareEase(i,!1),this._ease(z(o),(()=>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,o){!1===o.animate||0===o.duration?(t(1),i()):(this._easeStart=e.e.now(),this._easeOptions=o,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback));}_renderFrameCallback(){const t=Math.min((e.e.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.au(t,-180,180);const o=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0;}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.e.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const o=Math.ceil(15*t/1e3),r=[],a=e(i.clone());for(let e=0;e<=o;e++){const t=a(e/o);r.push(t.clone());}return r}_preloadTiles(e,t){}}class zn{constructor(t={}){this.options=t,e.bp([\"_toggleAttribution\",\"_updateEditLink\",\"_updateData\",\"_updateCompact\"],this);}getDefaultPosition(){return \"bottom-right\"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=a(\"div\",\"mapboxgl-ctrl mapboxgl-ctrl-attrib\"),this._compactButton=a(\"button\",\"mapboxgl-ctrl-attrib-button\",this._container),a(\"span\",\"mapboxgl-ctrl-icon\",this._compactButton).setAttribute(\"aria-hidden\",\"true\"),this._compactButton.type=\"button\",this._compactButton.addEventListener(\"click\",this._toggleAttribution),this._setElementTitle(this._compactButton,\"ToggleAttribution\"),this._innerContainer=a(\"div\",\"mapboxgl-ctrl-attrib-inner\",this._container),t&&this._container.classList.add(\"mapboxgl-compact\"),this._updateAttributions(),this._updateEditLink(),this._map.on(\"styledata\",this._updateData),this._map.on(\"sourcedata\",this._updateData),this._map.on(\"moveend\",this._updateEditLink),void 0===t&&(this._map.on(\"resize\",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off(\"styledata\",this._updateData),this._map.off(\"sourcedata\",this._updateData),this._map.off(\"moveend\",this._updateEditLink),this._map.off(\"resize\",this._updateCompact),this._map=void 0,this._attribHTML=void 0;}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.removeAttribute(\"title\"),e.firstElementChild&&e.firstElementChild.setAttribute(\"title\",i);}_toggleAttribution(){this._container.classList.contains(\"mapboxgl-compact-show\")?(this._container.classList.remove(\"mapboxgl-compact-show\"),this._compactButton.setAttribute(\"aria-expanded\",\"false\")):(this._container.classList.add(\"mapboxgl-compact-show\"),this._compactButton.setAttribute(\"aria-expanded\",\"true\"));}_updateEditLink(){let 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.d8.ACCESS_TOKEN}];if(t){const o=i.reduce(((e,t,o)=>(t.value&&(e+=`${t.key}=${t.value}${oe.length-t.length)),e=e.filter(((t,i)=>{for(let o=i+1;o=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 On{constructor(){e.bp([\"_updateLogo\",\"_updateCompact\"],this);}onAdd(e){this._map=e,this._container=a(\"div\",\"mapboxgl-ctrl\");const t=a(\"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 Fn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1;}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1;}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[];}}function Bn(t,i,o){if(t=new e.aI(t.lng,t.lat),i){const r=new e.aI(t.lng-360,t.lat),a=new e.aI(t.lng+360,t.lat),n=360*Math.ceil(Math.abs(t.lng-o.center.lng)/360),s=o.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>o.width||i.y>o.height;o.locationPoint(r).distSqr(i)180;){const e=o.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=o.width&&e.y<=o.height)break;t.lng>o.center.lng?t.lng-=360:t.lng+=360;}return t}const kn={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 Nn extends e.E{constructor(t,i){if(super(),(t instanceof HTMLElement||i)&&(t=e.W({element:t},i)),e.bp([\"_update\",\"_onMove\",\"_onUp\",\"_addDragHandler\",\"_onMapClick\",\"_onKeyPress\",\"_clearFadeTimer\"],this),this._anchor=t&&t.anchor||\"center\",this._color=t&&t.color||\"#3FB1CE\",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state=\"inactive\",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||\"auto\",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||\"auto\",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else {this._defaultMarker=!0,this._element=a(\"div\");const i=41,o=27,r=n(\"svg\",{display:\"block\",height:i*this._scale+\"px\",width:o*this._scale+\"px\",viewBox:`0 0 ${o} ${i}`},this._element),s=n(\"radialGradient\",{id:\"shadowGradient\"},n(\"defs\",{},r));n(\"stop\",{offset:\"10%\",\"stop-opacity\":.4},s),n(\"stop\",{offset:\"100%\",\"stop-opacity\":.05},s),n(\"ellipse\",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:\"url(#shadowGradient)\"},r),n(\"path\",{fill:this._color,d:\"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z\"},r),n(\"path\",{opacity:.25,d:\"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z\"},r),n(\"circle\",{fill:\"white\",cx:13.5,cy:13.5,r:5.5},r),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 o=this._element.classList;for(const e in kn)o.remove(`mapboxgl-marker-anchor-${e}`);o.add(`mapboxgl-marker-anchor-${this._anchor}`);const r=t&&t.className?t.className.trim().split(/\\s+/):[];o.add(...r),this._popup=null;}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on(\"move\",this._updateMoving),e.on(\"moveend\",this._update),e.on(\"remove\",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on(\"click\",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off(\"click\",this._onMapClick),e.off(\"move\",this._updateMoving),e.off(\"moveend\",this._update),e.off(\"mousedown\",this._addDragHandler),e.off(\"touchstart\",this._addDragHandler),e.off(\"mouseup\",this._onUp),e.off(\"touchend\",this._onUp),e.off(\"mousemove\",this._onMove),e.off(\"touchmove\",this._onMove),e.off(\"remove\",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.aI.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute(\"role\"),this._element.removeEventListener(\"keypress\",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(\"tabindex\")),e){if(!(\"offset\"in e.options)){const t=38.1,i=13.5,o=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\":[o,-1*(t-i+o)],\"bottom-right\":[-o,-1*(t-i+o)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset;}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute(\"role\",\"button\"),this._originalTabIndex=this._element.getAttribute(\"tabindex\"),this._originalTabIndex||this._element.setAttribute(\"tabindex\",\"0\"),this._element.addEventListener(\"keypress\",this._onKeyPress),this._element.setAttribute(\"aria-expanded\",\"false\");}return this}_onKeyPress(e){const t=e.code,i=e.charCode||e.keyCode;\"Space\"!==t&&\"Enter\"!==t&&32!==i&&13!==i||this.togglePopup();}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup();}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute(\"aria-expanded\",\"false\")):this._map&&(e.addTo(this._map),this._element.setAttribute(\"aria-expanded\",\"true\")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return !1;const i=e.unproject(t),o=e.getFreeCameraOptions();if(!o.position)return !1;const r=o.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 o=t.unproject(i);let r;t._showingGlobe()&&e.d9(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(o),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 ${kn[this._anchor]}\\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\\n translate(${t.x}px,${t.y}px)\\n `;}_calculateXYTransform(){const t=this._pos,i=this._map,o=this.getPitchAlignment();if(!i||!t||\"map\"!==o)return \"\";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:\"\"}const r=e.b0(e.da(i.transform,this._lngLat)),a=t.sub(e.db(i.transform)),n=Math.abs(a.x)+Math.abs(a.y);if(0===n)return \"\";const s=r/n;return `rotateX(${-a.y*s}deg) rotateY(${a.x*s}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return \"\";let o=0;const r=this.getRotationAlignment();if(\"map\"===r)if(i._showingGlobe()){const t=i.project(new e.aI(this._lngLat.lng,this._lngLat.lat+.001)),r=i.project(new e.aI(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);o=e.b0(Math.atan2(r.y,r.x))-90;}else o=-i.getBearing();else if(\"horizon\"===r){const r=e.$(4,6,i.getZoom()),a=e.db(i.transform);a.y+=r*i.transform.height;const n=t.sub(a),s=e.b0(Math.atan2(n.y,n.x));o=(s>90?s-270:s+90)*(1-r);}return o+=this._rotation,o?`rotateZ(${o}deg)`:\"\"}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Bn(this._lngLat,this._pos,t.transform)),this._pos=t.project(this._lngLat),!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=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 o=this._pointerdownPos,r=this._positionDelta;if(o&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(o)=this._endTime)return this._end;const i=e.b9((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 Wn={\"AttributionControl.ToggleAttribution\":\"Toggle attribution\",\"AttributionControl.MapFeedback\":\"Map feedback\",\"FullscreenControl.Enter\":\"Enter fullscreen\",\"FullscreenControl.Exit\":\"Exit fullscreen\",\"GeolocateControl.FindMyLocation\":\"Find my location\",\"GeolocateControl.LocationNotAvailable\":\"Location not available\",\"LogoControl.Title\":\"Mapbox logo\",\"Map.Title\":\"Map\",\"NavigationControl.ResetBearing\":\"Reset bearing to north\",\"NavigationControl.ZoomIn\":\"Zoom in\",\"NavigationControl.ZoomOut\":\"Zoom out\",\"ScrollZoomBlocker.CtrlMessage\":\"Use ctrl + scroll to zoom the map\",\"ScrollZoomBlocker.CmdMessage\":\"Use ⌘ + scroll to zoom the map\",\"TouchPanBlocker.Message\":\"Use two fingers to move the map\"};class Zn{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}const qn={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},Hn={showCompass:!0,showZoom:!0,visualizePitch:!1};class $n{constructor(t,i,o=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new rn({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,o&&(this.mousePitch=new an({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bp([\"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),h();}move(e,t){const i=this.map,o=this.mouseRotate.mousemoveWindow(e,t),r=o&&o.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const o=this.mousePitch.mousemoveWindow(e,t),r=o&&o.pitchDelta;r&&i.setPitch(i.getPitch()+r);}}off(){const e=this.element;e.removeEventListener(\"mousedown\",this.mousedown),e.removeEventListener(\"touchstart\",this.touchstart,{passive:!1}),e.removeEventListener(\"touchmove\",this.touchmove),e.removeEventListener(\"touchend\",this.touchend),e.removeEventListener(\"touchcancel\",this.reset),this.offTemp();}offTemp(){_(),window.removeEventListener(\"mousemove\",this.mousemove),window.removeEventListener(\"mouseup\",this.mouseup);}mousedown(t){this.down(e.W({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),window.addEventListener(\"mousemove\",this.mousemove),window.addEventListener(\"mouseup\",this.mouseup);}mousemove(e){this.move(e,p(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=f(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=f(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)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.de(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 di(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),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 Fn,this._domRenderTaskQueue=new Fn,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.df(),this._locale=e.W({},Wn,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._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Vn(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._lastDirtyFrameId=0,this._requestManager=new e.dg(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?{...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),e.bp([\"_onWindowOnline\",\"_onWindowResize\",\"_onVisibilityChange\",\"_onMapScroll\",\"_contextLost\",\"_contextRestored\"],this),this._setupContainer(),this._tp||(this._tp=new Zn),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._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 Rn(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.d8.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new za(\"string\"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==i.center&&null==i.zoom||(this.transform._unmodified=!1),this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch});const o=t.bounds;o&&(this.resize(),this.fitBounds(o,e.W({},t.fitBoundsOptions,{duration:0})));}this.resize(),t.attributionControl&&this.addControl(new zn({customAttribution:t.customAttribution})),this._logoControl=new On,this.addControl(this._logoControl,t.logoPosition),this.on(\"style.load\",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent();})),this.on(\"data\",(t=>{this._update(\"style\"===t.dataType),this.fire(new e.f(`${t.dataType}data`,t));})),this.on(\"dataloading\",(t=>{this.fire(new e.f(`${t.dataType}dataloading`,t));}));}_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.d(new Error(\"Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.\")));const o=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return -1!==i.indexOf(\"bottom\")?r.insertBefore(o,r.firstChild):r.appendChild(o),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.d(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.f(\"movestart\",t)).fire(new e.f(\"move\",t)),this.fire(new e.f(\"resize\",t)),i&&this.fire(new e.f(\"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.f(\"zoomstart\")).fire(new e.f(\"zoom\")).fire(new e.f(\"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.f(\"pitchstart\")).fire(new e.f(\"pitch\")).fire(new e.f(\"pitchend\")),this;throw new Error(\"maxPitch must be greater than or equal to minPitch\")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return \"auto\"===e?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.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 o;\"globe\"===i&&t.zoom>=e.aU?(t.setMercatorFromTransition(),o=!0):\"mercator\"===i&&t.zoom=e.aU?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),i&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t){return this.transform.locationPoint3D(e.aI.convert(t))}unproject(t){return this.transform.pointLocation3D(e.P.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,i){if(\"mouseenter\"===e||\"mouseover\"===e){let o=!1;const r=r=>{const a=t.filter((e=>this.getLayer(e))),n=a.length?this.queryRenderedFeatures(r.point,{layers:a}):[];n.length?o||(o=!0,i.call(this,new Wa(e,this,r.originalEvent,{features:n}))):o=!1;},a=()=>{o=!1;};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:a}}}if(\"mouseleave\"===e||\"mouseout\"===e){let o=!1;const r=r=>{const a=t.filter((e=>this.getLayer(e)));(a.length?this.queryRenderedFeatures(r.point,{layers:a}):[]).length?o=!0:o&&(o=!1,i.call(this,new Wa(e,this,r.originalEvent)));},a=t=>{o&&(o=!1,i.call(this,new Wa(e,this,t.originalEvent)));};return {layers:new Set(t),listener:i,delegates:{mousemove:r,mouseout:a}}}{const o=e=>{const o=t.filter((e=>this.getLayer(e))),r=o.length?this.queryRenderedFeatures(e.point,{layers:o}):[];r.length&&(e.features=r,i.call(this,e),delete e.features);};return {layers:new Set(t),listener:i,delegates:{[e]:o}}}}on(e,t,i){if(\"function\"==typeof t||void 0===i)return super.on(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(o);for(const e in o.delegates)this.on(e,o.delegates[e]);return this}once(e,t,i){if(\"function\"==typeof t||void 0===i)return super.once(e,t);if(Array.isArray(t)||(t=[t]),t)for(const e of t)if(!this._isValidId(e))return this;const o=this._createDelegatedListener(e,t,i);for(const e in o.delegates)this.once(e,o.delegates[e]);return this}off(e,t,i){if(\"function\"==typeof t||void 0===i)return super.off(e,t);const o=new Set(Array.isArray(t)?t:[t]);for(const e of o)if(!this._isValidId(e))return this;const r=(e,t)=>{if(e.size!==t.size)return !1;for(const i of e)if(!t.has(i))return !1;return !0},a=this._delegatedListeners?this._delegatedListeners[e]:void 0;return a&&(e=>{for(let t=0;t{o?(e.w(`Unable to perform style diff: ${String(o.message||o.error||o)}. Rebuilding the style from scratch.`),this._updateStyle(t,i)):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(t,i){if(this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),t){const o=e.W({},i);i&&i.config&&(o.initialConfig=i.config,delete o.config),this.style=new Da(this,o).load(t),this.style.setEventedParent(this,{style:this.style});}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Da(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.d(new Error(\"IDs can't be empty.\"))),!1):!e.cV(t)||(this.fire(new e.d(new Error(`IDs can't contain special symbols: \"${t}\".`))),!1)}addSource(e,t){return this._isValidId(e)?(this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)):this}isSourceLoaded(e){return !!this._isValidId(e)&&!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){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:o=1,sdf:r=!1,stretchX:a,stretchY:n,content:s}={}){if(this._lazyInitEmptyStyle(),i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:l,height:c,data:h}=e.e.getImageData(i);this.style.addImage(t,{data:new e.i({width:l,height:c},h),pixelRatio:o,stretchX:a,stretchY:n,content:s,sdf:r,version:0});}else if(void 0===i.width||void 0===i.height)this.fire(new e.d(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:l,height:c}=i,h=i;this.style.addImage(t,{data:new e.i({width:l,height:c},new Uint8Array(h.data)),pixelRatio:o,stretchX:a,stretchY:n,content:s,sdf:r,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t);}}updateImage(t,i){this._lazyInitEmptyStyle();const o=this.style.getImage(t);if(!o)return void this.fire(new e.d(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||ImageBitmap&&i instanceof ImageBitmap?e.e.getImageData(i):i,{width:a,height:n,data:s}=r;if(void 0===a||void 0===n)return void this.fire(new e.d(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(a!==o.data.width||n!==o.data.height)return void this.fire(new e.d(new Error(`The width and height of the updated image (${a}, ${n})\\n must be that same as the previous version of the image\\n (${o.data.width}, ${o.data.height})`)));const l=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);o.data.replace(s,l),this.style.updateImage(t,o);}hasImage(t){return t?!!this.style&&!!this.style.getImage(t):(this.fire(new e.d(new Error(\"Missing required image id\"))),!1)}removeImage(e){this.style.removeImage(e);}loadImage(t,i){e.h(this._requestManager.transformRequest(t,e.R.Image),((t,o)=>{i(t,o instanceof HTMLImageElement?e.e.getImageData(o):o);}));}listImages(){return this.style.listImages()}addModel(e,t){this._lazyInitEmptyStyle(),this.style.addModel(e,t);}hasModel(t){return t?this.style.hasModel(t):(this.fire(new e.d(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(e,t){return this.style.addImport(e,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?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,o={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,o),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,o={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,o),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}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)}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}setColorTheme(e){return this._lazyInitEmptyStyle(),this.style.setColorTheme(e),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.aI.convert(t),this.transform):0}setFeatureState(e,t){return this._isValidId(e.source)?(this.style.setFeatureState(e,t),this._update()):this}removeFeatureState(e,t){return this._isValidId(e.source)?(this.style.removeFeatureState(e,t),this._update()):this}getFeatureState(e){return this._isValidId(e.source)?this.style.getFeatureState(e):null}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,o,r,a=this._container;for(;a&&(!o||!r);){const e=window.getComputedStyle(a).transform;e&&\"none\"!==e&&(i=e.match(/matrix.*\\((.+)\\)/)[1].split(\", \"),i[0]&&\"0\"!==i[0]&&\"1\"!==i[0]&&(o=i[0]),i[3]&&\"0\"!==i[3]&&\"1\"!==i[3]&&(r=i[3])),a=a.parentElement;}this._containerWidth=o?Math.abs(e/o):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/.\");}_setupContainer(){const e=this._container;e.classList.add(\"mapboxgl-map\"),(this._missingCSSCanary=a(\"div\",\"mapboxgl-canary\",e)).style.visibility=\"hidden\",this._detectMissingCSS();const t=this._canvasContainer=a(\"div\",\"mapboxgl-canvas-container\",e);this._canvas=a(\"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=a(\"div\",\"mapboxgl-control-container\",e),o=this._controlPositions={};[\"top-left\",\"top-right\",\"bottom-left\",\"bottom-right\"].forEach((e=>{o[e]=a(\"div\",`mapboxgl-ctrl-${e}`,i);})),this._container.addEventListener(\"scroll\",this._onMapScroll,!1);}_resizeCanvas(t,i){const o=e.e.devicePixelRatio||1;this._canvas.width=o*Math.ceil(t),this._canvas.height=o*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=e.W({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._canvas.getContext(\"webgl2\",t);o?(e.dh(o,!0),this.painter=new Ar(o,this._contextCreateOptions,this.transform,this._tp),this.on(\"data\",(e=>{\"source\"===e.dataType&&this.painter.setTileLoadedFlag(!0);})),e.di.testSupport(o)):this.fire(new e.d(new Error(\"Failed to initialize WebGL\")));}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.f(\"webglcontextlost\",{originalEvent:t}));}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.f(\"webglcontextrestored\",{originalEvent:t}));}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return !this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}frameReady(){return this.loaded()&&!this._placementDirty&&!this._occlusionOpacityChanged&&this._occlusionCriteriaSatisfied()}_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 i;this.fire(new e.f(\"renderstart\")),++this._frameId;const o=this.painter.context.extTimerQuery,r=e.e.now(),a=this.painter.context.gl;if(this.listens(\"gpu-timing-frame\")&&(i=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],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 n=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,o=e.e.now(),r=new e.X(t,{now:o,fadeDuration:n,pitch:i,transition:this.style.transition});this.style.update(r);}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(r),this.style.updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(r);const l=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,n,this._crossSourceCollisions,this.painter.replacementSource);if(l&&(this._placementDirty=l.needsRerender,this._occlusionOpacityChanged=l.occlusionQueryBasedOpacityChanged),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:n,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.f(\"render\")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.dc.mark(e.dd.load),this.fire(new e.f(\"load\"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const t=e.e.now()-r;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout((()=>{const o=a.getQueryParameter(i,a.QUERY_RESULT)/1e6;a.deleteQuery(i),this.fire(new e.f(\"gpu-timing-frame\",{cpuTime:t,gpuTime:o}));}),50);}if(this.listens(\"gpu-timing-layer\")){const t=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.f(\"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.f(\"gpu-timing-deferred-render\",{gpuTime:i}));}),50);}const c=this._sourcesDirty||this._styleDirty||this._placementDirty||this._occlusionOpacityChanged||s;if((this._sourcesDirty||this._styleDirty||s||this._occlusionOpacityChanged)&&(this._lastDirtyFrameId=this._frameId),c||this._repaint||!this._occlusionCriteriaSatisfied())this.triggerRepaint();else {const t=!this.isMoving()&&this.loaded();if(t&&(s=this._updateAverageElevation(r,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.f(\"idle\")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.f(\"speedindexcompleted\",{speedIndex:t})),this.speedIndexTiming=!1;}}this._loaded&&!this._fullyLoaded&&!c&&this._occlusionCriteriaSatisfied()&&(this._fullyLoaded=!0,e.dc.mark(e.dd.fullLoad),this._performanceMetricsCollection&&e.dj(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 o=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(o||(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 a=Math.abs(t-r);if(a>1){if(this._isInitialLoad||o)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,300);}else if(a>1e-4)return this._averageElevation.jumpTo(r),i(r)}return !!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){e.dk(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(t=>{if(t&&(t.message===e.dl||401===t.status)){const t=this.painter.context.gl;e.dh(t,!1),this._logoControl instanceof On&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.d(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/\")));}})),e.dm(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}));}_postStyleLoadEvent(){this.style.globalId&&e.dn(this._requestManager._customAccessToken,{map:this,skuToken:this._requestManager._skuToken,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()});}_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,o=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,o),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let o=i[1]-i[0];const r=e.length/4;for(let a=0;a{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.ds(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.du(t,i);}_occlusionCriteriaSatisfied(){const e=this.style&&(this.style.has3DLayers()||this.style.terrain&&!this.style.disableElevatedTerrain);return !(this.style&&this.style.hasSymbolLayers()&&e&&this.painter)||this._frameId-this._lastDirtyFrameId>5+2*this.painter.symbolParams.occlusionQueryFrameWindow}get version(){return e.dt}},NavigationControl:class{constructor(t={}){this.options=e.W({},Hn,t),this._container=a(\"div\",\"mapboxgl-ctrl mapboxgl-ctrl-group\"),this._container.addEventListener(\"contextmenu\",(e=>e.preventDefault())),this.options.showZoom&&(e.bp([\"_setButtonTitle\",\"_updateZoomButtons\"],this),this._zoomInButton=this._createButton(\"mapboxgl-ctrl-zoom-in\",(e=>{this._map&&this._map.zoomIn({},{originalEvent:e});})),a(\"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});})),a(\"span\",\"mapboxgl-ctrl-icon\",this._zoomOutButton).setAttribute(\"aria-hidden\",\"true\")),this.options.showCompass&&(e.bp([\"_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=a(\"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(),o=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=o,this._zoomInButton.setAttribute(\"aria-disabled\",i.toString()),this._zoomOutButton.setAttribute(\"aria-disabled\",o.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 $n(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=a(\"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=e.W({geolocation:i},Xn,t),e.bp([\"_onSuccess\",\"_onError\",\"_onZoom\",\"_finish\",\"_setupUI\",\"_updateCamera\",\"_updateMarker\",\"_updateMarkerRotation\",\"_onDeviceOrientation\"],this),this._updateMarkerRotationThrottled=Ma(this._updateMarkerRotation,20),this._numberOfWatches=0;}onAdd(e){return this._map=e,this._container=a(\"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.f(\"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.f(\"geolocate\",t)),this._finish();}}_updateCamera(t){const i=new e.aI(t.coords.longitude,t.coords.latitude),o=t.coords.accuracy,r=this._map.getBearing(),a=e.W({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(o),a,{geolocateSource:!0});}_updateMarker(t){if(t){const i=new e.aI(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.ax(1,t._center.lat)*t.worldSize,o=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}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.f(\"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=a(\"button\",\"mapboxgl-ctrl-geolocate\",this._container),a(\"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=a(\"div\",\"mapboxgl-user-location\"),this._dotElement.appendChild(a(\"div\",\"mapboxgl-user-location-dot\")),this._dotElement.appendChild(a(\"div\",\"mapboxgl-user-location-heading\")),this._userLocationDotMarker=new Nn({element:this._dotElement,rotationAlignment:\"map\",pitchAlignment:\"map\"}),this._circleElement=a(\"div\",\"mapboxgl-user-location-accuracy-circle\"),this._accuracyCircleMarker=new Nn({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.f(\"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.f(\"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.f(\"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.f(\"trackuserlocationstart\"));}switch(this._watchState){case\"WAITING_ACTIVE\":this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-waiting\"),this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-active\");break;case\"ACTIVE_LOCK\":this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-active\");break;case\"ACTIVE_ERROR\":this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-waiting\"),this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-active-error\");break;case\"BACKGROUND\":this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-background\");break;case\"BACKGROUND_ERROR\":this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-waiting\"),this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-background-error\");}if(\"OFF\"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add(\"mapboxgl-ctrl-geolocate-waiting\"),this._geolocateButton.setAttribute(\"aria-pressed\",\"true\"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener();}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return !0}_addDeviceOrientationListener(){const e=()=>{\"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:zn,ScaleControl:class{constructor(t={}){this.options=e.W({},Yn,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat(\"en\",{style:\"unit\",unitDisplay:\"short\",unit:\"meter\"}),!0}catch(e){return !1}}(),e.bp([\"_update\",\"_setScale\",\"setUnit\"],this);}getDefaultPosition(){return \"bottom-left\"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,o=t._containerWidth/2-e/2,r=t.unproject([o,i]),a=t.unproject([o+e,i]),n=r.distanceTo(a);if(\"imperial\"===this.options.unit){const t=3.2808*n;t>5280?this._setScale(e,t/5280,\"mile\"):this._setScale(e,t,\"foot\");}else \"nautical\"===this.options.unit?this._setScale(e,n/1852,\"nautical-mile\"):n>=1e3?this._setScale(e,n/1e3,\"kilometer\"):this._setScale(e,n,\"meter\");}_setScale(e,t,i){this._map._requestDomTask((()=>{const o=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=o/t;this._container.innerHTML=this._isNumberFormatSupported&&\"nautical-mile\"!==i?new Intl.NumberFormat(this._language,{style:\"unit\",unitDisplay:\"short\",unit:i}).format(o):`${o} ${Kn[i]}`,this._container.style.width=e*r+\"px\";}));}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=a(\"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.bp([\"_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=a(\"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=a(\"button\",\"mapboxgl-ctrl-fullscreen\",this._controlContainer);a(\"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();}},Popup:class extends e.E{constructor(t){super(),this.options=e.W(Object.create(Un),t),e.bp([\"_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.f(\"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.f(\"close\")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aI.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}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 o;for(i.innerHTML=e;o=i.firstChild,o;)t.appendChild(o);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=a(\"div\",\"mapboxgl-popup-content\",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=a(\"button\",\"mapboxgl-popup-close-button\",t);e.type=\"button\",e.setAttribute(\"aria-label\",\"Close popup\"),e.setAttribute(\"aria-hidden\",\"true\"),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,o=this._pos;if(!t||!i||!o)return \"bottom\";const r=i.offsetWidth,a=i.offsetHeight,n=o.xt.transform.width-r/2;if(o.y+et.transform.height-a){if(n)return \"bottom-left\";if(s)return \"bottom-right\"}return n?\"left\":s?\"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,o=this._content;if(!i||!this._lngLat&&!this._trackPointer||!o)return;let r=this._container;if(r||(r=this._container=a(\"div\",\"mapboxgl-popup\",i.getContainer()),this._tip=a(\"div\",\"mapboxgl-popup-tip\",r),r.appendChild(o)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Bn(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const o=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat),r=jn(this.options.offset),a=this._anchor=this._getAnchor(r.y),n=jn(this.options.offset,a),s=o.add(n).round();i._requestDomTask((()=>{this._container&&a&&(this._container.style.transform=`${kn[a]} translate(${s.x}px,${s.y}px)`);}));}if(!this._marker&&i._showingGlobe()){const t=e.d9(i.transform,this._lngLat)?0:1;this._setOpacity(t);}this._updateClassList();}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Gn);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:Nn,Style:Da,LngLat:e.aI,LngLatBounds:e.ai,Point:e.P,MercatorCoordinate:e.Y,FreeCameraOptions:qt,Evented:e.E,config:e.d8,prewarm:e.dx,clearPrewarmedResources:e.dy,get accessToken(){return e.d8.ACCESS_TOKEN},set accessToken(t){e.d8.ACCESS_TOKEN=t;},get baseApiUrl(){return e.d8.API_URL},set baseApiUrl(t){e.d8.API_URL=t;},get workerCount(){return e.dz.workerCount},set workerCount(t){e.dz.workerCount=t;},get maxParallelImageRequests(){return e.d8.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.d8.MAX_PARALLEL_IMAGE_REQUESTS=t;},clearStorage(t){e.dA(t);},get workerUrl(){return e.dB.workerUrl},set workerUrl(t){e.dB.workerUrl=t;},get workerClass(){return e.dB.workerClass},set workerClass(t){e.dB.workerClass=t;},get workerParams(){return e.dB.workerParams},set workerParams(t){e.dB.workerParams=t;},get dracoUrl(){return e.dC()},set dracoUrl(t){e.dD(t);},get meshoptUrl(){return e.dE()},set meshoptUrl(t){e.dF(t);},setNow:e.e.setNow,restoreNow:e.e.restoreNow};return Qn}));\n\n//\n// Our custom intro provides a specialized \"define()\" function, called by the\n// AMD modules below, that sets up the worker blob URL and then executes the\n// main module, storing its exported value as 'mapboxgl'\n\n\nvar mapboxgl$1 = mapboxgl;\n\nreturn mapboxgl$1;\n\n}));\n//# sourceMappingURL=mapbox-gl.js.map\n","const copyTextToClipboard = (text) => {\n navigator.clipboard\n .writeText(text)\n .then(() => {\n showToast('Copied to clipboard', 'success');\n })\n .catch((err) => {\n console.error('Failed to copy text: ', err);\n showToast('Failed to copy text', 'error');\n });\n};\n\ndocument.querySelectorAll('[data-copyable]').forEach((element) => {\n if (element) element.addEventListener('click', () => copyTextToClipboard(element.innerText));\n});\n\nconst showToast = (message, type = 'neutral') => {\n const toast = document.createElement('div');\n toast.className = `toast toast--${type}`;\n toast.innerText = message;\n\n document.body.appendChild(toast);\n\n setTimeout(() => {\n toast.classList.add('show');\n }, 10);\n\n setTimeout(() => {\n toast.classList.remove('show');\n setTimeout(() => {\n document.body.removeChild(toast);\n }, 500);\n }, 1000);\n};\n","/** @returns {void} */\nexport function noop() {}\n\nexport const identity = (x) => x;\n\n/**\n * @template T\n * @template S\n * @param {T} tar\n * @param {S} src\n * @returns {T & S}\n */\nexport function assign(tar, src) {\n\t// @ts-ignore\n\tfor (const k in src) tar[k] = src[k];\n\treturn /** @type {T & S} */ (tar);\n}\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\n/**\n * @param {any} value\n * @returns {value is PromiseLike}\n */\nexport function is_promise(value) {\n\treturn (\n\t\t!!value &&\n\t\t(typeof value === 'object' || typeof value === 'function') &&\n\t\ttypeof (/** @type {any} */ (value).then) === 'function'\n\t);\n}\n\n/** @returns {void} */\nexport function add_location(element, file, line, column, char) {\n\telement.__svelte_meta = {\n\t\tloc: { file, line, column, char }\n\t};\n}\n\nexport function run(fn) {\n\treturn fn();\n}\n\nexport function blank_object() {\n\treturn Object.create(null);\n}\n\n/**\n * @param {Function[]} fns\n * @returns {void}\n */\nexport function run_all(fns) {\n\tfns.forEach(run);\n}\n\n/**\n * @param {any} thing\n * @returns {thing is Function}\n */\nexport function is_function(thing) {\n\treturn typeof thing === 'function';\n}\n\n/** @returns {boolean} */\nexport function safe_not_equal(a, b) {\n\treturn a != a ? b == b : a !== b || (a && typeof a === 'object') || typeof a === 'function';\n}\n\nlet src_url_equal_anchor;\n\n/**\n * @param {string} element_src\n * @param {string} url\n * @returns {boolean}\n */\nexport function src_url_equal(element_src, url) {\n\tif (element_src === url) return true;\n\tif (!src_url_equal_anchor) {\n\t\tsrc_url_equal_anchor = document.createElement('a');\n\t}\n\t// This is actually faster than doing URL(..).href\n\tsrc_url_equal_anchor.href = url;\n\treturn element_src === src_url_equal_anchor.href;\n}\n\n/** @param {string} srcset */\nfunction split_srcset(srcset) {\n\treturn srcset.split(',').map((src) => src.trim().split(' ').filter(Boolean));\n}\n\n/**\n * @param {HTMLSourceElement | HTMLImageElement} element_srcset\n * @param {string | undefined | null} srcset\n * @returns {boolean}\n */\nexport function srcset_url_equal(element_srcset, srcset) {\n\tconst element_urls = split_srcset(element_srcset.srcset);\n\tconst urls = split_srcset(srcset || '');\n\n\treturn (\n\t\turls.length === element_urls.length &&\n\t\turls.every(\n\t\t\t([url, width], i) =>\n\t\t\t\twidth === element_urls[i][1] &&\n\t\t\t\t// We need to test both ways because Vite will create an a full URL with\n\t\t\t\t// `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the\n\t\t\t\t// relative URLs inside srcset are not automatically resolved to absolute URLs by\n\t\t\t\t// browsers (in contrast to img.src). This means both SSR and DOM code could\n\t\t\t\t// contain relative or absolute URLs.\n\t\t\t\t(src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0]))\n\t\t)\n\t);\n}\n\n/** @returns {boolean} */\nexport function not_equal(a, b) {\n\treturn a != a ? b == b : a !== b;\n}\n\n/** @returns {boolean} */\nexport function is_empty(obj) {\n\treturn Object.keys(obj).length === 0;\n}\n\n/** @returns {void} */\nexport function validate_store(store, name) {\n\tif (store != null && typeof store.subscribe !== 'function') {\n\t\tthrow new Error(`'${name}' is not a store with a 'subscribe' method`);\n\t}\n}\n\nexport function subscribe(store, ...callbacks) {\n\tif (store == null) {\n\t\tfor (const callback of callbacks) {\n\t\t\tcallback(undefined);\n\t\t}\n\t\treturn noop;\n\t}\n\tconst unsub = store.subscribe(...callbacks);\n\treturn unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\n\n/**\n * Get the current value from a store by subscribing and immediately unsubscribing.\n *\n * https://svelte.dev/docs/svelte-store#get\n * @template T\n * @param {import('../store/public.js').Readable} store\n * @returns {T}\n */\nexport function get_store_value(store) {\n\tlet value;\n\tsubscribe(store, (_) => (value = _))();\n\treturn value;\n}\n\n/** @returns {void} */\nexport function component_subscribe(component, store, callback) {\n\tcomponent.$$.on_destroy.push(subscribe(store, callback));\n}\n\nexport function create_slot(definition, ctx, $$scope, fn) {\n\tif (definition) {\n\t\tconst slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n\t\treturn definition[0](slot_ctx);\n\t}\n}\n\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n\treturn definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;\n}\n\nexport function get_slot_changes(definition, $$scope, dirty, fn) {\n\tif (definition[2] && fn) {\n\t\tconst lets = definition[2](fn(dirty));\n\t\tif ($$scope.dirty === undefined) {\n\t\t\treturn lets;\n\t\t}\n\t\tif (typeof lets === 'object') {\n\t\t\tconst merged = [];\n\t\t\tconst len = Math.max($$scope.dirty.length, lets.length);\n\t\t\tfor (let i = 0; i < len; i += 1) {\n\t\t\t\tmerged[i] = $$scope.dirty[i] | lets[i];\n\t\t\t}\n\t\t\treturn merged;\n\t\t}\n\t\treturn $$scope.dirty | lets;\n\t}\n\treturn $$scope.dirty;\n}\n\n/** @returns {void} */\nexport function update_slot_base(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tslot_changes,\n\tget_slot_context_fn\n) {\n\tif (slot_changes) {\n\t\tconst slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n\t\tslot.p(slot_context, slot_changes);\n\t}\n}\n\n/** @returns {void} */\nexport function update_slot(\n\tslot,\n\tslot_definition,\n\tctx,\n\t$$scope,\n\tdirty,\n\tget_slot_changes_fn,\n\tget_slot_context_fn\n) {\n\tconst slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n\tupdate_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\n\n/** @returns {any[] | -1} */\nexport function get_all_dirty_from_scope($$scope) {\n\tif ($$scope.ctx.length > 32) {\n\t\tconst dirty = [];\n\t\tconst length = $$scope.ctx.length / 32;\n\t\tfor (let i = 0; i < length; i++) {\n\t\t\tdirty[i] = -1;\n\t\t}\n\t\treturn dirty;\n\t}\n\treturn -1;\n}\n\n/** @returns {{}} */\nexport function exclude_internal_props(props) {\n\tconst result = {};\n\tfor (const k in props) if (k[0] !== '$') result[k] = props[k];\n\treturn result;\n}\n\n/** @returns {{}} */\nexport function compute_rest_props(props, keys) {\n\tconst rest = {};\n\tkeys = new Set(keys);\n\tfor (const k in props) if (!keys.has(k) && k[0] !== '$') rest[k] = props[k];\n\treturn rest;\n}\n\n/** @returns {{}} */\nexport function compute_slots(slots) {\n\tconst result = {};\n\tfor (const key in slots) {\n\t\tresult[key] = true;\n\t}\n\treturn result;\n}\n\n/** @returns {(this: any, ...args: any[]) => void} */\nexport function once(fn) {\n\tlet ran = false;\n\treturn function (...args) {\n\t\tif (ran) return;\n\t\tran = true;\n\t\tfn.call(this, ...args);\n\t};\n}\n\nexport function null_to_empty(value) {\n\treturn value == null ? '' : value;\n}\n\nexport function set_store_value(store, ret, value) {\n\tstore.set(value);\n\treturn ret;\n}\n\nexport const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\n\nexport function action_destroyer(action_result) {\n\treturn action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\n/** @param {number | string} value\n * @returns {[number, string]}\n */\nexport function split_css_unit(value) {\n\tconst split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n\treturn split ? [parseFloat(split[1]), split[2] || 'px'] : [/** @type {number} */ (value), 'px'];\n}\n\nexport const contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n","import { noop } from './utils.js';\n\nexport const is_client = typeof window !== 'undefined';\n\n/** @type {() => number} */\nexport let now = is_client ? () => window.performance.now() : () => Date.now();\n\nexport let raf = is_client ? (cb) => requestAnimationFrame(cb) : noop;\n\n// used internally for testing\n/** @returns {void} */\nexport function set_now(fn) {\n\tnow = fn;\n}\n\n/** @returns {void} */\nexport function set_raf(fn) {\n\traf = fn;\n}\n","import { raf } from './environment.js';\n\nconst tasks = new Set();\n\n/**\n * @param {number} now\n * @returns {void}\n */\nfunction run_tasks(now) {\n\ttasks.forEach((task) => {\n\t\tif (!task.c(now)) {\n\t\t\ttasks.delete(task);\n\t\t\ttask.f();\n\t\t}\n\t});\n\tif (tasks.size !== 0) raf(run_tasks);\n}\n\n/**\n * For testing purposes only!\n * @returns {void}\n */\nexport function clear_loops() {\n\ttasks.clear();\n}\n\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n * @param {import('./private.js').TaskCallback} callback\n * @returns {import('./private.js').Task}\n */\nexport function loop(callback) {\n\t/** @type {import('./private.js').TaskEntry} */\n\tlet task;\n\tif (tasks.size === 0) raf(run_tasks);\n\treturn {\n\t\tpromise: new Promise((fulfill) => {\n\t\t\ttasks.add((task = { c: callback, f: fulfill }));\n\t\t}),\n\t\tabort() {\n\t\t\ttasks.delete(task);\n\t\t}\n\t};\n}\n","/** @type {typeof globalThis} */\nexport const globals =\n\ttypeof window !== 'undefined'\n\t\t? window\n\t\t: typeof globalThis !== 'undefined'\n\t\t? globalThis\n\t\t: // @ts-ignore Node typings have this\n\t\t global;\n","import { contenteditable_truthy_values, has_prop } from './utils.js';\n\nimport { ResizeObserverSingleton } from './ResizeObserverSingleton.js';\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;\n\n/**\n * @returns {void}\n */\nexport function start_hydrating() {\n\tis_hydrating = true;\n}\n\n/**\n * @returns {void}\n */\nexport function end_hydrating() {\n\tis_hydrating = false;\n}\n\n/**\n * @param {number} low\n * @param {number} high\n * @param {(index: number) => number} key\n * @param {number} value\n * @returns {number}\n */\nfunction upper_bound(low, high, key, value) {\n\t// Return first index of value larger than input value in the range [low, high)\n\twhile (low < high) {\n\t\tconst mid = low + ((high - low) >> 1);\n\t\tif (key(mid) <= value) {\n\t\t\tlow = mid + 1;\n\t\t} else {\n\t\t\thigh = mid;\n\t\t}\n\t}\n\treturn low;\n}\n\n/**\n * @param {NodeEx} target\n * @returns {void}\n */\nfunction init_hydrate(target) {\n\tif (target.hydrate_init) return;\n\ttarget.hydrate_init = true;\n\t// We know that all children have claim_order values since the unclaimed have been detached if target is not \n\n\tlet children = /** @type {ArrayLike} */ (target.childNodes);\n\t// If target is , there may be children without claim_order\n\tif (target.nodeName === 'HEAD') {\n\t\tconst my_children = [];\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst node = children[i];\n\t\t\tif (node.claim_order !== undefined) {\n\t\t\t\tmy_children.push(node);\n\t\t\t}\n\t\t}\n\t\tchildren = my_children;\n\t}\n\t/*\n\t * Reorder claimed children optimally.\n\t * We can reorder claimed children optimally by finding the longest subsequence of\n\t * nodes that are already claimed in order and only moving the rest. The longest\n\t * subsequence of nodes that are claimed in order can be found by\n\t * computing the longest increasing subsequence of .claim_order values.\n\t *\n\t * This algorithm is optimal in generating the least amount of reorder operations\n\t * possible.\n\t *\n\t * Proof:\n\t * We know that, given a set of reordering operations, the nodes that do not move\n\t * always form an increasing subsequence, since they do not move among each other\n\t * meaning that they must be already ordered among each other. Thus, the maximal\n\t * set of nodes that do not move form a longest increasing subsequence.\n\t */\n\t// Compute longest increasing subsequence\n\t// m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n\tconst m = new Int32Array(children.length + 1);\n\t// Predecessor indices + 1\n\tconst p = new Int32Array(children.length);\n\tm[0] = -1;\n\tlet longest = 0;\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst current = children[i].claim_order;\n\t\t// Find the largest subsequence length such that it ends in a value less than our current value\n\t\t// upper_bound returns first greater value, so we subtract one\n\t\t// with fast path for when we are on the current longest subsequence\n\t\tconst seq_len =\n\t\t\t(longest > 0 && children[m[longest]].claim_order <= current\n\t\t\t\t? longest + 1\n\t\t\t\t: upper_bound(1, longest, (idx) => children[m[idx]].claim_order, current)) - 1;\n\t\tp[i] = m[seq_len] + 1;\n\t\tconst new_len = seq_len + 1;\n\t\t// We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n\t\tm[new_len] = i;\n\t\tlongest = Math.max(new_len, longest);\n\t}\n\t// The longest increasing subsequence of nodes (initially reversed)\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst lis = [];\n\t// The rest of the nodes, nodes that will be moved\n\n\t/**\n\t * @type {NodeEx2[]}\n\t */\n\tconst to_move = [];\n\tlet last = children.length - 1;\n\tfor (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n\t\tlis.push(children[cur - 1]);\n\t\tfor (; last >= cur; last--) {\n\t\t\tto_move.push(children[last]);\n\t\t}\n\t\tlast--;\n\t}\n\tfor (; last >= 0; last--) {\n\t\tto_move.push(children[last]);\n\t}\n\tlis.reverse();\n\t// We sort the nodes being moved to guarantee that their insertion order matches the claim order\n\tto_move.sort((a, b) => a.claim_order - b.claim_order);\n\t// Finally, we move the nodes\n\tfor (let i = 0, j = 0; i < to_move.length; i++) {\n\t\twhile (j < lis.length && to_move[i].claim_order >= lis[j].claim_order) {\n\t\t\tj++;\n\t\t}\n\t\tconst anchor = j < lis.length ? lis[j] : null;\n\t\ttarget.insertBefore(to_move[i], anchor);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @returns {void}\n */\nexport function append(target, node) {\n\ttarget.appendChild(node);\n}\n\n/**\n * @param {Node} target\n * @param {string} style_sheet_id\n * @param {string} styles\n * @returns {void}\n */\nexport function append_styles(target, style_sheet_id, styles) {\n\tconst append_styles_to = get_root_for_style(target);\n\tif (!append_styles_to.getElementById(style_sheet_id)) {\n\t\tconst style = element('style');\n\t\tstyle.id = style_sheet_id;\n\t\tstyle.textContent = styles;\n\t\tappend_stylesheet(append_styles_to, style);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {ShadowRoot | Document}\n */\nexport function get_root_for_style(node) {\n\tif (!node) return document;\n\tconst root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n\tif (root && /** @type {ShadowRoot} */ (root).host) {\n\t\treturn /** @type {ShadowRoot} */ (root);\n\t}\n\treturn node.ownerDocument;\n}\n\n/**\n * @param {Node} node\n * @returns {CSSStyleSheet}\n */\nexport function append_empty_stylesheet(node) {\n\tconst style_element = element('style');\n\t// For transitions to work without 'style-src: unsafe-inline' Content Security Policy,\n\t// these empty tags need to be allowed with a hash as a workaround until we move to the Web Animations API.\n\t// Using the hash for the empty string (for an empty tag) works in all browsers except Safari.\n\t// So as a workaround for the workaround, when we append empty style tags we set their content to /* empty */.\n\t// The hash 'sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=' will then work even in Safari.\n\tstyle_element.textContent = '/* empty */';\n\tappend_stylesheet(get_root_for_style(node), style_element);\n\treturn style_element.sheet;\n}\n\n/**\n * @param {ShadowRoot | Document} node\n * @param {HTMLStyleElement} style\n * @returns {CSSStyleSheet}\n */\nfunction append_stylesheet(node, style) {\n\tappend(/** @type {Document} */ (node).head || node, style);\n\treturn style.sheet;\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @returns {void}\n */\nexport function append_hydration(target, node) {\n\tif (is_hydrating) {\n\t\tinit_hydrate(target);\n\t\tif (\n\t\t\ttarget.actual_end_child === undefined ||\n\t\t\t(target.actual_end_child !== null && target.actual_end_child.parentNode !== target)\n\t\t) {\n\t\t\ttarget.actual_end_child = target.firstChild;\n\t\t}\n\t\t// Skip nodes of undefined ordering\n\t\twhile (target.actual_end_child !== null && target.actual_end_child.claim_order === undefined) {\n\t\t\ttarget.actual_end_child = target.actual_end_child.nextSibling;\n\t\t}\n\t\tif (node !== target.actual_end_child) {\n\t\t\t// We only insert if the ordering of this node should be modified or the parent node is not target\n\t\t\tif (node.claim_order !== undefined || node.parentNode !== target) {\n\t\t\t\ttarget.insertBefore(node, target.actual_end_child);\n\t\t\t}\n\t\t} else {\n\t\t\ttarget.actual_end_child = node.nextSibling;\n\t\t}\n\t} else if (node.parentNode !== target || node.nextSibling !== null) {\n\t\ttarget.appendChild(node);\n\t}\n}\n\n/**\n * @param {Node} target\n * @param {Node} node\n * @param {Node} [anchor]\n * @returns {void}\n */\nexport function insert(target, node, anchor) {\n\ttarget.insertBefore(node, anchor || null);\n}\n\n/**\n * @param {NodeEx} target\n * @param {NodeEx} node\n * @param {NodeEx} [anchor]\n * @returns {void}\n */\nexport function insert_hydration(target, node, anchor) {\n\tif (is_hydrating && !anchor) {\n\t\tappend_hydration(target, node);\n\t} else if (node.parentNode !== target || node.nextSibling != anchor) {\n\t\ttarget.insertBefore(node, anchor || null);\n\t}\n}\n\n/**\n * @param {Node} node\n * @returns {void}\n */\nexport function detach(node) {\n\tif (node.parentNode) {\n\t\tnode.parentNode.removeChild(node);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function destroy_each(iterations, detaching) {\n\tfor (let i = 0; i < iterations.length; i += 1) {\n\t\tif (iterations[i]) iterations[i].d(detaching);\n\t}\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element(name) {\n\treturn document.createElement(name);\n}\n\n/**\n * @template {keyof HTMLElementTagNameMap} K\n * @param {K} name\n * @param {string} is\n * @returns {HTMLElementTagNameMap[K]}\n */\nexport function element_is(name, is) {\n\treturn document.createElement(name, { is });\n}\n\n/**\n * @template T\n * @template {keyof T} K\n * @param {T} obj\n * @param {K[]} exclude\n * @returns {Pick>}\n */\nexport function object_without_properties(obj, exclude) {\n\tconst target = /** @type {Pick>} */ ({});\n\tfor (const k in obj) {\n\t\tif (\n\t\t\thas_prop(obj, k) &&\n\t\t\t// @ts-ignore\n\t\t\texclude.indexOf(k) === -1\n\t\t) {\n\t\t\t// @ts-ignore\n\t\t\ttarget[k] = obj[k];\n\t\t}\n\t}\n\treturn target;\n}\n\n/**\n * @template {keyof SVGElementTagNameMap} K\n * @param {K} name\n * @returns {SVGElement}\n */\nexport function svg_element(name) {\n\treturn document.createElementNS('http://www.w3.org/2000/svg', name);\n}\n\n/**\n * @param {string} data\n * @returns {Text}\n */\nexport function text(data) {\n\treturn document.createTextNode(data);\n}\n\n/**\n * @returns {Text} */\nexport function space() {\n\treturn text(' ');\n}\n\n/**\n * @returns {Text} */\nexport function empty() {\n\treturn text('');\n}\n\n/**\n * @param {string} content\n * @returns {Comment}\n */\nexport function comment(content) {\n\treturn document.createComment(content);\n}\n\n/**\n * @param {EventTarget} node\n * @param {string} event\n * @param {EventListenerOrEventListenerObject} handler\n * @param {boolean | AddEventListenerOptions | EventListenerOptions} [options]\n * @returns {() => void}\n */\nexport function listen(node, event, handler, options) {\n\tnode.addEventListener(event, handler, options);\n\treturn () => node.removeEventListener(event, handler, options);\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function prevent_default(fn) {\n\treturn function (event) {\n\t\tevent.preventDefault();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopPropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => any} */\nexport function stop_immediate_propagation(fn) {\n\treturn function (event) {\n\t\tevent.stopImmediatePropagation();\n\t\t// @ts-ignore\n\t\treturn fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function self(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.target === this) fn.call(this, event);\n\t};\n}\n\n/**\n * @returns {(event: any) => void} */\nexport function trusted(fn) {\n\treturn function (event) {\n\t\t// @ts-ignore\n\t\tif (event.isTrusted) fn.call(this, event);\n\t};\n}\n\n/**\n * @param {Element} node\n * @param {string} attribute\n * @param {string} [value]\n * @returns {void}\n */\nexport function attr(node, attribute, value) {\n\tif (value == null) node.removeAttribute(attribute);\n\telse if (node.getAttribute(attribute) !== value) 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'];\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_attributes(node, attributes) {\n\t// @ts-ignore\n\tconst descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n\tfor (const key in attributes) {\n\t\tif (attributes[key] == null) {\n\t\t\tnode.removeAttribute(key);\n\t\t} else if (key === 'style') {\n\t\t\tnode.style.cssText = attributes[key];\n\t\t} else if (key === '__value') {\n\t\t\t/** @type {any} */ (node).value = node[key] = attributes[key];\n\t\t} else if (\n\t\t\tdescriptors[key] &&\n\t\t\tdescriptors[key].set &&\n\t\t\talways_set_through_set_attribute.indexOf(key) === -1\n\t\t) {\n\t\t\tnode[key] = attributes[key];\n\t\t} else {\n\t\t\tattr(node, key, attributes[key]);\n\t\t}\n\t}\n}\n\n/**\n * @param {Element & ElementCSSInlineStyle} node\n * @param {{ [x: string]: string }} attributes\n * @returns {void}\n */\nexport function set_svg_attributes(node, attributes) {\n\tfor (const key in attributes) {\n\t\tattr(node, key, attributes[key]);\n\t}\n}\n\n/**\n * @param {Record} data_map\n * @returns {void}\n */\nexport function set_custom_element_data_map(node, data_map) {\n\tObject.keys(data_map).forEach((key) => {\n\t\tset_custom_element_data(node, key, data_map[key]);\n\t});\n}\n\n/**\n * @returns {void} */\nexport function set_custom_element_data(node, prop, value) {\n\tconst lower = prop.toLowerCase(); // for backwards compatibility with existing behavior we do lowercase first\n\tif (lower in node) {\n\t\tnode[lower] = typeof node[lower] === 'boolean' && value === '' ? true : value;\n\t} else if (prop in node) {\n\t\tnode[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n\t} else {\n\t\tattr(node, prop, value);\n\t}\n}\n\n/**\n * @param {string} tag\n */\nexport function set_dynamic_element_data(tag) {\n\treturn /-/.test(tag) ? set_custom_element_data_map : set_attributes;\n}\n\n/**\n * @returns {void}\n */\nexport function xlink_attr(node, attribute, value) {\n\tnode.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\n\n/**\n * @param {HTMLElement} node\n * @returns {string}\n */\nexport function get_svelte_dataset(node) {\n\treturn node.dataset.svelteH;\n}\n\n/**\n * @returns {unknown[]} */\nexport function get_binding_group_value(group, __value, checked) {\n\tconst value = new Set();\n\tfor (let i = 0; i < group.length; i += 1) {\n\t\tif (group[i].checked) value.add(group[i].__value);\n\t}\n\tif (!checked) {\n\t\tvalue.delete(__value);\n\t}\n\treturn Array.from(value);\n}\n\n/**\n * @param {HTMLInputElement[]} group\n * @returns {{ p(...inputs: HTMLInputElement[]): void; r(): void; }}\n */\nexport function init_binding_group(group) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\treturn {\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\t_inputs.forEach((input) => group.push(input));\n\t\t},\n\t\t/* remove */ r() {\n\t\t\t_inputs.forEach((input) => group.splice(group.indexOf(input), 1));\n\t\t}\n\t};\n}\n\n/**\n * @param {number[]} indexes\n * @returns {{ u(new_indexes: number[]): void; p(...inputs: HTMLInputElement[]): void; r: () => void; }}\n */\nexport function init_binding_group_dynamic(group, indexes) {\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _group = get_binding_group(group);\n\n\t/**\n\t * @type {HTMLInputElement[]} */\n\tlet _inputs;\n\n\tfunction get_binding_group(group) {\n\t\tfor (let i = 0; i < indexes.length; i++) {\n\t\t\tgroup = group[indexes[i]] = group[indexes[i]] || [];\n\t\t}\n\t\treturn group;\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction push() {\n\t\t_inputs.forEach((input) => _group.push(input));\n\t}\n\n\t/**\n\t * @returns {void} */\n\tfunction remove() {\n\t\t_inputs.forEach((input) => _group.splice(_group.indexOf(input), 1));\n\t}\n\treturn {\n\t\t/* update */ u(new_indexes) {\n\t\t\tindexes = new_indexes;\n\t\t\tconst new_group = get_binding_group(group);\n\t\t\tif (new_group !== _group) {\n\t\t\t\tremove();\n\t\t\t\t_group = new_group;\n\t\t\t\tpush();\n\t\t\t}\n\t\t},\n\t\t/* push */ p(...inputs) {\n\t\t\t_inputs = inputs;\n\t\t\tpush();\n\t\t},\n\t\t/* remove */ r: remove\n\t};\n}\n\n/** @returns {number} */\nexport function to_number(value) {\n\treturn value === '' ? null : +value;\n}\n\n/** @returns {any[]} */\nexport function time_ranges_to_array(ranges) {\n\tconst array = [];\n\tfor (let i = 0; i < ranges.length; i += 1) {\n\t\tarray.push({ start: ranges.start(i), end: ranges.end(i) });\n\t}\n\treturn array;\n}\n\n/**\n * @param {Element} element\n * @returns {ChildNode[]}\n */\nexport function children(element) {\n\treturn Array.from(element.childNodes);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {void}\n */\nfunction init_claim_info(nodes) {\n\tif (nodes.claim_info === undefined) {\n\t\tnodes.claim_info = { last_index: 0, total_claimed: 0 };\n\t}\n}\n\n/**\n * @template {ChildNodeEx} R\n * @param {ChildNodeArray} nodes\n * @param {(node: ChildNodeEx) => node is R} predicate\n * @param {(node: ChildNodeEx) => ChildNodeEx | undefined} process_node\n * @param {() => R} create_node\n * @param {boolean} dont_update_last_index\n * @returns {R}\n */\nfunction claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {\n\t// Try to find nodes in an order such that we lengthen the longest increasing subsequence\n\tinit_claim_info(nodes);\n\tconst result_node = (() => {\n\t\t// We first try to find an element after the previous one\n\t\tfor (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// Otherwise, we try to find one before\n\t\t// We iterate in reverse so that we don't go too far back\n\t\tfor (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n\t\t\tconst node = nodes[i];\n\t\t\tif (predicate(node)) {\n\t\t\t\tconst replacement = process_node(node);\n\t\t\t\tif (replacement === undefined) {\n\t\t\t\t\tnodes.splice(i, 1);\n\t\t\t\t} else {\n\t\t\t\t\tnodes[i] = replacement;\n\t\t\t\t}\n\t\t\t\tif (!dont_update_last_index) {\n\t\t\t\t\tnodes.claim_info.last_index = i;\n\t\t\t\t} else if (replacement === undefined) {\n\t\t\t\t\t// Since we spliced before the last_index, we decrease it\n\t\t\t\t\tnodes.claim_info.last_index--;\n\t\t\t\t}\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\t// If we can't find any matching node, we create a new one\n\t\treturn create_node();\n\t})();\n\tresult_node.claim_order = nodes.claim_info.total_claimed;\n\tnodes.claim_info.total_claimed += 1;\n\treturn result_node;\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @param {(name: string) => Element | SVGElement} create_element\n * @returns {Element | SVGElement}\n */\nfunction claim_element_base(nodes, name, attributes, create_element) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Element | SVGElement} */\n\t\t(node) => node.nodeName === name,\n\t\t/** @param {Element} node */\n\t\t(node) => {\n\t\t\tconst remove = [];\n\t\t\tfor (let j = 0; j < node.attributes.length; j++) {\n\t\t\t\tconst attribute = node.attributes[j];\n\t\t\t\tif (!attributes[attribute.name]) {\n\t\t\t\t\tremove.push(attribute.name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tremove.forEach((v) => node.removeAttribute(v));\n\t\t\treturn undefined;\n\t\t},\n\t\t() => create_element(name)\n\t);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @param {string} name\n * @param {{ [key: string]: boolean }} attributes\n * @returns {Element | SVGElement}\n */\nexport function claim_svg_element(nodes, name, attributes) {\n\treturn claim_element_base(nodes, name, attributes, svg_element);\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Text}\n */\nexport function claim_text(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Text} */\n\t\t(node) => node.nodeType === 3,\n\t\t/** @param {Text} node */\n\t\t(node) => {\n\t\t\tconst data_str = '' + data;\n\t\t\tif (node.data.startsWith(data_str)) {\n\t\t\t\tif (node.data.length !== data_str.length) {\n\t\t\t\t\treturn node.splitText(data_str.length);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnode.data = data_str;\n\t\t\t}\n\t\t},\n\t\t() => text(data),\n\t\ttrue // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n\t);\n}\n\n/**\n * @returns {Text} */\nexport function claim_space(nodes) {\n\treturn claim_text(nodes, ' ');\n}\n\n/**\n * @param {ChildNodeArray} nodes\n * @returns {Comment}\n */\nexport function claim_comment(nodes, data) {\n\treturn claim_node(\n\t\tnodes,\n\t\t/** @returns {node is Comment} */\n\t\t(node) => node.nodeType === 8,\n\t\t/** @param {Comment} node */\n\t\t(node) => {\n\t\t\tnode.data = '' + data;\n\t\t\treturn undefined;\n\t\t},\n\t\t() => comment(data),\n\t\ttrue\n\t);\n}\n\nfunction get_comment_idx(nodes, text, start) {\n\tfor (let i = start; i < nodes.length; i += 1) {\n\t\tconst node = nodes[i];\n\t\tif (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n\t\t\treturn i;\n\t\t}\n\t}\n\treturn -1;\n}\n\n/**\n * @param {boolean} is_svg\n * @returns {HtmlTagHydration}\n */\nexport function claim_html_tag(nodes, is_svg) {\n\t// find html opening tag\n\tconst start_index = get_comment_idx(nodes, 'HTML_TAG_START', 0);\n\tconst end_index = get_comment_idx(nodes, 'HTML_TAG_END', start_index + 1);\n\tif (start_index === -1 || end_index === -1) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\n\tinit_claim_info(nodes);\n\tconst html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n\tdetach(html_tag_nodes[0]);\n\tdetach(html_tag_nodes[html_tag_nodes.length - 1]);\n\tconst claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n\tif (claimed_nodes.length === 0) {\n\t\treturn new HtmlTagHydration(is_svg);\n\t}\n\tfor (const n of claimed_nodes) {\n\t\tn.claim_order = nodes.claim_info.total_claimed;\n\t\tnodes.claim_info.total_claimed += 1;\n\t}\n\treturn new HtmlTagHydration(is_svg, claimed_nodes);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data(text, data) {\n\tdata = '' + data;\n\tif (text.data === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @returns {void}\n */\nexport function set_data_contenteditable(text, data) {\n\tdata = '' + data;\n\tif (text.wholeText === data) return;\n\ttext.data = /** @type {string} */ (data);\n}\n\n/**\n * @param {Text} text\n * @param {unknown} data\n * @param {string} attr_value\n * @returns {void}\n */\nexport function set_data_maybe_contenteditable(text, data, attr_value) {\n\tif (~contenteditable_truthy_values.indexOf(attr_value)) {\n\t\tset_data_contenteditable(text, data);\n\t} else {\n\t\tset_data(text, data);\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_input_value(input, value) {\n\tinput.value = value == null ? '' : value;\n}\n\n/**\n * @returns {void} */\nexport function set_input_type(input, type) {\n\ttry {\n\t\tinput.type = type;\n\t} catch (e) {\n\t\t// do nothing\n\t}\n}\n\n/**\n * @returns {void} */\nexport function set_style(node, key, value, important) {\n\tif (value == null) {\n\t\tnode.style.removeProperty(key);\n\t} else {\n\t\tnode.style.setProperty(key, value, important ? 'important' : '');\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_option(select, value, mounting) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\tif (option.__value === value) {\n\t\t\toption.selected = true;\n\t\t\treturn;\n\t\t}\n\t}\n\tif (!mounting || value !== undefined) {\n\t\tselect.selectedIndex = -1; // no option should be selected\n\t}\n}\n\n/**\n * @returns {void} */\nexport function select_options(select, value) {\n\tfor (let i = 0; i < select.options.length; i += 1) {\n\t\tconst option = select.options[i];\n\t\toption.selected = ~value.indexOf(option.__value);\n\t}\n}\n\nexport function select_value(select) {\n\tconst selected_option = select.querySelector(':checked');\n\treturn selected_option && selected_option.__value;\n}\n\nexport function select_multiple_value(select) {\n\treturn [].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\n\n/**\n * @type {boolean} */\nlet crossorigin;\n\n/**\n * @returns {boolean} */\nexport function is_crossorigin() {\n\tif (crossorigin === undefined) {\n\t\tcrossorigin = false;\n\t\ttry {\n\t\t\tif (typeof window !== 'undefined' && window.parent) {\n\t\t\t\tvoid window.parent.document;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tcrossorigin = true;\n\t\t}\n\t}\n\treturn crossorigin;\n}\n\n/**\n * @param {HTMLElement} node\n * @param {() => void} fn\n * @returns {() => void}\n */\nexport function add_iframe_resize_listener(node, fn) {\n\tconst computed_style = getComputedStyle(node);\n\tif (computed_style.position === 'static') {\n\t\tnode.style.position = 'relative';\n\t}\n\tconst iframe = element('iframe');\n\tiframe.setAttribute(\n\t\t'style',\n\t\t'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n\t\t\t'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;'\n\t);\n\tiframe.setAttribute('aria-hidden', 'true');\n\tiframe.tabIndex = -1;\n\tconst crossorigin = is_crossorigin();\n\n\t/**\n\t * @type {() => void}\n\t */\n\tlet unsubscribe;\n\tif (crossorigin) {\n\t\tiframe.src = \"data:text/html,\";\n\t\tunsubscribe = listen(\n\t\t\twindow,\n\t\t\t'message',\n\t\t\t/** @param {MessageEvent} event */ (event) => {\n\t\t\t\tif (event.source === iframe.contentWindow) fn();\n\t\t\t}\n\t\t);\n\t} else {\n\t\tiframe.src = 'about:blank';\n\t\tiframe.onload = () => {\n\t\t\tunsubscribe = listen(iframe.contentWindow, 'resize', fn);\n\t\t\t// make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n\t\t\t// see https://github.com/sveltejs/svelte/issues/4233\n\t\t\tfn();\n\t\t};\n\t}\n\tappend(node, iframe);\n\treturn () => {\n\t\tif (crossorigin) {\n\t\t\tunsubscribe();\n\t\t} else if (unsubscribe && iframe.contentWindow) {\n\t\t\tunsubscribe();\n\t\t}\n\t\tdetach(iframe);\n\t};\n}\nexport const resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'content-box'\n});\nexport const resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({\n\tbox: 'border-box'\n});\nexport const resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton(\n\t{ box: 'device-pixel-content-box' }\n);\nexport { ResizeObserverSingleton };\n\n/**\n * @returns {void} */\nexport function toggle_class(element, name, toggle) {\n\t// The `!!` is required because an `undefined` flag means flipping the current state.\n\telement.classList.toggle(name, !!toggle);\n}\n\n/**\n * @template T\n * @param {string} type\n * @param {T} [detail]\n * @param {{ bubbles?: boolean, cancelable?: boolean }} [options]\n * @returns {CustomEvent}\n */\nexport function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n\treturn new CustomEvent(type, { detail, bubbles, cancelable });\n}\n\n/**\n * @param {string} selector\n * @param {HTMLElement} parent\n * @returns {ChildNodeArray}\n */\nexport function query_selector_all(selector, parent = document.body) {\n\treturn Array.from(parent.querySelectorAll(selector));\n}\n\n/**\n * @param {string} nodeId\n * @param {HTMLElement} head\n * @returns {any[]}\n */\nexport function head_selector(nodeId, head) {\n\tconst result = [];\n\tlet started = 0;\n\tfor (const node of head.childNodes) {\n\t\tif (node.nodeType === 8 /* comment node */) {\n\t\t\tconst comment = node.textContent.trim();\n\t\t\tif (comment === `HEAD_${nodeId}_END`) {\n\t\t\t\tstarted -= 1;\n\t\t\t\tresult.push(node);\n\t\t\t} else if (comment === `HEAD_${nodeId}_START`) {\n\t\t\t\tstarted += 1;\n\t\t\t\tresult.push(node);\n\t\t\t}\n\t\t} else if (started > 0) {\n\t\t\tresult.push(node);\n\t\t}\n\t}\n\treturn result;\n}\n/** */\nexport class HtmlTag {\n\t/**\n\t * @private\n\t * @default false\n\t */\n\tis_svg = false;\n\t/** parent for creating node */\n\te = undefined;\n\t/** html tag nodes */\n\tn = undefined;\n\t/** target */\n\tt = undefined;\n\t/** anchor */\n\ta = undefined;\n\tconstructor(is_svg = false) {\n\t\tthis.is_svg = is_svg;\n\t\tthis.e = this.n = null;\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @returns {void}\n\t */\n\tc(html) {\n\t\tthis.h(html);\n\t}\n\n\t/**\n\t * @param {string} html\n\t * @param {HTMLElement | SVGElement} target\n\t * @param {HTMLElement | SVGElement} anchor\n\t * @returns {void}\n\t */\n\tm(html, target, anchor = null) {\n\t\tif (!this.e) {\n\t\t\tif (this.is_svg)\n\t\t\t\tthis.e = svg_element(/** @type {keyof SVGElementTagNameMap} */ (target.nodeName));\n\t\t\t/** #7364 target for