var Radar=function(){"use strict";class t{static setup(e={}){t.options=e}static get(){return t.options||{}}static clear(){t.options={}}}t.defaultOptions={live:!1,logLevel:"error",host:"https://api.radar.io",version:"v1",debug:!1};const e={none:0,error:1,warn:2,info:3,debug:4},i=()=>{if(window&&window.RADAR_TEST_ENV)return e.none;const{logLevel:i,debug:r}=t.get();return r?e.debug:i?e[i]:e.error};class r{static debug(t,r){i()===e.debug&&console.log(`Radar SDK (debug): ${t.trim()}`,r)}static info(t){i()>=e.info&&console.log(`Radar SDK: ${t.trim()}`)}static warn(t){i()>=e.warn&&console.warn(`Radar SDK: ${t.trim()}`)}static error(t){i()>=e.error&&console.error(`Radar SDK: ${t.trim()}`)}}class s{static get USER_ID(){return"radar-userId"}static get DEVICE_ID(){return"radar-deviceId"}static get INSTALL_ID(){return"radar-installId"}static get SESSION_ID(){return"radar-sessionId"}static get DESCRIPTION(){return"radar-description"}static get METADATA(){return"radar-metadata"}static get CACHED_LOCATION(){return"radar-cached-location"}static get TRIP_OPTIONS(){return"radar-trip-options"}static getStorage(){const t=null===window||void 0===window?void 0:window.localStorage;return t||r.warn("localStorage not available."),t}static setItem(t,e){const i=this.getStorage();i&&null!=e&&i.setItem(t,e)}static getItem(t){const e=this.getStorage();if(!e)return null;const i=e.getItem(t);return null!=i?i:null}static getJSON(t){const e=this.getItem(t);if(!e)return null;try{return JSON.parse(e)}catch(e){return r.warn(`could not getJSON from storage for key: ${t}`),null}}static removeItem(t){const e=this.getStorage();if(!e)return null;e.removeItem(t)}static clear(){const t=this.getStorage();if(!t)return null;t.clear()}}function n(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{l(r.next(t))}catch(t){n(t)}}function o(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))}class a extends Error{constructor(t){super(t),this.status=""}}class o extends a{constructor(t){super(t),this.name="RadarPublishableKeyError",this.status="ERROR_PUBLISHABLE_KEY"}}class l extends a{constructor(t){super(t),this.name="RadarLocationError",this.status="ERROR_LOCATION"}}class c extends a{constructor(t){super(t),this.name="RadarPermissionsError",this.status="ERROR_PERMISSIONS"}}class h extends a{constructor(){super("Radar Verify app not running."),this.name="RadarVerifyAppError",this.status="ERROR_VERIFY_APP"}}class u extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Bad request."),this.name="RadarBadRequestError",this.code=400,this.response=t,this.status="ERROR_BAD_REQUEST"}}class d extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Unauthorized."),this.name="RadarUnauthorizedError",this.code=401,this.response=t,this.status="ERROR_UNAUTHORIZED"}}class p extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Payment required."),this.name="RadarPaymentRequiredError",this.code=402,this.response=t,this.status="ERROR_PAYMENT_REQUIRED"}}class f extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Forbidden."),this.name="RadarForbiddenError",this.code=403,this.response=t,this.status="ERROR_FORBIDDEN"}}class m extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Not found."),this.name="RadarNotFoundError",this.code=404,this.response=t,this.status="ERROR_NOT_FOUND"}}class g extends a{constructor(t){var e,i;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Rate limit exceeded."),this.name="RadarRateLimitError",this.code=429,this.response=t,this.type=null===(i=null==t?void 0:t.meta)||void 0===i?void 0:i.type,this.status="ERROR_RATE_LIMIT"}}class _ extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Internal server error."),this.name="RadarServerError",this.response=t,this.status="ERROR_SERVER"}}class y extends a{constructor(){super("Request timed out."),this.name="RadarNetworkError",this.status="ERROR_NETWORK"}}class x extends a{constructor(t){var e;super((null===(e=null==t?void 0:t.meta)||void 0===e?void 0:e.message)||"Something went wrong."),this.name="RadarUnknownError",this.response=t,this.status="ERROR_UNKNOWN"}}class v extends a{constructor(t){super(t),this.name="RadarAutocompleteContainerNotFound",this.status="CONTAINER_NOT_FOUND"}}const b={maximumAge:0,timeout:1e4,enableHighAccuracy:!0},w=t=>Boolean("high"===t);class I{static getCurrentPosition(e={}){return n(this,void 0,void 0,(function*(){return new Promise(((i,n)=>{const a=t.get();if(!navigator||!navigator.geolocation)return n(new l("navigator.geolocation is not available."));if(a.cacheLocationMinutes)try{const t=s.getItem(s.CACHED_LOCATION);if(t){const e=JSON.parse(t),{latitude:r,longitude:s,accuracy:n,expiresAt:a}=e||{};if(Date.now(){if(!t||!t.coords)return n(new l("device location return empty coordinates."));const{latitude:e,longitude:r,accuracy:o}=t.coords;if(a.cacheLocationMinutes){const t=Number.parseFloat(a.cacheLocationMinutes),i=Date.now(),n={latitude:e,longitude:r,accuracy:o,updatedAt:i,expiresAt:i+60*t*1e3};s.setItem(s.CACHED_LOCATION,JSON.stringify(n))}return i({latitude:e,longitude:r,accuracy:o})}),(t=>t&&1===t.code?n(new c("Location permissions denied.")):n(new l("Could not determine location."))),o)}))}))}static getPermissionStatus(){return n(this,void 0,void 0,(function*(){return new Promise(((t,e)=>{if(!navigator||!navigator.permissions)return e(new l("navigator.permissions is not available."));navigator.permissions.query({name:"geolocation"}).then((e=>{let i="NOT_DETERMINED";switch(e.state){case"granted":i="GRANTED_FOREGROUND";break;case"denied":i="DENIED";break;case"prompt":i="NOT_DETERMINED"}return t(i)}))}))}))}}var T="4.4.9";const S=new Map;class A{static request({method:e,path:i,data:s,host:a,version:v,headers:b={},responseType:w,requestId:I}){return n(this,void 0,void 0,(function*(){return new Promise(((n,A)=>{const E=t.get(),P=E.publishableKey;if(!P)return void A(new o("publishableKey not set."));let C=`${a||E.host}/${v||E.version}/${i}`,M={};if(Object.keys(s||{}).forEach((t=>{const e=s[t];void 0!==e&&(M[t]=e)})),"GET"===e){const t=Object.keys(M).map((t=>`${t}=${encodeURIComponent(M[t])}`));if(t.length>0){const e=t.join("&");C=`${C}?${e}`}M=void 0}if(I){const t=S.get(I);t&&t.abort()}const k=new XMLHttpRequest;k.open(e,C,!0),I&&S.set(I,k);const z={Authorization:P,"Content-Type":"application/json","X-Radar-Device-Type":"Web","X-Radar-SDK-Version":T};let D={};"function"==typeof E.getRequestHeaders&&(D=E.getRequestHeaders());const R=Object.assign(z,D,b);Object.keys(R).forEach((t=>{k.setRequestHeader(t,R[t])})),w&&(k.responseType=w),k.onload=()=>{var t;let e;I&&S.delete(I);try{e="blob"===k.responseType?{code:k.status,data:k.response}:JSON.parse(k.response)}catch(t){return A(new _(e))}const i=null===(t=null==e?void 0:e.meta)||void 0===t?void 0:t.error;return"ERROR_PERMISSIONS"===i?A(new c("Location permissions not granted.")):"ERROR_LOCATION"===i?A(new l("Could not determine location.")):"ERROR_NETWORK"===i?A(new y):200==k.status?n(e):(E.debug&&(r.debug(`API call failed: ${C}`),r.debug(JSON.stringify(e))),void(400===k.status?A(new u(e)):401===k.status?A(new d(e)):402===k.status?A(new p(e)):403===k.status?A(new f(e)):404===k.status?A(new m(e)):429===k.status?A(new g(e)):500<=k.status&&k.status<600?A(new _(e)):A(new x(e))))},k.onerror=function(){A(!a||"http://localhost:52516"!==a&&"https://radar-verify.com:52516"!==a?new _:new h)},k.ontimeout=function(){A(new h)},k.send(JSON.stringify(M))}))}))}}class E{static validateAddress(e){return n(this,void 0,void 0,(function*(){const i=t.get(),r=yield A.request({method:"GET",path:"addresses/validate",data:e}),{address:s,result:n}=r,a={address:s,result:n};return i.debug&&(a.response=r),a}))}}const P=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}));class C{static getDeviceId(){const t=s.getItem(s.DEVICE_ID);if(t)return t;const e=P();return s.setItem(s.DEVICE_ID,e),e}static getInstallId(){const t=s.getItem(s.INSTALL_ID);if(t)return t;const e=P();return s.setItem(s.INSTALL_ID,e),e}}class M{static getSessionId(){const t=s.getItem(s.SESSION_ID);if(t&&(t=>{const e=Math.trunc(Date.now()/1e3),i=Number.parseInt(t);return Math.abs(e-i)<300})(t))return t;const e=Math.trunc(Date.now()/1e3).toString();return s.setItem(s.SESSION_ID,e),e}}class k{static getConfig(e={}){return n(this,void 0,void 0,(function*(){if("v1"!=t.get().version)return void r.info("Skipping /config call.");const i={deviceId:e.deviceId||C.getDeviceId(),installId:e.installId||C.getInstallId(),sessionId:M.getSessionId(),locationAuthorization:yield I.getPermissionStatus()};try{yield A.request({method:"GET",path:"config",data:i})}catch(t){r.warn(`Error calling /config: ${t.message}`)}}))}}class z{static getContext(e){return n(this,void 0,void 0,(function*(){const i=t.get();e.latitude&&e.longitude||(e=yield I.getCurrentPosition());const{latitude:r,longitude:s,accuracy:n}=e,a=yield A.request({method:"GET",path:"context",data:{coordinates:`${r},${s}`,accuracy:n}}),{geofences:o,place:l,country:c,state:h,dma:u,postalCode:d}=a,p={location:e,geofences:o,place:l,country:c,state:h,dma:u,postalCode:d};return i.debug&&(p.response=a),p}))}}class D{static logConversion(e){return n(this,void 0,void 0,(function*(){const i=t.get(),r=e.name,n=e.userId||s.getItem(s.USER_ID),a=e.deviceId||C.getDeviceId(),o=e.installId||C.getInstallId(),l=e.metadata||{},c=e.createdAt;e.revenue&&(l.revenue=e.revenue);const h={name:r,userId:n,deviceId:a,installId:o,metadata:l};"string"==typeof c?h.createdAt=c:c instanceof Date?h.createdAt=c.toISOString():h.createdAt=(new Date).toISOString();const u=yield A.request({method:"POST",path:"events",data:h}),d={event:u.event};return i.debug&&(d.response=u),d}))}}class R{static forwardGeocode(e){return n(this,void 0,void 0,(function*(){const i=t.get(),{query:r,layers:s,country:n,lang:a}=e,o=yield A.request({method:"GET",path:"geocode/forward",data:{query:r,layers:s,country:n,lang:a}}),l={addresses:o.addresses};return i.debug&&(l.response=o),l}))}static reverseGeocode(e){return n(this,void 0,void 0,(function*(){const i=t.get();let{latitude:r,longitude:s,layers:n}=e;if(!r||!s){const t=yield I.getCurrentPosition();r=t.latitude,s=t.longitude}const a=yield A.request({method:"GET",path:"geocode/reverse",data:{coordinates:`${r},${s}`,layers:n}}),o={addresses:a.addresses};return i.debug&&(o.response=a),o}))}static ipGeocode(){return n(this,void 0,void 0,(function*(){const e=t.get(),i=yield A.request({method:"GET",path:"geocode/ip"}),r={ip:i.ip,address:i.address,proxy:i.proxy};return e.debug&&(r.response=i),r}))}}class L{static distance(e){return n(this,void 0,void 0,(function*(){const i=t.get();let{origin:r,destination:s,modes:n,units:a,geometry:o,geometryPoints:l,avoid:c}=e;if(r){if("string"!=typeof r){const{latitude:t,longitude:e}=r;r=`${t},${e}`}}else{const{latitude:t,longitude:e}=yield I.getCurrentPosition();r=`${t},${e}`}if("string"!=typeof s){const{latitude:t,longitude:e}=s;s=`${t},${e}`}Array.isArray(n)&&(n=n.join(",")),Array.isArray(c)&&(c=c.join(","));const h=yield A.request({method:"GET",path:"route/distance",data:{origin:r,destination:s,modes:n,units:a,geometry:o,geometryPoints:l,avoid:c}}),u={routes:h.routes};return i.debug&&(u.response=h),u}))}static matrix(e){return n(this,void 0,void 0,(function*(){const i=t.get();let{origins:r,destinations:s,mode:n,units:a,avoid:o}=e;if(r)Array.isArray(r)&&(r=r.map((t=>`${t.latitude},${t.longitude}`)).join("|"));else{const{latitude:t,longitude:e}=yield I.getCurrentPosition();let i=[];for(let r=0;r`${t.latitude},${t.longitude}`)).join("|")),Array.isArray(o)&&(o=o.join(","));const l=yield A.request({method:"GET",path:"route/matrix",data:{origins:r,destinations:s,mode:n,units:a,avoid:o}}),c={origins:l.origins,destinations:l.destinations,matrix:l.matrix};return i.debug&&(c.response=l),c}))}}class F{static autocomplete(e,i){return n(this,void 0,void 0,(function*(){const r=t.get();let{query:s,near:n,limit:a,layers:o,countryCode:l,expandUnits:c,mailable:h,lang:u,postalCode:d}=e;n&&"string"!=typeof n&&n.latitude&&n.longitude&&(n=`${n.latitude},${n.longitude}`);const p=yield A.request({method:"GET",path:"search/autocomplete",data:{query:s,near:n,limit:a,layers:o,countryCode:l,expandUnits:c,mailable:h,lang:u,postalCode:d},requestId:i}),f={addresses:p.addresses};return r.debug&&(f.response=p),f}))}static searchGeofences(e){return n(this,void 0,void 0,(function*(){const i=t.get();let{near:r,radius:s,tags:n,metadata:a,limit:o,includeGeometry:l}=e;if(r){if("string"!=typeof r){const{latitude:t,longitude:e}=r;r=`${t},${e}`}}else{const{latitude:t,longitude:e}=yield I.getCurrentPosition();r=`${t},${e}`}Array.isArray(n)&&(n=n.join(","));const c=yield A.request({method:"GET",path:"search/geofences",data:{near:r,radius:s,tags:n,metadata:a,limit:o,includeGeometry:l}}),h={geofences:c.geofences};return i.debug&&(h.response=c),h}))}static searchPlaces(e){return n(this,void 0,void 0,(function*(){const i=t.get();let{near:r,radius:s,chains:n,categories:a,groups:o,limit:l}=e;if(r){if("string"!=typeof r){const{latitude:t,longitude:e}=r;r=`${t},${e}`}}else{const{latitude:t,longitude:e}=yield I.getCurrentPosition();r=`${t},${e}`}Array.isArray(n)&&(n=n.join(",")),Array.isArray(a)&&(a=a.join(",")),Array.isArray(o)&&(o=o.join(","));const c=yield A.request({method:"GET",path:"search/places",data:{near:r,radius:s,chains:n,categories:a,groups:o,limit:l}}),h={places:c.places};return i.debug&&(h.response=c),h}))}}const B=t=>t&&"[object Date]"===Object.prototype.toString.call(t)&&!isNaN(t);class O{static setTripOptions(t){if(!t)return void O.clearTripOptions();const e=JSON.stringify(t);r.debug(`Saving trip options: ${e}`),s.setItem(s.TRIP_OPTIONS,e)}static getTripOptions(){let t=s.getItem(s.TRIP_OPTIONS);return t&&(t=JSON.parse(t)),t}static clearTripOptions(){s.removeItem(s.TRIP_OPTIONS)}static startTrip(e){return n(this,void 0,void 0,(function*(){const i=t.get();(e=e||O.getTripOptions())||r.warn('tripOptions not set when calling "startTrip"');const n=e.userId||s.getItem(s.USER_ID);n&&n!==s.getItem(s.USER_ID)&&s.setItem(s.USER_ID,n);const{externalId:a,destinationGeofenceTag:o,destinationGeofenceExternalId:l,mode:c,metadata:h,approachingThreshold:u,scheduledArrivalAt:d}=e,p={userId:n,externalId:a,destinationGeofenceTag:o,destinationGeofenceExternalId:l,mode:c,metadata:h,approachingThreshold:u};B(d)?p.scheduledArrivalAt=null==d?void 0:d.toJSON():(d&&r.warn("Invalid date format for scheduledArrivalAt"),p.scheduledArrivalAt=void 0);const f=yield A.request({method:"POST",path:"trips",data:p});O.setTripOptions(e);const m={trip:f.trip,events:f.events};return i.debug&&(m.response=f),m}))}static updateTrip(e,i){return n(this,void 0,void 0,(function*(){const s=t.get();(e=e||O.getTripOptions())||r.warn('tripOptions not set when calling "startTrip"');const{externalId:n,destinationGeofenceTag:a,destinationGeofenceExternalId:o,mode:l,metadata:c,approachingThreshold:h,scheduledArrivalAt:u}=e,d={status:i,externalId:n,destinationGeofenceTag:a,destinationGeofenceExternalId:o,mode:l,metadata:c,approachingThreshold:h};B(u)?d.scheduledArrivalAt=null==u?void 0:u.toJSON():(u&&r.warn("Invalid date format for scheduledArrivalAt"),d.scheduledArrivalAt=void 0);const p=yield A.request({method:"PATCH",path:`trips/${n}/update`,data:d}),f={trip:p.trip,events:p.events};return s.debug&&(f.response=p),f}))}static completeTrip(){return n(this,void 0,void 0,(function*(){const t=O.getTripOptions(),e=yield O.updateTrip(t,"completed");return O.clearTripOptions(),e}))}static cancelTrip(){return n(this,void 0,void 0,(function*(){const t=O.getTripOptions(),e=yield O.updateTrip(t,"canceled");return O.clearTripOptions(),e}))}}const V=t=>btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");class N{static trackOnce(e){return n(this,void 0,void 0,(function*(){const i=t.get();let a,{latitude:o,longitude:l,accuracy:c,desiredAccuracy:h,fraud:u}=e;if(!o||!l){const t=yield I.getCurrentPosition({desiredAccuracy:h});o=t.latitude,l=t.longitude,c=t.accuracy}try{a=yield I.getPermissionStatus()}catch(t){r.warn(`Location authorization error: ${t.message}`)}const d=e.userId||s.getItem(s.USER_ID),p=e.deviceId||C.getDeviceId(),f=e.installId||C.getInstallId(),m=M.getSessionId(),g=e.deviceType||"Web",_=e.description||s.getItem(s.DESCRIPTION);let y;try{y=Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){r.warn(`Error getting time zone: ${t.message}`)}d?s.setItem(s.USER_ID,d):r.warn("userId not provided for trackOnce.");const x=e.metadata||s.getJSON(s.METADATA),v=e.tripOptions||O.getTripOptions();v&&(v.version="2");const b=Object.assign(Object.assign({},e),{locationAuthorization:a,accuracy:c,description:_,deviceId:p,deviceType:g,foreground:!0,installId:f,sessionId:m,latitude:o,longitude:l,metadata:x,sdkVersion:T,stopped:!0,userId:d,tripOptions:v,timeZone:y});let w;if(u){const t="https://api-verified.radar.io",e=navigator.language,r=navigator.languages,{dk:s}=yield A.request({host:t,method:"GET",path:"config",data:{deviceId:p,installId:f,sessionId:m,locationAuthorization:a},headers:{"X-Radar-Desktop-Device-Type":"Web"}});let h=-1,u=-1;const d={payload:JSON.stringify(Object.assign(Object.assign({},b),{scl:h,csl:u,lang:e,langs:r}))},g=yield((t,e)=>n(void 0,void 0,void 0,(function*(){const i=new TextEncoder,r=V(JSON.stringify({alg:"HS256",typ:"JWT"})),s=V(JSON.stringify(t)),n=i.encode(e),a=i.encode(`${r}.${s}`),o=yield crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),l=yield crypto.subtle.sign("HMAC",o,a);return`${r}.${s}.${V(String.fromCharCode(...Array.from(new Uint8Array(l))))}`})))(d,s);w=yield A.request({host:t,method:"POST",path:"track",data:{token:g},headers:{"X-Radar-Body-Is-Token":"true"}}),i.debug&&w&&w.user&&(w.user.metadata||(w.user.metadata={}),w.user.metadata["radar:debug"]={sclVal:h,cslVal:u});let{user:_,events:y,token:x,expiresAt:v,expiresIn:I,passed:T,failureReasons:S,_id:E}=w;const P={latitude:o,longitude:l,accuracy:c};v&&(v=new Date(v));const C={user:_,events:y,location:P,token:x,expiresAt:v,expiresIn:I,passed:T,failureReasons:S,_id:E};return i.debug&&(C.response=w),C}w=yield A.request({method:"POST",path:"track",data:b});const{user:S,events:E}=w,P={user:S,events:E,location:{latitude:o,longitude:l,accuracy:c}};return i.debug&&(P.response=w),P}))}}let j=null,U=null,$=null,q=0,Z=null,G=null;class W{static trackVerified(e,i=!1){return n(this,void 0,void 0,(function*(){const n=t.get(),{skipVerifyApp:a}=e,o=e.userId||s.getItem(s.USER_ID),l=C.getDeviceId(),c=C.getInstallId(),h=M.getSessionId(),u=e.description||s.getItem(s.DESCRIPTION);o?s.setItem(s.USER_ID,o):r.warn("userId not provided for trackVerified.");const d=e.metadata||s.getJSON(s.METADATA);let p;if(a)p=yield N.trackOnce({userId:null!=o?o:void 0,description:null!=u?u:void 0,metadata:d,fraud:!0});else{const t=Object.assign(Object.assign({},e),{description:u,deviceId:l,foreground:!0,installId:c,sessionId:h,metadata:d,sdkVersion:T,stopped:!0,userId:o,encrypted:i,expectedCountryCode:Z,expectedStateCode:G});let r=navigator.userAgent;const s=r&&(r.toLowerCase().includes("mac")||r.toLowerCase().includes("iphone")||r.toLowerCase().includes("ipod")||r.toLowerCase().includes("ipad")),a=yield A.request({method:"GET",path:"verify",data:t,host:s?"https://radar-verify.com:52516":"http://localhost:52516"});let f,{user:m,events:g,token:_,expiresAt:y,expiresIn:x,passed:v,failureReasons:b,_id:w}=a;m&&m.location&&m.location.coordinates&&m.locationAccuracy&&(f={latitude:m.location.coordinates[1],longitude:m.location.coordinates[0],accuracy:m.locationAccuracy}),y&&(y=new Date(y)),p={user:m,events:g,location:f,token:_,expiresAt:y,expiresIn:x,passed:v,failureReasons:b,_id:w},n.debug&&(p.response=a)}return $=p,q=performance.now(),U&&U(p),p}))}static startTrackingVerified(t){return n(this,void 0,void 0,(function*(){const e=()=>n(this,void 0,void 0,(function*(){let i;try{i=yield this.trackVerified(t)}catch(t){r.error(`trackVerified error: ${t.message}`)}const{interval:s}=t;let n=0,a=s;i&&(n=i.expiresIn||n,a=Math.min(n,s)),a>20&&(a-=10),a<10&&(a=10),j&&clearTimeout(j),j=setTimeout(e,1e3*a)}));e()}))}static stopTrackingVerified(){j&&clearTimeout(j)}static getVerifiedLocationToken(t){return n(this,void 0,void 0,(function*(){const e=(performance.now()-q)/1e3;return $&&$.passed&&e<($.expiresIn||0)?$:this.trackVerified(t)}))}static setExpectedJurisdiction(t,e){Z=t||null,G=e||null}static onTokenUpdated(t){U=t}}let H=class{static get VERSION(){return T}static initialize(e,i={}){if(!e)throw new o("Publishable key required in initialization.");if(e.includes("_sk_"))throw new o("Secret keys are not allowed. Please use your Radar publishable key.");const s=(t=>t.includes("_live_"))(e),n=s?"error":"info",a=!s,l=Object.assign(t.defaultOptions,{publishableKey:e,live:s,logLevel:n,debug:a},i);t.setup(l),r.info(`initialized with ${s?"live":"test"} publishableKey.`),i.debug&&r.debug("using options",i),(null===window||void 0===window?void 0:window.RADAR_TEST_ENV)||k.getConfig()}static clear(){t.clear()}static setUserId(t){t?s.setItem(s.USER_ID,String(t).trim()):s.removeItem(s.USER_ID)}static setDescription(t){t?s.setItem(s.DESCRIPTION,String(t).trim()):s.removeItem(s.DESCRIPTION)}static setMetadata(t){t?s.setItem(s.METADATA,JSON.stringify(t)):s.removeItem(s.METADATA)}static getLocation(){return I.getCurrentPosition()}static trackOnce(t={}){try{return N.trackOnce(t)}finally{k.getConfig(t)}}static trackVerified(t={}){return W.trackVerified(t)}static startTrackingVerified(t){return W.startTrackingVerified(t)}static stopTrackingVerified(){return W.stopTrackingVerified()}static getVerifiedLocationToken(t={}){return W.getVerifiedLocationToken(t)}static setExpectedJurisdiction(t,e){W.setExpectedJurisdiction(t,e)}static getContext(t){return z.getContext(t)}static setTripOptions(t){O.setTripOptions(t)}static clearTripOptions(){O.clearTripOptions()}static getTripOptions(){return O.getTripOptions()}static startTrip(t){return O.startTrip(t)}static updateTrip(t){return O.updateTrip(t)}static completeTrip(){return O.completeTrip()}static cancelTrip(){return O.cancelTrip()}static logConversion(t){return D.logConversion(t)}static onTokenUpdated(t){W.onTokenUpdated(t)}static forwardGeocode(t){return R.forwardGeocode(t)}static reverseGeocode(t){return R.reverseGeocode(t)}static ipGeocode(){return R.ipGeocode()}static autocomplete(t){return F.autocomplete(t)}static searchGeofences(t){return F.searchGeofences(t)}static searchPlaces(t){return F.searchPlaces(t)}static validateAddress(t){return E.validateAddress(t)}static distance(t){return L.distance(t)}static matrix(t){return L.matrix(t)}};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function X(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var K={exports:{}}; /** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.3.2/LICENSE.txt */K.exports=function(){var t={},e={};function i(i,r,s){if(e[i]=s,"index"===i){var n="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",a={};return e.shared(a),e.index(t,a),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([n],{type:"text/javascript"}))),t}}i("shared",["exports"],(function(t){function e(t,e,i,r){return new(i||(i=Promise))((function(s,n){function a(t){try{l(r.next(t))}catch(t){n(t)}}function o(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((r=r.apply(t,e||[])).next())}))}function i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}"function"==typeof SuppressedError&&SuppressedError;var r=s;function s(t,e){this.x=t,this.y=e}s.prototype={clone:function(){return new s(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,i=t.y-this.y;return e*e+i*i},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),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),r=Math.sin(t),s=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},s.convert=function(t){return t instanceof s?t:Array.isArray(t)?new s(t[0],t[1]):t};var n=i(r),a=o;function o(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}o.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)s?a=i:o=i,i=.5*(o-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var l=i(a);let c,h;function u(){return null==c&&(c="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),c}function d(){if(null==h&&(h=!1,u())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;is.solve(t)}const f=p(.25,.1,.25,1);function m(t,e,i){return Math.min(i,Math.max(e,t))}function g(t,e,i){const r=i-e,s=((t-e)%r+r)%r+e;return s===e?i:s}function _(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let y=1;function x(t,e,i){const r={};for(const i in t)r[i]=e.call(this,t[i],i,t);return r}function v(t,e,i){const r={};for(const i in t)e.call(this,t[i],i,t)&&(r[i]=t[i]);return r}function b(t){return Array.isArray(t)?t.map(b):"object"==typeof t&&t?x(t,b):t}const w={};function I(t){w[t]||("undefined"!=typeof console&&console.warn(t),w[t]=!0)}function T(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function S(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let A=null;function E(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const P="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function C(t,i,r,s,n){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const a=null==e?void 0:e.format;if(!a||!a.startsWith("BGR")&&!a.startsWith("RGB"))throw new Error(`Unrecognized format ${a}`);const o=a.startsWith("BGR"),l=new Uint8ClampedArray(s*n*4);if(yield e.copyTo(l,function(t,e,i,r,s){const n=4*Math.max(-e,0),a=(Math.max(0,i)-i)*r*4+n,o=4*r,l=Math.max(0,e),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+s)-c},layout:[{offset:a,stride:o}]}}(t,i,r,s,n)),o)for(let t=0;tS(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,V=function(t,i){if(/:\/\//.test(t.url)&&!/^https?:|^file:/.test(t.url)){const e=L(t.url);if(e)return e(t,i);if(S(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:F},i)}if(!(/^file:/.test(r=t.url)||/^file:/.test(O())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(t,i){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:O(),signal:i.signal});"json"===t.type&&e.headers.set("Accept","application/json");const r=yield fetch(e);if(!r.ok){const e=yield r.blob();throw new B(r.status,r.statusText,t.url,e)}let s;s="arrayBuffer"===t.type||"image"===t.type?r.arrayBuffer():"json"===t.type?r.json():r.text();const n=yield s;if(i.signal.aborted)throw D();return{data:n,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}}))}(t,i);if(S(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:F},i)}var r;return function(t,e){return new Promise(((i,r)=>{const s=new XMLHttpRequest;s.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(s.responseType="arraybuffer");for(const e in t.headers)s.setRequestHeader(e,t.headers[e]);"json"===t.type&&(s.responseType="text",s.setRequestHeader("Accept","application/json")),s.withCredentials="include"===t.credentials,s.onerror=()=>{r(new Error(s.statusText))},s.onload=()=>{if(!e.signal.aborted)if((s.status>=200&&s.status<300||0===s.status)&&null!==s.response){let e=s.response;if("json"===t.type)try{e=JSON.parse(s.response)}catch(t){return void r(t)}i({data:e,cacheControl:s.getResponseHeader("Cache-Control"),expires:s.getResponseHeader("Expires")})}else{const e=new Blob([s.response],{type:s.getResponseHeader("Content-Type")});r(new B(s.status,s.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{s.abort(),r(D())})),s.send(t.body)}))}(t,i)};function N(t){if(!t||t.indexOf("://")<=0||0===t.indexOf("data:image/")||0===t.indexOf("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function j(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function U(t,e,i){if(i&&i[t]){const r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}class ${constructor(t,e={}){_(this,e),this.type=t}}class q extends ${constructor(t,e={}){super("error",_({error:t},e))}}class Z{on(t,e){return this._listeners=this._listeners||{},j(t,e,this._listeners),this}off(t,e){return U(t,e,this._listeners),U(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},j(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new $(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of r)U(i,e,this._oneTimeListeners),e.call(this,t);const s=this._eventedParent;s&&(_(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),s.fire(t))}else t instanceof q&&console.error(t.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}}var G={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const W=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function H(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return W.forEach((t=>{t in e&&(i[t]=e[t])})),i}function X(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const wt=[lt,ct,ht,ut,dt,gt,pt,vt(ft),_t,yt,xt];function It(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!It(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 wt)if(!It(t,e))return null}return`Expected ${bt(t)} but found ${bt(e)} instead.`}function Tt(t,e){return e.some((e=>e.kind===t.kind))}function St(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))}function At(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Et=.96422,Pt=.82521,Ct=4/29,Mt=6/29,kt=3*Mt*Mt,zt=Mt*Mt*Mt,Dt=Math.PI/180,Rt=180/Math.PI;function Lt(t){return(t%=360)<0&&(t+=360),t}function Ft([t,e,i,r]){let s,n;const a=Ot((.2225045*(t=Bt(t))+.7168786*(e=Bt(e))+.0606169*(i=Bt(i)))/1);t===e&&e===i?s=n=a:(s=Ot((.4360747*t+.3850649*e+.1430804*i)/Et),n=Ot((.0139322*t+.0971045*e+.7141733*i)/Pt));const o=116*a-16;return[o<0?0:o,500*(s-a),200*(a-n),r]}function Bt(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ot(t){return t>zt?Math.pow(t,1/3):t/kt+Ct}function Vt([t,e,i,r]){let s=(t+16)/116,n=isNaN(e)?s:s+e/500,a=isNaN(i)?s:s-i/200;return s=1*jt(s),n=Et*jt(n),a=Pt*jt(a),[Nt(3.1338561*n-1.6168667*s-.4906146*a),Nt(-.9787684*n+1.9161415*s+.033454*a),Nt(.0719453*n-.2289914*s+1.4052427*a),r]}function Nt(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function jt(t){return t>Mt?t*t*t:kt*(t-Ct)}function Ut(t){return parseInt(t.padEnd(2,t),16)/255}function $t(t,e){return qt(e?t/100:t,0,1)}function qt(t,e,i){return Math.min(Math.max(e,t),i)}function Zt(t){return!t.some(Number.isNaN)}const Gt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Wt{constructor(t,e,i,r=1,s=!0){this.r=t,this.g=e,this.b=i,this.a=r,s||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static parse(t){if(t instanceof Wt)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=Gt[t];if(e){const[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[Ut(t.slice(i,i+=e)),Ut(t.slice(i,i+=e)),Ut(t.slice(i,i+=e)),Ut(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,r,s,n,a,o,l,c,h,u,d]=e,p=[s||" ",o||" ",h].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const t=[r,a,c].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[qt(+i/e,0,1),qt(+n/e,0,1),qt(+l/e,0,1),u?$t(+u,d):1];if(Zt(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,r,s,n,a,o,l,c]=i,h=[r||" ",n||" ",o].join("");if(" "===h||" /"===h||",,"===h||",,,"===h){const t=[+e,qt(+s,0,100),qt(+a,0,100),l?$t(+l,c):1];if(Zt(t))return function([t,e,i,r]){function s(r){const s=(r+t/30)%12,n=e*Math.min(i,1-i);return i-n*Math.max(-1,Math.min(s-3,9-s,1))}return t=Lt(t),e/=100,i/=100,[s(0),s(8),s(4),r]}(t)}}}(t);return e?new Wt(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:r}=this,s=r||1/0;return this.overwriteGetter("rgb",[t/s,e/s,i/s,r])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,r,s]=Ft(t),n=Math.sqrt(i*i+r*r);return[Math.round(1e4*n)?Lt(Math.atan2(r,i)*Rt):NaN,n,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Ft(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}}Wt.black=new Wt(0,0,0,1),Wt.white=new Wt(1,1,1,1),Wt.transparent=new Wt(0,0,0,0),Wt.red=new Wt(1,0,0,1);class Ht{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,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 Xt{constructor(t,e,i,r,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=s}}class Kt{constructor(t){this.sections=t}static fromString(t){return new Kt([new Xt(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Kt?t:Kt.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class Jt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Jt)return t;if("number"==typeof t)return new Jt([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new Jt(t)}}toString(){return JSON.stringify(this.values)}}const Yt=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Qt{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Qt)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function ie(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Wt||t instanceof Ht||t instanceof Kt||t instanceof Jt||t instanceof Qt||t instanceof te)return!0;if(Array.isArray(t)){for(const e of t)if(!ie(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!ie(t[e]))return!1;return!0}return!1}function re(t){if(null===t)return lt;if("string"==typeof t)return ht;if("boolean"==typeof t)return ut;if("number"==typeof t)return ct;if(t instanceof Wt)return dt;if(t instanceof Ht)return mt;if(t instanceof Kt)return gt;if(t instanceof Jt)return _t;if(t instanceof Qt)return xt;if(t instanceof te)return yt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=re(e);if(i){if(i===t)continue;i=ft;break}i=t}return vt(i||ft,e)}return pt}function se(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Wt||t instanceof Kt||t instanceof Jt||t instanceof Qt||t instanceof te?t.toString():JSON.stringify(t)}class ne{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(!ie(t[1]))return e.error("invalid value");const i=t[1];let r=re(i);const s=e.expectedType;return"array"!==r.kind||0!==r.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(r=s),new ne(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class ae{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}}const oe={string:ht,number:ct,boolean:ut,object:pt};class le{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 i,r=1;const s=t[0];if("array"===s){let s,n;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in oe)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=oe[i],r++}else s=ft;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);n=t[2],r++}i=vt(s,n)}else{if(!oe[s])throw new Error(`Types doesn't contain name = ${s}`);i=oe[s]}const n=[];for(;rt.outputDefined()))}}const ce={"to-boolean":ut,"to-color":dt,"to-number":ct,"to-string":ht};class he{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 i=t[0];if(!ce[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const r=ce[i],s=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:ee(e[0],e[1],e[2],e[3]),!i))return new Wt(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new ae(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const r=Jt.parse(e);if(r)return r}throw new ae(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const r=Qt.parse(e);if(r)return r}throw new ae(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new ae(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Kt.fromString(se(this.args[0].evaluate(t)));case"resolvedImage":return te.fromString(se(this.args[0].evaluate(t)));default:return se(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const ue=["Unknown","Point","LineString","Polygon"];class de{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?ue[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Wt.parse(t)),e}}class pe{constructor(t,e,i=[],r,s=new ot,n=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=s,this.errors=n,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,s={}){return e?this.concat(e,i,r)._parse(t,s):this._parse(t,s)}_parse(t,e){function i(t,e,i){return"assert"===i?new le(e,[t]):"coerce"===i?new he(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 r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[r];if(s){let r=s.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,s=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==s.kind&&"string"!==s.kind)if("padding"!==t.kind||"value"!==s.kind&&"number"!==s.kind&&"array"!==s.kind)if("variableAnchorOffsetCollection"!==t.kind||"value"!==s.kind&&"array"!==s.kind){if(this.checkSubtype(t,s))return null}else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"coerce");else r=i(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ne)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const e=new de;try{r=new ne(r.type,r.evaluate(e))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}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,i){const r="number"==typeof t?this.path.concat(t):this.path,s=i?this.scope.concat(i):this.scope;return new pe(this.registry,this._isConstant,r,e||null,s,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new at(i,t))}checkSubtype(t,e){const i=It(t,e);return i&&this.error(i),i}}class fe{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 i=[];for(let r=1;r=i.length)throw new ae(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new ae(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class _e{constructor(t,e){this.type=ut,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 i=e.parse(t[1],1,ft),r=e.parse(t[2],2,ft);return i&&r?Tt(i.type,[ut,ht,ct,lt,ft])?new _e(i,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${bt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!St(e,["boolean","string","number","null"]))throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${bt(re(e))} instead.`);if(!St(i,["string","array"]))throw new ae(`Expected second argument to be of type array or string, but found ${bt(re(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class ye{constructor(t,e,i){this.type=ct,this.needle=t,this.haystack=e,this.fromIndex=i}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 i=e.parse(t[1],1,ft),r=e.parse(t[2],2,ft);if(!i||!r)return null;if(!Tt(i.type,[ut,ht,ct,lt,ft]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${bt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,ct);return s?new ye(i,r,s):null}return new ye(i,r)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!St(e,["boolean","string","number","null"]))throw new ae(`Expected first argument to be of type boolean, string, number or null, but found ${bt(re(e))} instead.`);if(!St(i,["string","array"]))throw new ae(`Expected second argument to be of type array or string, but found ${bt(re(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return i.indexOf(e,r)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class xe{constructor(t,e,i,r,s,n){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=s,this.otherwise=n}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 i,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const s={},n=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,re(t)))return null}else i=re(t);if(void 0!==s[String(t)])return c.error("Branch labels must be unique.");s[String(t)]=n.length}const h=e.parse(l,a,r);if(!h)return null;r=r||h.type,n.push(h)}const a=e.parse(t[1],1,ft);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,r);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(i,a.type)?null:new xe(i,r,a,s,n,o):null}evaluate(t){const e=this.input.evaluate(t);return(re(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()}}class ve{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}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 i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const r=[];for(let s=1;se.outputDefined()))&&this.otherwise.outputDefined()}}class be{constructor(t,e,i,r){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=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 i=e.parse(t[1],1,ft),r=e.parse(t[2],2,ct);if(!i||!r)return null;if(!Tt(i.type,[vt(ft),ht,ft]))return e.error(`Expected first argument to be of type array or string, but found ${bt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,ct);return s?new be(i.type,i,r,s):null}return new be(i.type,i,r)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!St(e,["string","array"]))throw new ae(`Expected first argument to be of type array or string, but found ${bt(re(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(i,r)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function we(t,e){const i=t.length-1;let r,s,n=0,a=i,o=0;for(;n<=a;)if(o=Math.floor((n+a)/2),r=t[o],s=t[o+1],r<=e){if(o===i||ee))throw new ae("Input is not a number.");a=o-1}return 0}class Ie{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)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 i=e.parse(t[1],1,ct);if(!i)return null;const r=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let i=1;i=n)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const c=e.parse(a,l,s);if(!c)return null;s=s||c.type,r.push([n,c])}return new Ie(s,i,r)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;return r>=e[s-1]?i[s-1].evaluate(t):i[we(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function Te(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Se=Ae;function Ae(t,e,i,r){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=r}Ae.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,r=0;r<8;r++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)s?a=i:o=i,i=.5*(o-a)+a;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Ee=Te(Se);function Pe(t,e,i){return t+i*(e-t)}function Ce(t,e,i){return t.map(((t,r)=>Pe(t,e[r],i)))}const Me={number:Pe,color:function(t,e,i,r="rgb"){switch(r){case"rgb":{const[r,s,n,a]=Ce(t.rgb,e.rgb,i);return new Wt(r,s,n,a,!1)}case"hcl":{const[r,s,n,a]=t.hcl,[o,l,c,h]=e.hcl;let u,d;if(isNaN(r)||isNaN(o))isNaN(r)?isNaN(o)?u=NaN:(u=o,1!==n&&0!==n||(d=l)):(u=r,1!==c&&0!==c||(d=s));else{let t=o-r;o>r&&t>180?t-=360:o180&&(t+=360),u=r+i*t}const[p,f,m,g]=function([t,e,i,r]){return t=isNaN(t)?0:t*Dt,Vt([i,Math.cos(t)*e,Math.sin(t)*e,r])}([u,null!=d?d:Pe(s,l,i),Pe(n,c,i),Pe(a,h,i)]);return new Wt(p,f,m,g,!1)}case"lab":{const[r,s,n,a]=Vt(Ce(t.lab,e.lab,i));return new Wt(r,s,n,a,!1)}}},array:Ce,padding:function(t,e,i){return new Jt(Ce(t.values,e.values,i))},variableAnchorOffsetCollection:function(t,e,i){const r=t.values,s=e.values;if(r.length!==s.length)throw new ae(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const n=[];for(let t=0;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);r={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(s=e.parse(s,2,ct),!s)return null;const a=[];let o=null;"interpolate-hcl"===i||"interpolate-lab"===i?o=dt:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const c=e.parse(r,l,o);if(!c)return null;o=o||c.type,a.push([i,c])}return At(o,ct)||At(o,dt)||At(o,_t)||At(o,xt)||At(o,vt(ct))?new ke(o,i,r,s,a):e.error(`Type ${bt(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);const s=e.length;if(r>=e[s-1])return i[s-1].evaluate(t);const n=we(e,r),a=ke.interpolationFactor(this.interpolation,r,e[n],e[n+1]),o=i[n].evaluate(t),l=i[n+1].evaluate(t);switch(this.operator){case"interpolate":return Me[this.type.kind](o,l,a);case"interpolate-hcl":return Me.color(o,l,a,"hcl");case"interpolate-lab":return Me.color(o,l,a,"lab")}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function ze(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}class De{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let i=null;const r=e.expectedType;r&&"value"!==r.kind&&(i=r);const s=[];for(const r of t.slice(1)){const t=e.parse(r,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,s.push(t)}if(!i)throw new Error("No output type");const n=r&&s.some((t=>It(r,t.type)));return new De(n?ft:i,s)}evaluate(t){let e,i=null,r=0;for(const s of this.args)if(r++,i=s.evaluate(t),i&&i instanceof te&&!i.available&&(e||(e=i.name),i=null,r===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function Re(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 Le(t,e,i,r){return 0===r.compare(e,i)}function Fe(t,e,i){const r="=="!==t&&"!="!==t;return class s{constructor(t,e,i){this.type=ut,this.lhs=t,this.rhs=e,this.collator=i,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 i=t[0];let n=e.parse(t[1],1,ft);if(!n)return null;if(!Re(i,n.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${bt(n.type)}'.`);let a=e.parse(t[2],2,ft);if(!a)return null;if(!Re(i,a.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${bt(a.type)}'.`);if(n.type.kind!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${bt(n.type)}' and '${bt(a.type)}'.`);r&&("value"===n.type.kind&&"value"!==a.type.kind?n=new le(a.type,[n]):"value"!==n.type.kind&&"value"===a.type.kind&&(a=new le(n.type,[a])));let o=null;if(4===t.length){if("string"!==n.type.kind&&"string"!==a.type.kind&&"value"!==n.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,mt),!o)return null}return new s(n,a,o)}evaluate(s){const n=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(r&&this.hasUntypedArgument){const e=re(n),i=re(a);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new ae(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=re(n),i=re(a);if("string"!==t.kind||"string"!==i.kind)return e(s,n,a)}return this.collator?i(s,n,a,this.collator.evaluate(s)):e(s,n,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Be=Fe("==",(function(t,e,i){return e===i}),Le),Oe=Fe("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!Le(0,e,i,r)})),Ve=Fe("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),je=Fe("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),Ue=Fe(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));class $e{constructor(t,e,i){this.type=mt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,ut);if(!r)return null;const s=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,ut);if(!s)return null;let n=null;return i.locale&&(n=e.parse(i.locale,1,ht),!n)?null:new $e(r,s,n)}evaluate(t){return new Ht(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class qe{constructor(t,e,i,r,s){this.type=ht,this.number=t,this.locale=e,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ct);if(!i)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=e.parse(r.locale,1,ht),!s))return null;let n=null;if(r.currency&&(n=e.parse(r.currency,1,ht),!n))return null;let a=null;if(r["min-fraction-digits"]&&(a=e.parse(r["min-fraction-digits"],1,ct),!a))return null;let o=null;return r["max-fraction-digits"]&&(o=e.parse(r["max-fraction-digits"],1,ct),!o)?null:new qe(i,s,n,a,o)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Ze{constructor(t){this.type=gt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const r=[];let s=!1;for(let i=1;i<=t.length-1;++i){const n=t[i];if(s&&"object"==typeof n&&!Array.isArray(n)){s=!1;let t=null;if(n["font-scale"]&&(t=e.parse(n["font-scale"],1,ct),!t))return null;let i=null;if(n["text-font"]&&(i=e.parse(n["text-font"],1,vt(ht)),!i))return null;let a=null;if(n["text-color"]&&(a=e.parse(n["text-color"],1,dt),!a))return null;const o=r[r.length-1];o.scale=t,o.font=i,o.textColor=a}else{const n=e.parse(t[i],1,ft);if(!n)return null;const a=n.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:n,scale:null,font:null,textColor:null})}}return new Ze(r)}evaluate(t){return new Kt(this.sections.map((e=>{const i=e.content.evaluate(t);return re(i)===yt?new Xt("",i,null,null,null):new Xt(se(i),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}}class Ge{constructor(t){this.type=yt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ht);return i?new Ge(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=te.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class We{constructor(t){this.type=ct,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${bt(i.type)} instead.`):new We(i):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 ae(`Expected value to be of type string or array, but found ${bt(re(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const He=8192;function Xe(t,e){const i=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*He),Math.round(r*s*He)]}function Ke(t,e){const i=Math.pow(2,e.z);return[(s=(t[0]/He+e.x)/i,360*s-180),(r=(t[1]/He+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,s}function Je(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Ye(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Qe(t,e,i){const r=t[0]-e[0],s=t[1]-e[1],n=t[0]-i[0],a=t[1]-i[1];return r*a-n*s==0&&r*n<=0&&s*a<=0}function ti(t,e,i,r){return 0!=(s=[r[0]-i[0],r[1]-i[1]])[0]*(n=[e[0]-t[0],e[1]-t[1]])[1]-s[1]*n[0]&&!(!ai(t,e,i,r)||!ai(i,r,t,e));var s,n}function ei(t,e,i){for(const r of i)for(let i=0;i(s=t)[1]!=(a=o[e+1])[1]>s[1]&&s[0]<(a[0]-n[0])*(s[1]-n[1])/(a[1]-n[1])+n[0]&&(r=!r)}var s,n,a;return r}function ri(t,e){for(const i of e)if(ii(t,i))return!0;return!1}function si(t,e){for(const i of t)if(!ii(i,e))return!1;for(let i=0;i0&&o<0||a<0&&o>0}function oi(t,e,i){const r=[];for(let s=0;si[2]){const e=.5*r;let s=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===s&&(s=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=s}Je(e,t)}function hi(t,e,i,r){const s=Math.pow(2,r.z)*He,n=[r.x*He,r.y*He],a=[];for(const r of t)for(const t of r){const r=[t.x+n[0],t.y+n[1]];ci(r,e,i,s),a.push(r)}return a}function ui(t,e,i,r){const s=Math.pow(2,r.z)*He,n=[r.x*He,r.y*He],a=[];for(const i of t){const t=[];for(const r of i){const i=[r.x+n[0],r.y+n[1]];Je(e,i),t.push(i)}a.push(t)}if(e[2]-e[0]<=s/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const r of t)ci(r,e,i,s)}var o;return a}class di{constructor(t,e){this.type=ut,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(ie(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const i of e.features){const{type:e,coordinates:r}=i.geometry;"Polygon"===e&&t.push(r),"MultiPolygon"===e&&t.push(...r)}if(t.length)return new di(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new di(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new di(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=oi(e.coordinates,r,s),a=hi(t.geometry(),i,r,s);if(!Ye(i,r))return!1;for(const t of a)if(!ii(t,n))return!1}if("MultiPolygon"===e.type){const n=li(e.coordinates,r,s),a=hi(t.geometry(),i,r,s);if(!Ye(i,r))return!1;for(const t of a)if(!ri(t,n))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const n=oi(e.coordinates,r,s),a=ui(t.geometry(),i,r,s);if(!Ye(i,r))return!1;for(const t of a)if(!si(t,n))return!1}if("MultiPolygon"===e.type){const n=li(e.coordinates,r,s),a=ui(t.geometry(),i,r,s);if(!Ye(i,r))return!1;for(const t of a)if(!ni(t,n))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let pi=class{constructor(t=[],e=fi){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.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const s=t-1>>1,n=e[s];if(i(r,n)>=0)break;e[t]=n,t=s}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,s=e[t];for(;t=0)break;e[t]=n,t=r}e[t]=s}};function fi(t,e){return te?1:0}function mi(t,e,i,r,s){gi(t,e,i,r||t.length-1,s||yi)}function gi(t,e,i,r,s){for(;r>i;){if(r-i>600){var n=r-i+1,a=e-i+1,o=Math.log(n),l=.5*Math.exp(2*o/3),c=.5*Math.sqrt(o*l*(n-l)/n)*(a-n/2<0?-1:1);gi(t,e,Math.max(i,Math.floor(e-a*l/n+c)),Math.min(r,Math.floor(e+(n-a)*l/n+c)),s)}var h=t[e],u=i,d=r;for(_i(t,i,e),s(t[r],h)>0&&_i(t,i,r);u0;)d--}0===s(t[i],h)?_i(t,i,d):_i(t,++d,r),d<=e&&(i=d+1),e<=d&&(r=d-1)}}function _i(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function yi(t,e){return te?1:0}function xi(t,e){if(t.length<=1)return[t];const i=[];let r,s;for(const e of t){const t=bi(e);0!==t&&(e.area=Math.abs(t),void 0===s&&(s=t<0),s===t<0?(r&&i.push(r),r=[e]):r.push(e))}if(r&&i.push(r),e>1)for(let t=0;t1?(l=t[o+1][0],c=t[o+1][1]):d>0&&(l+=h/this.kx*d,c+=u/this.ky*d)),h=this.wrap(e[0]-l)*this.kx,u=(e[1]-c)*this.ky;const p=h*h+u*u;p180;)t-=360;return t}}function Ai(t,e){return e[0]-t[0]}function Ei(t){return t[1]-t[0]+1}function Pi(t,e){return t[1]>=t[0]&&t[1]t[1])return[null,null];const i=Ei(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];const r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function Mi(t,e){if(!Pi(e,t.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)Je(i,t[r]);return i}function ki(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const t of i)Je(e,t);return e}function zi(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Di(t,e,i){if(!zi(t)||!zi(e))return NaN;let r=0,s=0;return t[2]e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(s=t[1]-e[3]),t[3]=r)return r;if(Ye(s,n)){if(Ni(t,e))return 0}else if(Ni(e,t))return 0;let a=1/0;for(const r of t)for(let t=0,s=r.length,n=s-1;t0;){const s=a.pop();if(s[0]>=n)continue;const l=s[1],c=e?50:100;if(Ei(l)<=c){if(!Pi(l,t.length))return NaN;if(e){const e=Vi(t,l,i,r);if(isNaN(e)||0===e)return e;n=Math.min(n,e)}else for(let e=l[0];e<=l[1];++e){const s=Oi(t[e],i,r);if(n=Math.min(n,s),0===n)return 0}}else{const i=Ci(l,e);Ui(a,n,r,t,o,i[0]),Ui(a,n,r,t,o,i[1])}}return n}function Zi(t,e,i,r,s,n=1/0){let a=Math.min(n,s.distance(t[0],i[0]));if(0===a)return a;const o=new pi([[0,[0,t.length-1],[0,i.length-1]]],Ai);for(;o.length>0;){const n=o.pop();if(n[0]>=a)continue;const l=n[1],c=n[2],h=e?50:100,u=r?50:100;if(Ei(l)<=h&&Ei(c)<=u){if(!Pi(l,t.length)&&Pi(c,i.length))return NaN;let n;if(e&&r)n=Fi(t,l,i,c,s),a=Math.min(a,n);else if(e&&!r){const e=t.slice(l[0],l[1]+1);for(let t=c[0];t<=c[1];++t)if(n=Ri(i[t],e,s),a=Math.min(a,n),0===a)return a}else if(!e&&r){const e=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(n=Ri(t[i],e,s),a=Math.min(a,n),0===a)return a}else n=Bi(t,l,i,c,s),a=Math.min(a,n)}else{const n=Ci(l,e),h=Ci(c,r);$i(o,a,s,t,i,n[0],h[0]),$i(o,a,s,t,i,n[0],h[1]),$i(o,a,s,t,i,n[1],h[0]),$i(o,a,s,t,i,n[1],h[1])}}return a}function Gi(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class Wi{constructor(t,e){this.type=ct,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(ie(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new Wi(e,e.features.map((t=>Gi(t.geometry))).flat());if("Feature"===e.type)return new Wi(e,Gi(e.geometry));if("type"in e&&"coordinates"in e)return new Wi(e,Gi(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map((e=>Ke([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const s=new Si(r[0][1]);let n=1/0;for(const t of e){switch(t.type){case"Point":n=Math.min(n,Zi(r,!1,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,Zi(r,!1,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,qi(r,!1,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=t.geometry(),r=i.flat().map((e=>Ke([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const s=new Si(r[0][1]);let n=1/0;for(const t of e){switch(t.type){case"Point":n=Math.min(n,Zi(r,!0,[t.coordinates],!1,s,n));break;case"LineString":n=Math.min(n,Zi(r,!0,t.coordinates,!0,s,n));break;case"Polygon":n=Math.min(n,qi(r,!0,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const i=t.geometry();if(0===i.length||0===i[0].length)return NaN;const r=xi(i,0).map((e=>e.map((e=>e.map((e=>Ke([e.x,e.y],t.canonical))))))),s=new Si(r[0][0][0][1]);let n=1/0;for(const t of e)for(const e of r){switch(t.type){case"Point":n=Math.min(n,qi([t.coordinates],!1,e,s,n));break;case"LineString":n=Math.min(n,qi(t.coordinates,!0,e,s,n));break;case"Polygon":n=Math.min(n,ji(e,t.coordinates,s,n))}if(0===n)return n}return n}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}const Hi={"==":Be,"!=":Oe,">":Ne,"<":Ve,">=":Ue,"<=":je,array:le,at:ge,boolean:le,case:ve,coalesce:De,collator:$e,format:Ze,image:Ge,in:_e,"index-of":ye,interpolate:ke,"interpolate-hcl":ke,"interpolate-lab":ke,length:We,let:fe,literal:ne,match:xe,number:le,"number-format":qe,object:le,slice:be,step:Ie,string:le,"to-boolean":he,"to-color":he,"to-number":he,"to-string":he,var:me,within:di,distance:Wi};class Xi{constructor(t,e,i,r){this.name=t,this.type=e,this._evaluate=i,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],r=Xi.definitions[i];if(!r)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(r)?r[0]:r.type,n=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=n.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[r,n]of a){o=new pe(e.registry,tr,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(bt).join(", ")})`:`(${bt(e.type)}...)`;var e})).join(" | "),r=[];for(let i=1;i{i=e?i&&tr(t):i&&t instanceof ne})),!!i&&er(t)&&rr(t,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function er(t){if(t instanceof Xi){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 di)return!1;if(t instanceof Wi)return!1;let e=!0;return t.eachChild((t=>{e&&!er(t)&&(e=!1)})),e}function ir(t){if(t instanceof Xi&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!ir(t)&&(e=!1)})),e}function rr(t,e){if(t instanceof Xi&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!rr(t,e)&&(i=!1)})),i}function sr(t){return{result:"success",value:t}}function nr(t){return{result:"error",value:t}}function ar(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function or(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function lr(t){return!!t.expression&&t.expression.interpolated}function cr(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function hr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function ur(t){return t}function dr(t,e){const i="color"===e.type,r=t.stops&&"object"==typeof t.stops[0][0],s=r||!(r||void 0!==t.property),n=t.type||(lr(e)?"exponential":"interval");if(i||"padding"===e.type){const r=i?Wt.parse:Jt.parse;(t=nt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)}if(t.colorSpace&&"rgb"!==(a=t.colorSpace)&&"hcl"!==a&&"lab"!==a)throw new Error(`Unknown color space: "${t.colorSpace}"`);var a;let o,l,c;if("exponential"===n)o=gr;else if("interval"===n)o=mr;else if("categorical"===n){o=fr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];c=typeof t.stops[0][0]}else{if("identity"!==n)throw new Error(`Unknown function type "${n}"`);o=_r}if(r){const i={},r=[];for(let e=0;et[0])),evaluate:({zoom:i},r)=>gr({stops:s,base:t.base},e,i).evaluate(i,r)}}if(s){const i="exponential"===n?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:ke.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>o(t,e,i,l,c)}}return{kind:"source",evaluate(i,r){const s=r&&r.properties?r.properties[t.property]:void 0;return void 0===s?pr(t.default,e.default):o(t,e,s,l,c)}}}function pr(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function fr(t,e,i,r,s){return pr(typeof i===s?r[i]:void 0,t.default,e.default)}function mr(t,e,i){if("number"!==cr(i))return pr(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const s=we(t.stops.map((t=>t[0])),i);return t.stops[s][1]}function gr(t,e,i){const r=void 0!==t.base?t.base:1;if("number"!==cr(i))return pr(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const n=we(t.stops.map((t=>t[0])),i),a=function(t,e,i,r){const s=r-i,n=t-i;return 0===s?0:1===e?n/s:(Math.pow(e,n)-1)/(Math.pow(e,s)-1)}(i,r,t.stops[n][0],t.stops[n+1][0]),o=t.stops[n][1],l=t.stops[n+1][1],c=Me[e.type]||ur;return"function"==typeof o.evaluate?{evaluate(...e){const i=o.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return c(i,r,a,t.colorSpace)}}:c(o,l,a,t.colorSpace)}function _r(t,e,i){switch(e.type){case"color":i=Wt.parse(i);break;case"formatted":i=Kt.fromString(i.toString());break;case"resolvedImage":i=te.fromString(i.toString());break;case"padding":i=Jt.parse(i);break;default:cr(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return pr(i,t.default,e.default)}Xi.register(Hi,{error:[{kind:"error"},[ht],(t,[e])=>{throw new ae(e.evaluate(t))}],typeof:[ht,[ft],(t,[e])=>bt(re(e.evaluate(t)))],"to-rgba":[vt(ct,4),[dt],(t,[e])=>{const[i,r,s,n]=e.evaluate(t).rgb;return[255*i,255*r,255*s,n]}],rgb:[dt,[ct,ct,ct],Ki],rgba:[dt,[ct,ct,ct,ct],Ki],has:{type:ut,overloads:[[[ht],(t,[e])=>Ji(e.evaluate(t),t.properties())],[[ht,pt],(t,[e,i])=>Ji(e.evaluate(t),i.evaluate(t))]]},get:{type:ft,overloads:[[[ht],(t,[e])=>Yi(e.evaluate(t),t.properties())],[[ht,pt],(t,[e,i])=>Yi(e.evaluate(t),i.evaluate(t))]]},"feature-state":[ft,[ht],(t,[e])=>Yi(e.evaluate(t),t.featureState||{})],properties:[pt,[],t=>t.properties()],"geometry-type":[ht,[],t=>t.geometryType()],id:[ft,[],t=>t.id()],zoom:[ct,[],t=>t.globals.zoom],"heatmap-density":[ct,[],t=>t.globals.heatmapDensity||0],"line-progress":[ct,[],t=>t.globals.lineProgress||0],accumulated:[ft,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ct,Qi(ct),(t,e)=>{let i=0;for(const r of e)i+=r.evaluate(t);return i}],"*":[ct,Qi(ct),(t,e)=>{let i=1;for(const r of e)i*=r.evaluate(t);return i}],"-":{type:ct,overloads:[[[ct,ct],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ct],(t,[e])=>-e.evaluate(t)]]},"/":[ct,[ct,ct],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ct,[ct,ct],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ct,[],()=>Math.LN2],pi:[ct,[],()=>Math.PI],e:[ct,[],()=>Math.E],"^":[ct,[ct,ct],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ct,[ct],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ct,[ct],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ct,[ct],(t,[e])=>Math.log(e.evaluate(t))],log2:[ct,[ct],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ct,[ct],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ct,[ct],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ct,[ct],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ct,[ct],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ct,[ct],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ct,[ct],(t,[e])=>Math.atan(e.evaluate(t))],min:[ct,Qi(ct),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ct,Qi(ct),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ct,[ct],(t,[e])=>Math.abs(e.evaluate(t))],round:[ct,[ct],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[ct,[ct],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ct,[ct],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[ut,[ht,ft],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[ut,[ft],(t,[e])=>t.id()===e.value],"filter-type-==":[ut,[ht],(t,[e])=>t.geometryType()===e.value],"filter-<":[ut,[ht,ft],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r{const i=t.id(),r=e.value;return typeof i==typeof r&&i":[ut,[ht,ft],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>s}],"filter-id->":[ut,[ft],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[ut,[ht,ft],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r<=s}],"filter-id-<=":[ut,[ft],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[ut,[ht,ft],(t,[e,i])=>{const r=t.properties()[e.value],s=i.value;return typeof r==typeof s&&r>=s}],"filter-id->=":[ut,[ft],(t,[e])=>{const i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[ut,[ft],(t,[e])=>e.value in t.properties()],"filter-has-id":[ut,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[ut,[vt(ht)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[ut,[vt(ft)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[ut,[ht,vt(ft)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[ut,[ht,vt(ft)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){const s=i+r>>1;if(e[s]===t)return!0;e[s]>t?r=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:ut,overloads:[[[ut,ut],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Qi(ut),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:ut,overloads:[[[ut,ut],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Qi(ut),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[ut,[ut],(t,[e])=>!e.evaluate(t)],"is-supported-script":[ut,[ht],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ht,[ht],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ht,[ht],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ht,Qi(ft),(t,e)=>e.map((e=>se(e.evaluate(t)))).join("")],"resolved-locale":[ht,[mt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class yr{constructor(t,e){var i;this.expression=t,this._warningHistory={},this._evaluator=new de,this._defaultValue=e?"color"===(i=e).type&&hr(i.default)?new Wt(0,0,0,0):"color"===i.type?Wt.parse(i.default)||null:"padding"===i.type?Jt.parse(i.default)||null:"variableAnchorOffsetCollection"===i.type?Qt.parse(i.default)||null:void 0===i.default?null:i.default:null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,s,n){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=n||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new ae(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.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 xr(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Hi}function vr(t,e){const i=new pe(Hi,tr,[],e?function(t){const e={color:dt,string:ht,number:ct,enum:ht,boolean:ut,formatted:gt,padding:_t,resolvedImage:yt,variableAnchorOffsetCollection:xt};return"array"===t.type?vt(e[t.value]||ft,t.length):e[t.type]}(e):void 0),r=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?sr(new yr(r,e)):nr(i.errors)}class br{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!ir(e.expression)}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}}class wr{constructor(t,e,i,r){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!ir(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,i,r,s,n){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,s,n)}evaluate(t,e,i,r,s,n){return this._styleExpression.evaluate(t,e,i,r,s,n)}interpolationFactor(t,e,i){return this.interpolationType?ke.interpolationFactor(this.interpolationType,t,e,i):0}}function Ir(t,e){const i=vr(t,e);if("error"===i.result)return i;const r=i.value.expression,s=er(r);if(!s&&!ar(e))return nr([new at("","data expressions not supported")]);const n=rr(r,["zoom"]);if(!n&&!or(e))return nr([new at("","zoom expressions not supported")]);const a=Sr(r);return a||n?a instanceof at?nr([a]):a instanceof ke&&!lr(e)?nr([new at("",'"interpolate" expressions cannot be used with this property')]):sr(a?new wr(s?"camera":"composite",i.value,a.labels,a instanceof ke?a.interpolation:void 0):new br(s?"constant":"source",i.value)):nr([new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Tr{constructor(t,e){this._parameters=t,this._specification=e,nt(this,dr(this._parameters,this._specification))}static deserialize(t){return new Tr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function Sr(t){let e=null;if(t instanceof fe)e=Sr(t.result);else if(t instanceof De){for(const i of t.args)if(e=Sr(i),e)break}else(t instanceof Ie||t instanceof ke)&&t.input instanceof Xi&&"zoom"===t.input.name&&(e=t);return e instanceof at||t.eachChild((t=>{const i=Sr(t);i instanceof at?e=i:!e&&i?e=new at("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new at("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Ar(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(!Ar(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const Er={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Pr(t){if(null==t)return{filter:()=>!0,needGeometry:!1};Ar(t)||(t=kr(t));const e=vr(t,Er);if("error"===e.result)throw new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,i,r)=>e.value.evaluate(t,i,{},r),needGeometry:Mr(t)}}function Cr(t,e){return te?1:0}function Mr(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?zr(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(kr))):"all"===e?["all"].concat(t.slice(1).map(kr)):"none"===e?["all"].concat(t.slice(1).map(kr).map(Lr)):"in"===e?Dr(t[1],t.slice(2)):"!in"===e?Lr(Dr(t[1],t.slice(2))):"has"===e?Rr(t[1]):"!has"!==e||Lr(Rr(t[1]));var i}function zr(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function Dr(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(Cr)]]:["filter-in-small",t,["literal",e]]}}function Rr(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Lr(t){return["!",t]}function Fr(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${Fr(i)},`;return`${e}]`}const i=Object.keys(t).sort();let r="{";for(let e=0;er.maximum?[new st(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function qr(t){const e=t.valueSpec,i=Vr(t.value.type);let r,s,n,a={};const o="categorical"!==i&&void 0===t.value.property,l=!o,c="array"===cr(t.value.stops)&&"array"===cr(t.value.stops[0])&&"object"===cr(t.value.stops[0][0]),h=jr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new st(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const r=t.value;return e=e.concat(Ur({key:t.key,value:r,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===cr(r)&&0===r.length&&e.push(new st(t.key,r,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&o&&h.push(new st(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||h.push(new st(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!lr(t.valueSpec)&&h.push(new st(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!ar(t.valueSpec)?h.push(new st(t.key,t.value,"property functions not supported")):o&&!or(t.valueSpec)&&h.push(new st(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||h.push(new st(t.key,t.value,'"property" property is required')),h;function u(t){let i=[];const r=t.value,o=t.key;if("array"!==cr(r))return[new st(o,r,`array expected, ${cr(r)} found`)];if(2!==r.length)return[new st(o,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==cr(r[0]))return[new st(o,r,`object expected, ${cr(r[0])} found`)];if(void 0===r[0].zoom)return[new st(o,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new st(o,r,"object stop key must have value")];if(n&&n>Vr(r[0].zoom))return[new st(o,r[0].zoom,"stop zoom values must appear in ascending order")];Vr(r[0].zoom)!==n&&(n=Vr(r[0].zoom),s=void 0,a={}),i=i.concat(jr({key:`${o}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:$r,value:d}}))}else i=i.concat(d({key:`${o}[0]`,value:r[0],valueSpec:{},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec},r));return xr(Nr(r[1]))?i.concat([new st(`${o}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${o}[1]`,value:r[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function d(t,n){const o=cr(t.value),l=Vr(t.value),c=null!==t.value?t.value:n;if(r){if(o!==r)return[new st(t.key,c,`${o} stop domain type must match previous stop domain type ${r}`)]}else r=o;if("number"!==o&&"string"!==o&&"boolean"!==o)return[new st(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==o&&"categorical"!==i){let r=`number expected, ${o} found`;return ar(e)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new st(t.key,c,r)]}return"categorical"!==i||"number"!==o||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===o&&void 0!==s&&lnew st(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new st(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&&!ir(i))return[new st(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!ir(i))return[new st(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!rr(i,["zoom","feature-state"]))return[new st(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!er(i))return[new st(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Gr(t){const e=t.key,i=t.value,r=t.valueSpec,s=[];return Array.isArray(r.values)?-1===r.values.indexOf(Vr(i))&&s.push(new st(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Vr(i))&&s.push(new st(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function Wr(t){return Ar(Nr(t.value))?Zr(nt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Hr(t)}function Hr(t){const e=t.value,i=t.key;if("array"!==cr(e))return[new st(i,e,`array expected, ${cr(e)} found`)];const r=t.styleSpec;let s,n=[];if(e.length<1)return[new st(i,e,"filter array must have at least 1 element")];switch(n=n.concat(Gr({key:`${i}[0]`,value:e[0],valueSpec:r.filter_operator,style:t.style,styleSpec:t.styleSpec})),Vr(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Vr(e[1])&&n.push(new st(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&n.push(new st(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=cr(e[1]),"string"!==s&&n.push(new st(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let a=2;a{t in i&&e.push(new st(r,i[t],`"${t}" is prohibited for ref layers`))})),s.layers.forEach((e=>{Vr(e.id)===o&&(t=e)})),t?t.ref?e.push(new st(r,i.ref,"ref cannot reference another ref layer")):a=Vr(t.type):e.push(new st(r,i.ref,`ref layer "${o}" not found`))}else if("background"!==a)if(i.source){const t=s.sources&&s.sources[i.source],n=t&&Vr(t.type);t?"vector"===n&&"raster"===a?e.push(new st(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==n&&"hillshade"===a?e.push(new st(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===n&&"raster"!==a?e.push(new st(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==n||i["source-layer"]?"raster-dem"===n&&"hillshade"!==a?e.push(new st(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!i.paint||!i.paint["line-gradient"]||"geojson"===n&&t.lineMetrics||e.push(new st(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new st(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new st(r,i.source,`source "${i.source}" not found`))}else e.push(new st(r,i,'missing required property "source"'));return e=e.concat(jr({key:r,value:i,valueSpec:n.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:n.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:Wr,layout:t=>jr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Jr(nt({layerType:a},t))}}),paint:t=>jr({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Kr(nt({layerType:a},t))}})}})),e}function Qr(t){const e=t.value,i=t.key,r=cr(e);return"string"!==r?[new st(i,e,`string expected, ${r} found`)]:[]}const ts={promoteId:function({key:t,value:e}){if("string"===cr(e))return Qr({key:t,value:e});{const i=[];for(const r in e)i.push(...Qr({key:`${t}.${r}`,value:e[r]}));return i}}};function es(t){const e=t.value,i=t.key,r=t.styleSpec,s=t.style,n=t.validateSpec;if(!e.type)return[new st(i,e,'"type" is required')];const a=Vr(e.type);let o;switch(a){case"vector":case"raster":return o=jr({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ts,validateSpec:n}),o;case"raster-dem":return o=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",r=t.value,s=t.styleSpec,n=s.source_raster_dem,a=t.style;let o=[];const l=cr(r);if(void 0===r)return o;if("object"!==l)return o.push(new st("source_raster_dem",r,`object expected, ${l} found`)),o;const c="custom"===Vr(r.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in r)!c&&h.includes(e)?o.push(new st(e,r[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):n[e]?o=o.concat(t.validateSpec({key:e,value:r[e],valueSpec:n[e],validateSpec:t.validateSpec,style:a,styleSpec:s})):o.push(new st(e,r[e],`unknown property "${e}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:n}),o;case"geojson":if(o=jr({key:i,value:e,valueSpec:r.source_geojson,style:s,styleSpec:r,validateSpec:n,objectElementValidators:ts}),e.cluster)for(const t in e.clusterProperties){const[r,s]=e.clusterProperties[t],a="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...Zr({key:`${i}.${t}.map`,value:s,validateSpec:n,expressionContext:"cluster-map"})),o.push(...Zr({key:`${i}.${t}.reduce`,value:a,validateSpec:n,expressionContext:"cluster-reduce"}))}return o;case"video":return jr({key:i,value:e,valueSpec:r.source_video,style:s,validateSpec:n,styleSpec:r});case"image":return jr({key:i,value:e,valueSpec:r.source_image,style:s,validateSpec:n,styleSpec:r});case"canvas":return[new st(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Gr({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:s,validateSpec:n,styleSpec:r})}}function is(t){const e=t.value,i=t.styleSpec,r=i.light,s=t.style;let n=[];const a=cr(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new st("light",e,`object expected, ${a} found`)]),n;for(const a in e){const o=a.match(/^(.*)-transition$/);n=n.concat(o&&r[o[1]]&&r[o[1]].transition?t.validateSpec({key:a,value:e[a],valueSpec:i.transition,validateSpec:t.validateSpec,style:s,styleSpec:i}):r[a]?t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new st(a,e[a],`unknown property "${a}"`)])}return n}function rs(t){const e=t.value,i=t.styleSpec,r=i.sky,s=t.style,n=cr(e);if(void 0===e)return[];if("object"!==n)return[new st("sky",e,`object expected, ${n} found`)];let a=[];for(const n in e)a=a.concat(r[n]?t.validateSpec({key:n,value:e[n],valueSpec:r[n],style:s,styleSpec:i}):[new st(n,e[n],`unknown property "${n}"`)]);return a}function ss(t){const e=t.value,i=t.styleSpec,r=i.terrain,s=t.style;let n=[];const a=cr(e);if(void 0===e)return n;if("object"!==a)return n=n.concat([new st("terrain",e,`object expected, ${a} found`)]),n;for(const a in e)n=n.concat(r[a]?t.validateSpec({key:a,value:e[a],valueSpec:r[a],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new st(a,e[a],`unknown property "${a}"`)]);return n}function ns(t){let e=[];const i=t.value,r=t.key;if(Array.isArray(i)){const s=[],n=[];for(const a in i)i[a].id&&s.includes(i[a].id)&&e.push(new st(r,i,`all the sprites' ids must be unique, but ${i[a].id} is duplicated`)),s.push(i[a].id),i[a].url&&n.includes(i[a].url)&&e.push(new st(r,i,`all the sprites' URLs must be unique, but ${i[a].url} is duplicated`)),n.push(i[a].url),e=e.concat(jr({key:`${r}[${a}]`,value:i[a],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Qr({key:r,value:i})}const as={"*":()=>[],array:Ur,boolean:function(t){const e=t.value,i=t.key,r=cr(e);return"boolean"!==r?[new st(i,e,`boolean expected, ${r} found`)]:[]},number:$r,color:function(t){const e=t.key,i=t.value,r=cr(i);return"string"!==r?[new st(e,i,`color expected, ${r} found`)]:Wt.parse(String(i))?[]:[new st(e,i,`color expected, "${i}" found`)]},constants:Or,enum:Gr,filter:Wr,function:qr,layer:Yr,object:jr,source:es,light:is,sky:rs,terrain:ss,string:Qr,formatted:function(t){return 0===Qr(t).length?[]:Zr(t)},resolvedImage:function(t){return 0===Qr(t).length?[]:Zr(t)},padding:function(t){const e=t.key,i=t.value;if("array"===cr(i)){if(i.length<1||i.length>4)return[new st(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let s=[];for(let n=0;n[]}})),t.constants&&(i=i.concat(Or({key:"constants",value:t.constants,style:t,styleSpec:e,validateSpec:os}))),us(i)}function hs(t){return function(e){return t({...e,validateSpec:os})}}function us(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function ds(t){return function(...e){return us(t.apply(this,e))}}cs.source=ds(hs(es)),cs.sprite=ds(hs(ns)),cs.glyphs=ds(hs(ls)),cs.light=ds(hs(is)),cs.sky=ds(hs(rs)),cs.terrain=ds(hs(ss)),cs.layer=ds(hs(Yr)),cs.filter=ds(hs(Wr)),cs.paintProperty=ds(hs(Kr)),cs.layoutProperty=ds(hs(Jr));const ps=cs,fs=ps.light,ms=ps.paintProperty,gs=ps.layoutProperty;function _s(t,e){let i=!1;if(e&&e.length)for(const r of e)t.fire(new q(new Error(r.message))),i=!0;return i}class ys{constructor(t,e,i){const r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t=c[l+0]&&r>=c[l+1])?(a[u]=!0,n.push(s[u])):a[u]=!1}}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.d*l+d;if((!o||o(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&s.call(this,t,e,i,r,c,n,a,o))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(let t=0;t=0)continue;const n=t[i];s[i]=xs[r].shallow.indexOf(i)>=0?n:ws(n,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(s.$name=r),s}throw new Error("can't serialize object of type "+typeof t)}function Is(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||t instanceof Blob||t instanceof Error||bs(t)||E(t)||ArrayBuffer.isView(t)||t instanceof ImageData)return t;if(Array.isArray(t))return t.map(Is);if("object"==typeof t){const e=t.$name||"Object";if(!xs[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=xs[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const r=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const s=t[i];r[i]=xs[e].shallow.indexOf(i)>=0?s:Is(s)}return r}throw new Error("can't deserialize object of type "+typeof t)}class Ts{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoomt>=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};function As(t){for(const e of t)if(Cs(e.charCodeAt(0)))return!0;return!1}function Es(t){for(const e of t)if(!Ps(e.charCodeAt(0)))return!1;return!0}function Ps(t){return!(Ss.Arabic(t)||Ss["Arabic Supplement"](t)||Ss["Arabic Extended-A"](t)||Ss["Arabic Presentation Forms-A"](t)||Ss["Arabic Presentation Forms-B"](t))}function Cs(t){return!(746!==t&&747!==t&&(t<4352||!(Ss["Bopomofo Extended"](t)||Ss.Bopomofo(t)||Ss["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Ss["CJK Compatibility Ideographs"](t)||Ss["CJK Compatibility"](t)||Ss["CJK Radicals Supplement"](t)||Ss["CJK Strokes"](t)||!(!Ss["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Ss["CJK Unified Ideographs Extension A"](t)||Ss["CJK Unified Ideographs"](t)||Ss["Enclosed CJK Letters and Months"](t)||Ss["Hangul Compatibility Jamo"](t)||Ss["Hangul Jamo Extended-A"](t)||Ss["Hangul Jamo Extended-B"](t)||Ss["Hangul Jamo"](t)||Ss["Hangul Syllables"](t)||Ss.Hiragana(t)||Ss["Ideographic Description Characters"](t)||Ss.Kanbun(t)||Ss["Kangxi Radicals"](t)||Ss["Katakana Phonetic Extensions"](t)||Ss.Katakana(t)&&12540!==t||!(!Ss["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)||!(!Ss["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Ss["Unified Canadian Aboriginal Syllabics"](t)||Ss["Unified Canadian Aboriginal Syllabics Extended"](t)||Ss["Vertical Forms"](t)||Ss["Yijing Hexagram Symbols"](t)||Ss["Yi Syllables"](t)||Ss["Yi Radicals"](t))))}function Ms(t){return!(Cs(t)||function(t){return!!(Ss["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||Ss["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)||Ss["Letterlike Symbols"](t)||Ss["Number Forms"](t)||Ss["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)||Ss["Control Pictures"](t)&&9251!==t||Ss["Optical Character Recognition"](t)||Ss["Enclosed Alphanumerics"](t)||Ss["Geometric Shapes"](t)||Ss["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||Ss["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||Ss["CJK Symbols and Punctuation"](t)||Ss.Katakana(t)||Ss["Private Use Area"](t)||Ss["CJK Compatibility Forms"](t)||Ss["Small Form Variants"](t)||Ss["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 ks(t){return t>=1424&&t<=2303||Ss["Arabic Presentation Forms-A"](t)||Ss["Arabic Presentation Forms-B"](t)}function zs(t,e){return!(!e&&ks(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Ss.Khmer(t))}function Ds(t){for(const e of t)if(ks(e.charCodeAt(0)))return!0;return!1}const Rs=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class Ls{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.zoomHistory=e.zoomHistory,this.transition=e.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Ts,this.transition={})}isSupportedScript(t){return function(t,e){for(const i of t)if(!zs(i.charCodeAt(0),e))return!1;return!0}(t,"loaded"===Rs.getRTLTextPluginStatus())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}class Fs{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(hr(t))return new Tr(t,e);if(xr(t)){const i=Ir(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=Wt.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)&&(i=Qt.parse(t)):i=Jt.parse(t),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Bs{constructor(t){this.property=t,this.value=new Fs(t,void 0)}transitioned(t,e){return new Vs(this.property,this.value,e,_({},t.transition,this.transition),t.now)}untransitioned(){return new Vs(this.property,this.value,null,{},0)}}class Os{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return b(this._values[t].value.value)}setValue(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Bs(this._values[t].property)),this._values[t].value=new Fs(this._values[t].property,null===e?void 0:b(e))}getTransition(t){return b(this._values[t].transition)}setTransition(t,e){Object.prototype.hasOwnProperty.call(this._values,t)||(this._values[t]=new Bs(this._values[t].property)),this._values[t].transition=b(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){const i=new Ns(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){const t=new Ns(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Vs{constructor(t,e,i,r,s){this.property=t,this.value=e,this.begin=s+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const r=t.now||0,s=this.value.possiblyEvaluate(t,e,i),n=this.prior;if(n){if(r>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(r=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(a))}}return s}}class Ns{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const r=new $s(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class js{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}hasValue(t){return void 0!==this._values[t].value}getValue(t){return b(this._values[t].value)}setValue(t,e){this._values[t]=new Fs(this._values[t].property,null===e?void 0:b(e))}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const r=new $s(this._properties);for(const s of Object.keys(this._values))r._values[s]=this._values[s].possiblyEvaluate(t,e,i);return r}}class Us{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}}class $s{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class qs{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const r=Me[this.specification.type];return r?r(t,e,i):t}}class Zs{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,r){return new Us(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Us(this,{kind:"constant",value:void 0},t.parameters);const r=Me[this.specification.type];if(r){const s=r(t.value.value,e.value.value,i);return new Us(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,e,i,r,s,n){return"constant"===t.kind?t.value:t.evaluate(e,i,r,s,n)}}class Gs extends Zs{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new Us(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r),n="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,a=this._calculate(n,n,n,e);return new Us(this,{kind:"constant",value:a},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Us(this,{kind:"constant",value:i},e)}return new Us(this,t.expression,e)}evaluate(t,e,i,r,s,n){if("source"===t.kind){const a=t.evaluate(e,i,r,s,n);return this._calculate(a,a,a,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Ws{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,r);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new Ls(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Ls(Math.floor(e.zoom),e)),t.expression.evaluate(new Ls(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Hs{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}}class Xs{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const r=this.defaultPropertyValues[e]=new Fs(i,void 0),s=this.defaultTransitionablePropertyValues[e]=new Bs(i);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}}vs("DataDrivenProperty",Zs),vs("DataConstantProperty",qs),vs("CrossFadedDataDrivenProperty",Gs),vs("CrossFadedProperty",Ws),vs("ColorRampProperty",Hs);const Ks="-transition";class Js extends Z{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1},"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new js(e.layout)),e.paint)){this._transitionablePaint=new Os(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new $s(e.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(gs,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return t.endsWith(Ks)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(ms,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(Ks))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),n=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const a=this._transitionablePaint._values[t].value;return a.isDataDriven()||s||r||this._handleOverridablePaintPropertyUpdate(t,n,a)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){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){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),v(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,s={}){return(!s||!1!==s.validate)&&_s(this,t.call(ps,{key:e,layerType:this.type,objectKey:i,value:r,styleSpec:G,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Us&&ar(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}const Ys={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Qs{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 tn{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(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("_refreshViews() must be implemented by each concrete StructArray layout")}}function en(t,e=1){let i=0,r=0;return{members:t.map((t=>{const s=Ys[t.type].BYTES_PER_ELEMENT,n=i=rn(i,Math.max(e,s)),a=t.components||1;return r=Math.max(r,s),i+=s*a,{name:t.name,type:t.type,components:a,offset:n}})),size:rn(i,Math.max(r,e)),alignment:e}}function rn(t,e){return Math.ceil(t/e)*e}class sn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}}sn.prototype.bytesPerElement=4,vs("StructArrayLayout2i4",sn);class nn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,t}}nn.prototype.bytesPerElement=6,vs("StructArrayLayout3i6",nn);class an extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,this.int16[n+3]=s,t}}an.prototype.bytesPerElement=8,vs("StructArrayLayout4i8",an);class on extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}on.prototype.bytesPerElement=12,vs("StructArrayLayout2i4i12",on);class ln extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=4*t,l=8*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=s,this.uint8[l+6]=n,this.uint8[l+7]=a,t}}ln.prototype.bytesPerElement=8,vs("StructArrayLayout2i4ub8",ln);class cn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}}cn.prototype.bytesPerElement=8,vs("StructArrayLayout2f8",cn);class hn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,s,n,a,o,l,c)}emplace(t,e,i,r,s,n,a,o,l,c,h){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=s,this.uint16[u+4]=n,this.uint16[u+5]=a,this.uint16[u+6]=o,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,t}}hn.prototype.bytesPerElement=20,vs("StructArrayLayout10ui20",hn);class un extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,r,s,n,a,o,l,c,h,u)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,d){const p=12*t;return this.int16[p+0]=e,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=s,this.uint16[p+4]=n,this.uint16[p+5]=a,this.uint16[p+6]=o,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=h,this.int16[p+10]=u,this.int16[p+11]=d,t}}un.prototype.bytesPerElement=24,vs("StructArrayLayout4i4ui4i24",un);class dn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}dn.prototype.bytesPerElement=12,vs("StructArrayLayout3f12",dn);class pn extends tn{_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}}pn.prototype.bytesPerElement=4,vs("StructArrayLayout1ul4",pn);class fn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,r,s,n,a,o,l)}emplace(t,e,i,r,s,n,a,o,l,c){const h=10*t,u=5*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.int16[h+2]=r,this.int16[h+3]=s,this.int16[h+4]=n,this.int16[h+5]=a,this.uint32[u+3]=o,this.uint16[h+8]=l,this.uint16[h+9]=c,t}}fn.prototype.bytesPerElement=20,vs("StructArrayLayout6i1ul2ui20",fn);class mn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=6*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=s,this.int16[o+4]=n,this.int16[o+5]=a,t}}mn.prototype.bytesPerElement=12,vs("StructArrayLayout2i2i2i12",mn);class gn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r,s)}emplace(t,e,i,r,s,n){const a=4*t,o=8*t;return this.float32[a+0]=e,this.float32[a+1]=i,this.float32[a+2]=r,this.int16[o+6]=s,this.int16[o+7]=n,t}}gn.prototype.bytesPerElement=16,vs("StructArrayLayout2f1f2i16",gn);class _n extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,r,s,n)}emplace(t,e,i,r,s,n,a){const o=16*t,l=4*t,c=8*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[l+1]=r,this.float32[l+2]=s,this.int16[c+6]=n,this.int16[c+7]=a,t}}_n.prototype.bytesPerElement=16,vs("StructArrayLayout2ub2f2i16",_n);class yn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=r,t}}yn.prototype.bytesPerElement=6,vs("StructArrayLayout3ui6",yn);class xn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_){const y=24*t,x=12*t,v=48*t;return this.int16[y+0]=e,this.int16[y+1]=i,this.uint16[y+2]=r,this.uint16[y+3]=s,this.uint32[x+2]=n,this.uint32[x+3]=a,this.uint32[x+4]=o,this.uint16[y+10]=l,this.uint16[y+11]=c,this.uint16[y+12]=h,this.float32[x+7]=u,this.float32[x+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[x+10]=g,this.int16[y+22]=_,t}}xn.prototype.bytesPerElement=48,vs("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",xn);class vn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,I,T,S,A,E){const P=this.length;return this.resize(P+1),this.emplace(P,t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,I,T,S,A,E)}emplace(t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,I,T,S,A,E,P){const C=32*t,M=16*t;return this.int16[C+0]=e,this.int16[C+1]=i,this.int16[C+2]=r,this.int16[C+3]=s,this.int16[C+4]=n,this.int16[C+5]=a,this.int16[C+6]=o,this.int16[C+7]=l,this.uint16[C+8]=c,this.uint16[C+9]=h,this.uint16[C+10]=u,this.uint16[C+11]=d,this.uint16[C+12]=p,this.uint16[C+13]=f,this.uint16[C+14]=m,this.uint16[C+15]=g,this.uint16[C+16]=_,this.uint16[C+17]=y,this.uint16[C+18]=x,this.uint16[C+19]=v,this.uint16[C+20]=b,this.uint16[C+21]=w,this.uint16[C+22]=I,this.uint32[M+12]=T,this.float32[M+13]=S,this.float32[M+14]=A,this.uint16[C+30]=E,this.uint16[C+31]=P,t}}vn.prototype.bytesPerElement=64,vs("StructArrayLayout8i15ui1ul2f2ui64",vn);class bn extends tn{_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}}bn.prototype.bytesPerElement=4,vs("StructArrayLayout1f4",bn);class wn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=3*t;return this.uint16[6*t+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,t}}wn.prototype.bytesPerElement=12,vs("StructArrayLayout1ui2f12",wn);class In extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){const s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=r,t}}In.prototype.bytesPerElement=8,vs("StructArrayLayout1ul2ui8",In);class Tn extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}}Tn.prototype.bytesPerElement=4,vs("StructArrayLayout2ui4",Tn);class Sn extends tn{_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}}Sn.prototype.bytesPerElement=2,vs("StructArrayLayout1ui2",Sn);class An extends tn{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r)}emplace(t,e,i,r,s){const n=4*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,this.float32[n+3]=s,t}}An.prototype.bytesPerElement=16,vs("StructArrayLayout4f16",An);class En extends Qs{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new n(this.anchorPointX,this.anchorPointY)}}En.prototype.size=20;class Pn extends fn{get(t){return new En(this,t)}}vs("CollisionBoxArray",Pn);class Cn extends Qs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Cn.prototype.size=48;class Mn extends xn{get(t){return new Cn(this,t)}}vs("PlacedSymbolArray",Mn);class kn extends Qs{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}kn.prototype.size=64;class zn extends vn{get(t){return new kn(this,t)}}vs("SymbolInstanceArray",zn);class Dn extends bn{getoffsetX(t){return this.float32[1*t+0]}}vs("GlyphOffsetArray",Dn);class Rn extends nn{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}vs("SymbolLineVertexArray",Rn);class Ln extends Qs{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Ln.prototype.size=12;class Fn extends wn{get(t){return new Ln(this,t)}}vs("TextAnchorOffsetArray",Fn);class Bn extends Qs{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]}}Bn.prototype.size=8;class On extends In{get(t){return new Bn(this,t)}}vs("FeatureIndexArray",On);class Vn extends sn{}class Nn extends sn{}class jn extends sn{}class Un extends on{}class $n extends ln{}class qn extends cn{}class Zn extends hn{}class Gn extends un{}class Wn extends dn{}class Hn extends pn{}class Xn extends mn{}class Kn extends _n{}class Jn extends yn{}class Yn extends Tn{}const Qn=en([{name:"a_pos",components:2,type:"Int16"}],4),{members:ta}=Qn;class ea{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,r){let s=this.segments[this.segments.length-1];return t>ea.MAX_VERTEX_ARRAY_LENGTH&&I(`Max vertices per segment is ${ea.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!s||s.vertexLength+t>ea.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==r)&&(s={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(s.sortKey=r),this.segments.push(s)),s}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,i,r){return new ea([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function ia(t,e){return 256*(t=m(Math.floor(t),0,255))+m(Math.floor(e),0,255)}ea.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,vs("SegmentVector",ea);const ra=en([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var sa={exports:{}},na={exports:{}};na.exports=function(t,e){var i,r,s,n,a,o,l,c;for(r=t.length-(i=3&t.length),s=e,a=3432918353,o=461845907,c=0;c>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(n>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:s^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*o+(((l>>>16)*o&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0};var aa=na.exports,oa={exports:{}};oa.exports=function(t,e){for(var i,r=t.length,s=e^r,n=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(n)|(255&t.charCodeAt(++n))<<8|(255&t.charCodeAt(++n))<<16|(255&t.charCodeAt(++n))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++n;switch(r){case 3:s^=(255&t.charCodeAt(n+2))<<16;case 2:s^=(255&t.charCodeAt(n+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(n)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0};var la=aa,ca=oa.exports;sa.exports=la,sa.exports.murmur3=la,sa.exports.murmur2=ca;var ha=i(sa.exports);class ua{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(da(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=da(t);let i=0,r=this.ids.length-1;for(;i>1;this.ids[t]>=e?r=t:i=t+1}const s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){const i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return pa(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(t){const e=new ua;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function da(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ha(String(t))}function pa(t,e,i,r){for(;i>1];let n=i-1,a=r+1;for(;;){do{n++}while(t[n]s);if(n>=a)break;fa(t,n,a),fa(e,3*n,3*a),fa(e,3*n+1,3*a+1),fa(e,3*n+2,3*a+2)}a-i`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new ya(t,e):new ga(t,e)}}class wa{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setUniform(t,e,i,r){const s="u_pattern_to"===r?this.patternTo:"u_pattern_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;s&&t.set(s)}getBinding(t,e,i){return"u_pattern"===i.substr(0,9)?new _a(t,e):new ga(t,e)}}class Ia{constructor(t,e,i,r){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i,r,s){const n=this.paintVertexArray.length,a=this.expression.evaluate(new Ls(0),e,{},r,[],s);this.paintVertexArray.resize(t),this._setPaintValue(n,t,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:0},i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){const r=va(i);for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,r,s){const n=this.expression.evaluate(new Ls(this.zoom),e,{},r,[],s),a=this.expression.evaluate(new Ls(this.zoom+1),e,{},r,[],s),o=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(o,t,n,a)}updatePaintArray(t,e,i,r){const s=this.expression.evaluate({zoom:this.zoom},i,r),n=this.expression.evaluate({zoom:this.zoom+1},i,r);this._setPaintValue(t,e,s,n)}_setPaintValue(t,e,i,r){if("color"===this.type){const s=va(i),n=va(r);for(let i=t;i`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ia||i instanceof Ta)for(let e=0;e!0)){this.programConfigurations={};for(const r of t)this.programConfigurations[r.id]=new Aa(r,e,i);this.needsUpload=!1,this._featureMap=new ua,this._bufferOffset=0}populatePaintArrays(t,e,i,r,s,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r,s,n);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,r)||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()}}function Pa(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function Ca(t,e,i){const r={color:{source:cn,composite:An},number:{source:bn,composite:cn}},s=function(t){return{"line-pattern":{source:Zn,composite:Zn},"fill-pattern":{source:Zn,composite:Zn},"fill-extrusion-pattern":{source:Zn,composite:Zn}}[t]}(t);return s&&s[i]||r[e][i]}vs("ConstantBinder",ba),vs("CrossFadedConstantBinder",wa),vs("SourceExpressionBinder",Ia),vs("CrossFadedCompositeBinder",Sa),vs("CompositeExpressionBinder",Ta),vs("ProgramConfiguration",Aa,{omit:["_buffers"]}),vs("ProgramConfigurationSet",Ea);const Ma=8192,ka=Math.pow(2,14)-1,za=-ka-1;function Da(t){const e=Ma/t.extent,i=t.loadGeometry();for(let t=0;ti.x+1||ni.y+1)&&I("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Ra(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Da(t):[]}}function La(t,e,i,r,s){t.emplaceBack(2*e+(r+1)/2,2*i+(s+1)/2)}class Fa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Nn,this.indexArray=new Jn,this.segments=new ea,this.programConfigurations=new Ea(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const r=this.layers[0],s=[];let n=null,a=!1;"circle"===r.type&&(n=r.layout.get("circle-sort-key"),a=!n.isConstant());for(const{feature:e,id:r,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ra(e,t);if(!this.layers[0]._featureFilter.filter(new Ls(this.zoom),c,i))continue;const h=a?n.evaluate(c,{},i):void 0,u={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:Da(e),patterns:{},sortKey:h};s.push(u)}a&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of s){const{geometry:s,index:n,sourceLayerIndex:a}=r,o=t[n].feature;this.addFeature(r,s,n,i),e.featureIndex.insert(o,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ta),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,r){for(const i of e)for(const e of i){const i=e.x,r=e.y;if(i<0||i>=Ma||r<0||r>=Ma)continue;const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),n=s.vertexLength;La(this.layoutVertexArray,i,r,-1,-1),La(this.layoutVertexArray,i,r,1,-1),La(this.layoutVertexArray,i,r,1,1),La(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(n,n+1,n+2),this.indexArray.emplaceBack(n,n+3,n+2),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},r)}}function Ba(t,e){for(let i=0;i1){if(ja(t,e))return!0;for(let r=0;r1?i:i.sub(e)._mult(s)._add(e))}function Za(t,e){let i,r,s,n=!1;for(let a=0;ae.y!=s.y>e.y&&e.x<(s.x-r.x)*(e.y-r.y)/(s.y-r.y)+r.x&&(n=!n)}return n}function Ga(t,e){let i=!1;for(let r=0,s=t.length-1;re.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i)}return i}function Wa(t,e,i){const r=i[0],s=i[2];if(t.xs.x&&e.x>s.x||t.ys.y&&e.y>s.y)return!1;const n=T(t,e,i[0]);return n!==T(t,e,i[1])||n!==T(t,e,i[2])||n!==T(t,e,i[3])}function Ha(t,e,i){const r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Xa(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ka(t,e,i,r,s){if(!e[0]&&!e[1])return t;const a=n.convert(e)._mult(s);"viewport"===i&&a._rotate(-r);const o=[];for(let e=0;elo(t,e)))}(l,o),d=h?c*a:c;for(const t of r)for(const e of t){const t=h?e:lo(e,o);let i=d;const r=ao([],[e.x,e.y,0,1],o);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/n.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=n.cameraToCenterDistance/r[3]),Oa(u,t,i))return!0}return!1}}function lo(t,e){const i=ao([],[t.x,t.y,0,1],e);return new n(i[0]/i[3],i[1]/i[3])}class co extends Fa{}let ho;vs("HeatmapBucket",co,{omit:["layers"]});var uo={get paint(){return ho=ho||new Xs({"heatmap-radius":new Zs(G.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Zs(G.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qs(G.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Hs(G.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qs(G.paint_heatmap["heatmap-opacity"])})}};function po(t,{width:e,height:i},r,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*r)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*r}`)}else s=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=s,t}function fo(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;const s=po({},{width:e,height:i},r);mo(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=s.data}function mo(t,e,i,r,s,n){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||r.x>e.width-s.width||r.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{e[t.evaluationKey]=n;const a=t.expression.evaluate(e);s.data[i+r+0]=Math.floor(255*a.r/a.a),s.data[i+r+1]=Math.floor(255*a.g/a.a),s.data[i+r+2]=Math.floor(255*a.b/a.a),s.data[i+r+3]=Math.floor(255*a.a)};if(t.clips)for(let e=0,s=0;e80*i){r=n=t[0],s=a=t[1];for(var f=i;fn&&(n=o),l>a&&(a=l);c=0!==(c=Math.max(n-r,a-s))?32767/c:0}return Co(d,p,i,r,s,c,0),p}function Eo(t,e,i,r,s){var n,a;if(s===Jo(t,e,i,r)>0)for(n=e;n=e;n-=r)a=Ho(n,t[n],t[n+1],a);return a&&Uo(a,a.next)&&(Xo(a),a=a.next),a}function Po(t,e){if(!t)return t;e||(e=t);var i,r=t;do{if(i=!1,r.steiner||!Uo(r,r.next)&&0!==jo(r.prev,r,r.next))r=r.next;else{if(Xo(r),(r=e=r.prev)===r.next)break;i=!0}}while(i||r!==e);return e}function Co(t,e,i,r,s,n,a){if(t){!a&&n&&function(t,e,i,r){var s=t;do{0===s.z&&(s.z=Bo(s.x,s.y,e,i,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){var e,i,r,s,n,a,o,l,c=1;do{for(i=t,t=null,n=null,a=0;i;){for(a++,r=i,o=0,e=0;e0||l>0&&r;)0!==o&&(0===l||!r||i.z<=r.z)?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,l--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;i=r}n.nextZ=null,c*=2}while(a>1)}(s)}(t,r,s,n);for(var o,l,c=t;t.prev!==t.next;)if(o=t.prev,l=t.next,n?ko(t,r,s,n):Mo(t))e.push(o.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),Xo(t),t=l.next,c=l.next;else if((t=l)===c){a?1===a?Co(t=zo(Po(t),e,i),e,i,r,s,n,2):2===a&&Do(t,e,i,r,s,n):Co(Po(t),e,i,r,s,n,1);break}}}function Mo(t){var e=t.prev,i=t,r=t.next;if(jo(e,i,r)>=0)return!1;for(var s=e.x,n=i.x,a=r.x,o=e.y,l=i.y,c=r.y,h=sn?s>a?s:a:n>a?n:a,p=o>l?o>c?o:c:l>c?l:c,f=r.next;f!==e;){if(f.x>=h&&f.x<=d&&f.y>=u&&f.y<=p&&Vo(s,o,n,l,a,c,f.x,f.y)&&jo(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ko(t,e,i,r){var s=t.prev,n=t,a=t.next;if(jo(s,n,a)>=0)return!1;for(var o=s.x,l=n.x,c=a.x,h=s.y,u=n.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,_=Bo(p,f,e,i,r),y=Bo(m,g,e,i,r),x=t.prevZ,v=t.nextZ;x&&x.z>=_&&v&&v.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==a&&Vo(o,h,l,u,c,d,x.x,x.y)&&jo(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Vo(o,h,l,u,c,d,v.x,v.y)&&jo(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;x&&x.z>=_;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==s&&x!==a&&Vo(o,h,l,u,c,d,x.x,x.y)&&jo(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=y;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==s&&v!==a&&Vo(o,h,l,u,c,d,v.x,v.y)&&jo(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function zo(t,e,i){var r=t;do{var s=r.prev,n=r.next.next;!Uo(s,n)&&$o(s,r,r.next,n)&&Go(s,n)&&Go(n,s)&&(e.push(s.i/i|0),e.push(r.i/i|0),e.push(n.i/i|0),Xo(r),Xo(r.next),r=t=n),r=r.next}while(r!==t);return Po(r)}function Do(t,e,i,r,s,n){var a=t;do{for(var o=a.next.next;o!==a.prev;){if(a.i!==o.i&&No(a,o)){var l=Wo(a,o);return a=Po(a,a.next),l=Po(l,l.next),Co(a,e,i,r,s,n,0),void Co(l,e,i,r,s,n,0)}o=o.next}a=a.next}while(a!==t)}function Ro(t,e){return t.x-e.x}function Lo(t,e){var i=function(t,e){var i,r=e,s=t.x,n=t.y,a=-1/0;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){var o=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=s&&o>a&&(a=o,i=r.x=r.x&&r.x>=h&&s!==r.x&&Vo(ni.x||r.x===i.x&&Fo(i,r)))&&(i=r,d=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=Wo(i,t);return Po(r,r.next),Po(i,i.next)}function Fo(t,e){return jo(t.prev,t,e.prev)<0&&jo(e.next,t,t.next)<0}function Bo(t,e,i,r,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Oo(t){var e=t,i=t;do{(e.x=(t-a)*(n-o)&&(t-a)*(r-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(s-a)*(r-o)}function No(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&$o(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(Go(t,e)&&Go(e,t)&&function(t,e){var i=t,r=!1,s=(t.x+e.x)/2,n=(t.y+e.y)/2;do{i.y>n!=i.next.y>n&&i.next.y!==i.y&&s<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(jo(t.prev,t,e.prev)||jo(t,e.prev,e))||Uo(t,e)&&jo(t.prev,t,t.next)>0&&jo(e.prev,e,e.next)>0)}function jo(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Uo(t,e){return t.x===e.x&&t.y===e.y}function $o(t,e,i,r){var s=Zo(jo(t,e,i)),n=Zo(jo(t,e,r)),a=Zo(jo(i,r,t)),o=Zo(jo(i,r,e));return s!==n&&a!==o||!(0!==s||!qo(t,i,e))||!(0!==n||!qo(t,r,e))||!(0!==a||!qo(i,t,r))||!(0!==o||!qo(i,e,r))}function qo(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function Zo(t){return t>0?1:t<0?-1:0}function Go(t,e){return jo(t.prev,t,t.next)<0?jo(t,e,t.next)>=0&&jo(t,t.prev,e)>=0:jo(t,e,t.prev)<0||jo(t,t.next,e)<0}function Wo(t,e){var i=new Ko(t.i,t.x,t.y),r=new Ko(e.i,e.x,e.y),s=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,r.next=i,i.prev=r,n.next=r,r.prev=n,r}function Ho(t,e,i,r){var s=new Ko(t,e,i);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Xo(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 Ko(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Jo(t,e,i,r){for(var s=0,n=e,a=i-r;n0&&i.holes.push(r+=t[s-1].length)}return i};var Yo=i(So.exports);function Qo(t,e,i){const r=i.patternDependencies;let s=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(s=!0);const n=e.constantOr(null);n&&(s=!0,r[n.to]=!0,r[n.from]=!0)}return s}function tl(t,e,i,r,s){const n=s.patternDependencies;for(const a of e){const e=a.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},s.availableImages),o=e.evaluate({zoom:r},i,{},s.availableImages),l=e.evaluate({zoom:r+1},i,{},s.availableImages);t=t&&t.name?t.name:t,o=o&&o.name?o.name:o,l=l&&l.name?l.name:l,n[t]=!0,n[o]=!0,n[l]=!0,i.patterns[a.id]={min:t,mid:o,max:l}}}return i}class el{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new jn,this.indexArray=new Jn,this.indexArray2=new Yn,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new ea,this.segments2=new ea,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qo("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),s=!r.isConstant(),n=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=Ra(a,t);if(!this.layers[0]._featureFilter.filter(new Ls(this.zoom),h,i))continue;const u=s?r.evaluate(h,{},i,e.availableImages):void 0,d={id:o,properties:a.properties,type:a.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Da(a),patterns:{},sortKey:u};n.push(d)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=tl("fill",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,To),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,i,r,s){for(const t of xi(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),r=i.vertexLength,s=[],n=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&n.push(s.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(r+e.length-1,r),s.push(e[0].x),s.push(e[0].y);for(let t=1;t>3}if(s--,1===r||2===r)n+=t.readSVarint(),a+=t.readSVarint(),1===r&&(e&&o.push(e),e=[]),e.push(new hl(n,a));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&o.push(e),o},dl.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,s=0,n=0,a=1/0,o=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===i||2===i)(s+=t.readSVarint())o&&(o=s),(n+=t.readSVarint())c&&(c=n);else if(7!==i)throw new Error("unknown command "+i)}return[a,l,o,c]},dl.prototype.toGeoJSON=function(t,e,i){var r,s,n=this.extent*Math.pow(2,i),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),c=dl.types[this.type];function h(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}_l.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 ml(this._pbf,e,this.extent,this._keys,this._values)};var xl=gl;function vl(t,e,i){if(3===t){var r=new xl(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}cl.VectorTile=function(t,e){this.layers=t.readFields(vl,{},e)},cl.VectorTileFeature=ul,cl.VectorTileLayer=gl;const bl=cl.VectorTileFeature.types,wl=Math.pow(2,13);function Il(t,e,i,r,s,n,a,o){t.emplaceBack(e,i,2*Math.floor(r*wl)+a,s*wl*2,n*wl*2,Math.round(o))}class Tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new Un,this.centroidVertexArray=new Vn,this.indexArray=new Jn,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new ea,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=Qo("fill-extrusion",this.layers,e);for(const{feature:r,id:s,index:n,sourceLayerIndex:a}of t){const t=this.layers[0]._featureFilter.needGeometry,o=Ra(r,t);if(!this.layers[0]._featureFilter.filter(new Ls(this.zoom),o,i))continue;const l={id:s,sourceLayerIndex:a,index:n,geometry:t?o.geometry:Da(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(tl("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,n,i,{}),e.featureIndex.insert(r,l.geometry,n,a,this.index,!0)}}addFeatures(t,e,i){for(const t of this.features){const{geometry:r}=t;this.addFeature(t,r,t.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ll),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,ol.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,s){const n={x:0,y:0,vertexCount:0};for(const i of xi(e,500)){let e=0;for(const t of i)e+=t.length;let r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of i){if(0===t.length)continue;if(Al(t))continue;let e=0;for(let i=0;i=1){const a=t[i-1];if(!Sl(s,a)){r.vertexLength+4>ea.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=s.sub(a)._perp()._unit(),i=a.dist(s);e+i>32768&&(e=0),Il(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,0,e),Il(this.layoutVertexArray,s.x,s.y,t.x,t.y,0,1,e),n.x+=2*s.x,n.y+=2*s.y,n.vertexCount+=2,e+=i,Il(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,0,e),Il(this.layoutVertexArray,a.x,a.y,t.x,t.y,0,1,e),n.x+=2*a.x,n.y+=2*a.y,n.vertexCount+=2;const o=r.vertexLength;this.indexArray.emplaceBack(o,o+2,o+1),this.indexArray.emplaceBack(o+1,o+2,o+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+e>ea.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==bl[t.type])continue;const s=[],a=[],o=r.vertexLength;for(const t of i)if(0!==t.length){t!==i[0]&&a.push(s.length/2);for(let e=0;eMa)||t.y===e.y&&(t.y<0||t.y>Ma)}function Al(t){return t.every((t=>t.x<0))||t.every((t=>t.x>Ma))||t.every((t=>t.y<0))||t.every((t=>t.y>Ma))}let El;vs("FillExtrusionBucket",Tl,{omit:["layers","features"]});var Pl={get paint(){return El=El||new Xs({"fill-extrusion-opacity":new qs(G["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Zs(G["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qs(G["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qs(G["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Gs(G["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Zs(G["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Zs(G["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new qs(G["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Cl extends Js{constructor(t){super(t,Pl)}createBucket(t){return new Tl(t)}queryRadius(){return Xa(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,s,a,o,l){const c=Ka(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),h=this.paint.get("fill-extrusion-height").evaluate(e,i),u=this.paint.get("fill-extrusion-base").evaluate(e,i),d=function(t,e,i,r){const s=[];for(const i of t){const t=[i.x,i.y,0,1];ao(t,t,e),s.push(new n(t[0]/t[3],t[1]/t[3]))}return s}(c,l),p=function(t,e,i,r){const s=[],a=[],o=r[8]*e,l=r[9]*e,c=r[10]*e,h=r[11]*e,u=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const s of e){const e=s.x,a=s.y,m=r[0]*e+r[4]*a+r[12],g=r[1]*e+r[5]*a+r[13],_=r[2]*e+r[6]*a+r[14],y=r[3]*e+r[7]*a+r[15],x=_+c,v=y+h,b=m+u,w=g+d,I=_+p,T=y+f,S=new n((m+o)/v,(g+l)/v);S.z=x/v,t.push(S);const A=new n(b/T,w/T);A.z=I/T,i.push(A)}s.push(t),a.push(i)}return[s,a]}(r,u,h,l);return function(t,e,i){let r=1/0;Va(i,e)&&(r=kl(i,e[0]));for(let s=0;st.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new $n,this.layoutVertexArray2=new qn,this.indexArray=new Jn,this.programConfigurations=new Ea(t.layers,t.zoom),this.segments=new ea,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=Qo("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),s=!r.isConstant(),n=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Ra(e,t);if(!this.layers[0]._featureFilter.filter(new Ls(this.zoom),c,i))continue;const h=s?r.evaluate(c,{},i):void 0,u={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?c.geometry:Da(e),patterns:{},sortKey:h};n.push(u)}s&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(const r of n){const{geometry:s,index:n,sourceLayerIndex:a}=r;if(this.hasPattern){const t=tl("line",this.layers,r,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(r,s,n,i,{});e.featureIndex.insert(t[n].feature,s,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i)}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,Ll)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Dl),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,s){const n=this.layers[0].layout,a=n.get("line-join").evaluate(t,{}),o=n.get("line-cap"),l=n.get("line-miter-limit"),c=n.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,o,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,s,r)}addLine(t,e,i,r,s,n){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(b&&e>l){const t=u.dist(d);if(t>2*c){const e=u.sub(u.sub(d)._mult(c/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,f,0,0,h),d=e}}const I=d&&p;let T=I?i:a?"butt":r;if(I&&"round"===T&&(xs&&(T="bevel"),"bevel"===T&&(x>2&&(T="flipbevel"),x100)g=m.mult(-1);else{const t=x*f.add(m).mag()/f.sub(m).mag();g._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,g,0,0,h),this.addCurrentVertex(u,g.mult(-1),0,0,h)}else if("bevel"===T||"fakeround"===T){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(d&&this.addCurrentVertex(u,f,e,i,h),"fakeround"===T){const t=Math.round(180*v/Math.PI/20);for(let e=1;e2*c){const e=u.add(p.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,m,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,s,n=!1){const a=e.y*r-e.x,o=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,n,!1,i,s),this.addHalfVertex(t,a,o,n,!0,-r,s),this.distance>Ol/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,s,n))}addHalfVertex({x:t,y:e},i,r,s,n,a,o){const l=.5*(this.lineClips?this.scaledDistance*(Ol-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(n?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),o.primitiveLength++),n?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}let Nl,jl;vs("LineBucket",Vl,{omit:["layers","patternFeatures"]});var Ul={get paint(){return jl=jl||new Xs({"line-opacity":new Zs(G.paint_line["line-opacity"]),"line-color":new Zs(G.paint_line["line-color"]),"line-translate":new qs(G.paint_line["line-translate"]),"line-translate-anchor":new qs(G.paint_line["line-translate-anchor"]),"line-width":new Zs(G.paint_line["line-width"]),"line-gap-width":new Zs(G.paint_line["line-gap-width"]),"line-offset":new Zs(G.paint_line["line-offset"]),"line-blur":new Zs(G.paint_line["line-blur"]),"line-dasharray":new Ws(G.paint_line["line-dasharray"]),"line-pattern":new Gs(G.paint_line["line-pattern"]),"line-gradient":new Hs(G.paint_line["line-gradient"])})},get layout(){return Nl=Nl||new Xs({"line-cap":new qs(G.layout_line["line-cap"]),"line-join":new Zs(G.layout_line["line-join"]),"line-miter-limit":new qs(G.layout_line["line-miter-limit"]),"line-round-limit":new qs(G.layout_line["line-round-limit"]),"line-sort-key":new Zs(G.layout_line["line-sort-key"])})}};class $l extends Zs{possiblyEvaluate(t,e){return e=new Ls(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=_({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}let ql;class Zl extends Js{constructor(t){super(t,Ul),this.gradientVersion=0,ql||(ql=new $l(Ul.paint.properties["line-width"].specification),ql.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Ie,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=ql.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new Vl(t)}queryRadius(t){const e=t,i=Gl(Ha("line-width",this,e),Ha("line-gap-width",this,e)),r=Ha("line-offset",this,e);return i/2+Math.abs(r)+Xa(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,r,s,a,o){const l=Ka(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),a.angle,o),c=o/2*Gl(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),h=this.paint.get("line-offset").evaluate(e,i);return h&&(r=function(t,e){const i=[];for(let r=0;r=3)for(let e=0;e0?e+2*t:t}const Wl=en([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Hl=en([{name:"a_projected_pos",components:3,type:"Float32"}],4);en([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Xl=en([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);en([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Kl=en([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Jl=en([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Yl(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Rs.applyArabicShaping&&(t=Rs.applyArabicShaping(t)),t}(t.text,e,i)})),t}en([{name:"triangle",components:3,type:"Uint16"}]),en([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),en([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),en([{type:"Float32",name:"offsetX"}]),en([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),en([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Ql={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var tc=24,ec=sc,ic=function(t,e,i,r,s){var n,a,o=8*s-r-1,l=(1<>1,h=-7,u=i?s-1:0,d=i?-1:1,p=t[e+u];for(u+=d,n=p&(1<<-h)-1,p>>=-h,h+=o;h>0;n=256*n+t[e+u],u+=d,h-=8);for(a=n&(1<<-h)-1,n>>=-h,h+=r;h>0;a=256*a+t[e+u],u+=d,h-=8);if(0===n)n=1-c;else{if(n===l)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,r),n-=c}return(p?-1:1)*a*Math.pow(2,n-r)},rc=function(t,e,i,r,s,n){var a,o,l,c=8*n-s-1,h=(1<>1,d=23===s?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,f=r?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=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(a++,l/=2),a+u>=h?(o=0,a=h):a+u>=1?(o=(e*l-1)*Math.pow(2,s),a+=u):(o=e*Math.pow(2,u-1)*Math.pow(2,s),a=0));s>=8;t[i+p]=255&o,p+=f,o/=256,s-=8);for(a=a<0;t[i+p]=255&a,p+=f,a/=256,c-=8);t[i+p-f]|=128*m};function sc(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}sc.Varint=0,sc.Fixed64=1,sc.Bytes=2,sc.Fixed32=5;var nc=4294967296,ac=1/nc,oc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function lc(t){return t.type===sc.Bytes?t.readVarint()+t.pos:t.pos+1}function cc(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function hc(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var s=i.pos-1;s>=t;s--)i.buf[s+r]=i.buf[s]}function uc(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function wc(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}sc.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos>3,n=this.pos;this.type=7&r,t(s,e,this),this.pos===n&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=vc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=wc(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=vc(this.buf,this.pos)+vc(this.buf,this.pos+4)*nc;return this.pos+=8,t},readSFixed64:function(){var t=vc(this.buf,this.pos)+wc(this.buf,this.pos+4)*nc;return this.pos+=8,t},readFloat:function(){var t=ic(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ic(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,s,n=i.buf;if(r=(112&(s=n[i.pos++]))>>4,s<128)return cc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<3,s<128)return cc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<10,s<128)return cc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<17,s<128)return cc(t,r,e);if(r|=(127&(s=n[i.pos++]))<<24,s<128)return cc(t,r,e);if(r|=(1&(s=n[i.pos++]))<<31,s<128)return cc(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[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&&oc?function(t,e,i){return oc.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",s=e;s239?4:l>223?3:l>191?2:1;if(s+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(n=t[s+1]))&&(c=(31&l)<<6|63&n)<=127&&(c=null):3===h?(a=t[s+2],128==(192&(n=t[s+1]))&&128==(192&a)&&((c=(15&l)<<12|(63&n)<<6|63&a)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(a=t[s+2],o=t[s+3],128==(192&(n=t[s+1]))&&128==(192&a)&&128==(192&o)&&((c=(15&l)<<18|(63&n)<<12|(63&a)<<6|63&o)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),s+=h}return r}(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!==sc.Bytes)return t.push(this.readVarint(e));var i=lc(this);for(t=t||[];this.pos127;);else if(e===sc.Bytes)this.pos=this.readVarint()+this.pos;else if(e===sc.Fixed32)this.pos+=4;else{if(e!==sc.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 i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((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)))))}(r,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,i){for(var r,s,n=0;n55295&&r<57344){if(!s){r>56319||n+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):s=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,s=r;continue}r=s-55296<<10|r-56320|65536,s=null}else s&&(t[i++]=239,t[i++]=191,t[i++]=189,s=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&hc(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),rc(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),rc(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 i=0;i=128&&hc(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,sc.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,uc,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,dc,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,mc,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,pc,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,fc,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,gc,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,_c,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,yc,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,xc,e)},writeBytesField:function(t,e){this.writeTag(t,sc.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,sc.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,sc.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,sc.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,sc.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,sc.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,sc.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,sc.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,sc.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,sc.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Ic=i(ec);const Tc=3;function Sc(t,e,i){1===t&&i.readMessage(Ac,e)}function Ac(t,e,i){if(3===t){const{id:t,bitmap:r,width:s,height:n,left:a,top:o,advance:l}=i.readMessage(Ec,{});e.push({id:t,bitmap:new go({width:s+2*Tc,height:n+2*Tc},r),metrics:{width:s,height:n,left:a,top:o,advance:l}})}}function Ec(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const Pc=Tc;function Cc(t){let e=0,i=0;for(const r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,n=0;for(const e of t)for(let t=r.length-1;t>=0;t--){const i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,n=Math.max(n,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){const e=r.pop();t=0&&i>=t&&Oc[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Fc;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}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(Lc.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Bc(e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g){const _=Fc.fromFeature(e,n);let y;d===t.ah.vertical&&_.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Rs;if(x&&1===_.sections.length){y=[];const t=x(_.toString(),Zc(_,h,a,i,s,f,m));for(const e of t){const t=new Fc;t.text=e,t.sections=_.sections;for(let i=0;i0&&r>w&&(w=r)}else{const t=r[m.fontStack],e=t&&t[_];if(e&&e.rect)I=e.rect,v=e.metrics;else{const t=i[m.fontStack],e=t&&t[_];if(!e)continue;v=e.metrics}y=(n-m.scale)*tc}A?(e.verticalizable=!0,b.push({glyph:_,imageName:T,x:p,y:f+y,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:v,rect:I}),p+=S*m.scale+h):(b.push({glyph:_,imageName:T,x:p,y:f+y,vertical:A,scale:m.scale,fontStack:m.fontStack,sectionIndex:g,metrics:v,rect:I}),p+=v.advance*m.scale+h)}0!==b.length&&(m=Math.max(p-h,m),Wc(b,0,b.length-1,_,w)),p=0;const I=a*n+w;v.lineOffset=Math.max(w,l),f+=I,g=Math.max(I,g),++y}var x;const v=f-Rc,{horizontalAlign:b,verticalAlign:w}=Gc(o);(function(t,e,i,r,s,n,a,o,l){const c=(e-i)*s;let h=0;h=n!==a?-o*r-Rc:(-r*l+.5)*a;for(const e of t)for(const t of e.positionedGlyphs)t.x+=c,t.y+=h})(e.positionedLines,_,b,w,m,g,a,v,n.length),e.top+=-w*v,e.bottom=e.top+v,e.left+=-b*m,e.right=e.left+m}(w,i,r,s,y,o,l,c,d,h,p,g),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&w}const Oc={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Vc={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Nc(t,e,i,r,s,n){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*tc/n+s:0}{const r=i[e.fontStack],n=r&&r[t];return n?n.metrics.advance*e.scale+s:0}}function jc(t,e,i,r){const s=Math.pow(t-e,2);return r?t=0;let h=0;for(let i=0;ic){const t=Math.ceil(n/c);s*=t/a,a=t}return{x1:r,y1:s,x2:r+n,y2:s+a}}function Kc(t,e,i,r,s,n){const a=t.image;let o;if(a.content){const t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e]}const l=e.left*n,c=e.right*n;let h,u,d,p;"width"===i||"both"===i?(p=s[0]+l-r[3],u=s[0]+c+r[1]):(p=s[0]+(l+c-a.displaySize[0])/2,u=p+a.displaySize[0]);const f=e.top*n,m=e.bottom*n;return"height"===i||"both"===i?(h=s[1]+f-r[0],d=s[1]+m+r[2]):(h=s[1]+(f+m-a.displaySize[1])/2,d=h+a.displaySize[1]),{image:a,top:h,right:u,bottom:d,left:p,collisionPadding:o}}const Jc=255,Yc=128,Qc=Jc*Yc;function th(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ls(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:r}=i;let s=0;for(;st.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=io([]),this.placementViewportMatrix=io([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=th(this.zoom,i["text-size"]),this.iconSizeData=th(this.zoom,i["icon-size"]);const r=this.layers[0].layout,s=r.get("symbol-sort-key"),n=r.get("symbol-z-order");this.canOverlap="never"!==eh(r,"text-overlap","text-allow-overlap")||"never"!==eh(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&!s.isConstant(),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.ah[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new oh(new Ea(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new oh(new Ea(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Dn,this.lineVertexArray=new Rn,this.symbolInstances=new zn,this.textAnchorOffsets=new Fn}calculateGlyphDependencies(t,e,i,r,s){for(let n=0;n0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=n.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Ls(this.zoom);for(const{feature:i,id:o,index:l,sourceLayerIndex:g}of e){const e=s._featureFilter.needGeometry,_=Ra(i,e);if(!s._featureFilter.filter(m,_,r))continue;let y,x;if(e||(_.geometry=Da(i)),c){const t=s.getValueAndResolveTokens("text-field",_,r,f),e=Kt.factory(t),i=this.hasRTLText=this.hasRTLText||ah(e);(!i||"unavailable"===Rs.getRTLTextPluginStatus()||i&&Rs.isParsed())&&(y=Yl(e,s,_))}if(h){const t=s.getValueAndResolveTokens("icon-image",_,r,f);x=t instanceof te?t:te.fromString(t)}if(!y&&!x)continue;const v=this.sortFeaturesByKey?u.evaluate(_,{},r):void 0;if(this.features.push({id:o,text:y,icon:x,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:ih[i.type],sortKey:v}),x&&(d[x.name]=!0),y){const e=a.evaluate(_,{},r).join(","),i="viewport"!==n.get("text-rotation-alignment")&&"point"!==n.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.ah.vertical)>=0;for(const t of y.sections)if(t.image)d[t.image.name]=!0;else{const r=As(y.toString()),s=t.fontStack||e,n=p[s]=p[s]||{};this.calculateGlyphDependencies(t.text,n,i,this.allowVerticalPlacement,r)}}}"line"===n.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let s=0;function n(e){r.push(t[e]),s++}function a(t,e,s){const n=i[t];return delete i[t],i[e]=n,r[n].geometry[0].pop(),r[n].geometry[0]=r[n].geometry[0].concat(s[0]),n}function o(t,i,s){const n=e[i];return delete e[i],e[t]=n,r[n].geometry[0].shift(),r[n].geometry[0]=s[0].concat(r[n].geometry[0]),n}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}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.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const s={};for(let r=t.segment+1;r=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;er[t]-r[e]||s[e]-s[t])),n}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.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),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let hh,uh;vs("SymbolBucket",ch,{omit:["layers","collisionBoxArray","features","compareText"]}),ch.MAX_GLYPHS=65535,ch.addDynamicAttributes=nh;var dh={get paint(){return uh=uh||new Xs({"icon-opacity":new Zs(G.paint_symbol["icon-opacity"]),"icon-color":new Zs(G.paint_symbol["icon-color"]),"icon-halo-color":new Zs(G.paint_symbol["icon-halo-color"]),"icon-halo-width":new Zs(G.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Zs(G.paint_symbol["icon-halo-blur"]),"icon-translate":new qs(G.paint_symbol["icon-translate"]),"icon-translate-anchor":new qs(G.paint_symbol["icon-translate-anchor"]),"text-opacity":new Zs(G.paint_symbol["text-opacity"]),"text-color":new Zs(G.paint_symbol["text-color"],{runtimeType:dt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Zs(G.paint_symbol["text-halo-color"]),"text-halo-width":new Zs(G.paint_symbol["text-halo-width"]),"text-halo-blur":new Zs(G.paint_symbol["text-halo-blur"]),"text-translate":new qs(G.paint_symbol["text-translate"]),"text-translate-anchor":new qs(G.paint_symbol["text-translate-anchor"])})},get layout(){return hh=hh||new Xs({"symbol-placement":new qs(G.layout_symbol["symbol-placement"]),"symbol-spacing":new qs(G.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qs(G.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Zs(G.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qs(G.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new qs(G.layout_symbol["icon-allow-overlap"]),"icon-overlap":new qs(G.layout_symbol["icon-overlap"]),"icon-ignore-placement":new qs(G.layout_symbol["icon-ignore-placement"]),"icon-optional":new qs(G.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qs(G.layout_symbol["icon-rotation-alignment"]),"icon-size":new Zs(G.layout_symbol["icon-size"]),"icon-text-fit":new qs(G.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qs(G.layout_symbol["icon-text-fit-padding"]),"icon-image":new Zs(G.layout_symbol["icon-image"]),"icon-rotate":new Zs(G.layout_symbol["icon-rotate"]),"icon-padding":new Zs(G.layout_symbol["icon-padding"]),"icon-keep-upright":new qs(G.layout_symbol["icon-keep-upright"]),"icon-offset":new Zs(G.layout_symbol["icon-offset"]),"icon-anchor":new Zs(G.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qs(G.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qs(G.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qs(G.layout_symbol["text-rotation-alignment"]),"text-field":new Zs(G.layout_symbol["text-field"]),"text-font":new Zs(G.layout_symbol["text-font"]),"text-size":new Zs(G.layout_symbol["text-size"]),"text-max-width":new Zs(G.layout_symbol["text-max-width"]),"text-line-height":new qs(G.layout_symbol["text-line-height"]),"text-letter-spacing":new Zs(G.layout_symbol["text-letter-spacing"]),"text-justify":new Zs(G.layout_symbol["text-justify"]),"text-radial-offset":new Zs(G.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qs(G.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Zs(G.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Zs(G.layout_symbol["text-anchor"]),"text-max-angle":new qs(G.layout_symbol["text-max-angle"]),"text-writing-mode":new qs(G.layout_symbol["text-writing-mode"]),"text-rotate":new Zs(G.layout_symbol["text-rotate"]),"text-padding":new qs(G.layout_symbol["text-padding"]),"text-keep-upright":new qs(G.layout_symbol["text-keep-upright"]),"text-transform":new Zs(G.layout_symbol["text-transform"]),"text-offset":new Zs(G.layout_symbol["text-offset"]),"text-allow-overlap":new qs(G.layout_symbol["text-allow-overlap"]),"text-overlap":new qs(G.layout_symbol["text-overlap"]),"text-ignore-placement":new qs(G.layout_symbol["text-ignore-placement"]),"text-optional":new qs(G.layout_symbol["text-optional"])})}};class ph{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:lt,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}}vs("FormatSectionOverride",ph,{omit:["defaultValue"]});class fh extends Js{constructor(t){super(t,dh)}recalculate(t,e){if(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"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const s=this.layout.get(t).evaluate(e,{},i,r),n=this._unevaluatedLayout._values[t];return n.isDataDriven()||xr(n.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new ch(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of dh.paint.overridableProperties){if(!fh.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new ph(e),r=new yr(i,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new br("source",r):new wr("composite",r,e.value.zoomStops),this.paint._values[t]=new Us(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&fh.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=dh.paint.properties[e];let s=!1;const n=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof Kt)n(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{s||(e instanceof ne&&re(e.value)===gt?n(e.value.sections):e instanceof Ze?n(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}let mh;var gh={get paint(){return mh=mh||new Xs({"background-color":new qs(G.paint_background["background-color"]),"background-pattern":new Ws(G.paint_background["background-pattern"]),"background-opacity":new qs(G.paint_background["background-opacity"])})}};class _h extends Js{constructor(t){super(t,gh)}}let yh;var xh={get paint(){return yh=yh||new Xs({"raster-opacity":new qs(G.paint_raster["raster-opacity"]),"raster-hue-rotate":new qs(G.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qs(G.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qs(G.paint_raster["raster-brightness-max"]),"raster-saturation":new qs(G.paint_raster["raster-saturation"]),"raster-contrast":new qs(G.paint_raster["raster-contrast"]),"raster-resampling":new qs(G.paint_raster["raster-resampling"]),"raster-fade-duration":new qs(G.paint_raster["raster-fade-duration"])})}};class vh extends Js{constructor(t){super(t,xh)}}class bh extends Js{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class wh{constructor(t){this._methodToThrottle=t,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._methodToThrottle()}),0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ih=6371008.8;class Th{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 Th(g(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,i=this.lat*e,r=t.lat*e,s=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Ih*Math.acos(Math.min(s,1))}static convert(t){if(t instanceof Th)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Th(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Th(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 [, ]")}}const Sh=2*Math.PI*Ih;function Ah(t){return Sh*Math.cos(t*Math.PI/180)}function Eh(t){return(180+t)/360}function Ph(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Ch(t,e){return t/Ah(e)}function Mh(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class kh{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Th.convert(t);return new kh(Eh(i.lng),Ph(i.lat),Ch(e,i.lat))}toLngLat(){return new Th(360*this.x-180,Mh(this.y))}toAltitude(){return this.z*Ah(Mh(this.y))}meterInMercatorCoordinateUnits(){return 1/Sh*(t=Mh(this.y),1/Math.cos(t*Math.PI/180));var t}}function zh(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class Dh{constructor(t,e,i){if(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=Fh(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(n=this.y,a=this.z,o=zh(256*(s=this.x),256*(n=Math.pow(2,a)-n-1),a),l=zh(256*(s+1),256*(n+1),a),o[0]+","+o[1]+","+l[0]+","+l[1]);var s,n,a,o,l;const c=function(t,e,i){let r,s="";for(let n=t;n>0;n--)r=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new n((t.x*e-this.x)*Ma,(t.y*e-this.y)*Ma)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Rh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Fh(t,e.z,e.z,e.x,e.y)}}class Lh{constructor(t,e,i,r,s){if(t= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Dh(i,+r,+s),this.key=Fh(e,t,i,r,s)}clone(){return new Lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Lh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?Fh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Fh(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}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 Lh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Lh(e,this.wrap,e,i,r),new Lh(e,this.wrap,e,i+1,r),new Lh(e,this.wrap,e,i,r+1),new Lh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=i),i=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)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}getPixels(){return new _o({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,s=e*this.dim+this.dim,n=i*this.dim,a=i*this.dim+this.dim;switch(e){case-1:r=s-1;break;case 1:s=r+1}switch(i){case-1:n=a-1;break;case 1:a=n+1}const o=-e*this.dim,l=-i*this.dim;for(let e=n;e=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class Vh{constructor(t,e,i,r,s){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=s}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class Nh{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ys(Ma,16,0),this.grid3D=new ys(Ma,16,0),this.featureIndexArray=new On,this.promoteId=e}insert(t,e,i,r,s,n){const a=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,s);const o=n?this.grid3D:this.grid;for(let t=0;t=0&&r[3]>=0&&o.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new cl.VectorTile(new Ic(this.rawTileData)).layers,this.sourceLayerCoder=new Oh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const s=t.params||{},a=Ma/t.tileSize/t.scale,o=Pr(s.filter),l=t.queryGeometry,c=t.queryPadding*a,h=Uh(l),u=this.grid.query(h.minX-c,h.minY-c,h.maxX+c,h.maxY+c),d=Uh(t.cameraQueryGeometry),p=this.grid3D.query(d.minX-c,d.minY-c,d.maxX+c,d.maxY+c,((e,i,r,s)=>function(t,e,i,r,s){for(const n of t)if(e<=n.x&&i<=n.y&&r>=n.x&&s>=n.y)return!0;const a=[new n(e,i),new n(e,s),new n(r,s),new n(r,i)];if(t.length>2)for(const e of a)if(Ga(t,e))return!0;for(let e=0;e(d||(d=Da(e)),i.queryIntersectsFeature(l,e,r,d,this.z,t.transform,a,t.pixelPosMatrix))))}return f}loadMatchingFeature(t,e,i,r,s,n,a,o,l,c,h){const u=this.bucketLayerIDs[e];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,u))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(s.needGeometry){const t=Ra(p,!0);if(!s.filter(new Ls(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new Ls(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let e=0;e{const a=e instanceof $s?e.get(n):null;return a&&a.evaluate?a.evaluate(i,r,s):a}))}function Uh(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return{minX:e,minY:i,maxX:r,maxY:s}}function $h(t,e){return e-t}function qh(t,e,i,r,s){const a=[];for(let o=0;o=r&&h.x>=r||(o.x>=r?o=new n(r,o.y+(r-o.x)/(h.x-o.x)*(h.y-o.y))._round():h.x>=r&&(h=new n(r,o.y+(r-o.x)/(h.x-o.x)*(h.y-o.y))._round()),o.y>=s&&h.y>=s||(o.y>=s?o=new n(o.x+(s-o.y)/(h.y-o.y)*(h.x-o.x),s)._round():h.y>=s&&(h=new n(o.x+(s-o.y)/(h.y-o.y)*(h.x-o.x),s)._round()),c&&o.equals(c[c.length-1])||(c=[o],a.push(c)),c.push(h)))))}}return a}vs("FeatureIndex",Nh,{omit:["rawTileData","sourceLayerCoder"]});class Zh extends n{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new Zh(this.x,this.y,this.angle,this.segment)}}function Gh(t,e,i,r,s){if(void 0===e.segment||0===i)return!0;let n=e,a=e.segment+1,o=0;for(;o>-i/2;){if(a--,a<0)return!1;o-=t[a].dist(n),n=t[a]}o+=t[a].dist(t[a+1]),a++;const l=[];let c=0;for(;or;)c-=l.shift().angleDelta;if(c>s)return!1;a++,o+=e.dist(i)}return!0}function Wh(t){let e=0;for(let i=0;ic){const h=(c-l)/n,u=Me.number(r.x,s.x,h),d=Me.number(r.y,s.y,h),p=new Zh(u,d,s.angleTo(r),i);return p._round(),!a||Gh(t,p,o,a,e)?p:void 0}l+=n}}function Jh(t,e,i,r,s,n,a,o,l){const c=Hh(r,n,a),h=Xh(r,s),u=h*a,d=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&_=0&&y=0&&d+c<=h){const i=new Zh(_,y,m,e);i._round(),r&&!Gh(t,i,n,r,s)||p.push(i)}}u+=f}return o||p.length||a||(p=Yh(t,u/2,i,r,s,n,a,!0,l)),p}vs("Anchor",Zh);const Qh=Mc;function tu(t,e,i,r){const s=[],a=t.image,o=a.pixelRatio,l=a.paddedRect.w-2*Qh,c=a.paddedRect.h-2*Qh;let h={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const u=a.stretchX||[[0,l]],d=a.stretchY||[[0,c]],p=(t,e)=>t+e[1]-e[0],f=u.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let y=0,x=f,v=0,b=m,w=0,I=g,T=0,S=_;if(a.content&&r){const e=a.content,i=e[2]-e[0],r=e[3]-e[1];(a.textFitWidth||a.textFitHeight)&&(h=Xc(t)),y=eu(u,0,e[0]),v=eu(d,0,e[1]),x=eu(u,e[0],e[2]),b=eu(d,e[1],e[3]),w=e[0]-y,T=e[1]-v,I=i-x,S=r-b}const A=h.x1,E=h.y1,P=h.x2-A,C=h.y2-E,M=(t,r,s,l)=>{const c=ru(t.stretch-y,x,P,A),h=su(t.fixed-w,I,t.stretch,f),u=ru(r.stretch-v,b,C,E),d=su(r.fixed-T,S,r.stretch,m),p=ru(s.stretch-y,x,P,A),g=su(s.fixed-w,I,s.stretch,f),_=ru(l.stretch-v,b,C,E),M=su(l.fixed-T,S,l.stretch,m),k=new n(c,u),z=new n(p,u),D=new n(p,_),R=new n(c,_),L=new n(h/o,d/o),F=new n(g/o,M/o),B=e*Math.PI/180;if(B){const t=Math.sin(B),e=Math.cos(B),i=[e,-t,t,e];k._matMult(i),z._matMult(i),R._matMult(i),D._matMult(i)}const O=t.stretch+t.fixed,V=r.stretch+r.fixed;return{tl:k,tr:z,bl:R,br:D,tex:{x:a.paddedRect.x+Qh+O,y:a.paddedRect.y+Qh+V,w:s.stretch+s.fixed-O,h:l.stretch+l.fixed-V},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:F,minFontScaleX:I/o/P,minFontScaleY:S/o/C,isSDF:i}};if(r&&(a.stretchX||a.stretchY)){const t=iu(u,g,f),e=iu(d,_,m);for(let i=0;i0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const c=(null===(u=a.image)||void 0===u?void 0:u.content)&&(a.image.textFitWidth||a.image.textFitHeight)?Xc(a):{x1:a.left,y1:a.top,x2:a.right,y2:a.bottom};c.y1=c.y1*o-l[0],c.y2=c.y2*o+l[2],c.x1=c.x1*o-l[3],c.x2=c.x2*o+l[1];const d=a.collisionPadding;if(d&&(c.x1-=d[0]*o,c.y1-=d[1]*o,c.x2+=d[2]*o,c.y2+=d[3]*o),h){const t=new n(c.x1,c.y1),e=new n(c.x2,c.y1),i=new n(c.x1,c.y2),r=new n(c.x2,c.y2),s=h*Math.PI/180;t._rotate(s),e._rotate(s),i._rotate(s),r._rotate(s),c.x1=Math.min(t.x,e.x,i.x,r.x),c.x2=Math.max(t.x,e.x,i.x,r.x),c.y1=Math.min(t.y,e.y,i.y,r.y),c.y2=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,c.x1,c.y1,c.x2,c.y2,i,r,s)}this.boxEndIndex=t.length}}class au{constructor(t=[],e=ou){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.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,r=e[t];for(;t>0;){const s=t-1>>1,n=e[s];if(i(r,n)>=0)break;e[t]=n,t=s}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,s=e[t];for(;t=0)break;e[t]=n,t=r}e[t]=s}}function ou(t,e){return te?1:0}function lu(t,e=1,i=!1){let r=1/0,s=1/0,a=-1/0,o=-1/0;const l=t[0];for(let t=0;ta)&&(a=e.x),(!t||e.y>o)&&(o=e.y)}const c=Math.min(a-r,o-s);let h=c/2;const u=new au([],cu);if(0===c)return new n(r,s);for(let e=r;ed.d||!d.d)&&(d=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-d.d<=e||(h=r.h/2,u.push(new hu(r.p.x-h,r.p.y-h,h,t)),u.push(new hu(r.p.x+h,r.p.y-h,h,t)),u.push(new hu(r.p.x-h,r.p.y+h,h,t)),u.push(new hu(r.p.x+h,r.p.y+h,h,t)),p+=4)}return i&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function cu(t,e){return e.max-t.max}function hu(t,e,i,r){this.p=new n(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let s=0;st.y!=o.y>t.y&&t.x<(o.x-s.x)*(t.y-s.y)/(o.y-s.y)+s.x&&(i=!i),r=Math.min(r,qa(t,s,o))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var uu;t.aq=void 0,(uu=t.aq||(t.aq={}))[uu.center=1]="center",uu[uu.left=2]="left",uu[uu.right=3]="right",uu[uu.top=4]="top",uu[uu.bottom=5]="bottom",uu[uu["top-left"]=6]="top-left",uu[uu["top-right"]=7]="top-right",uu[uu["bottom-left"]=8]="bottom-left",uu[uu["bottom-right"]=9]="bottom-right";const du=7,pu=Number.POSITIVE_INFINITY;function fu(t,e){return e[1]!==pu?function(t,e,i){let r=0,s=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-du;break;case"bottom-right":case"bottom-left":case"bottom":s=-i+du}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,s]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const s=e/Math.SQRT2;switch(t){case"top-right":case"top-left":r=s-du;break;case"bottom-right":case"bottom-left":r=-s+du;break;case"bottom":r=-e+du;break;case"top":r=e-du}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function mu(t,e,i){var r;const s=t.layout,n=null===(r=s.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(e,{},i);if(n){const t=n.values,e=[];for(let i=0;it*tc));r.startsWith("top")?s[1]-=du:r.startsWith("bottom")&&(s[1]+=du),e[i+1]=s}return new Qt(e)}const a=s.get("text-variable-anchor");if(a){let r;r=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[s.get("text-radial-offset").evaluate(e,{},i)*tc,pu]:s.get("text-offset").evaluate(e,{},i).map((t=>t*tc));const n=[];for(const t of a)n.push(t,fu(t,r));return new Qt(n)}return null}function gu(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 _u(e,i,r,s,n,a,o,l,c,h,u){let d=a.textMaxSize.evaluate(i,{});void 0===d&&(d=o);const p=e.layers[0].layout,f=p.get("icon-offset").evaluate(i,{},u),m=xu(r.horizontal),g=o/24,_=e.tilePixelRatio*g,y=e.tilePixelRatio*d/24,x=e.tilePixelRatio*l,v=e.tilePixelRatio*p.get("symbol-spacing"),b=p.get("text-padding")*e.tilePixelRatio,w=function(t,e,i,r=1){const s=t.get("icon-padding").evaluate(e,{},i),n=s&&s.values;return[n[0]*r,n[1]*r,n[2]*r,n[3]*r]}(p,i,u,e.tilePixelRatio),T=p.get("text-max-angle")/180*Math.PI,S="viewport"!==p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),A="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),E=p.get("symbol-placement"),P=v/2,C=p.get("icon-text-fit");let M;s&&"none"!==C&&(e.allowVerticalPlacement&&r.vertical&&(M=Kc(s,r.vertical,C,p.get("icon-text-fit-padding"),f,g)),m&&(s=Kc(s,m,C,p.get("icon-text-fit-padding"),f,g)));const k=(l,d)=>{d.x<0||d.x>=Ma||d.y<0||d.y>=Ma||function(e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_,y,x,v,b,w,T,S,A){const E=e.addToLineVertexArray(i,r);let P,C,M,k,z=0,D=0,R=0,L=0,F=-1,B=-1;const O={};let V=ha("");if(e.allowVerticalPlacement&&s.vertical){const t=l.layout.get("text-rotate").evaluate(b,{},S)+90;M=new nu(c,i,h,u,d,s.vertical,p,f,m,t),o&&(k=new nu(c,i,h,u,d,o,_,y,m,t))}if(n){const r=l.layout.get("icon-rotate").evaluate(b,{}),s="none"!==l.layout.get("icon-text-fit"),a=tu(n,r,T,s),p=o?tu(o,r,T,s):void 0;C=new nu(c,i,h,u,d,n,_,y,!1,r),z=4*a.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[Yc*l.layout.get("icon-size").evaluate(b,{})],m[0]>Qc&&I(`${e.layerIds[0]}: Value for "icon-size" is >= ${Jc}. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Yc*w.compositeIconSizes[0].evaluate(b,{},S),Yc*w.compositeIconSizes[1].evaluate(b,{},S)],(m[0]>Qc||m[1]>Qc)&&I(`${e.layerIds[0]}: Value for "icon-size" is >= ${Jc}. Reduce your "icon-size".`)),e.addSymbols(e.icon,a,m,v,x,b,t.ah.none,i,E.lineStartIndex,E.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1,p&&(D=4*p.length,e.addSymbols(e.icon,p,m,v,x,b,t.ah.vertical,i,E.lineStartIndex,E.lineLength,-1,S),B=e.icon.placedSymbolArray.length-1)}const N=Object.keys(s.horizontal);for(const r of N){const n=s.horizontal[r];if(!P){V=ha(n.text);const t=l.layout.get("text-rotate").evaluate(b,{},S);P=new nu(c,i,h,u,d,n,p,f,m,t)}const o=1===n.positionedLines.length;if(R+=yu(e,i,n,a,l,m,b,g,E,s.vertical?t.ah.horizontal:t.ah.horizontalOnly,o?N:[r],O,F,w,S),o)break}s.vertical&&(L+=yu(e,i,s.vertical,a,l,m,b,g,E,t.ah.vertical,["vertical"],O,B,w,S));const j=P?P.boxStartIndex:e.collisionBoxArray.length,U=P?P.boxEndIndex:e.collisionBoxArray.length,$=M?M.boxStartIndex:e.collisionBoxArray.length,q=M?M.boxEndIndex:e.collisionBoxArray.length,Z=C?C.boxStartIndex:e.collisionBoxArray.length,G=C?C.boxEndIndex:e.collisionBoxArray.length,W=k?k.boxStartIndex:e.collisionBoxArray.length,H=k?k.boxEndIndex:e.collisionBoxArray.length;let X=-1;const K=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;X=K(P,X),X=K(M,X),X=K(C,X),X=K(k,X);const J=X>-1?1:0;J&&(X*=A/tc),e.glyphOffsetArray.length>=ch.MAX_GLYPHS&&I("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const Y=mu(l,b,S),[Q,tt]=function(e,i){const r=e.length,s=null==i?void 0:i.values;if((null==s?void 0:s.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,F,B,V,j,U,$,q,Z,G,W,H,h,R,L,z,D,J,0,p,X,Q,tt)}(e,d,l,r,s,n,M,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,_,[b,b,b,b],S,c,x,w,A,f,i,a,h,u,o)};if("line"===E)for(const t of qh(i.geometry,0,0,Ma,Ma)){const i=Jh(t,v,T,r.vertical||m,s,24,y,e.overscaling,Ma);for(const r of i)m&&vu(e,m.text,P,r)||k(t,r)}else if("line-center"===E){for(const t of i.geometry)if(t.length>1){const e=Kh(t,T,r.vertical||m,s,24,y);e&&k(t,e)}}else if("Polygon"===i.type)for(const t of xi(i.geometry,0)){const e=lu(t,16);k(t[0],new Zh(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry)k(t,new Zh(t[0].x,t[0].y,0));else if("Point"===i.type)for(const t of i.geometry)for(const e of t)k([e],new Zh(e.x,e.y,0))}function yu(t,e,i,r,s,a,o,l,c,h,u,d,p,f,m){const g=function(t,e,i,r,s,a,o,l){const c=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,h=[];for(const t of e.positionedLines)for(const r of t.positionedGlyphs){if(!r.rect)continue;const a=r.rect||{};let u=Pc+1,d=!0,p=1,f=0;const m=(s||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&e.verticalizable&&(f=t.lineOffset/2-(r.imageName?-(tc-r.metrics.width*r.scale)/2:(r.scale-1)*tc)),r.imageName){const t=o[r.imageName];d=t.sdf,p=t.pixelRatio,u=Mc/p}const _=s?[r.x+g,r.y]:[0,0];let y=s?[0,0]:[r.x+g+i[0],r.y+i[1]-f],x=[0,0];m&&(x=y,y=[0,0]);const v=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-u)*r.scale-g+y[0],w=(-r.metrics.top-u)*r.scale+y[1],I=b+a.w/v*r.scale/p,T=w+a.h/v*r.scale/p,S=new n(b,w),A=new n(I,w),E=new n(b,T),P=new n(I,T);if(m){const t=new n(-g,g-Rc),e=-Math.PI/2,i=tc/2-g,s=new n(5-Rc-i,-(r.imageName?i:0)),a=new n(...x);S._rotateAround(e,t)._add(s)._add(a),A._rotateAround(e,t)._add(s)._add(a),E._rotateAround(e,t)._add(s)._add(a),P._rotateAround(e,t)._add(s)._add(a)}if(c){const t=Math.sin(c),e=Math.cos(c),i=[e,-t,t,e];S._matMult(i),A._matMult(i),E._matMult(i),P._matMult(i)}const C=new n(0,0),M=new n(0,0);h.push({tl:S,tr:A,bl:E,br:P,tex:a,writingMode:e.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:C,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return h}(0,i,l,s,a,o,r,t.allowVerticalPlacement),_=t.textSizeData;let y=null;"source"===_.kind?(y=[Yc*s.layout.get("text-size").evaluate(o,{})],y[0]>Qc&&I(`${t.layerIds[0]}: Value for "text-size" is >= ${Jc}. Reduce your "text-size".`)):"composite"===_.kind&&(y=[Yc*f.compositeTextSizes[0].evaluate(o,{},m),Yc*f.compositeTextSizes[1].evaluate(o,{},m)],(y[0]>Qc||y[1]>Qc)&&I(`${t.layerIds[0]}: Value for "text-size" is >= ${Jc}. Reduce your "text-size".`)),t.addSymbols(t.text,g,y,l,a,o,h,e,c.lineStartIndex,c.lineLength,p,m);for(const e of u)d[e]=t.text.placedSymbolArray.length-1;return 4*g.length}function xu(t){for(const e in t)return t[e];return null}function vu(t,e,i,r){const s=t.compareText;if(e in s){const t=s[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const s=bu[15&i];if(!s)throw new Error("Unrecognized array type.");const[n]=new Uint16Array(t,2,1),[a]=new Uint32Array(t,4,1);return new wu(a,n,s,t)}constructor(t,e=64,i=Float64Array,r){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=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=bu.indexOf(this.ArrayType),n=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,o=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,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+n+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+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Iu(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:n,nodeSize:a}=this,o=[0,s.length-1,0],l=[];for(;o.length;){const c=o.pop()||0,h=o.pop()||0,u=o.pop()||0;if(h-u<=a){for(let a=u;a<=h;a++){const o=n[2*a],c=n[2*a+1];o>=t&&o<=i&&c>=e&&c<=r&&l.push(s[a])}continue}const d=u+h>>1,p=n[2*d],f=n[2*d+1];p>=t&&p<=i&&f>=e&&f<=r&&l.push(s[d]),(0===c?t<=p:e<=f)&&(o.push(u),o.push(d-1),o.push(1-c)),(0===c?i>=p:r>=f)&&(o.push(d+1),o.push(h),o.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:s,nodeSize:n}=this,a=[0,r.length-1,0],o=[],l=i*i;for(;a.length;){const c=a.pop()||0,h=a.pop()||0,u=a.pop()||0;if(h-u<=n){for(let i=u;i<=h;i++)Eu(s[2*i],s[2*i+1],t,e)<=l&&o.push(r[i]);continue}const d=u+h>>1,p=s[2*d],f=s[2*d+1];Eu(p,f,t,e)<=l&&o.push(r[d]),(0===c?t-i<=p:e-i<=f)&&(a.push(u),a.push(d-1),a.push(1-c)),(0===c?t+i>=p:e+i>=f)&&(a.push(d+1),a.push(h),a.push(1-c))}return o}}function Iu(t,e,i,r,s,n){if(s-r<=i)return;const a=r+s>>1;Tu(t,e,a,r,s,n),Iu(t,e,i,r,a-1,1-n),Iu(t,e,i,a+1,s,1-n)}function Tu(t,e,i,r,s,n){for(;s>r;){if(s-r>600){const a=s-r+1,o=i-r+1,l=Math.log(a),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(a-c)/a)*(o-a/2<0?-1:1);Tu(t,e,i,Math.max(r,Math.floor(i-o*c/a+h)),Math.min(s,Math.floor(i+(a-o)*c/a+h)),n)}const a=e[2*i+n];let o=r,l=s;for(Su(t,e,r,i),e[2*s+n]>a&&Su(t,e,r,s);oa;)l--}e[2*r+n]===a?Su(t,e,r,l):(l++,Su(t,e,l,s)),l<=i&&(r=l+1),i<=l&&(s=l-1)}}function Su(t,e,i,r){Au(t,i,r),Au(e,2*i,2*r),Au(e,2*i+1,2*r+1)}function Au(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function Eu(t,e,i,r){const s=t-i,n=e-r;return s*s+n*n}var Pu;t.be=void 0,(Pu=t.be||(t.be={})).create="create",Pu.load="load",Pu.fullLoad="fullLoad";let Cu=null,Mu=[];const ku=1e3/60,zu="loadTime",Du="fullLoadTime",Ru={mark(t){performance.mark(t)},frame(t){const e=t;null!=Cu&&Mu.push(e-Cu),Cu=e},clearMetrics(){Cu=null,Mu=[],performance.clearMeasures(zu),performance.clearMeasures(Du);for(const e in t.be)performance.clearMarks(t.be[e])},getPerformanceMetrics(){performance.measure(zu,t.be.create,t.be.load),performance.measure(Du,t.be.create,t.be.fullLoad);const e=performance.getEntriesByName(zu)[0].duration,i=performance.getEntriesByName(Du)[0].duration,r=Mu.length,s=1/(Mu.reduce(((t,e)=>t+e),0)/r/1e3),n=Mu.filter((t=>t>ku)).reduce(((t,e)=>t+(e-ku)/ku),0);return{loadTime:e,fullLoadTime:i,fps:s,percentDroppedFrames:n/(r+n)*100,totalFrames:r}}};t.$=ea,t.A=eo,t.B=function(t){if(null==A){const e=t.navigator?t.navigator.userAgent:null;A=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return A},t.C=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new wh((()=>this.process())),this.subscription=function(t,e,i,r){return t.addEventListener(e,i,!1),{unsubscribe:()=>{t.removeEventListener(e,i,!1)}}}(this.target,"message",(t=>this.receive(t))),this.globalScope=S(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}sendAsync(t,e){return new Promise(((i,r)=>{const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[s]={resolve:i,reject:r},e&&e.signal.addEventListener("abort",(()=>{delete this.resolveRejects[s];const e={id:s,type:"",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)}),{once:!0});const n=[],a=Object.assign(Object.assign({},t),{id:s,sourceMapId:this.mapId,origin:location.origin,data:ws(t.data,n)});this.target.postMessage(a,{transfer:n})}))}receive(t){const e=t.data,i=e.id;if(!("file://"!==e.origin&&"file://"!==location.origin&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(""===e.type){delete this.tasks[i];const t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(S(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,i){return e(this,void 0,void 0,(function*(){if(""===i.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(i.error?e.reject(Is(i.error)):e.resolve(Is(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=Is(i.data),r=new AbortController;this.abortControllers[t]=r;try{const s=yield this.messageHandlers[i.type](i.sourceMapId,e,r);this.completeTask(t,null,s)}catch(e){this.completeTask(t,e)}}))}completeTask(t,e,i){const r=[];delete this.abortControllers[t];const s={id:t,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?ws(e):null,data:ws(i,r)};this.target.postMessage(s,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},t.D=qs,t.E=Z,t.F=function(){var t=new eo(16);return eo!=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},t.G=F,t.H=function(t,e,i){var r,s,n,a,o,l,c,h,u,d,p,f,m=i[0],g=i[1],_=i[2];return e===t?(t[12]=e[0]*m+e[4]*g+e[8]*_+e[12],t[13]=e[1]*m+e[5]*g+e[9]*_+e[13],t[14]=e[2]*m+e[6]*g+e[10]*_+e[14],t[15]=e[3]*m+e[7]*g+e[11]*_+e[15]):(s=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],u=e[8],d=e[9],p=e[10],f=e[11],t[0]=r=e[0],t[1]=s,t[2]=n,t[3]=a,t[4]=o,t[5]=l,t[6]=c,t[7]=h,t[8]=u,t[9]=d,t[10]=p,t[11]=f,t[12]=r*m+o*g+u*_+e[12],t[13]=s*m+l*g+d*_+e[13],t[14]=n*m+c*g+p*_+e[14],t[15]=a*m+h*g+f*_+e[15]),t},t.I=kc,t.J=function(t,e,i){var r=i[0],s=i[1],n=i[2];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]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.K=ro,t.L=function(t,e){const i={};for(let r=0;r{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const i of t){const t=window.document.createElement("source");N(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))},t.a3=function(){return y++},t.a4=Pn,t.a5=ch,t.a6=Pr,t.a7=Ra,t.a8=Ls,t.a9=Vh,t.aA=function(t){if("custom"===t.type)return new bh(t);switch(t.type){case"background":return new _h(t);case"circle":return new oo(t);case"fill":return new nl(t);case"fill-extrusion":return new Cl(t);case"heatmap":return new xo(t);case"hillshade":return new wo(t);case"line":return new Zl(t);case"raster":return new vh(t);case"symbol":return new fh(t)}},t.aB=b,t.aC=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!X(t.version,e.version))return[{command:"setStyle",args:[e]}];X(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),X(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),X(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),X(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),X(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),X(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),X(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),X(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),X(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),X(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]});const r={},s=[];!function(t,e,i,r){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||Y(s,i,r));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?X(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&tt(t,e,s)?K(i,{command:"setGeoJSONSourceData",args:[s,e[s].data]}):Q(s,e,i,r)):J(s,e,i))}(t.sources,e.sources,s,r);const n=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):n.push(t)})),i=i.concat(s),function(t,e,i){e=e||[];const r=(t=t||[]).map(it),s=e.map(it),n=t.reduce(rt,{}),a=e.reduce(rt,{}),o=r.slice(),l=Object.create(null);let c,h,u,d,p;for(let t=0,e=0;t@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,s)=>{const n=r||s;return e[i]=!n||n.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e},t.ab=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i},t.ac=m,t.ad=function(t,e,i){var r=Math.sin(i),s=Math.cos(i),n=e[0],a=e[1],o=e[2],l=e[3],c=e[4],h=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*s+c*r,t[1]=a*s+h*r,t[2]=o*s+u*r,t[3]=l*s+d*r,t[4]=c*s-n*r,t[5]=h*s-a*r,t[6]=u*s-o*r,t[7]=d*s-l*r,t},t.ae=function(t){var e=new eo(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},t.af=ao,t.ag=function(t,e){let i=0,r=0;if("constant"===t.kind)r=t.layoutSize;else if("source"!==t.kind){const{interpolationType:s,minZoom:n,maxZoom:a}=t,o=s?m(ke.interpolationFactor(s,e,n,a),0,1):0;"camera"===t.kind?r=Me.number(t.minSize,t.maxSize,o):i=o}return{uSizeT:i,uSize:r}},t.ai=function(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:s}){return"source"===t.kind?r/Yc:"composite"===t.kind?Me.number(r/Yc,s/Yc,i):e},t.aj=nh,t.ak=function(t,e,i,r){const s=e.y-t.y,a=e.x-t.x,o=r.y-i.y,l=r.x-i.x,c=o*a-l*s;if(0===c)return null;const h=(l*(t.y-i.y)-o*(t.x-i.x))/c;return new n(t.x+h*a,t.y+h*s)},t.al=qh,t.am=Ba,t.an=io,t.ao=function(t){let e=1/0,i=1/0,r=-1/0,s=-1/0;for(const n of t)e=Math.min(e,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),s=Math.max(s,n.y);return[e,i,r,s]},t.ap=tc,t.ar=eh,t.as=function(t,e){var i=e[0],r=e[1],s=e[2],n=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],f=e[12],m=e[13],g=e[14],_=e[15],y=i*o-r*a,x=i*l-s*a,v=i*c-n*a,b=r*l-s*o,w=r*c-n*o,I=s*c-n*l,T=h*m-u*f,S=h*g-d*f,A=h*_-p*f,E=u*g-d*m,P=u*_-p*m,C=d*_-p*g,M=y*C-x*P+v*E+b*A-w*S+I*T;return M?(t[0]=(o*C-l*P+c*E)*(M=1/M),t[1]=(s*P-r*C-n*E)*M,t[2]=(m*I-g*w+_*b)*M,t[3]=(d*w-u*I-p*b)*M,t[4]=(l*A-a*C-c*S)*M,t[5]=(i*C-s*A+n*S)*M,t[6]=(g*v-f*I-_*x)*M,t[7]=(h*I-d*v+p*x)*M,t[8]=(a*P-o*A+c*T)*M,t[9]=(r*A-i*P-n*T)*M,t[10]=(f*w-m*v+_*y)*M,t[11]=(u*v-h*w-p*y)*M,t[12]=(o*S-a*E-l*T)*M,t[13]=(i*E-r*S+s*T)*M,t[14]=(m*x-f*b-g*y)*M,t[15]=(h*b-u*x+d*y)*M,t):null},t.at=gu,t.au=Gc,t.av=wu,t.aw=function(){const t={},e=G.$version;for(const i in G.$root){const r=G.$root[i];if(r.required){let s=null;s="version"===i?e:"array"===r.type?[]:{},null!=s&&(t[i]=s)}}return t},t.ax=Ts,t.ay=O,t.az=function(t){t=t.slice();const e=Object.create(null);for(let i=0;it*tc))}let x=o?"center":r.get("text-justify").evaluate(s,{},e.canonical);const v=r.get("symbol-placement"),b="point"===v?r.get("text-max-width").evaluate(s,{},e.canonical)*tc:0,w=()=>{e.bucket.allowVerticalPlacement&&As(n)&&(f.vertical=Bc(m,e.glyphMap,e.glyphPositions,e.imagePositions,h,b,a,g,"left",p,_,t.ah.vertical,!0,v,d,u))};if(!o&&y){const i=new Set;if("auto"===x)for(let t=0;te(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw 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.`)}})),t.e=_,t.f=t=>new Promise(((e,i)=>{const r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>{r.src=P}))},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const s=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=t.byteLength?URL.createObjectURL(s):P})),t.g=L,t.h=(t,e)=>V(_(t,{type:"json"}),e),t.i=S,t.j=q,t.k=$,t.l=(t,e)=>V(_(t,{type:"arrayBuffer"}),e),t.m=V,t.n=function(t){return new Ic(t).readFields(Sc,[])},t.o=go,t.p=Cc,t.q=Xs,t.r=fs,t.s=N,t.t=_s,t.u=Ss,t.v=G,t.w=I,t.x=ps,t.y=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}},t.z=Me})),i("worker",["./shared"],(function(t){class e{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,i){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.aA(i);e._featureFilter=t.a6(e.filter),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=t.bi(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const e=t.map((t=>this._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let s=this.familiesBySource[r];s||(s=this.familiesBySource[r]={});const n=i.sourceLayer||"_geojsonTileLayer";let a=s[n];a||(a=s[n]=[]),a.push(e)}}}class i{constructor(e){const i={},r=[];for(const t in e){const s=e[t],n=i[t]={};for(const t in s){const e=s[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),n[t]={rect:i,metrics:e.metrics}}}const{w:s,h:n}=t.p(r),a=new t.o({width:s||1,height:n||1});for(const r in e){const s=e[r];for(const e in s){const n=s[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const o=i[r][e].rect;t.o.copy(n.bitmap,a,{x:0,y:0},{x:o.x+1,y:o.y+1},n.bitmap)}}this.image=a,this.positions=i}}t.bj("GlyphAtlas",i);class r{constructor(e){this.tileID=new t.Q(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,r,n,a){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.a4;const o=new t.bk(Object.keys(e.layers).sort()),l=new t.bl(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},h={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:n},u=r.familiesBySource[this.source];for(const i in u){const r=e.layers[i];if(!r)continue;1===r.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const a=o.encode(i),d=[];for(let t=0;t=i.maxzoom||"none"!==i.visibility&&(s(e,this.zoom,n),(c[i.id]=i.createBucket({index:l.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:a,sourceID:this.source})).populate(d,h,this.tileID.canonical),l.bucketLayerIDs.push(e.map((t=>t.id))))}}const d=t.aF(h.glyphDependencies,(t=>Object.keys(t).map(Number)));this.inFlightDependencies.forEach((t=>null==t?void 0:t.abort())),this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(d).length){const t=new AbortController;this.inFlightDependencies.push(t),p=a.sendAsync({type:"GG",data:{stacks:d,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const f=Object.keys(h.iconDependencies);let m=Promise.resolve({});if(f.length){const t=new AbortController;this.inFlightDependencies.push(t),m=a.sendAsync({type:"GI",data:{icons:f,source:this.source,tileID:this.tileID,type:"icons"}},t)}const g=Object.keys(h.patternDependencies);let _=Promise.resolve({});if(g.length){const t=new AbortController;this.inFlightDependencies.push(t),_=a.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const[y,x,v]=yield Promise.all([p,m,_]),b=new i(y),w=new t.bm(x,v);for(const e in c){const i=c[e];i instanceof t.a5?(s(i.layers,this.zoom,n),t.bn({bucket:i,glyphMap:y,glyphPositions:b.positions,imageMap:x,imagePositions:w.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):i.hasPattern&&(i instanceof t.bo||i instanceof t.bp||i instanceof t.bq)&&(s(i.layers,this.zoom,n),i.addFeatures(h,this.tileID.canonical,w.patternPositions))}return this.status="done",{buckets:Object.values(c).filter((t=>!t.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,imageAtlas:w,glyphMap:this.returnDependencies?y:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?b.positions:null}}))}}function s(e,i,r){const s=new t.a8(i);for(const t of e)t.recalculate(s,r)}class n{constructor(t,e,i){this.actor=t,this.layerIndex=e,this.availableImages=i,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const r=yield t.l(e.request,i);try{return{vectorTile:new t.br.VectorTile(new t.bs(r.data)),rawData:r.data,cacheControl:r.cacheControl,expires:r.expires}}catch(t){const i=new Uint8Array(r.data);let s=`Unable to parse the tile at ${e.request.url}, `;throw s+=31===i[0]&&139===i[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.messge}`,new Error(s)}}))}loadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid,s=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bt(e.request),n=new r(e);this.loading[i]=n;const a=new AbortController;n.abort=a;try{const r=yield this.loadVectorTile(e,a);if(delete this.loading[i],!r)return null;const o=r.rawData,l={};r.expires&&(l.expires=r.expires),r.cacheControl&&(l.cacheControl=r.cacheControl);const c={};if(s){const t=s.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}n.vectorTile=r.vectorTile;const h=n.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[i]=n,this.fetching[i]={rawTileData:o,cacheControl:l,resourceTiming:c};try{const e=yield h;return t.e({rawTileData:o.slice(0)},e,l,c)}finally{delete this.fetching[i]}}catch(t){throw delete this.loading[i],n.status="done",this.loaded[i]=n,t}}))}reloadTile(e){return t._(this,void 0,void 0,(function*(){const i=e.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[i];if(r.showCollisionBoxes=e.showCollisionBoxes,"parsing"===r.status){const e=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor);let s;if(this.fetching[i]){const{rawTileData:r,cacheControl:n,resourceTiming:a}=this.fetching[i];delete this.fetching[i],s=t.e({rawTileData:r.slice(0)},e,n,a)}else s=e;return s}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){const t=this.loading,i=e.uid;t&&t[i]&&t[i].abort&&(t[i].abort.abort(),delete t[i])}))}removeTile(e){return t._(this,void 0,void 0,(function*(){this.loaded&&this.loaded[e.uid]&&delete this.loaded[e.uid]}))}}class a{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:i,encoding:r,rawImageData:s,redFactor:n,greenFactor:a,blueFactor:o,baseShift:l}=e,c=s.width+2,h=s.height+2,u=t.b(s)?new t.R({width:c,height:h},yield t.bu(s,-1,-1,c,h)):s,d=new t.bv(i,u,r,n,a,o,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d}))}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}function o(t,e){if(0!==t.length){l(t[0],e);for(var i=1;i=Math.abs(o)?i-l+o:o-l+i,i=l}i+r>=0!=!!e&&t.reverse()}var c=t.bw((function t(e,i){var r,s=e&&e.type;if("FeatureCollection"===s)for(r=0;r>31}function S(t,e){for(var i=t.loadGeometry(),r=t.type,s=0,n=0,a=i.length,o=0;ot},C=Math.fround||(M=new Float32Array(1),t=>(M[0]=+t,M[0]));var M;const k=3,z=5,D=6;class R{constructor(t){this.options=Object.assign(Object.create(P),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:r}=this.options;e&&console.time("total time");const s=`prepare ${t.length} points`;e&&console.time(s),this.points=t;const n=[];for(let e=0;e=i;t--){const i=+Date.now();a=this.trees[t]=this._createTree(this._cluster(a,t)),e&&console.log("z%d: %d clusters in %dms",t,a.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let s=180===t[2]?180:((t[2]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,s=180;else if(i>s){const t=this.getClusters([i,r,180,n],e),a=this.getClusters([-180,r,s,n],e);return t.concat(a)}const a=this.trees[this._limitZoom(e)],o=a.range(B(i),O(n),B(s),O(r)),l=a.data,c=[];for(const t of o){const e=this.stride*t;c.push(l[e+z]>1?L(l,e,this.clusterProps):this.points[l[e+k]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",s=this.trees[i];if(!s)throw new Error(r);const n=s.data;if(e*this.stride>=n.length)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,i-1)),o=s.within(n[e*this.stride],n[e*this.stride+1],a),l=[];for(const e of o){const i=e*this.stride;n[i+4]===t&&l.push(n[i+z]>1?L(n,i,this.clusterProps):this.points[n[i+k]])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],s=Math.pow(2,t),{extent:n,radius:a}=this.options,o=a/n,l=(i-o)/s,c=(i+1+o)/s,h={features:[]};return this._addTileFeatures(r.range((e-o)/s,l,(e+1+o)/s,c),r.data,e,i,s,h),0===e&&this._addTileFeatures(r.range(1-o/s,l,1,c),r.data,s,i,s,h),e===s-1&&this._addTileFeatures(r.range(0,l,o/s,c),r.data,-1,i,s,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,s){const n=this.getChildren(e);for(const e of n){const n=e.properties;if(n&&n.cluster?s+n.point_count<=r?s+=n.point_count:s=this._appendLeaves(t,n.cluster_id,i,r,s):s1;let l,c,h;if(o)l=F(e,t,this.clusterProps),c=e[t],h=e[t+1];else{const i=this.points[e[t+k]];l=i.properties;const[r,s]=i.geometry.coordinates;c=B(r),h=O(s)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*s-i)),Math.round(this.options.extent*(h*s-r))]],tags:l};let d;d=o||this.options.generateId?e[t+k]:this.points[e[t+k]].id,void 0!==d&&(u.id=d),n.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:r,reduce:s,minPoints:n}=this.options,a=i/(r*Math.pow(2,e)),o=t.data,l=[],c=this.stride;for(let i=0;ie&&(p+=o[i+z])}if(p>d&&p>=n){let t,n=r*d,a=h*d,f=-1;const m=((i/c|0)<<5)+(e+1)+this.points.length;for(const r of u){const l=r*c;if(o[l+2]<=e)continue;o[l+2]=e;const h=o[l+z];n+=o[l]*h,a+=o[l+1]*h,o[l+4]=m,s&&(t||(t=this._map(o,i,!0),f=this.clusterProps.length,this.clusterProps.push(t)),s(t,this._map(o,l)))}o[i+4]=m,l.push(n/p,a/p,1/0,m,-1,p),s&&l.push(f)}else{for(let t=0;t1)for(const t of u){const i=t*c;if(!(o[i+2]<=e)){o[i+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+z]>1){const r=this.clusterProps[t[e+D]];return i?Object.assign({},r):r}const r=this.points[t[e+k]].properties,s=this.options.map(r);return i&&s===r?Object.assign({},s):s}}function L(t,e,i){return{type:"Feature",id:t[e+k],properties:F(t,e,i),geometry:{type:"Point",coordinates:[(r=t[e],360*(r-.5)),V(t[e+1])]}};var r}function F(t,e,i){const r=t[e+z],s=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,n=t[e+D],a=-1===n?{}:Object.assign({},i[n]);return Object.assign(a,{cluster:!0,cluster_id:t[e+k],point_count:r,point_count_abbreviated:s})}function B(t){return t/360+.5}function O(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function V(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function N(t,e,i,r){for(var s,n=r,a=i-e>>1,o=i-e,l=t[e],c=t[e+1],h=t[i],u=t[i+1],d=e+3;dn)s=d,n=p;else if(p===n){var f=Math.abs(d-a);fr&&(s-e>3&&N(t,e,s,r),t[s+2]=n,i-s>3&&N(t,s,i,r))}function j(t,e,i,r,s,n){var a=s-i,o=n-r;if(0!==a||0!==o){var l=((t-i)*a+(e-r)*o)/(a*a+o*o);l>1?(i=s,r=n):l>0&&(i+=a*l,r+=o*l)}return(a=t-i)*a+(o=e-r)*o}function U(t,e,i,r){var s={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)$(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r0&&(a+=r?(s*c-l*n)/2:Math.sqrt(Math.pow(l-s,2)+Math.pow(c-n,2))),s=l,n=c}var h=e.length-3;e[2]=1,N(e,0,h,i),e[h+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function W(t,e,i,r){for(var s=0;s1?1:i}function K(t,e,i,r,s,n,a,o){if(r/=e,n>=(i/=e)&&a=r)return null;for(var l=[],c=0;c=i&&f=r)){var m=[];if("Point"===d||"MultiPoint"===d)J(u,m,i,r,s);else if("LineString"===d)Y(u,m,i,r,s,!1,o.lineMetrics);else if("MultiLineString"===d)tt(u,m,i,r,s,!1);else if("Polygon"===d)tt(u,m,i,r,s,!0);else if("MultiPolygon"===d)for(var g=0;g=i&&a<=r&&(e.push(t[n]),e.push(t[n+1]),e.push(t[n+2]))}}function Y(t,e,i,r,s,n,a){for(var o,l,c=Q(t),h=0===s?it:rt,u=t.start,d=0;di&&(l=h(c,p,f,g,_,i),a&&(c.start=u+o*l)):y>r?x=i&&(l=h(c,p,f,g,_,i),v=!0),x>r&&y<=r&&(l=h(c,p,f,g,_,r),v=!0),!n&&v&&(a&&(c.end=u+o*l),e.push(c),c=Q(t)),a&&(u+=o)}var b=t.length-3;p=t[b],f=t[b+1],m=t[b+2],(y=0===s?p:f)>=i&&y<=r&&et(c,p,f,m),b=c.length-3,n&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&et(c,c[0],c[1],c[2]),c.length&&e.push(c)}function Q(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function tt(t,e,i,r,s,n){for(var a=0;aa.maxX&&(a.maxX=h),u>a.maxY&&(a.maxY=u)}return a}function ct(t,e,i,r){var s=e.geometry,n=e.type,a=[];if("Point"===n||"MultiPoint"===n)for(var o=0;o0&&e.size<(s?a:r))i.numPoints+=e.length/3;else{for(var o=[],l=0;la)&&(i.numSimplified++,o.push(e[l]),o.push(e[l+1])),i.numPoints++;s&&function(t,e){for(var i=0,r=0,s=t.length,n=s-2;r0===e)for(r=0,s=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r1&&console.time("creation"),d=this.tiles[u]=lt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+e;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(d.source=t,s){if(e===l.maxZoom||e===s)continue;var f=1<1&&console.time("clipping");var m,g,_,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,I=.5+b,T=1+b;m=g=_=y=null,x=K(t,h,i-b,i+I,0,d.minX,d.maxX,l),v=K(t,h,i+w,i+T,0,d.minX,d.maxX,l),t=null,x&&(m=K(x,h,r-b,r+I,1,d.minY,d.maxY,l),g=K(x,h,r+w,r+T,1,d.minY,d.maxY,l),x=null),v&&(_=K(v,h,r-b,r+I,1,d.minY,d.maxY,l),y=K(v,h,r+w,r+T,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd("clipping"),o.push(m||[],e+1,2*i,2*r),o.push(g||[],e+1,2*i,2*r+1),o.push(_||[],e+1,2*i+1,2*r),o.push(y||[],e+1,2*i+1,2*r+1)}}},ut.prototype.getTile=function(t,e,i){var r=this.options,s=r.extent,n=r.debug;if(t<0||t>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,h=e,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[dt(c,h,u)];return l&&l.source?(n>1&&console.log("found parent tile z%d-%d-%d",c,h,u),n>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,t,e,i),n>1&&console.timeEnd("drilling down"),this.tiles[o]?at(this.tiles[o],s):null):null};class gt extends n{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(e,i){return t._(this,void 0,void 0,(function*(){const i=e.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return null;const s=new class{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.W,this.length=e.length,this._features=e}feature(e){return new class{constructor(e){this._feature=e,this.extent=t.W,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.P(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.P(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return h.call(this,t,e,i)}}(this._features[e])}}(r.features);let n=E(s);return 0===n.byteOffset&&n.byteLength===n.buffer.byteLength||(n=new Uint8Array(n)),{vectorTile:s,rawData:n.buffer}}))}loadData(e){return t._(this,void 0,void 0,(function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const r=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.bt(e.request);this._pendingRequest=new AbortController;try{this._pendingData=this.loadAndProcessGeoJSON(e,this._pendingRequest),this._geoJSONIndex=e.cluster?new R(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},s={},n={accumulated:null,zoom:0},a={properties:null},o=Object.keys(i);for(const e of o){const[n,a]=i[e],o=t.bA(a),l=t.bA("string"==typeof n?[n,["accumulated"],["get",e]]:n);r[e]=o.value,s[e]=l.value}return e.map=t=>{a.properties=t;const e={};for(const t of o)e[t]=r[t].evaluate(n,a);return e},e.reduce=(t,e)=>{a.properties=e;for(const e of o)n.accumulated=t[e],t[e]=s[e].evaluate(n,a)},e}(e)).load((yield this._pendingData).features):new ut(yield this._pendingData,e.geojsonVtOptions),this.loaded={};const i={};if(r){const t=r.finish();t&&(i.resourceTiming={},i.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}return i}catch(e){if(delete this._pendingRequest,t.bz(e))return{abandoned:!0};throw e}}))}getData(){return t._(this,void 0,void 0,(function*(){return this._pendingData}))}reloadTile(t){const e=this.loaded;return e&&e[t.uid]?super.reloadTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){let r=yield this.loadGeoJSON(e,i);if(delete this._pendingRequest,"object"!=typeof r)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(c(r,!0),e.filter){const i=t.bA(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const s=r.features.filter((t=>i.value.evaluate({zoom:0},t)));r={type:"FeatureCollection",features:s}}return r}))}loadGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){const{promoteId:r}=e;if(e.request){const s=yield t.h(e.request,i);return this._dataUpdateable=ft(s.data,r)?mt(s.data,r):void 0,s.data}if("string"==typeof e.data)try{const t=JSON.parse(e.data);return this._dataUpdateable=ft(t,r)?mt(t,r):void 0,t}catch(t){throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}if(!e.dataDiff)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${e.source}`);return function(t,e,i){var r,s,n,a;if(e.removeAll&&t.clear(),e.remove)for(const i of e.remove)t.delete(i);if(e.add)for(const r of e.add){const e=pt(r,i);null!=e&&t.set(e,r)}if(e.update)for(const i of e.update){let e=t.get(i.id);if(null==e)continue;const o=!i.removeAllProperties&&((null===(r=i.removeProperties)||void 0===r?void 0:r.length)>0||(null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0);if((i.newGeometry||i.removeAllProperties||o)&&(e=Object.assign({},e),t.set(i.id,e),o&&(e.properties=Object.assign({},e.properties))),i.newGeometry&&(e.geometry=i.newGeometry),i.removeAllProperties)e.properties={};else if((null===(n=i.removeProperties)||void 0===n?void 0:n.length)>0)for(const t of i.removeProperties)Object.prototype.hasOwnProperty.call(e.properties,t)&&delete e.properties[t];if((null===(a=i.addOrUpdateProperties)||void 0===a?void 0:a.length)>0)for(const{key:t,value:r}of i.addOrUpdateProperties)e.properties[t]=r}}(this._dataUpdateable,e.dataDiff,r),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}}))}removeSource(e){return t._(this,void 0,void 0,(function*(){this._pendingRequest&&this._pendingRequest.abort()}))}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset)}}class _t{constructor(e){this.self=e,this.actor=new t.C(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=t.bg,this.self.removeProtocol=t.bh,this.self.registerRTLTextPlugin=e=>{if(t.bB.isParsed())throw new Error("RTL text plugin already registered.");t.bB.setMethods(e)},this.actor.registerMessageHandler("LDT",((t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e))),this.actor.registerMessageHandler("RDT",((e,i)=>t._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,i.source).removeTile(i)})))),this.actor.registerMessageHandler("GCEZ",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterExpansionZoom(i)})))),this.actor.registerMessageHandler("GCC",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterChildren(i)})))),this.actor.registerMessageHandler("GCL",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterLeaves(i)})))),this.actor.registerMessageHandler("LD",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e))),this.actor.registerMessageHandler("GD",((t,e)=>this._getWorkerSource(t,e.type,e.source).getData())),this.actor.registerMessageHandler("LT",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e))),this.actor.registerMessageHandler("RT",((t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e))),this.actor.registerMessageHandler("AT",((t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e))),this.actor.registerMessageHandler("RMT",((t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e))),this.actor.registerMessageHandler("RS",((e,i)=>t._(this,void 0,void 0,(function*(){if(!this.workerSources[e]||!this.workerSources[e][i.type]||!this.workerSources[e][i.type][i.source])return;const t=this.workerSources[e][i.type][i.source];delete this.workerSources[e][i.type][i.source],void 0!==t.removeSource&&t.removeSource(i)})))),this.actor.registerMessageHandler("RM",(e=>t._(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e]})))),this.actor.registerMessageHandler("SR",((e,i)=>t._(this,void 0,void 0,(function*(){this.referrer=i})))),this.actor.registerMessageHandler("SRPS",((t,e)=>this._syncRTLPluginState(t,e))),this.actor.registerMessageHandler("IS",((e,i)=>t._(this,void 0,void 0,(function*(){this.self.importScripts(i)})))),this.actor.registerMessageHandler("SI",((t,e)=>this._setImages(t,e))),this.actor.registerMessageHandler("UL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(i.layers,i.removedIds)})))),this.actor.registerMessageHandler("SL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(i)}))))}_setImages(e,i){return t._(this,void 0,void 0,(function*(){this.availableImages[e]=i;for(const t in this.workerSources[e]){const r=this.workerSources[e][t];for(const t in r)r[t].availableImages=i}}))}_syncRTLPluginState(e,i){return t._(this,void 0,void 0,(function*(){if(t.bB.isParsed())return t.bB.getState();if("loading"!==i.pluginStatus)return t.bB.setState(i),i;const e=i.pluginURL;if(this.self.importScripts(e),t.bB.isParsed()){const i={pluginStatus:"loaded",pluginURL:e};return t.bB.setState(i),i}throw t.bB.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let i=this.layerIndexes[t];return i||(i=this.layerIndexes[t]=new e),i}_getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={sendAsync:(e,i)=>(e.targetMapId=t,this.actor.sendAsync(e,i))};switch(e){case"vector":this.workerSources[t][e][i]=new n(r,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][i]=new gt(r,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][i]=new this.externalWorkerSourceTypes[e](r,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][i]}_getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new a),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new _t(self)),_t})),i("index",["exports","./shared"],(function(t,e){var i="4.3.2";let r,s;const n={now:"undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:t=>new Promise(((i,r)=>{const s=requestAnimationFrame(i);t.signal.addEventListener("abort",(()=>{cancelAnimationFrame(s),r(e.c())}))})),getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(r||(r=document.createElement("a")),r.href=t,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(null==s&&(s=matchMedia("(prefers-reduced-motion: reduce)")),s.matches)}};class a{static testProp(t){if(!a.docStyle)return t[0];for(let e=0;e{window.removeEventListener("click",a.suppressClickInternal,!0)}),0)}static getScale(t){const e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,i,r){const s=i.boundingClientRect;return new e.P((r.clientX-s.left)/i.x-t.clientLeft,(r.clientY-s.top)/i.y-t.clientTop)}static mousePos(t,e){const i=a.getScale(t);return a.getPoint(t,i,e)}static touchPos(t,e){const i=[],r=a.getScale(t);for(let s=0;s{l&&d(l),l=null,u=!0},c.onerror=()=>{h=!0,l=null},c.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(t){let i,r,s,n;t.resetRequestQueue=()=>{i=[],r=0,s=0,n={}},t.addThrottleControl=t=>{const e=s++;return n[e]=t,e},t.removeThrottleControl=t=>{delete n[t],l()},t.getImage=(t,r,s=!0)=>new Promise(((n,a)=>{o.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),e.e(t,{type:"image"}),i.push({abortController:r,requestParameters:t,supportImageRefresh:s,state:"queued",onError:t=>{a(t)},onSuccess:t=>{n(t)}}),l()}));const a=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:i,supportImageRefresh:s,onError:n,onSuccess:a,abortController:o}=t,h=!1===s&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0));r++;const u=h?c(i,o):e.m(i,o);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?a(i):i.data&&a({data:yield(d=i.data,"function"==typeof createImageBitmap?e.d(d):e.f(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(e){delete t.abortController,n(e)}finally{r--,l()}var d})),l=()=>{const t=(()=>{for(const t of Object.keys(n))if(n[t]())return!0;return!1})()?e.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=r;e0;e++){const t=i.shift();t.abortController.signal.aborted?e--:a(t)}},c=(t,i)=>new Promise(((r,s)=>{const n=new Image,a=t.url,o=t.credentials;o&&"include"===o?n.crossOrigin="use-credentials":(o&&"same-origin"===o||!e.s(a))&&(n.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{n.src="",s(e.c())})),n.fetchPriority="high",n.onload=()=>{n.onerror=n.onload=null,r({data:n})},n.onerror=()=>{n.onerror=n.onload=null,i.signal.aborted||s(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."))},n.src=a}))}(p||(p={})),p.resetRequestQueue();class f{constructor(t){this._transformRequestFn=t}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function m(t){var i=new e.A(3);return i[0]=t[0],i[1]=t[1],i[2]=t[2],i}var g,_=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t};g=new e.A(3),e.A!=Float32Array&&(g[0]=0,g[1]=0,g[2]=0);var y=function(t){var e=t[0],i=t[1];return e*e+i*i};function x(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:r,url:s}of t){const t=`${r}${s}`;-1===i.indexOf(t)&&(i.push(t),e.push({id:r,url:s}))}}return e}function v(t,e,i){const r=t.split("?");return r[0]+=`${e}${i}`,r.join("?")}!function(){var t=new e.A(2);e.A!=Float32Array&&(t[0]=0,t[1]=0)}();class b{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this.update(e,r)}update(t,i,r){const{width:s,height:n}=t,a=!(this.size&&this.size[0]===s&&this.size[1]===n||r),{context:o}=this,{gl:l}=o;if(this.useMipmap=Boolean(i&&i.useMipmap),l.bindTexture(l.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===l.RGBA&&(!i||!1!==i.premultiply)),a)this.size=[s,n],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texImage2D(l.TEXTURE_2D,0,this.format,this.format,l.UNSIGNED_BYTE,t):l.texImage2D(l.TEXTURE_2D,0,this.format,s,n,0,this.format,l.UNSIGNED_BYTE,t.data);else{const{x:i,y:a}=r||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||e.b(t)?l.texSubImage2D(l.TEXTURE_2D,0,i,a,l.RGBA,l.UNSIGNED_BYTE,t):l.texSubImage2D(l.TEXTURE_2D,0,i,a,s,n,l.RGBA,l.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&l.generateMipmap(l.TEXTURE_2D)}bind(t,e,i){const{context:r}=this,{gl:s}=r;s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function w(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class I extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,i){let r=!0;const s=i.data||i.spriteData;return this._validateStretch(i.stretchX,s&&s.width)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,s&&s.height)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.j(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(t,e){if(!t)return!0;let i=0;for(const r of t){if(r[0]{let r=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(r=!1);this.isLoaded()||r?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){const i={};for(const r of t){let t=this.getImage(r);t||(this.fire(new e.k("styleimagemissing",{id:r})),t=this.getImage(r)),t?i[r]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const i=this.patterns[t],r=this.getImage(t);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},s=new e.I(i,r);this.patterns[t]={bin:i,position:s}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const e=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new b(t,this.atlasImage,e.RGBA),this.atlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:r}=e.p(t),s=this.atlasImage;s.resize({width:i||1,height:r||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],r=i.x+1,n=i.y+1,a=this.getImage(t).data,o=a.width,l=a.height;e.R.copy(a,s,{x:0,y:0},{x:r,y:n},{width:o,height:l}),e.R.copy(a,s,{x:0,y:l-1},{x:r,y:n-1},{width:o,height:1}),e.R.copy(a,s,{x:0,y:0},{x:r,y:n+l},{width:o,height:1}),e.R.copy(a,s,{x:o-1,y:0},{x:r-1,y:n},{width:1,height:l}),e.R.copy(a,s,{x:0,y:0},{x:r+o,y:n},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),w(t)&&this.updateImage(i,t)}}}const T=1e20;function S(t,e,i,r,s,n,a,o,l){for(let c=e;c-1);l++,n[l]=o,a[l]=c,a[l+1]=T}for(let o=0,l=0;o65535)throw new Error("glyphs > 65535 not supported");if(e.ranges[s])return{stack:t,id:i,glyph:r};if(!this.url)throw new Error("glyphsUrl is not set");if(!e.requests[s]){const i=E.loadGlyphRange(t,s,this.url,this.requestManager);e.requests[s]=i}const n=yield e.requests[s];for(const t in n)this._doesCharSupportLocalGlyph(+t)||(e.glyphs[+t]=n[+t]);return e.ranges[s]=!0,{stack:t,id:i,glyph:n[i]||null}}))}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(e.u["CJK Unified Ideographs"](t)||e.u["Hangul Syllables"](t)||e.u.Hiragana(t)||e.u.Katakana(t))}_tinySDF(t,i,r){const s=this.localIdeographFontFamily;if(!s)return;if(!this._doesCharSupportLocalGlyph(r))return;let n=t.tinySDF;if(!n){let e="400";/bold/i.test(i)?e="900":/medium/i.test(i)?e="500":/light/i.test(i)&&(e="200"),n=t.tinySDF=new E.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:s,fontWeight:e})}const a=n.draw(String.fromCharCode(r));return{id:r,bitmap:new e.o({width:a.width||60,height:a.height||60},a.data),metrics:{width:a.glyphWidth/2||24,height:a.glyphHeight/2||24,left:a.glyphLeft/2+.5||0,top:a.glyphTop/2-27.5||-8,advance:a.glyphAdvance/2||24,isDoubleResolution:!0}}}}E.loadGlyphRange=function(t,i,r,s){return e._(this,void 0,void 0,(function*(){const n=256*i,a=n+255,o=s.transformRequest(r.replace("{fontstack}",t).replace("{range}",`${n}-${a}`),"Glyphs"),l=yield e.l(o,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${n}-${a}`);const c={};for(const t of e.n(l.data))c[t.id]=t;return c}))},E.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:s="sans-serif",fontWeight:n="normal",fontStyle:a="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const o=this.size=t+4*e,l=this._createCanvas(o),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${a} ${n} ${t}px ${s}`,c.textBaseline="alphabetic",c.textAlign="left",c.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:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:s,actualBoundingBoxRight:n}=this.ctx.measureText(t),a=Math.ceil(i),o=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(n-s))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),c=o+2*this.buffer,h=l+2*this.buffer,u=Math.max(c*h,0),d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;f.clearRect(m,m,o,l),f.fillText(t,m,m+a);const y=f.getImageData(m,m,o,l);_.fill(T,0,u),g.fill(0,0,u);for(let t=0;t0?t*t:0,g[r]=t<0?t*t:0}}S(_,0,0,c,h,c,this.f,this.v,this.z),S(g,m,m,o,l,c,this.f,this.v,this.z);for(let t=0;t1&&(a=t[++n]);const l=Math.abs(o-a.left),c=Math.abs(o-a.right),h=Math.min(l,c);let u;const d=e/i*(r+1);if(a.isDash){const t=r-Math.abs(d);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+d*d);this.data[s+o]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r&&r.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let s=0,n=t[s];for(let e=0;e1&&(n=t[++s]);const i=Math.abs(e-n.left),a=Math.abs(e-n.right),o=Math.min(i,a);this.data[r+e]=Math.max(0,Math.min(255,(n.isDash?o:-o)+128))}}addDash(t,i){const r=i?7:0,s=2*r+1;if(this.nextRow+s>this.height)return e.w("LineAtlas out of space"),null;let n=0;for(let e=0;e{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[z]}numActive(){return Object.keys(this.active).length}}const R=Math.floor(n.hardwareConcurrency/2);let L,F;function B(){return L||(L=new D),L}D.workerCount=e.B(globalThis)?Math.max(Math.min(R,3),1):1;class O{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let t=0;t{t.remove()})),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e)}}function V(){return F||(F=new O(B(),e.G),F.registerMessageHandler("GR",((t,i,r)=>e.m(i,r)))),F}function N(t,i){const r=e.F();return e.H(r,r,[1,1,0]),e.J(r,r,[.5*t.width,.5*t.height,1]),e.K(r,r,t.calculatePosMatrix(i.toUnwrapped()))}function j(t,e,i,r,s,n){const a=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(s&&s.layers,e,t.id),o=n.maxPitchScaleFactor(),l=t.tilesIn(r,o,a);l.sort(U);const c=[];for(const r of l)c.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t._state,r.queryGeometry,r.cameraQueryGeometry,r.scale,s,n,o,N(t.transform,r.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,s=r.wrappedTileID,n=i[s]=i[s]||{};for(const i in t){const r=t[i],s=n[i]=n[i]||{},a=e[i]=e[i]||[];for(const t of r)s[t.featureIndex]||(s[t.featureIndex]=!0,a.push(t))}}return e}(c);for(const e in h)h[e].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function U(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function $(t,i,r){return e._(this,void 0,void 0,(function*(){let s=t;if(t.url?s=(yield e.h(i.transformRequest(t.url,"Source"),r)).data:yield n.frameAsync(r),!s)return null;const a=e.L(e.e(s,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in s&&s.vector_layers&&(a.vectorLayerIds=s.vector_layers.map((t=>t.id))),a}))}class q{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof e.M?new e.M(t.lng,t.lat):e.M.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.M?new e.M(t.lng,t.lat):e.M.convert(t),this}extend(t){const i=this._sw,r=this._ne;let s,n;if(t instanceof e.M)s=t,n=t;else{if(!(t instanceof q))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(q.convert(t)):this.extend(e.M.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.M.convert(t)):this;if(s=t._sw,n=t._ne,!s||!n)return this}return i||r?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),r.lng=Math.max(n.lng,r.lng),r.lat=Math.max(n.lat,r.lat)):(this._sw=new e.M(s.lng,s.lat),this._ne=new e.M(n.lng,n.lat)),this}getCenter(){return new e.M((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 e.M(this.getWest(),this.getNorth())}getSouthEast(){return new e.M(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:i,lat:r}=e.M.convert(t);let s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&s}static convert(t){return t instanceof q?t:t?new q(t):t}static fromLngLat(t,i=0){const r=360*i/40075017,s=r/Math.cos(Math.PI/180*t.lat);return new q(new e.M(t.lng-s,t.lat-r),new e.M(t.lng+s,t.lat+r))}}class Z{constructor(t,e,i){this.bounds=q.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),r=Math.floor(e.N(this.bounds.getWest())*i),s=Math.floor(e.O(this.bounds.getNorth())*i),n=Math.ceil(e.N(this.bounds.getEast())*i),a=Math.ceil(e.O(this.bounds.getSouth())*i);return t.x>=r&&t.x=s&&t.y{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i}}))}else t.actor=this.dispatcher.getActor(),r="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e)}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_afterTileLoadWorkerResponse(t,e){if(e&&e.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class W extends e.E{constructor(t,i,r,s){super(),this.id=t,this.dispatcher=r,this.setEventedParent(s),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.L(i,["url","scheme","tileSize"]))}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield $(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(e.e(this,t),t.bounds&&(this.tileBounds=new Z(t.bounds,this.minzoom,this.maxzoom)),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new e.j(t))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const i=yield p.getImage(this.map._requestManager.transformRequest(e,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const e=this.map.painter.context,r=e.gl,s=i.data;t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0}):(t.texture=new b(e,s,r.RGBA,{useMipmap:!0}),t.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST),e.extTextureFilterAnisotropic&&r.texParameterf(r.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class H extends W{constructor(t,i,r,s){super(t,i,r,s),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield p.getImage(r,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&i.cacheControl&&i.expires&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const s=e.b(r)&&e.S()?r:yield this.readImageNow(r),n={type:this.type,uid:t.uid,source:this.id,rawImageData:s,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||"expired"===t.state){t.actor=this.dispatcher.getActor();const e=yield t.actor.sendAsync({type:"LDT",data:n});t.dem=e,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.U()){const i=t.width+2,r=t.height+2;try{return new e.R({width:i,height:r},yield e.V(t,-1,-1,i,r))}catch(t){}}return n.getImageData(t,1)}))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),s=(i.x-1+r)%r,n=0===i.x?t.wrap-1:t.wrap,a=(i.x+1+r)%r,o=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.Q(t.overscaledZ,n,i.z,s,i.y).key]={backfilled:!1},l[new e.Q(t.overscaledZ,o,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new e.Q(t.overscaledZ,n,i.z,s,i.y-1).key]={backfilled:!1},l[new e.Q(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.Q(t.overscaledZ,o,i.z,a,i.y-1).key]={backfilled:!1}),i.y+10&&e.e(s,{resourceTiming:r}),this.fire(new e.k("data",Object.assign(Object.assign({},s),{sourceDataType:"metadata"}))),this.fire(new e.k("data",Object.assign(Object.assign({},s),{sourceDataType:"content"})))}catch(t){if(this._pendingLoads--,this._removed)return void this.fire(new e.k("dataabort",{dataType:"source"}));this.fire(new e.j(t))}}))}loaded(){return 0===this._pendingLoads}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const r=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var K=e.X([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class J extends e.E{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield p.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,e&&e.data&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,this.fire(new e.j(t))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const i=t.map(e.Y.fromLngLat);this.tileID=function(t){let i=1/0,r=1/0,s=-1/0,n=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),s=Math.max(s,e.x),n=Math.max(n,e.y);const a=Math.max(s-i,n-r),o=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,o);return new e.a0(o,Math.floor((i+s)/2*l),Math.floor((r+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const r=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new e.Z,this._boundsArray.emplaceBack(r[0].x,r[0].y,0,0),this._boundsArray.emplaceBack(r[1].x,r[1].y,e.W,0),this._boundsArray.emplaceBack(r[3].x,r[3].y,0,e.W),this._boundsArray.emplaceBack(r[2].x,r[2].y,e.W,e.W),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new e.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,K.members)),this.boundsSegments||(this.boundsSegments=e.$.simpleSegment(0,0,4,2)),this.texture||(this.texture=new b(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Y extends J{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push(this.map._requestManager.transformRequest(e,"Source").url);try{const t=yield e.a2(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.j(t))}}))}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.j(new e.a1(`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(t){this.map||(this.map=t,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.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,K.members)),this.boundsSegments||(this.boundsSegments=e.$.simpleSegment(0,0,4,2)),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 b(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Q extends J{constructor(t,i,r,s){super(t,i,r,s),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.j(new e.a1(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.j(new e.a1(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.j(new e.a1(`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.j(new e.a1(`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.j(new e.a1(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.j(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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){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,r=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,K.members)),this.boundsSegments||(this.boundsSegments=e.$.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new b(i,this.canvas,r.RGBA,{premultiply:!0});let s=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,s=!0)}s&&this.fire(new e.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const tt={},et=t=>{switch(t){case"geojson":return X;case"image":return J;case"raster":return W;case"raster-dem":return H;case"vector":return G;case"video":return Y;case"canvas":return Q}return tt[t]},it="RTLPluginLoaded";class rt extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=V()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=n.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.k(it))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let st=null;function nt(){return st||(st=new rt),st}class at{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=e.a3(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(t.buckets,i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.a5){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.a5&&i.hasRTLText){this.hasRTLText=!0,nt().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new e.a4}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new b(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new b(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,s,n,a,o,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:s,scale:n,tileSize:this.tileSize,pixelPosMatrix:c,transform:o,params:a,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(t,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const s=r.loadVTLayers(),n=i&&i.sourceLayer?i.sourceLayer:"",a=s._geojsonTileLayer||s[n];if(!a)return;const o=e.a6(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let i=0;it)e=!1;else if(i)if(this.expirationTime{this.remove(t,s)}),i)),this.data[r].push(s),this.order.push(r),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 i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][r];return this.data[i].splice(r,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),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 i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const t of e)this.remove(t.value.tileID,t)}}class lt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,i,r){const s=String(i);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][s]=this.stateChanges[t][s]||{},e.e(this.stateChanges[t][s],r),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==s&&(this.deletedStates[t][e]=null)}else if(this.deletedStates[t]&&null===this.deletedStates[t][s]){this.deletedStates[t][s]={};for(const e in this.state[t][s])r[e]||(this.deletedStates[t][s][e]=null)}else for(const e in r)this.deletedStates[t]&&this.deletedStates[t][s]&&null===this.deletedStates[t][s][e]&&delete this.deletedStates[t][s][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,i){const r=String(i),s=e.e({},(this.state[t]||{})[r],(this.stateChanges[t]||{})[r]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete s[t]}return s}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,i){const r={};for(const t in this.stateChanges){this.state[t]=this.state[t]||{};const i={};for(const r in this.stateChanges[t])this.state[t][r]||(this.state[t][r]={}),e.e(this.state[t][r],this.stateChanges[t][r]),i[r]=this.state[t][r];r[t]=i}for(const t in this.deletedStates){this.state[t]=this.state[t]||{};const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}r[t]=r[t]||{},e.e(r[t],i)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const e in t)t[e].setFeatureState(r,i)}}class ct extends e.E{constructor(t,e,i){super(),this.id=t,this.dispatcher=i,this.on("data",(t=>this._dataHandler(t))),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,r)=>{const s=new(et(e.type))(t,e,i,r);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return s})(t,e,i,this),this._tiles={},this._cache=new ot(0,(t=>this._unloadTile(t))),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new lt,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)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,this.terrain)}_loadTile(t,i,r){return e._(this,void 0,void 0,(function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,i,r)}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.j(i,{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}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 i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(ht).map((t=>t.key))}getRenderableIds(t){const i=[];for(const e in this._tiles)this._isIdRenderable(e,t)&&i.push(this._tiles[e]);return t?i.sort(((t,i)=>{const r=t.tileID,s=i.tileID,n=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),a=new e.P(s.canonical.x,s.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-s.overscaledZ||a.y-n.y||a.x-n.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(ht).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}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,i){return e._(this,void 0,void 0,(function*(){const e=this._tiles[t];e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i))}))}_tileLoaded(t,i,r){t.timeAdded=n.now(),"expired"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),"raster-dem"===this.getSource().type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+s)?i+=s:1===Math.abs(i-s)&&(i-=s)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[n]&&(t.neighboringTiles[n].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const s in this._tiles){let n=this._tiles[s];if(r[s]||!n.hasData()||n.tileID.overscaledZ<=e||n.tileID.overscaledZ>i)continue;let a=n.tileID;for(;n&&n.tileID.overscaledZ>e+1;){const t=n.tileID.scaledTo(n.tileID.overscaledZ-1);n=this._tiles[t.key],n&&n.hasData()&&(a=t)}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){r[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}findLoadedSibling(t){return this._getLoadedTile(t)}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,r=Math.ceil(t.height/this._source.tileSize)+1,s=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?e.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(n)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}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])}}_updateCoveredAndRetainedTiles(t,e,i,r,s,a){const o={},l={},c=Object.keys(t),h=n.now();for(const i of c){const r=t[i],s=this._tiles[i];if(!s||0!==s.fadeEndTime&&s.fadeEndTime<=h)continue;const n=this.findLoadedParent(r,e),a=this.findLoadedSibling(r),c=n||a||null;c&&(this._addTile(c.tileID),o[c.tileID.key]=c.tileID),l[i]=r}this._retainLoadedChildren(l,r,i,t);for(const e in o)t[e]||(this._coveredTiles[e]=!0,t[e]=o[e]);if(a){const e={},i={};for(const t of s)this._tiles[t.key].hasData()?e[t.key]=t:i[t.key]=t;for(const r in i){const s=i[r].children(this._source.maxzoom);this._tiles[s[0].key]&&this._tiles[s[1].key]&&this._tiles[s[2].key]&&this._tiles[s[3].key]&&(e[s[0].key]=t[s[0].key]=s[0],e[s[1].key]=t[s[1].key]=s[1],e[s[2].key]=t[s[2].key]=s[2],e[s[3].key]=t[s[3].key]=s[3],delete i[r])}for(const r in i){const s=i[r],n=this.findLoadedParent(s,this._source.minzoom),a=this.findLoadedSibling(s),o=n||a||null;if(o){e[o.tileID.key]=t[o.tileID.key]=o.tileID;for(const t in e)e[t].isChildOf(o.tileID)&&delete e[t]}}for(const t in this._tiles)e[t]||(this._coveredTiles[t]=!0)}}update(t,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.Q(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(r=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const s=t.coveringZoomLevel(this._source),n=Math.max(s-ct.maxOverzooming,this._source.minzoom),a=Math.max(s+ct.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of r)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}r=r.concat(Object.values(t))}const o=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,o&&this.fire(new e.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const l=this._updateRetainedTiles(r,s);ut(this._source.type)&&this._updateCoveredAndRetainedTiles(l,n,a,s,r,i);for(const t in l)this._tiles[t].clearFadeHold();const c=e.ab(this._tiles,l);for(const t of c){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache(),this._updateLoadedSiblingTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var i;const r={},s={},n=Math.max(e-ct.maxOverzooming,this._source.minzoom),a=Math.max(e+ct.maxUnderzooming,this._source.minzoom),o={};for(const i of t){const t=this._addTile(i);r[i.key]=i,t.hasData()||ethis._source.maxzoom){const t=a.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){r[t.key]=t;continue}}else{const t=a.children(this._source.maxzoom);if(r[t[0].key]&&r[t[1].key]&&r[t[2].key]&&r[t[3].key])continue}let o=t.wasRequested();for(let e=a.overscaledZ-1;e>=n;--e){const n=a.scaledTo(e);if(s[n.key])break;if(s[n.key]=!0,t=this.getTile(n),!t&&o&&(t=this._addTile(n)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||o)&&(r[n.key]=n),o=t.wasRequested(),e)break}}}return r}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_updateLoadedSiblingTileCache(){this._loadedSiblingTiles={};for(const t in this._tiles){const e=this._tiles[t].tileID,i=this._getLoadedTile(e);this._loadedSiblingTiles[e.key]=i}}_addTile(t){let i=this._tiles[t.key];if(i)return i;i=this._cache.getAndRemove(t),i&&(this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,i)));const r=i;return i||(i=new at(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._tiles[t.key]=i,r||this._source.fire(new e.k("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_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?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){const e=t.sourceDataType;"source"===t.dataType&&"metadata"===e&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===e&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,i,r){const s=[],n=this.transform;if(!n)return s;const a=r?n.getCameraQueryGeometry(t):t,o=t.map((t=>n.pointCoordinate(t,this.terrain))),l=a.map((t=>n.pointCoordinate(t,this.terrain))),c=this.getIds();let h=1/0,u=1/0,d=-1/0,p=-1/0;for(const t of l)h=Math.min(h,t.x),u=Math.min(u,t.y),d=Math.max(d,t.x),p=Math.max(p,t.y);for(let t=0;t=0&&g[1].y+m>=0){const t=o.map((t=>a.getTilePoint(t))),e=l.map((t=>a.getTilePoint(t)));s.push({tile:r,tileID:a,queryGeometry:t,cameraQueryGeometry:e,scale:f})}}return s}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.posMatrix=this.transform.calculatePosMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(ut(this._source.type)){const t=n.now();for(const e in this._tiles)if(this._tiles[e].fadeEndTime>=t)return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function ht(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function ut(t){return"raster"===t||"image"===t||"video"===t}ct.maxOverzooming=10,ct.maxUnderzooming=3;class dt{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t0?(s-a)/o:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}function pt(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class ft{constructor(t,e,i){const r=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||r<0||e>this.height)return[];const o=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t0}hitTestCircle(t,e,i,r,s){const n=t-i,a=t+i,o=e-i,l=e+i;if(a<0||n>this.width||l<0||o>this.height)return!1;const c=[];return this._forEachCell(n,o,a,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),c.length>0}_queryCell(t,e,i,r,s,n,a,o){const{seenUids:l,hitTest:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const s=this.bboxes;for(const a of u)if(!l.box[a]){l.box[a]=!0;const u=4*a,d=this.boxKeys[a];if(t<=s[u+2]&&e<=s[u+3]&&i>=s[u+0]&&r>=s[u+1]&&(!o||o(d))&&(!c||!pt(h,d.overlapMode))&&(n.push({key:d,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),c))return!0}}const d=this.circleCells[s];if(null!==d){const s=this.circles;for(const a of d)if(!l.circle[a]){l.circle[a]=!0;const u=3*a,d=this.circleKeys[a];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,r)&&(!o||o(d))&&(!c||!pt(h,d.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(n.push({key:d,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,s,n,a,o){const{circle:l,seenUids:c,overlapMode:h}=a,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!o||o(r))&&!pt(h,r.overlapMode))return n.push(!0),!0}}const d=this.circleCells[s];if(null!==d){const t=this.circles;for(const e of d)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!o||o(r))&&!pt(h,r.overlapMode))return n.push(!0),!0}}}_forEachCell(t,e,i,r,s,n,a,o){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++)if(s.call(this,t,e,i,r,this.xCellCount*l+d,n,a,o))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,s,n){const a=r-t,o=s-e,l=i+n;return l*l>a*a+o*o}_circleAndRectCollide(t,e,i,r,s,n,a){const o=(n-r)/2,l=Math.abs(t-(r+o));if(l>o+i)return!1;const c=(a-s)/2,h=Math.abs(e-(s+c));if(h>c+i)return!1;if(l<=o||h<=c)return!0;const u=l-o,d=h-c;return u*u+d*d<=i*i}}function mt(t,i,r,s,n){const a=e.F();return i?(e.J(a,a,[1/n,1/n,1]),r||e.ad(a,a,s.angle)):e.K(a,s.labelPlaneMatrix,t),a}function gt(t,i,r,s,n){if(i){const i=e.ae(t);return e.J(i,i,[n,n,1]),r||e.ad(i,i,-s.angle),i}return s.glCoordMatrix}function _t(t,i,r){let s;r?(s=[t.x,t.y,r(t.x,t.y),1],e.af(s,s,i)):(s=[t.x,t.y,0,1],function(t,e,i){const r=e[0],s=e[1];t[0]=i[0]*r+i[4]*s+i[12],t[1]=i[1]*r+i[5]*s+i[13],t[3]=i[3]*r+i[7]*s+i[15]}(s,s,i));const n=s[3];return{point:new e.P(s[0]/n,s[1]/n),signedDistanceFromCamera:n,isOccluded:!1}}function yt(t,e){return.5+t/e*.5}function xt(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function vt(t,i,r,s,n,a,o,l,c,h,u,d,p,f,m){const g=s?t.textSizeData:t.iconSizeData,_=e.ag(g,r.transform.zoom),y=[256/r.width*2+1,256/r.height*2+1],x=s?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;x.clear();const v=t.lineVertexArray,b=s?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=r.transform.width/r.transform.height;let I=!1;for(let s=0;sMath.abs(r.x-i.x)*s?{useVertical:!0}:(t===e.ah.vertical?i.yr.x)?{needsFlipping:!0}:null}function It(t,i,r,s,n,a,o,l,c,h,u){const d=r/24,p=i.lineOffsetX*d,f=i.lineOffsetY*d;let m;if(i.numGlyphs>1){const e=i.glyphStartIndex+i.numGlyphs,r=i.lineStartIndex,a=i.lineStartIndex+i.lineLength,c=bt(d,l,p,f,s,i,u,t);if(!c)return{notEnoughRoom:!0};const g=_t(c.first.point,o,t.getElevation).point,_=_t(c.last.point,o,t.getElevation).point;if(n&&!s){const t=wt(i.writingMode,g,_,h);if(t)return t}m=[c.first];for(let n=i.glyphStartIndex+1;n0?o.point:function(t,e,i,r,s,n){return Tt(t,e,i,1,s,n)}(t.tileAnchorPoint,n,r,0,a,t),c=wt(i.writingMode,r,l,h);if(c)return c}const r=Ct(d*l.getoffsetX(i.glyphStartIndex),p,f,s,i.segment,i.lineStartIndex,i.lineStartIndex+i.lineLength,t,u);if(!r||t.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[r]}for(const t of m)e.aj(c,t.point,t.angle);return{}}function Tt(t,e,i,r,s,n){const a=t.add(t.sub(e)._unit()),o=void 0!==s?_t(a,s,n.getElevation).point:At(a.x,a.y,n).point,l=i.sub(o);return i.add(l._mult(r/l.mag()))}function St(t,i,r){const s=i.projectionCache;if(s.projections[t])return s.projections[t];const n=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),a=At(n.x,n.y,i);if(a.signedDistanceFromCamera>0)return s.projections[t]=a.point,s.anyProjectionOccluded=s.anyProjectionOccluded||a.isOccluded,a.point;const o=t-r.direction;return function(t,e,i,r,s){return Tt(t,e,i,r,void 0,s)}(0===r.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(o),i.lineVertexArray.gety(o)),n,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function At(t,i,r){const s=t+r.translation[0],n=i+r.translation[1];let a;return!r.pitchWithMap&&r.projection.useSpecialProjectionForSymbols?(a=r.projection.projectTileCoordinates(s,n,r.unwrappedTileID,r.getElevation),a.point.x=(.5*a.point.x+.5)*r.width,a.point.y=(.5*-a.point.y+.5)*r.height):(a=_t(new e.P(s,n),r.labelPlaneMatrix,r.getElevation),a.isOccluded=!1),a}function Et(t,e,i){return t._unit()._perp()._mult(e*i)}function Pt(t,i,r,s,n,a,o,l,c){if(l.projectionCache.offsets[t])return l.projectionCache.offsets[t];const h=r.add(i);if(t+c.direction=n)return l.projectionCache.offsets[t]=h,h;const u=St(t+c.direction,l,c),d=Et(u.sub(r),o,c.direction),p=r.add(d),f=u.add(d);return l.projectionCache.offsets[t]=e.ak(a,h,p,f)||h,l.projectionCache.offsets[t]}function Ct(t,e,i,r,s,n,a,o,l){const c=r?t-e:t+e;let h=c>0?1:-1,u=0;r&&(h*=-1,u=Math.PI),h<0&&(u+=Math.PI);let d,p=h>0?n+s:n+s+1;o.projectionCache.cachedAnchorPoint?d=o.projectionCache.cachedAnchorPoint:(d=At(o.tileAnchorPoint.x,o.tileAnchorPoint.y,o).point,o.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,y=0,x=0;const v=Math.abs(c),b=[];let w;for(;y+x<=v;){if(p+=h,p=a)return null;y+=x,_=g,m=f;const t={absOffsetX:v,direction:h,distanceFromAnchor:y,previousVertex:_};if(g=St(p,o,t),0===i)b.push(_),w=g.sub(_);else{let e;const r=g.sub(_);e=0===r.mag()?Et(St(p+h,o,t).sub(g),i,h):Et(r,i,h),m||(m=_.add(e)),f=Pt(p,e,g,n,a,m,i,o,t),b.push(m),w=f.sub(m)}x=w.mag()}const I=w._mult((v-y)/x)._add(m||_),T=u+Math.atan2(g.y-_.y,g.x-_.x);return b.push(I),{point:I,angle:l?T:0,path:b}}const Mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function kt(t,e){for(let i=0;i=1;t--)l.push(a.path[t]);for(let t=1;tt.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let m=[];if(l.length>0){const t=l[0].clone(),i=l[0].clone();for(let e=1;e=r.x&&i.x<=s.x&&t.y>=r.y&&i.y<=s.y?[l]:i.xs.x||i.ys.y?[]:e.al([l],r.x,r.y,s.x,s.y)}for(const e of m){n.reset(e,.25*i);let r=0;r=n.length<=.5*i?1:Math.ceil(n.paddedLength/u)+1;for(let e=0;e_t(t,i,e.getElevation)))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,s=1/0,n=-1/0,a=-1/0;for(const o of t){const t=new e.P(o.x+zt,o.y+zt);r=Math.min(r,t.x),s=Math.min(s,t.y),n=Math.max(n,t.x),a=Math.max(a,t.y),i.push(t)}const o=this.grid.query(r,s,n,a).concat(this.ignoredGrid.query(r,s,n,a)),l={},c={};for(const t of o){const r=t.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const s=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.am(i,s)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(t,e,i,r,s,n){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,s,n){const a=i?this.ignoredGrid:this.grid,o={bucketInstanceId:r,featureIndex:s,collisionGroupID:n,overlapMode:e};for(let e=0;e=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t=0&&ethis.projectAndGetPerspectiveRatio(r,t.x,t.y,s,c)));S=t.some((t=>!t.isOccluded)),T=t.map((t=>t.point))}else S=!0;return{box:e.ao(T),allPointsOccluded:!S}}}function Rt(t,i,r){return i*(e.W/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}class Lt{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class Ft{constructor(t,e,i,r,s){this.text=new Lt(t?t.text:null,e,i,s),this.icon=new Lt(t?t.icon:null,e,r,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Bt{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class Ot{constructor(){this.invProjMatrix=e.F(),this.viewportMatrix=e.F(),this.circles=[]}}class Vt{constructor(t,e,i,r,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=s}}class Nt{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function jt(t,i,r,s,n){const{horizontalAlign:a,verticalAlign:o}=e.au(t);return new e.P(-(a-.5)*i+s[0]*n,-(o-.5)*r+s[1]*n)}class Ut{constructor(t,e,i,r,s,n){this.transform=t.clone(),this.terrain=i,this.collisionIndex=new Dt(this.transform,e),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=r,this.retainedQueryData={},this.collisionGroups=new Nt(s),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,r)=>e.getElevation(t,i,r):null}getBucketParts(t,i,r,s){const n=r.getBucket(i),a=r.latestFeatureIndex;if(!n||!a||i.id!==n.layerIds[0])return;const o=r.collisionBoxArray,l=n.layers[0].layout,c=n.layers[0].paint,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),u=r.tileSize/e.W,d=r.tileID.toUnwrapped(),p=this.transform.calculatePosMatrix(d),f="map"===l.get("text-pitch-alignment"),m="map"===l.get("text-rotation-alignment"),g=Rt(r,1,this.transform.zoom),_=this.collisionIndex.mapProjection.translatePosition(this.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),y=this.collisionIndex.mapProjection.translatePosition(this.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),x=mt(p,f,m,this.transform,g);let v=null;if(f){const t=gt(p,f,m,this.transform,g);v=e.K([],this.transform.labelPlaneMatrix,t)}this.retainedQueryData[n.bucketInstanceId]=new Vt(n.bucketInstanceId,a,n.sourceLayerIndex,n.index,r.tileID);const b={bucket:n,layout:l,translationText:_,translationIcon:y,posMatrix:p,unwrappedTileID:d,textLabelPlaneMatrix:x,labelToScreenMatrix:v,scale:h,textPixelRatio:u,holdingForFade:r.holdingForFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:e.ag(n.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(s)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:s,parameters:b})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:b})}attemptAnchorPlacement(t,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_,y,x){const v=e.aq[t.textAnchor],b=[t.textOffset0,t.textOffset1],w=jt(v,r,s,b,n),I=this.collisionIndex.placeCollisionBox(i,d,l,c,h,o,a,g,u.predicate,x,w);if((!y||this.collisionIndex.placeCollisionBox(y,d,l,c,h,o,a,_,u.predicate,x,w).placeable)&&I.placeable){let t;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(t=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:r,height:s,anchor:v,textBoxScale:n,prevAnchor:t},this.markUsedJustification(f,v,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:I}}}placeLayerBucketPart(t,i,r){const{bucket:s,layout:n,translationText:a,translationIcon:o,posMatrix:l,unwrappedTileID:c,textLabelPlaneMatrix:h,labelToScreenMatrix:u,textPixelRatio:d,holdingForFade:p,collisionBoxArray:f,partiallyEvaluatedTextSize:m,collisionGroup:g}=t.parameters,_=n.get("text-optional"),y=n.get("icon-optional"),x=e.ar(n,"text-overlap","text-allow-overlap"),v="always"===x,b=e.ar(n,"icon-overlap","icon-allow-overlap"),w="always"===b,I="map"===n.get("text-rotation-alignment"),T="map"===n.get("text-pitch-alignment"),S="none"!==n.get("icon-text-fit"),A="viewport-y"===n.get("symbol-z-order"),E=v&&(w||!s.hasIconData()||y),P=w&&(v||!s.hasTextData()||_);!s.collisionArrays&&f&&s.deserializeCollisionBoxes(f);const C=this._getTerrainElevationFunc(this.retainedQueryData[s.bucketInstanceId].tileID),M=(t,f,w)=>{var A,M;if(i[t.crossTileID])return;if(p)return void(this.placements[t.crossTileID]=new Bt(!1,!1,!1));let k=!1,z=!1,D=!0,R=null,L={box:null,placeable:!1,offscreen:null},F={box:null,placeable:!1,offscreen:null},B=null,O=null,V=null,N=0,j=0,U=0;f.textFeatureIndex?N=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(N=t.featureIndex),f.verticalTextFeatureIndex&&(j=f.verticalTextFeatureIndex);const $=f.textBox;if($){const i=i=>{let r=e.ah.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(s,r,t))}return r},n=(i,r)=>{if(s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const t of s.writingModes)if(t===e.ah.vertical?(L=r(),F=L):L=i(),L&&L.placeable)break}else L=i()},h=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===h){const r=(e,i)=>{const r=this.collisionIndex.placeCollisionBox(e,x,d,l,c,T,I,a,g.predicate,C);return r&&r.placeable&&(this.markUsedOrientation(s,i,t),this.placedOrientations[t.crossTileID]=i),r};n((()=>r($,e.ah.horizontal)),(()=>{const i=f.verticalTextBox;return s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?r(i,e.ah.vertical):{box:null,offscreen:null}})),i(L&&L.placeable)}else{let p=e.aq[null===(M=null===(A=this.prevPlacement)||void 0===A?void 0:A.variableOffsets[t.crossTileID])||void 0===M?void 0:M.anchor];const m=(i,n,f)=>{const m=i.x2-i.x1,_=i.y2-i.y1,y=t.textBoxScale,v=S&&"never"===b?n:null;let w=null,A="never"===x?1:2,E="never";p&&A++;for(let e=0;em($,f.iconBox,e.ah.horizontal)),(()=>{const i=f.verticalTextBox;return s.allowVerticalPlacement&&(!L||!L.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,f.verticalIconBox,e.ah.vertical):{box:null,occluded:!0,offscreen:null}})),L&&(k=L.placeable,D=L.offscreen);const _=i(L&&L.placeable);if(!k&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(s,e.anchor,t,_))}}}if(B=L,k=B&&B.placeable,D=B&&B.offscreen,t.useRuntimeCollisionCircles){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),o=e.ai(s.textSizeData,m,i),d=n.get("text-padding");O=this.collisionIndex.placeCollisionCircles(x,i,s.lineVertexArray,s.glyphOffsetArray,o,l,c,h,u,r,T,g.predicate,t.collisionCircleDiameter,d,a,C),O.circles.length&&O.collisionDetected&&!r&&e.w("Collisions detected, but collision boxes are not shown"),k=v||O.circles.length>0&&!O.collisionDetected,D=D&&O.offscreen}if(f.iconFeatureIndex&&(U=f.iconFeatureIndex),f.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,b,d,l,c,T,I,o,g.predicate,C,S&&R?R:void 0);F&&F.placeable&&f.verticalIconBox?(V=t(f.verticalIconBox),z=V.placeable):(V=t(f.iconBox),z=V.placeable),D=D&&V.offscreen}const q=_||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,Z=y||0===t.numIconVertices;q||Z?Z?q||(z=z&&k):k=z&&k:z=k=z&&k;const G=z&&V.placeable;if(k&&B.placeable&&this.collisionIndex.insertCollisionBox(B.box,x,n.get("text-ignore-placement"),s.bucketInstanceId,F&&F.placeable&&j?j:N,g.ID),G&&this.collisionIndex.insertCollisionBox(V.box,b,n.get("icon-ignore-placement"),s.bucketInstanceId,U,g.ID),O&&k&&this.collisionIndex.insertCollisionCircles(O.circles,x,n.get("text-ignore-placement"),s.bucketInstanceId,N,g.ID),r&&this.storeCollisionData(s.bucketInstanceId,w,f,B,V,O),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===s.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new Bt(k||E,z||P,D||s.justReloaded),i[t.crossTileID]=!0};if(A){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=s.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];M(s.symbolInstances.get(i),s.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=n>=0&&e!==n?0:r.crossTileID)}markUsedOrientation(t,i,r){const s=i===e.ah.horizontal||i===e.ah.horizontalOnly?i:0,n=i===e.ah.vertical?i:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const e of a)t.text.placedSymbolArray.get(e).placedOrientation=s;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},n=e?e.variableOffsets:{},a=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],n=s[t];n?(this.opacities[t]=new Ft(n,r,e.text,e.icon),i=i||e.text!==n.text.placed||e.icon!==n.icon.placed):(this.opacities[t]=new Ft(null,r,e.text,e.icon,e.skipFade),i=i||e.text||e.icon)}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new Ft(e,r,!1,!1);s.isHidden()||(this.opacities[t]=s,i=i||e.text.placed||e.icon.placed)}}for(const t in n)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=n[t]);for(const t in a)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=a[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(t,i,r,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const n=t.layers[0],a=n.layout,o=new Ft(null,0,!1,!1,!0),l=a.get("text-allow-overlap"),c=a.get("icon-allow-overlap"),h=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===a.get("text-rotation-alignment"),d="map"===a.get("text-pitch-alignment"),p="none"!==a.get("icon-text-fit"),f=new Ft(null,0,l&&(c||!t.hasIconData()||a.get("icon-optional")),c&&(l||!t.hasTextData()||a.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const m=(t,e,i)=>{for(let r=0;r0,y=this.placedOrientations[s.crossTileID],x=y===e.ah.vertical,v=y===e.ah.horizontal||y===e.ah.horizontalOnly;if(n>0||a>0){const e=Jt(c.text);m(t.text,n,x?Yt:e),m(t.text,a,v?Yt:e);const i=c.text.isHidden();[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex].forEach((e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||x?1:0)})),s.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const r=this.variableOffsets[s.crossTileID];r&&this.markUsedJustification(t,r.anchor,s,y);const o=this.placedOrientations[s.crossTileID];o&&(this.markUsedJustification(t,"left",s,o),this.markUsedOrientation(t,o,s))}if(_){const e=Jt(c.icon),i=!(p&&s.verticalPlacedIconSymbolIndex&&x);s.placedIconSymbolIndex>=0&&(m(t.icon,s.numIconVertices,i?e:Yt),t.icon.placedSymbolArray.get(s.placedIconSymbolIndex).hidden=c.icon.isHidden()),s.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,s.numVerticalIconVertices,i?Yt:e),t.icon.placedSymbolArray.get(s.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const b=g&&g.has(i)?g.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const r=t.collisionArrays[i];if(r){let i=new e.P(0,0);if(r.textBox||r.verticalTextBox){let e=!0;if(h){const t=this.variableOffsets[l];t?(i=jt(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(d?this.transform.angle:-this.transform.angle)):e=!1}if(r.textBox||r.verticalTextBox){let s;r.textBox&&(s=x),r.verticalTextBox&&(s=v),$t(t.textCollisionBox.collisionVertexArray,c.text.placed,!e||s,b.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){const e=Boolean(!v&&r.verticalIconBox);let s;r.iconBox&&(s=e),r.verticalIconBox&&(s=!e),$t(t.iconCollisionBox.collisionVertexArray,c.icon.placed,s,b.icon,p?i.x:0,p?i.y:0)}}}}if(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.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(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(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function $t(t,e,i,r,s,n){r&&0!==r.length||(r=[0,0,0,0]);const a=r[0]-zt,o=r[1]-zt,l=r[2]-zt,c=r[3]-zt;t.emplaceBack(e?1:0,i?1:0,s||0,n||0,a,o),t.emplaceBack(e?1:0,i?1:0,s||0,n||0,l,o),t.emplaceBack(e?1:0,i?1:0,s||0,n||0,l,c),t.emplaceBack(e?1:0,i?1:0,s||0,n||0,a,c)}const qt=Math.pow(2,25),Zt=Math.pow(2,24),Gt=Math.pow(2,17),Wt=Math.pow(2,16),Ht=Math.pow(2,9),Xt=Math.pow(2,8),Kt=Math.pow(2,1);function Jt(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*qt+e*Zt+i*Gt+e*Wt+i*Ht+e*Xt+i*Kt+e}const Yt=0;function Qt(){return{isOccluded:(t,e,i)=>!1,getPitchedTextCorrection:(t,e,i)=>1,get useSpecialProjectionForSymbols(){return!1},projectTileCoordinates(t,e,i,r){throw new Error("Not implemented.")},translatePosition:(t,e,i,r)=>function(t,e,i,r,s=!1){if(!i[0]&&!i[1])return[0,0];const n=s?"map"===r?t.angle:0:"viewport"===r?-t.angle:0;if(n){const t=Math.sin(n),e=Math.cos(n);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[s?i[0]:Rt(e,i[0],t.zoom),s?i[1]:Rt(e,i[1],t.zoom)]}(t,e,i,r),getCircleRadiusCorrection:t=>1}}class te{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,s){const n=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex!this._forceFullPlacement&&n.now()-r>2;for(;this._currentPlacementIndex>=0;){const r=e[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=n)&&(!r.maxzoom||r.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new te(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,s))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const ie=512/e.W/2;class re{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this._symbolsByKey={};const s=new Map;for(let t=0;t({x:Math.floor(t.anchorX*ie),y:Math.floor(t.anchorY*ie)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(r.positions.length>128){const t=new e.av(r.positions.length,16,Uint16Array);for(const{x:e,y:i}of r.positions)t.add(e,i);t.finish(),delete r.positions,r.index=t}this._symbolsByKey[t]=r}}getScaledCoordinates(t,i){const{x:r,y:s,z:n}=this.tileID.canonical,{x:a,y:o,z:l}=i.canonical,c=ie/Math.pow(2,l-n),h=(o*e.W+t.anchorY)*c,u=s*e.W*ie;return{x:Math.floor((a*e.W+t.anchorX)*c-r*e.W*ie),y:Math.floor(h-u)}}findMatches(t,e,i){const r=this.tileID.canonical.zt))}}class se{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ne{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],r={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),r[s.tileID.key]=s}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;tt.overscaledZ)for(const i in s){const n=s[i];n.tileID.isChildOf(t)&&n.findMatches(e.symbolInstances,t,r)}else{const n=s[t.scaledTo(Number(i)).key];n&&n.findMatches(e.symbolInstances,t,r)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const oe=(t,i)=>e.t(t,i&&i.filter((t=>"source.canvas"!==t.identifier))),le=e.aw();class ce extends e.E{constructor(t,i={}){super(),this._rtlPluginLoaded=()=>{for(const t in this.sourceCaches){const e=this.sourceCaches[t].getSource().type;"vector"!==e&&"geojson"!==e||this.sourceCaches[t].reload()}},this.map=t,this.dispatcher=new O(B(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.imageManager=new I,this.imageManager.setEventedParent(this),this.glyphManager=new E(t._requestManager,i.localIdeographFontFamily),this.lineAtlas=new k(256,512),this.crossTileSymbolIndex=new ae,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new e.ax,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",e.ay()),nt().on(it,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}loadURL(t,i={},r){this.fire(new e.k("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const s=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController,e.h(s,this._loadStyleRequest).then((t=>{this._loadStyleRequest=null,this._load(t.data,i,r)})).catch((t=>{this._loadStyleRequest=null,t&&this.fire(new e.j(t))}))}loadJSON(t,i={},r){this.fire(new e.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,n.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,r)})).catch((()=>{}))}loadEmpty(){this.fire(new e.k("dataloading",{dataType:"style"})),this._load(le,{validate:!1})}_load(t,i,r){var s;const n=i.transformStyle?i.transformStyle(r,t):t;if(!i.validate||!oe(this,e.x(n))){this._loaded=!0,this.stylesheet=n;for(const t in n.sources)this.addSource(t,n.sources[t],{validate:!1});n.sprite?this._loadSprite(n.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(n.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this.map.setTerrain(null!==(s=this.stylesheet.terrain)&&void 0!==s?s:null),this.fire(new e.k("data",{dataType:"style"})),this.fire(new e.k("style.load"))}}_createLayers(){const t=e.az(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const i of t){const t=e.aA(i);t.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=t}}_loadSprite(t,i=!1,r=void 0){let s;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(t,i,r,s){return e._(this,void 0,void 0,(function*(){const a=x(t),o=r>1?"@2x":"",l={},c={};for(const{id:t,url:r}of a){const n=i.transformRequest(v(r,o,".json"),"SpriteJSON");l[t]=e.h(n,s);const a=i.transformRequest(v(r,o,".png"),"SpriteImage");c[t]=p.getImage(a,s)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(t,i){return e._(this,void 0,void 0,(function*(){const e={};for(const r in t){e[r]={};const s=n.getImageCanvasContext((yield i[r]).data),a=(yield t[r]).data;for(const t in a){const{width:i,height:n,x:o,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=a[t];e[r][t]={data:null,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:n,x:o,y:l,context:s}}}}return e}))}(l,c)}))}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const r=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of r)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const r in t[e]){const s="default"===e?r:`${e}:${r}`;this._spritesImagesIds[e].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,t[e][r],!1):this.imageManager.addImage(s,t[e][r]),i&&(this._changedImages[s]=!0)}}})).catch((t=>{this._spriteRequest=null,s=t,this.fire(new e.j(s))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"})),r&&r(s)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}_validateLayer(t){const i=this.sourceCaches[t.source];if(!i)return;const r=t.sourceLayer;if(!r)return;const s=i.getSource();("geojson"===s.type||s.vectorLayerIds&&-1===s.vectorLayerIds.indexOf(r))&&this.fire(new e.j(new Error(`Source layer "${r}" does not exist on source "${s.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const e=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e);const i=[];for(const r of t)e[r]&&i.push(e[r]);return i}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const r={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];r[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const t in r){const i=this.sourceCaches[t];!!r[t]!=!!i.used&&i.fire(new e.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.z=t.zoom,i&&this.fire(new e.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){var r;this._checkLoaded();const s=this.serialize();if(t=i.transformStyle?i.transformStyle(s,t):t,(null===(r=i.validate)||void 0===r||r)&&oe(this,e.x(t)))return!1;(t=e.aB(t)).layers=e.az(t.layers);const n=e.aC(s,t),a=this._getOperationsToPerform(n);if(a.unimplemented.length>0)throw new Error(`Unimplemented: ${a.unimplemented.join(", ")}.`);if(0===a.operations.length)return!1;for(const t of a.operations)t();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const e=[],i=[];for(const r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setTransition":e.push((()=>{}));break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[t])throw new Error(`Source "${t}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.x.source,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const s=this.sourceCaches[t]=new ct(t,i,this.dispatcher);s.style=this,s.setEventedParent(this,(()=>({isSourceLoaded:s.loaded(),source:s.serialize(),sourceId:t}))),s.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.sourceCaches[t])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.j(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],i.fire(new e.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,i,r={}){this._checkLoaded();const s=t.id;if(this.getLayer(s))return void this.fire(new e.j(new Error(`Layer "${s}" already exists on this map.`)));let n;if("custom"===t.type){if(oe(this,e.aD(t)))return;n=e.aA(t)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(s,t.source),t=e.aB(t),t=e.e(t,{source:s})),this._validate(e.x.layer,`layers.${s}`,t,{arrayIndex:-1},r))return;n=e.aA(t),this._validateLayer(n),n.setEventedParent(this,{layer:{id:s}})}const a=i?this._order.indexOf(i):this._order.length;if(i&&-1===a)this.fire(new e.j(new Error(`Cannot add layer "${s}" before non-existing layer "${i}".`)));else{if(this._order.splice(a,0,s),this._layerOrderChanged=!0,this._layers[s]=n,this._removedLayers[s]&&n.source&&"custom"!==n.type){const t=this._removedLayers[s];delete this._removedLayers[s],t.type!==n.type?this._updatedSources[n.source]="clear":(this._updatedSources[n.source]="reload",this.sourceCaches[n.source].pause())}this._updateLayer(n),n.onAdd&&n.onAdd(this.map)}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);const s=i?this._order.indexOf(i):this._order.length;i&&-1===s?this.fire(new e.j(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(s,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.j(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,r){this._checkLoaded();const s=this.getLayer(t);s?s.minzoom===i&&s.maxzoom===r||(null!=i&&(s.minzoom=i),null!=r&&(s.maxzoom=r),this._updateLayer(s)):this.fire(new e.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,i,r={}){this._checkLoaded();const s=this.getLayer(t);if(s){if(!e.aE(s.filter,i))return null==i?(s.filter=void 0,void this._updateLayer(s)):void(this._validate(e.x.filter,`layers.${s.id}.filter`,i,null,r)||(s.filter=e.aB(i),this._updateLayer(s)))}else this.fire(new e.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.aB(this.getLayer(t).filter)}setLayoutProperty(t,i,r,s={}){this._checkLoaded();const n=this.getLayer(t);n?e.aE(n.getLayoutProperty(i),r)||(n.setLayoutProperty(i,r,s),this._updateLayer(n)):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,i){const r=this.getLayer(t);if(r)return r.getLayoutProperty(i);this.fire(new e.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,r,s={}){this._checkLoaded();const n=this.getLayer(t);n?e.aE(n.getPaintProperty(i),r)||(n.setPaintProperty(i,r,s)&&this._updateLayer(n),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new e.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const r=t.source,s=t.sourceLayer,n=this.sourceCaches[r];if(void 0===n)return void this.fire(new e.j(new Error(`The source '${r}' does not exist in the map's style.`)));const a=n.getSource().type;"geojson"===a&&s?this.fire(new e.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==a||s?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),n.setFeatureState(s,t.id,i)):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,i){this._checkLoaded();const r=t.source,s=this.sourceCaches[r];if(void 0===s)return void this.fire(new e.j(new Error(`The source '${r}' does not exist in the map's style.`)));const n=s.getSource().type,a="vector"===n?t.sourceLayer:void 0;"vector"!==n||a?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.j(new Error("A feature id is required to remove its specific state property."))):s.removeFeatureState(a,t.id,i):this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,s=this.sourceCaches[i];if(void 0!==s)return"vector"!==s.getSource().type||r?(void 0===t.id&&this.fire(new e.j(new Error("The feature id parameter must be provided."))),s.getFeatureState(r,t.id)):void this.fire(new e.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.j(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return e.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=e.aF(this.sourceCaches,(t=>t.serialize())),i=this._serializeByIds(this._order),r=this.map.getTerrain()||void 0,s=this.stylesheet;return e.aG({version:s.version,name:s.name,metadata:s.metadata,light:s.light,center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch,sprite:s.sprite,glyphs:s.glyphs,transition:s.transition,sources:t,layers:i,terrain:r},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let s=this._order.length-1;s>=0;s--){const n=this._order[s];if(e(n)){i[n]=s;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let n=this._order.length-1;n>=0;n--){const a=this._order[n];if(e(a))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]{const r=i.featureSortOrder;if(r){const i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of s)e.push(t)}}for(const e in o)o[e].forEach((r=>{const s=r.feature,n=i[t[e].source].getFeatureState(s.layer["source-layer"],s.id);s.source=s.layer.source,s.layer["source-layer"]&&(s.sourceLayer=s.layer["source-layer"]),s.state=n}));return o}(this._layers,a,this.sourceCaches,t,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.x.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[t];return r?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],s={};for(let t=0;tt.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((s=s||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(n.now(),t.zoom))&&(this.pauseablePlacement=new ee(t,this.map.terrain,this._order,s,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(n.now()),o=!0),a&&this.pauseablePlacement.placement.setStale()),o||a)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(n.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t}))}getGlyphs(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.sourceCaches[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.x.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,i,r={},s){this._checkLoaded();const n=[{id:t,url:i}],a=[...x(this.stylesheet.sprite),...n];this._validate(e.x.sprite,"sprite",a,null,r)||(this.stylesheet.sprite=a,this._loadSprite(n,!0,s))}removeSprite(t){this._checkLoaded();const i=x(this.stylesheet.sprite);if(i.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.k("data",{dataType:"style"}))}else this.fire(new e.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return x(this.stylesheet.sprite)}setSprite(t,i={},r){this._checkLoaded(),t&&this._validate(e.x.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,r):(this._unloadSprite(),r&&r(null)))}}var he=e.X([{name:"a_pos",type:"Int16",components:2}]),ue="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const de={prelude:pe("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\n","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:pe("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:pe("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:pe("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);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(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:pe("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:pe("uniform highp float u_intensity;varying 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);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying 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;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}"),heatmapTexture:pe("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:pe("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_anchor_pos;attribute vec2 a_placed;attribute vec2 a_box_real;uniform mat4 u_matrix;uniform vec2 u_pixel_extrude_scale;varying float v_placed;varying float v_notUsed;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:pe("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying 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);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying 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;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;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(0.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:pe("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:pe("#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_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute 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);}"),fillOutline:pe("varying 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\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying 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;}"),fillOutlinePattern:pe("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillPattern:pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:pe("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform 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;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:pe("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying 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:pe("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(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);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:pe("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\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#endif\nv_width2=vec2(outset,inset);}"),lineGradient:pe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\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#endif\nv_width2=vec2(outset,inset);}"),linePattern:pe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\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#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:pe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\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#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:pe("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:pe("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_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 bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_tex;varying float v_fade_opacity;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:pe("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_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_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec2 v_data0;varying vec3 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:pe("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;varying vec4 v_data0;varying vec4 v_data1;vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_matrix*vec4(posInTile,elevation,1.0);}\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:pe("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",ue),terrainDepth:pe("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",ue),terrainCoords:pe("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",ue)};function pe(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=n?n.concat(s):s,o={};return{fragmentSource:t=t.replace(i,((t,e,i,r,s)=>(o[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,s)=>{const n="float"===r?"vec2":"vec4",a=s.match(/color/)?"color":n;return o[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\nvarying ${i} ${r} ${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nattribute ${i} ${n} a_${s};\n#else\nuniform ${i} ${r} u_${s};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = a_${s};\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${r} ${s} = unpack_mix_${a}(a_${s}, u_${s}_t);\n#else\n ${i} ${r} ${s} = u_${s};\n#endif\n`})),staticAttributes:r,staticUniforms:a}}class fe{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,s,n,a,o,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!c&&t({u_depth:new e.aH(t,i.u_depth),u_terrain:new e.aH(t,i.u_terrain),u_terrain_dim:new e.aI(t,i.u_terrain_dim),u_terrain_matrix:new e.aJ(t,i.u_terrain_matrix),u_terrain_unpack:new e.aK(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.aI(t,i.u_terrain_exaggeration)}))(t,b),this.binderUniforms=r?r.getUniforms(t,b):[]}draw(t,e,i,r,s,n,a,o,l,c,h,u,d,p,f,m,g,_){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(s),t.setCullFace(n),o){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,o.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,o.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(o[t])}for(const t in this.fixedUniforms)this.fixedUniforms[t].set(a[t]);f&&f.setUniforms(t,this.binderUniforms,d,{zoom:p});let x=0;switch(e){case y.LINES:x=2;break;case y.TRIANGLES:x=3;break;case y.LINE_STRIP:x=1}for(const i of u.get()){const r=i.vaos||(i.vaos={});(r[l]||(r[l]=new fe)).bind(t,this,c,f?f.getPaintVertexBuffers():[],h,i.vertexOffset,m,g,_),y.drawElements(e,i.primitiveLength*x,y.UNSIGNED_SHORT,i.primitiveOffset*x*2)}}}function _e(t,e,i){const r=1/Rt(i,1,e.transform.tileZoom),s=Math.pow(2,i.tileID.overscaledZ),n=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,a=n*(i.tileID.canonical.x+i.tileID.wrap*s),o=n*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,o>>16],u_pixel_coord_lower:[65535&a,65535&o]}}const ye=(t,i,r,s)=>{const n=i.style.light,a=n.properties.get("position"),o=[a.x,a.y,a.z],l=function(){var t=new e.A(9);return e.A!=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}();"viewport"===n.properties.get("anchor")&&function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(l,-i.transform.angle),function(t,e,i){var r=e[0],s=e[1],n=e[2];t[0]=r*i[0]+s*i[3]+n*i[6],t[1]=r*i[1]+s*i[4]+n*i[7],t[2]=r*i[2]+s*i[5]+n*i[8]}(o,o,l);const c=n.properties.get("color");return{u_matrix:t,u_lightpos:o,u_lightintensity:n.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+r,u_opacity:s}},xe=(t,i,r,s,n,a,o)=>e.e(ye(t,i,r,s),_e(a,i,o),{u_height_factor:-Math.pow(2,n.overscaledZ)/o.tileSize/8}),ve=t=>({u_matrix:t}),be=(t,i,r,s)=>e.e(ve(t),_e(r,i,s)),we=(t,e)=>({u_matrix:t,u_world:e}),Ie=(t,i,r,s,n)=>e.e(be(t,i,r,s),{u_world:n}),Te=(t,e,i,r)=>{const s=t.transform;let n,a;if("map"===r.paint.get("circle-pitch-alignment")){const t=Rt(i,1,s.zoom);n=!0,a=[t,t]}else n=!1,a=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+n,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},Se=(t,e,i)=>({u_matrix:t,u_inv_matrix:e,u_camera_to_center_distance:i.cameraToCenterDistance,u_viewport_size:[i.width,i.height]}),Ae=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Ee=t=>({u_matrix:t}),Pe=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:Rt(e,1,i),u_intensity:r});function Ce(t,i){const r=Math.pow(2,i.canonical.z),s=i.canonical.y;return[new e.Y(0,s/r).toLngLat().lat,new e.Y(0,(s+1)/r).toLngLat().lat]}const Me=(t,e,i,r)=>{const s=t.transform;return{u_matrix:Le(t,e,i,r),u_ratio:1/Rt(e,1,s.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},ke=(t,i,r,s,n)=>e.e(Me(t,i,r,n),{u_image:0,u_image_height:s}),ze=(t,e,i,r,s)=>{const n=t.transform,a=Re(e,n);return{u_matrix:Le(t,e,i,s),u_texsize:e.imageAtlasTexture.size,u_ratio:1/Rt(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},De=(t,i,r,s,n,a)=>{const o=t.lineAtlas,l=Re(i,t.transform),c="round"===r.layout.get("line-cap"),h=o.getDash(s.from,c),u=o.getDash(s.to,c),d=h.width*n.fromScale,p=u.width*n.toScale;return e.e(Me(t,i,r,a),{u_patternscale_a:[l/d,-h.height/2],u_patternscale_b:[l/p,-u.height/2],u_sdfgamma:o.width/(256*Math.min(d,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:n.t})};function Re(t,e){return 1/Rt(t,1,e.tileZoom)}function Le(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Fe=(t,e,i,r,s)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*s.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:s.paint.get("raster-brightness-min"),u_brightness_high:s.paint.get("raster-brightness-max"),u_saturation_factor:(a=s.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(n=s.paint.get("raster-contrast"),n>0?1/(1-n):1+n),u_spin_weights:Be(s.paint.get("raster-hue-rotate"))};var n,a};function Be(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Oe=(t,e,i,r,s,n,a,o,l,c,h,u,d,p)=>{const f=a.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:f.cameraToCenterDistance,u_pitch:f.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:f.width/f.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:l,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:s,u_is_variable_anchor:n,u_texsize:d,u_texture:0,u_translation:h,u_pitched_scale:p}},Ve=(t,i,r,s,n,a,o,l,c,h,u,d,p,f,m)=>{const g=o.transform;return e.e(Oe(t,i,r,s,n,a,o,l,c,h,u,d,p,m),{u_gamma_scale:s?Math.cos(g._pitch)*g.cameraToCenterDistance:1,u_device_pixel_ratio:o.pixelRatio,u_is_halo:+f})},Ne=(t,i,r,s,n,a,o,l,c,h,u,d,p,f)=>e.e(Ve(t,i,r,s,n,a,o,l,c,h,u,!0,d,!0,f),{u_texsize_icon:p,u_texture_icon:1}),je=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),Ue=(t,i,r,s,n,a)=>e.e(function(t,e,i,r){const s=i.imageManager.getPattern(t.from.toString()),n=i.imageManager.getPattern(t.to.toString()),{width:a,height:o}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:s.tl,u_pattern_br_a:s.br,u_pattern_tl_b:n.tl,u_pattern_br_b:n.br,u_texsize:[a,o],u_mix:e.t,u_pattern_size_a:s.displaySize,u_pattern_size_b:n.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/Rt(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(s,a,r,n),{u_matrix:t,u_opacity:i}),$e={fillExtrusion:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_lightpos:new e.aL(t,i.u_lightpos),u_lightintensity:new e.aI(t,i.u_lightintensity),u_lightcolor:new e.aL(t,i.u_lightcolor),u_vertical_gradient:new e.aI(t,i.u_vertical_gradient),u_opacity:new e.aI(t,i.u_opacity)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_lightpos:new e.aL(t,i.u_lightpos),u_lightintensity:new e.aI(t,i.u_lightintensity),u_lightcolor:new e.aL(t,i.u_lightcolor),u_vertical_gradient:new e.aI(t,i.u_vertical_gradient),u_height_factor:new e.aI(t,i.u_height_factor),u_image:new e.aH(t,i.u_image),u_texsize:new e.aM(t,i.u_texsize),u_pixel_coord_upper:new e.aM(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aM(t,i.u_pixel_coord_lower),u_scale:new e.aL(t,i.u_scale),u_fade:new e.aI(t,i.u_fade),u_opacity:new e.aI(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_texsize:new e.aM(t,i.u_texsize),u_pixel_coord_upper:new e.aM(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aM(t,i.u_pixel_coord_lower),u_scale:new e.aL(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aM(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aM(t,i.u_world),u_image:new e.aH(t,i.u_image),u_texsize:new e.aM(t,i.u_texsize),u_pixel_coord_upper:new e.aM(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aM(t,i.u_pixel_coord_lower),u_scale:new e.aL(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_scale_with_map:new e.aH(t,i.u_scale_with_map),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_extrude_scale:new e.aM(t,i.u_extrude_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_matrix:new e.aJ(t,i.u_matrix)}),collisionBox:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_pixel_extrude_scale:new e.aM(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_inv_matrix:new e.aJ(t,i.u_inv_matrix),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_viewport_size:new e.aM(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.aN(t,i.u_color),u_matrix:new e.aJ(t,i.u_matrix),u_overlay:new e.aH(t,i.u_overlay),u_overlay_scale:new e.aI(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.aI(t,i.u_extrude_scale),u_intensity:new e.aI(t,i.u_intensity),u_matrix:new e.aJ(t,i.u_matrix)}),heatmapTexture:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_world:new e.aM(t,i.u_world),u_image:new e.aH(t,i.u_image),u_color_ramp:new e.aH(t,i.u_color_ramp),u_opacity:new e.aI(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_latrange:new e.aM(t,i.u_latrange),u_light:new e.aM(t,i.u_light),u_shadow:new e.aN(t,i.u_shadow),u_highlight:new e.aN(t,i.u_highlight),u_accent:new e.aN(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_image:new e.aH(t,i.u_image),u_dimension:new e.aM(t,i.u_dimension),u_zoom:new e.aI(t,i.u_zoom),u_unpack:new e.aK(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aM(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aM(t,i.u_units_to_pixels),u_image:new e.aH(t,i.u_image),u_image_height:new e.aI(t,i.u_image_height)}),linePattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texsize:new e.aM(t,i.u_texsize),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_image:new e.aH(t,i.u_image),u_units_to_pixels:new e.aM(t,i.u_units_to_pixels),u_scale:new e.aL(t,i.u_scale),u_fade:new e.aI(t,i.u_fade)}),lineSDF:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ratio:new e.aI(t,i.u_ratio),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aM(t,i.u_units_to_pixels),u_patternscale_a:new e.aM(t,i.u_patternscale_a),u_patternscale_b:new e.aM(t,i.u_patternscale_b),u_sdfgamma:new e.aI(t,i.u_sdfgamma),u_image:new e.aH(t,i.u_image),u_tex_y_a:new e.aI(t,i.u_tex_y_a),u_tex_y_b:new e.aI(t,i.u_tex_y_b),u_mix:new e.aI(t,i.u_mix)}),raster:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_tl_parent:new e.aM(t,i.u_tl_parent),u_scale_parent:new e.aI(t,i.u_scale_parent),u_buffer_scale:new e.aI(t,i.u_buffer_scale),u_fade_t:new e.aI(t,i.u_fade_t),u_opacity:new e.aI(t,i.u_opacity),u_image0:new e.aH(t,i.u_image0),u_image1:new e.aH(t,i.u_image1),u_brightness_low:new e.aI(t,i.u_brightness_low),u_brightness_high:new e.aI(t,i.u_brightness_high),u_saturation_factor:new e.aI(t,i.u_saturation_factor),u_contrast_factor:new e.aI(t,i.u_contrast_factor),u_spin_weights:new e.aL(t,i.u_spin_weights)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aM(t,i.u_texsize),u_texture:new e.aH(t,i.u_texture),u_translation:new e.aM(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aM(t,i.u_texsize),u_texture:new e.aH(t,i.u_texture),u_gamma_scale:new e.aI(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_is_halo:new e.aH(t,i.u_is_halo),u_translation:new e.aM(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.aH(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aH(t,i.u_is_size_feature_constant),u_size_t:new e.aI(t,i.u_size_t),u_size:new e.aI(t,i.u_size),u_camera_to_center_distance:new e.aI(t,i.u_camera_to_center_distance),u_pitch:new e.aI(t,i.u_pitch),u_rotate_symbol:new e.aH(t,i.u_rotate_symbol),u_aspect_ratio:new e.aI(t,i.u_aspect_ratio),u_fade_change:new e.aI(t,i.u_fade_change),u_matrix:new e.aJ(t,i.u_matrix),u_label_plane_matrix:new e.aJ(t,i.u_label_plane_matrix),u_coord_matrix:new e.aJ(t,i.u_coord_matrix),u_is_text:new e.aH(t,i.u_is_text),u_pitch_with_map:new e.aH(t,i.u_pitch_with_map),u_is_along_line:new e.aH(t,i.u_is_along_line),u_is_variable_anchor:new e.aH(t,i.u_is_variable_anchor),u_texsize:new e.aM(t,i.u_texsize),u_texsize_icon:new e.aM(t,i.u_texsize_icon),u_texture:new e.aH(t,i.u_texture),u_texture_icon:new e.aH(t,i.u_texture_icon),u_gamma_scale:new e.aI(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aI(t,i.u_device_pixel_ratio),u_is_halo:new e.aH(t,i.u_is_halo),u_translation:new e.aM(t,i.u_translation),u_pitched_scale:new e.aI(t,i.u_pitched_scale)}),background:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_opacity:new e.aI(t,i.u_opacity),u_color:new e.aN(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_opacity:new e.aI(t,i.u_opacity),u_image:new e.aH(t,i.u_image),u_pattern_tl_a:new e.aM(t,i.u_pattern_tl_a),u_pattern_br_a:new e.aM(t,i.u_pattern_br_a),u_pattern_tl_b:new e.aM(t,i.u_pattern_tl_b),u_pattern_br_b:new e.aM(t,i.u_pattern_br_b),u_texsize:new e.aM(t,i.u_texsize),u_mix:new e.aI(t,i.u_mix),u_pattern_size_a:new e.aM(t,i.u_pattern_size_a),u_pattern_size_b:new e.aM(t,i.u_pattern_size_b),u_scale_a:new e.aI(t,i.u_scale_a),u_scale_b:new e.aI(t,i.u_scale_b),u_pixel_coord_upper:new e.aM(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aM(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aI(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texture:new e.aH(t,i.u_texture),u_ele_delta:new e.aI(t,i.u_ele_delta)}),terrainDepth:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_ele_delta:new e.aI(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_matrix:new e.aJ(t,i.u_matrix),u_texture:new e.aH(t,i.u_texture),u_terrain_coords_id:new e.aI(t,i.u_terrain_coords_id),u_ele_delta:new e.aI(t,i.u_ele_delta)})};class qe{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");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)}}const Ze={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Ge{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i0){const i=e.F();e.aQ(i,m.placementInvProjMatrix,t.transform.glCoordMatrix),e.aQ(i,i,m.placementViewportMatrix),c.push({circleArray:_,circleOffset:u,transform:f.posMatrix,invTransform:i,coord:f}),h+=_.length/4,u=h}g&&l.draw(a,o.LINES,Ri.disabled,Fi.disabled,t.colorModeForRenderPass(),Bi.disabled,{u_matrix:f.posMatrix,u_pixel_extrude_scale:[1/(d=t.transform).width,1/d.height]},t.style.map.terrain&&t.style.map.terrain.getTerrainData(f),r.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,null,t.transform.zoom,null,null,g.collisionVertexBuffer)}var d;if(!n||!c.length)return;const p=t.useProgram("collisionCircle"),f=new e.aR;f.resize(4*h),f._trim();let m=0;for(const t of c)for(let e=0;e=0&&(y[x.associatedIconIndex]={shiftedAnchor:M,angle:k})}else kt(x.numGlyphs,g)}if(h){_.clear();const i=t.icon.placedSymbolArray;for(let t=0;tt.style.map.terrain.getElevation(l,e,i):null,i="map"===r.layout.get("text-rotation-alignment");vt(c,l.posMatrix,t,n,N,U,y,h,i,g,l.toUnwrapped(),m.width,m.height,$,e)}const G=l.posMatrix,W=n&&S||Z,H=x||W?Ni:N,X=j,K=p&&0!==r.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);let J;J=p?c.iconsInText?Ne(T.kind,M,v,y,x,W,t,G,H,X,$,z,F,E):Ve(T.kind,M,v,y,x,W,t,G,H,X,$,n,z,!0,E):Oe(T.kind,M,v,y,x,W,t,G,H,X,$,n,z,E);const Y={program:C,buffers:u,uniformValues:J,atlasTexture:D,atlasTextureIcon:B,atlasInterpolation:R,atlasInterpolationIcon:L,isSDF:p,hasHalo:K};if(w&&c.canOverlap){I=!0;const t=u.segments.get();for(const i of t)A.push({segments:new e.$([i]),sortKey:i.sortKey,state:Y,terrainData:k})}else A.push({segments:u.segments,sortKey:0,state:Y,terrainData:k})}I&&A.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of A){const i=e.state;if(p.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const s=i.uniformValues;i.hasHalo&&(s.u_is_halo=1,Gi(i.buffers,e.segments,r,t,i.program,T,u,d,s,e.terrainData)),s.u_is_halo=0}Gi(i.buffers,e.segments,r,t,i.program,T,u,d,i.uniformValues,e.terrainData)}}function Gi(t,e,i,r,s,n,a,o,l,c){const h=r.context;s.draw(h,h.gl.TRIANGLES,n,a,o,Bi.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Wi(t,e,i,r,s){if(!i||!r||!r.imageAtlas)return;const n=r.imageAtlas.patternPositions;let a=n[i.to.toString()],o=n[i.from.toString()];if(!a&&o&&(a=o),!o&&a&&(o=a),!a||!o){const t=s.getPaintProperty(e);a=n[t],o=n[t]}a&&o&&t.setConstantPatternPositions(a,o)}function Hi(t,e,i,r,s,n,a){const o=t.context.gl,l="fill-pattern",c=i.paint.get(l),h=c&&c.constantOr(1),u=i.getCrossfadeParameters();let d,p,f,m,g;a?(p=h&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=o.LINES):(p=h?"fillPattern":"fill",d=o.TRIANGLES);const _=c.constantOr(null);for(const c of r){const r=e.getTile(c);if(h&&!r.patternsLoaded())continue;const y=r.getBucket(i);if(!y)continue;const x=y.programConfigurations.get(i.id),v=t.useProgram(p,x),b=t.style.map.terrain&&t.style.map.terrain.getTerrainData(c);h&&(t.context.activeTexture.set(o.TEXTURE0),r.imageAtlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),x.updatePaintBuffers(u)),Wi(x,l,_,r,i);const w=b?c:null,I=t.translatePosMatrix(w?w.posMatrix:c.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,g=y.segments2;const e=[o.drawingBufferWidth,o.drawingBufferHeight];f="fillOutlinePattern"===p&&h?Ie(I,t,u,r,e):we(I,e)}else m=y.indexBuffer,g=y.segments,f=h?be(I,t,u,r):ve(I);v.draw(t.context,d,s,t.stencilModeForClipping(c),n,Bi.disabled,f,b,i.id,y.layoutVertexBuffer,m,g,i.paint,t.transform.zoom,x)}}function Xi(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c="fill-extrusion-pattern",h=i.paint.get(c),u=h.constantOr(1),d=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity"),f=h.constantOr(null);for(const h of r){const r=e.getTile(h),m=r.getBucket(i);if(!m)continue;const g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(h),_=m.programConfigurations.get(i.id),y=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",_);u&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.updatePaintBuffers(d)),Wi(_,c,f,r,i);const x=t.translatePosMatrix(h.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=u?xe(x,t,v,p,h,d,r):ye(x,t,v,p);y.draw(o,o.gl.TRIANGLES,s,n,a,Bi.backCCW,b,g,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,_,t.style.map.terrain&&m.centroidVertexBuffer)}}function Ki(t,e,i,r,s,n,a){const o=t.context,l=o.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);o.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(o,l.TRIANGLES,s,n,a,Bi.disabled,((t,e,i,r)=>{const s=i.paint.get("hillshade-shadow-color"),n=i.paint.get("hillshade-highlight-color"),a=i.paint.get("hillshade-accent-color");let o=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(o-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:Ce(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),o],u_shadow:s,u_highlight:n,u_accent:a}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function Ji(t,i,r,s,n,a){const o=t.context,l=o.gl,c=i.dem;if(c&&c.data){const h=c.dim,u=c.stride,d=c.getPixels();if(o.activeTexture.set(l.TEXTURE1),o.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(u),i.demTexture){const t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new b(o,d,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);o.activeTexture.set(l.TEXTURE0);let p=i.fbo;if(!p){const t=new b(o,{width:h,height:h,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),p=i.fbo=o.createFramebuffer(h,h,!0,!1),p.colorAttachment.set(t.texture)}o.bindFramebuffer.set(p.framebuffer),o.viewport.set([0,0,h,h]),t.useProgram("hillshadePrepare").draw(o,l.TRIANGLES,s,n,a,Bi.disabled,((t,i)=>{const r=i.stride,s=e.F();return e.aO(s,0,e.W,-e.W,0,0,1),e.H(s,s,[0,-e.W,0]),{u_matrix:s,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,c),null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}}function Yi(t,i,r,s,a,o){const l=s.paint.get("raster-fade-duration");if(!o&&l>0){const s=n.now(),o=(s-t.timeAdded)/l,c=i?(s-i.timeAdded)/l:-1,h=r.getSource(),u=a.coveringZoomLevel({tileSize:h.tileSize,roundZoom:h.roundZoom}),d=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),p=d&&t.refreshedUponExpiration?1:e.ac(d?o:1-c,0,1);return t.refreshedUponExpiration&&o>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const Qi=new e.aP(1,0,0,1),tr=new e.aP(0,1,0,1),er=new e.aP(0,0,1,1),ir=new e.aP(1,0,1,1),rr=new e.aP(0,1,1,1);function sr(t,e,i,r){ar(t,0,e+i/2,t.transform.width,i,r)}function nr(t,e,i,r){ar(t,e-i/2,0,i,t.transform.height,r)}function ar(t,e,i,r,s,n){const a=t.context,o=a.gl;o.enable(o.SCISSOR_TEST),o.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,s*t.pixelRatio),a.clear({color:n}),o.disable(o.SCISSOR_TEST)}function or(t,i,r){const s=t.context,n=s.gl,a=r.posMatrix,o=t.useProgram("debug"),l=Ri.disabled,c=Fi.disabled,h=t.colorModeForRenderPass(),u="$debug",d=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r);s.activeTexture.set(n.TEXTURE0);const p=i.getTileByID(r.key).latestRawTileData,f=Math.floor((p&&p.byteLength||0)/1024),m=i.getTile(r).tileSize,g=512/Math.min(m,512)*(r.overscaledZ/t.transform.zoom)*.5;let _=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(_+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${f}kB`),o.draw(s,n.TRIANGLES,l,c,zi.alphaBlended,Bi.disabled,Ae(a,e.aP.transparent,g),null,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),o.draw(s,n.LINE_STRIP,l,c,h,Bi.disabled,Ae(a,e.aP.red),d,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function lr(t,e,i){const r=t.context,s=r.gl,n=t.colorModeForRenderPass(),a=new Ri(s.LEQUAL,Ri.ReadWrite,t.depthRangeFor3D),o=t.useProgram("terrain"),l=e.getTerrainMesh();r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]);for(const c of i){const i=t.renderToTexture.getTexture(c),h=e.getTerrainData(c.tileID);r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,i.texture);const u={u_matrix:t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),u_texture:0,u_ele_delta:e.getMeshFrameDelta(t.transform.zoom)};o.draw(r,s.TRIANGLES,a,Fi.disabled,n,Bi.backCCW,u,h,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class cr{constructor(t,i){this.context=new Di(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ct.maxUnderzooming+ct.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ae}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,i=new e.aW;i.emplaceBack(0,0),i.emplaceBack(e.W,0),i.emplaceBack(0,e.W),i.emplaceBack(e.W,e.W),this.tileExtentBuffer=t.createVertexBuffer(i,he.members),this.tileExtentSegments=e.$.simpleSegment(0,0,4,2);const r=new e.aW;r.emplaceBack(0,0),r.emplaceBack(e.W,0),r.emplaceBack(0,e.W),r.emplaceBack(e.W,e.W),this.debugBuffer=t.createVertexBuffer(r,he.members),this.debugSegments=e.$.simpleSegment(0,0,4,5);const s=new e.Z;s.emplaceBack(0,0,0,0),s.emplaceBack(e.W,0,e.W,0),s.emplaceBack(0,e.W,0,e.W),s.emplaceBack(e.W,e.W,e.W,e.W),this.rasterBoundsBuffer=t.createVertexBuffer(s,K.members),this.rasterBoundsSegments=e.$.simpleSegment(0,0,4,2);const n=new e.aW;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,he.members),this.viewportSegments=e.$.simpleSegment(0,0,4,2);const a=new e.aX;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(a);const o=new e.aY;o.emplaceBack(0,1,2),o.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o);const l=this.context.gl;this.stencilClearMode=new Fi({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=e.F();e.aO(r,0,this.width,this.height,0,0,1),e.J(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,i.TRIANGLES,Ri.disabled,this.stencilClearMode,zi.disabled,Bi.disabled,Ee(r),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;const i=this.context,r=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(zi.disabled),i.setDepthMode(Ri.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of e){const e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,n=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);s.draw(i,r.TRIANGLES,Ri.disabled,new Fi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),zi.disabled,Bi.disabled,Ee(t.posMatrix),n,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Fi({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Fi({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,s=i[0].overscaledZ-r+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],e=s[t.source],i=a[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayeri.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[])),s=r.filter((t=>"vector"===t.getSource().type)),n=r.filter((t=>"vector"!==t.getSource().type)),a=t=>{(!i||i.getSource().maxzooma(t))),i||n.forEach((t=>a(t))),i}(this.style,this.transform.zoom);t&&function(t,e,i){for(let r=0;r0),s&&(e.a$(i,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){const r=t.context,s=r.gl,n=zi.unblended,a=new Ri(s.LEQUAL,Ri.ReadWrite,[0,1]),o=i.getTerrainMesh(),l=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");r.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.aP.transparent,depth:1});for(const e of l){const l=i.getTerrainData(e.tileID),h={u_matrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};c.draw(r,s.TRIANGLES,a,Fi.disabled,n,Bi.backCCW,h,l,"terrain",o.vertexBuffer,o.indexBuffer,o.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){const r=t.context,s=r.gl,n=zi.unblended,a=new Ri(s.LEQUAL,Ri.ReadWrite,[0,1]),o=i.getTerrainMesh(),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),h=t.useProgram("terrainCoords");r.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:e.aP.transparent,depth:1}),i.coordsIndex=[];for(const e of c){const c=i.getTerrainData(e.tileID);r.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,l.texture);const u={u_matrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped()),u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};h.draw(r,s.TRIANGLES,a,Fi.disabled,n,Bi.backCCW,u,c,"terrain",o.vertexBuffer,o.indexBuffer,o.segments),i.coordsIndex.push(e.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,r,s){if(!r.isHidden(this.transform.zoom)&&("background"===r.type||"custom"===r.type||(s||[]).length))switch(this.id=r.id,r.type){case"symbol":!function(t,i,r,s,n){if("translucent"!==t.renderPass)return;const a=Fi.disabled,o=t.colorModeForRenderPass();(r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,r,s,n,a,o,l,c){const h=i.transform,u=Qt(),d="map"===n,p="map"===a;for(const n of t){const t=s.getTile(n),a=t.getBucket(r);if(!a||!a.text||!a.text.segments.get().length)continue;const f=e.ag(a.textSizeData,h.zoom),m=Rt(t,1,i.transform.zoom),g=mt(n.posMatrix,p,d,i.transform,m),_="none"!==r.layout.get("icon-text-fit")&&a.hasIconData();if(f){const e=Math.pow(2,h.zoom-t.tileID.overscaledZ),r=i.style.map.terrain?(t,e)=>i.style.map.terrain.getElevation(n,t,e):null,s=u.translatePosition(h,t,o,l);$i(a,d,p,c,h,g,n.posMatrix,e,f,_,u,s,n.toUnwrapped(),r)}}}(s,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),n),0!==r.paint.get("icon-opacity").constantOr(1)&&Zi(t,i,r,s,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,o),0!==r.paint.get("text-opacity").constantOr(1)&&Zi(t,i,r,s,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,o),i.map.showCollisionBoxes&&(Vi(t,i,r,s,!0),Vi(t,i,r,s,!1))}(t,i,r,s,this.style.placement.variableOffsets);break;case"circle":!function(t,i,r,s){if("translucent"!==t.renderPass)return;const n=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),o=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(0===n.constantOr(1)&&(0===a.constantOr(1)||0===o.constantOr(1)))return;const c=t.context,h=c.gl,u=t.depthModeForSublayer(0,Ri.ReadOnly),d=Fi.disabled,p=t.colorModeForRenderPass(),f=[];for(let n=0;nt.sortKey-e.sortKey));for(const e of f){const{programConfiguration:i,program:s,layoutVertexBuffer:n,indexBuffer:a,uniformValues:o,terrainData:l}=e.state;s.draw(c,h.TRIANGLES,u,d,p,Bi.disabled,o,l,r.id,n,a,e.segments,r.paint,t.transform.zoom,i)}}(t,i,r,s);break;case"heatmap":!function(t,i,r,s){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const n=t.context,a=n.gl,o=Fi.disabled,l=new zi([a.ONE,a.ONE],e.aP.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let s=i.heatmapFbo;if(s)r.bindTexture(r.TEXTURE_2D,s.colorAttachment.get()),t.bindFramebuffer.set(s.framebuffer);else{const n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),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=t.createFramebuffer(e.width/4,e.height/4,!1,!1),function(t,e,i,r){var s,n;const a=t.gl,o=null!==(s=t.HALF_FLOAT)&&void 0!==s?s:a.UNSIGNED_BYTE,l=null!==(n=t.RGBA16F)&&void 0!==n?n:a.RGBA;a.texImage2D(a.TEXTURE_2D,0,l,e.width/4,e.height/4,0,a.RGBA,o,null),r.colorAttachment.set(i)}(t,e,n,s)}}(n,t,r),n.clear({color:e.aP.transparent});for(let e=0;e{const n=e.F();e.aO(n,0,t.width,t.height,0,0,1);const a=t.context.gl;return{u_matrix:n,u_world:[a.drawingBufferWidth,a.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(t,i),null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,r))}(t,i,r,s);break;case"line":!function(t,i,r,s){if("translucent"!==t.renderPass)return;const n=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===n.constantOr(1)||0===a.constantOr(1))return;const o=t.depthModeForSublayer(0,Ri.ReadOnly),l=t.colorModeForRenderPass(),c=r.paint.get("line-dasharray"),h=r.paint.get("line-pattern"),u=h.constantOr(1),d=r.paint.get("line-gradient"),p=r.getCrossfadeParameters(),f=u?"linePattern":c?"lineSDF":d?"lineGradient":"line",m=t.context,g=m.gl;let _=!0;for(const n of s){const s=i.getTile(n);if(u&&!s.patternsLoaded())continue;const a=s.getBucket(r);if(!a)continue;const y=a.programConfigurations.get(r.id),x=t.context.program.get(),v=t.useProgram(f,y),w=_||v.program!==x,I=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n),T=h.constantOr(null);if(T&&s.imageAtlas){const t=s.imageAtlas,e=t.patternPositions[T.to.toString()],i=t.patternPositions[T.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const S=I?n:null,A=u?ze(t,s,r,p,S):c?De(t,s,r,c,p,S):d?ke(t,s,r,a.lineClipsArray.length,S):Me(t,s,r,S);if(u)m.activeTexture.set(g.TEXTURE0),s.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),y.updatePaintBuffers(p);else if(c&&(w||t.lineAtlas.dirty))m.activeTexture.set(g.TEXTURE0),t.lineAtlas.bind(m);else if(d){const s=a.gradients[r.id];let o=s.texture;if(r.gradientVersion!==s.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,s=n.canonical.z===r?Math.ceil(1<0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new ge(this.context,de[t],e,$e[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new b(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class hr{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,i,r){const s=Math.pow(2,r),n=[[-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((r=>{const n=1/(r=e.af([],r,t))[3]/i*s;return e.b0(r,r,[n,n,1/r[3],n])})),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=function(t,e){var i=e[0],r=e[1],s=e[2],n=i*i+r*r+s*s;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}([],function(t,e,i){var r=e[0],s=e[1],n=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-n*o,t[1]=n*a-r*l,t[2]=r*o-s*a,t}([],_([],n[t[0]],n[t[1]]),_([],n[t[2]],n[t[1]]))),i=-((r=e)[0]*(s=n[t[1]])[0]+r[1]*s[1]+r[2]*s[2]);var r,s;return e.concat(i)}));return new hr(n,a)}}class ur{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max))}quadrant(t){const e=[t%2==0,t<2],i=m(this.min),r=m(this.max);for(let t=0;t=0&&a++;if(0===a)return 0;a!==i.length&&(r=!1)}if(r)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let s=0;sthis.max[e]-this.min[e])return 0}return 1}}class dr{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.z.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.z.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.z.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.z.number(t.right,i.right,r)),this}getCenter(t,i){const r=e.ac((this.left+t-this.right)/2,0,t),s=e.ac((this.top+i-this.bottom)/2,0,i);return new e.P(r,s)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new dr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const pr=85.051129;class fr{constructor(t,i,r,s,n){this.tileSize=512,this._renderWorldCopies=void 0===n||!!n,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==s?60:s,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new dr,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new fr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const i=-e.b2(t,-180,180)*Math.PI/180;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=function(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}(),function(t,e,i){var r=e[0],s=e[1],n=e[2],a=e[3],o=Math.sin(i),l=Math.cos(i);t[0]=r*l+n*o,t[1]=s*l+a*o,t[2]=r*-o+n*l,t[3]=s*-o+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(t){const i=[new e.b3(0,t)];if(this._renderWorldCopies){const r=this.pointCoordinate(new e.P(0,0)),s=this.pointCoordinate(new e.P(this.width,0)),n=this.pointCoordinate(new e.P(this.width,this.height)),a=this.pointCoordinate(new e.P(0,this.height)),o=Math.floor(Math.min(r.x,s.x,n.x,a.x)),l=Math.floor(Math.max(r.x,s.x,n.x,a.x)),c=1;for(let r=o-c;r<=l+c;r++)0!==r&&i.push(new e.b3(r,t))}return i}coveringTiles(t){var i,r;let s=this.coveringZoomLevel(t);const n=s;if(void 0!==t.minzoom&&st.maxzoom&&(s=t.maxzoom);const a=this.pointCoordinate(this.getCameraPoint()),o=e.Y.fromLngLat(this.center),l=Math.pow(2,s),c=[l*a.x,l*a.y,0],h=[l*o.x,l*o.y,0],u=hr.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,s);let d=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(d=s);const p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,f=t=>({aabb:new ur([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),m=[],g=[],_=s,x=t.reparseOverscaled?n:s;if(this._renderWorldCopies)for(let t=1;t<=3;t++)m.push(f(-t)),m.push(f(t));for(m.push(f(0));m.length>0;){const s=m.pop(),n=s.x,a=s.y;let o=s.fullyVisible;if(!o){const t=s.aabb.intersects(u);if(0===t)continue;o=2===t}const l=t.terrain?c:h,f=s.aabb.distanceX(l),v=s.aabb.distanceY(l),b=Math.max(Math.abs(f),Math.abs(v));if(s.zoom===_||b>p+(1<<_-s.zoom)-2&&s.zoom>=d){const t=_-s.zoom,i=c[0]-.5-(n<>1),u=s.zoom+1;let d=s.aabb.quadrant(l);if(t.terrain){const n=new e.Q(u,s.wrap,u,c,h),a=t.terrain.getMinMaxElevation(n),o=null!==(i=a.minElevation)&&void 0!==i?i:this.elevation,l=null!==(r=a.maxElevation)&&void 0!==r?r:this.elevation;d=new ur([d.min[0],d.min[1],o],[d.max[0],d.max[1],l])}m.push({aabb:d,zoom:u,x:c,y:h,wrap:s.wrap,fullyVisible:o})}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const i=e.ac(t.lat,-85.051129,pr);return new e.P(e.N(t.lng)*this.worldSize,e.O(i)*this.worldSize)}unproject(t){return new e.Y(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const i=this.elevation,r=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,s=this.pointLocation(this.centerPoint,t),n=t.getElevationForLngLatZoom(s,this.tileZoom);if(!(this.elevation-n))return;const a=r+i-n,o=Math.cos(this._pitch)*this.cameraToCenterDistance/a/e.b4(1,s.lat),l=this.scaleZoom(o/this.tileSize);this._elevation=n,this._center=s,this.zoom=l}setLocationAtPoint(t,i){const r=this.pointCoordinate(i),s=this.pointCoordinate(this.centerPoint),n=this.locationCoordinate(t),a=new e.Y(n.x-(r.x-s.x),n.y-(r.y-s.y));this.center=this.coordinateLocation(a),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Y.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(null!=e)return e}const r=[t.x,t.y,0,1],s=[t.x,t.y,1,1];e.af(r,r,this.pixelMatrixInverse),e.af(s,s,this.pixelMatrixInverse);const n=r[3],a=s[3],o=r[1]/n,l=s[1]/a,c=r[2]/n,h=s[2]/a,u=c===h?0:(0-c)/(h-c);return new e.Y(e.z.number(r[0]/n,s[0]/a,u)/this.worldSize,e.z.number(o,l,u)/this.worldSize)}coordinatePoint(t,i=0,r=this.pixelMatrix){const s=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.af(s,s,r),new e.P(s[0]/s[3],s[1]/s[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return(new q).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new q([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,pr])}calculatePosMatrix(t,i=!1){const r=t.key,s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s[r])return s[r];const n=t.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*t.wrap,l=e.an(new Float64Array(16));return e.H(l,l,[o*a,n.y*a,0]),e.J(l,l,[a/e.W,a/e.W,1]),e.K(l,i?this.alignedProjMatrix:this.projMatrix,l),s[r]=new Float32Array(l),s[r]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,i){i=e.ac(+i,this.minZoom,this.maxZoom);const r={center:new e.M(t.lng,t.lat),zoom:i};let s=this.lngRange;if(!this._renderWorldCopies&&null===s){const t=180-1e-10;s=[-t,t]}const n=this.tileSize*this.zoomScale(r.zoom);let a=0,o=n,l=0,c=n,h=0,u=0;const{x:d,y:p}=this.size;if(this.latRange){const t=this.latRange;a=e.O(t[1])*n,o=e.O(t[0])*n,o-ao&&(_=o-t)}if(s){const t=(l+c)/2;let i=f;this._renderWorldCopies&&(i=e.b2(f,t-n/2,t+n/2));const r=d/2;i-rc&&(g=c-r)}if(void 0!==g||void 0!==_){const t=new e.P(null!=g?g:f,null!=_?_:m);r.center=this.unproject.call({worldSize:n},t).wrap()}return r}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=i,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,i=this.point.x,r=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=e.b4(1,this.center.lat)*this.worldSize;let s=e.an(new Float64Array(16));e.J(s,s,[this.width/2,-this.height/2,1]),e.H(s,s,[1,-1,0]),this.labelPlaneMatrix=s,s=e.an(new Float64Array(16)),e.J(s,s,[1,-1,1]),e.H(s,s,[-1,-1,0]),e.J(s,s,[2/this.width,2/this.height,1]),this.glCoordMatrix=s;const n=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),a=Math.min(this.elevation,this.minElevationForCurrentTile),o=n-a*this._pixelPerMeter/Math.cos(this._pitch),l=a<0?o:n,c=Math.PI/2+this._pitch,h=this._fov*(.5+t.y/this.height),u=Math.sin(h)*l/Math.sin(e.ac(Math.PI-c-h,.01,Math.PI-.01)),d=this.getHorizon(),p=2*Math.atan(d/this.cameraToCenterDistance)*(.5+t.y/(2*d)),f=Math.sin(p)*l/Math.sin(e.ac(Math.PI-c-p,.01,Math.PI-.01)),m=Math.min(u,f),g=1.01*(Math.cos(Math.PI/2-this._pitch)*m+l),_=this.height/50;s=new Float64Array(16),e.b5(s,this._fov,this.width/this.height,_,g),s[8]=2*-t.x/this.width,s[9]=2*t.y/this.height,e.J(s,s,[1,-1,1]),e.H(s,s,[0,0,-this.cameraToCenterDistance]),e.b6(s,s,this._pitch),e.ad(s,s,this.angle),e.H(s,s,[-i,-r,0]),this.mercatorMatrix=e.J([],s,[this.worldSize,this.worldSize,this.worldSize]),e.J(s,s,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.K(new Float64Array(16),this.labelPlaneMatrix,s),e.H(s,s,[0,0,-this.elevation]),this.projMatrix=s,this.invProjMatrix=e.as([],s),this.pixelMatrix3D=e.K(new Float64Array(16),this.labelPlaneMatrix,s);const y=this.width%2/2,x=this.height%2/2,v=Math.cos(this.angle),b=Math.sin(this.angle),w=i-Math.round(i)+v*y+b*x,I=r-Math.round(r)+v*x+b*y,T=new Float64Array(s);if(e.H(T,T,[w>.5?w-1:w,I>.5?I-1:I,0]),this.alignedProjMatrix=T,s=e.as(new Float64Array(16),this.pixelMatrix),!s)throw new Error("failed to invert matrix");this.pixelMatrixInverse=s,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.af(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}getCameraQueryGeometry(t){const i=this.getCameraPoint();if(1===t.length)return[t[0],i];{let r=i.x,s=i.y,n=i.x,a=i.y;for(const e of t)r=Math.min(r,e.x),s=Math.min(s,e.y),n=Math.max(n,e.x),a=Math.max(a,e.y);return[new e.P(r,s),new e.P(n,s),new e.P(n,a),new e.P(r,a),new e.P(r,s)]}}lngLatToCameraDepth(t,i){const r=this.locationCoordinate(t),s=[r.x*this.worldSize,r.y*this.worldSize,i,1];return e.af(s,s,this.projMatrix),s[2]/s[3]}}function mr(t,e){let i,r=!1,s=null,n=null;const a=()=>{s=null,r&&(t.apply(n,i),s=setTimeout(a,e),r=!1)};return(...t)=>(r=!0,n=this,i=t,s||a(),s)}class gr{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}},this._updateHash=mr(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,r),n=Math.round(e.lng*s)/s,a=Math.round(e.lat*s)/s,o=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${n}/${a}/${i}`:`${i}/${a}/${n}`,(o||l)&&(c+="/"+Math.round(10*o)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}}const _r={linearity:.3,easing:e.b7(0,0,.3,1)},yr=e.e({deceleration:2500,maxSpeed:1400},_r),xr=e.e({deceleration:20,maxSpeed:1400},_r),vr=e.e({deceleration:1e3,maxSpeed:360},_r),br=e.e({deceleration:1e3,maxSpeed:90},_r);class wr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:n.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=n.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){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:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,s={};if(i.pan.mag()){const n=Tr(i.pan.mag(),r,e.e({},yr,t||{}));s.offset=i.pan.mult(n.amount/i.pan.mag()),s.center=this._map.transform.center,Ir(s,n)}if(i.zoom){const t=Tr(i.zoom,r,xr);s.zoom=this._map.transform.zoom+t.amount,Ir(s,t)}if(i.bearing){const t=Tr(i.bearing,r,vr);s.bearing=this._map.transform.bearing+e.ac(t.amount,-179,179),Ir(s,t)}if(i.pitch){const t=Tr(i.pitch,r,br);s.pitch=this._map.transform.pitch+t.amount,Ir(s,t)}if(s.zoom||s.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;s.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(s,{noMoveStart:!0})}}function Ir(t,e){(!t.duration||t.durationi.unproject(t))),l=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new e.P(0,0));super(t,{points:n,point:l,lngLats:o,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}}class Er extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class Pr{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Er(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new Sr(t.type,this._map,t))}mouseup(t){this._map.fire(new Sr(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new Sr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Sr(t.type,this._map,t))}mouseover(t){this._map.fire(new Sr(t.type,this._map,t))}mouseout(t){this._map.fire(new Sr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Ar(t.type,this._map,t))}touchmove(t){this._map.fire(new Ar(t.type,this._map,t))}touchend(t){this._map.fire(new Ar(t.type,this._map,t))}touchcancel(t){this._map.fire(new Ar(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Cr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Sr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Sr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Sr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Mr{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class kr{constructor(t,e){this._map=t,this._tr=new Mr(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(a.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)t.fitScreenCoordinates(r,s,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.k(t,{originalEvent:i}))}}function zr(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.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=zr(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=zr(i,e);for(const t in this.touches){const e=r[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class Rr{constructor(t){this.singleTap=new Dr(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Lr{constructor(t){this._tr=new Mr(t),this._zoomIn=new Rr({numTouches:1,numTaps:2}),this._zoomOut=new Rr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),s=this._zoomOut.touchend(t,e,i),n=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:n.zoom+1,around:n.unproject(r)},{originalEvent:t})}):s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:n.zoom-1,around:n.unproject(s)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fr{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const r=e.length?e[0]:e;return!this._moved&&r.dist(i){t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}},jr=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const r=new Or({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)});return new Fr({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:r,enable:t,assignEvents:Nr})},Ur=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const r=new Or({checkCorrectEvent:t=>0===a.mouseButton(t)&&t.ctrlKey||2===a.mouseButton(t)});return new Fr({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:Nr})};class $r{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length0&&(this._active=!0);const s=zr(r,i),n=new e.P(0,0),a=new e.P(0,0);let o=0;for(const t in s){const e=s[t],i=this._touches[t];i&&(n._add(e),a._add(e.sub(i)),o++,s[t]=e)}if(this._touches=s,oMath.abs(t.x)}class Jr extends qr{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Kr(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,s=e.mag()>=2;if(!r&&!s)return;if(!r||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const n=t.y>0==e.y>0;return Kr(t)&&Kr(e)&&n}}const Yr={panStep:100,bearingStep:15,pitchStep:10};class Qr{constructor(t){this._tr=new Mr(t);const e=Yr;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,s=0,n=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),s=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),s=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),n=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),n=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:a=>{const o=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:ts,zoom:e?Math.round(o.zoom)+e*(t.shiftKey?2:1):o.zoom,bearing:o.bearing+i*this._bearingStep,pitch:o.pitch+r*this._pitchStep,offset:[-s*this._panStep,-n*this._panStep],center:o.center},{originalEvent:t})}}}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 ts(t){return t*(2-t)}const es=4.000244140625;class is{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new Mr(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled())return;if(this._map.cooperativeGestures.isEnabled()&&!t[this._map.cooperativeGestures._bypassKey])return;let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=n.now(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%es==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=a.mousePos(this._map.getCanvas(),t),r=this._tr;this._around=i.y>r.transform.height/2-r.transform.getHorizon()?e.M.convert(this._aroundCenter?r.center:r.unproject(i)):e.M.convert(r.center),this._aroundPoint=r.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._tr.transform;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>es?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,r=this._startZoom,s=this._easing;let a,o=!1;if("wheel"===this._type&&r&&s){const t=Math.min((n.now()-this._lastWheelEventTime)/200,1),l=s(t);a=e.z.number(r,i,l),t<1?this._frameId||(this._frameId=!0):o=!0}else a=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.b8;if(this._prevEase){const t=this._prevEase,r=(n.now()-t.start)/t.duration,s=t.easing(r+.01)-t.easing(r),a=.27/Math.sqrt(s*s+1e-4)*.01,o=Math.sqrt(.0729-a*a);i=e.b7(a,o,.25,1)}return this._prevEase={start:n.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class rs{constructor(t,e){this._clickZoom=t,this._tapZoom=e}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 ss{constructor(t){this._tr=new Mr(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ns{constructor(){this._tap=new Rr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const r=e[0],s=t.timeStamp-this._tapTime<500,n=this._tapPoint.dist(r)<30;s&&n?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],s=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:s/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class as{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class os{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,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 ls{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class cs{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=a.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);const s=document.createElement("div");s.className="maplibregl-mobile-message",s.textContent=i,this._container.appendChild(s),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(a.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destoryUI()}isEnabled(){return this._enabled}touchmove(t){this._onCooperativeGesture(1===t.touches.length)}wheel(t){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!t[this._bypassKey])}_onCooperativeGesture(t){this._enabled&&t&&(this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const hs=t=>t.zoom||t.drag||t.pitch||t.rotate;class us extends e.k{}function ds(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class ps{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},s={},n={},o=t.touches,l=o?this._getMapTouches(o):void 0,c=l?a.touchPos(this._map.getCanvas(),l):a.mousePos(this._map.getCanvas(),t);for(const{handlerName:a,handler:o,allowed:h}of this._handlers){if(!o.isEnabled())continue;let u;this._blockedByActive(n,h,a)?o.reset():o[e||t.type]&&(u=o[e||t.type](t,c,l),this.mergeHandlerResult(r,s,u,a,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||o.isActive())&&(n[a]=o)}const h={};for(const t in this._previousActiveHandlers)n[t]||(h[t]=i);this._previousActiveHandlers=n,(Object.keys(h).length||ds(r))&&(this._changes.push([r,s,h]),this._triggerRenderFrame()),(Object.keys(n).length||ds(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new wr(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);const i=this._el;this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,e,i]of this._listeners)a.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)a.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new Pr(e,t));const r=e.boxZoom=new kr(e,t);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();const s=e.cooperativeGestures=new cs(e,t.cooperativeGestures);this._add("cooperativeGestures",s),t.cooperativeGestures&&s.enable();const n=new Lr(e),o=new ss(e);e.doubleClickZoom=new rs(o,n),this._add("tapZoom",n),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();const l=new ns;this._add("tapDragZoom",l);const c=e.touchPitch=new Jr(e);this._add("touchPitch",c),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);const h=jr(t),u=Ur(t);e.dragRotate=new os(t,h,u),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();const d=(({enable:t,clickTolerance:e})=>{const i=new Or({checkCorrectEvent:t=>0===a.mouseButton(t)&&!t.ctrlKey});return new Fr({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:Nr})})(t),p=new $r(t,e);e.dragPan=new as(i,d,p),this._add("mousePan",d),this._add("touchPan",p,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);const f=new Xr,m=new Wr;e.touchZoomRotate=new ls(i,m,f,l),this._add("touchRotate",f,["touchPan","touchZoom"]),this._add("touchZoom",m,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);const g=e.scrollZoom=new is(e,(()=>this._triggerRenderFrame()));this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);const _=e.keyboard=new Qr(e);this._add("keyboard",_),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new Cr(e))}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(hs(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,r,s,n){if(!r)return;e.e(t,r);const a={handlerName:s,originalEvent:r.originalEvent||n};void 0!==r.zoomDelta&&(i.zoom=a),void 0!==r.panDelta&&(i.drag=a),void 0!==r.pitchDelta&&(i.pitch=a),void 0!==r.bearingDelta&&(i.rotate=a)}_applyChanges(){const t={},i={},r={};for(const[s,n,a]of this._changes)s.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(s.panDelta)),s.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+s.pitchDelta),void 0!==s.around&&(t.around=s.around),void 0!==s.pinchAround&&(t.pinchAround=s.pinchAround),s.noInertia&&(t.noInertia=s.noInertia),e.e(i,n),e.e(r,a);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,e,i){const r=this._map,s=r._getTransformForUpdate(),n=r.terrain;if(!(ds(t)||n&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:a,zoomDelta:o,bearingDelta:l,pitchDelta:c,around:h,pinchAround:u}=t;void 0!==u&&(h=u),r._stop(!0),h=h||r.transform.centerPoint;const d=s.pointLocation(a?h.sub(a):h);l&&(s.bearing+=l),c&&(s.pitch+=c),o&&(s.zoom+=o),n?this._terrainMovement||!e.drag&&!e.zoom?e.drag&&this._terrainMovement?s.center=s.pointLocation(s.centerPoint.sub(a)):s.setLocationAtPoint(d,h):(this._terrainMovement=!0,this._map._elevationFreeze=!0,s.setLocationAtPoint(d,h)):s.setLocationAtPoint(d,h),r._applyUpdatedTransform(s),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,i,r){const s=hs(this._eventsInProgress),a=hs(t),o={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(o[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!s&&a&&this._fireEvent("movestart",a.originalEvent);for(const t in o)this._fireEvent(t,o[t]);a&&this._fireEvent("move",a.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const l={};let c;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],c=i[e]||r,l[`${t}end`]=c)}for(const t in l)this._fireEvent(t,l[t]);const h=hs(this._eventsInProgress),u=(s||a)&&!h;if(u&&this._terrainMovement&&(this._map._elevationFreeze=!1,this._terrainMovement=!1,this._map.transform.recalculateZoom(this._map.terrain)),r&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new us("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class fs extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{const t=Math.min((n.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",(()=>{delete this._requestedCameraState}))}getCenter(){return new e.M(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.e({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,r){return this.easeTo(e.e({zoom:t},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,r){return this.easeTo(e.e({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(s.zoom=e.z.number(a,_,r)),this._rotating&&(s.bearing=e.z.number(o,h,r)),this._pitching&&(s.pitch=e.z.number(l,u,r)),this._padding&&(s.interpolatePadding(c,d,r),f=s.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(r),b)s.setLocationAtPoint(b,w);else{const t=s.zoomScale(s.zoom-a),e=_>a?Math.min(2,v):Math.max(.5,v),i=Math.pow(e,1-r),n=s.unproject(y.add(x.mult(r*i)).mult(t));s.setLocationAtPoint(s.renderWorldCopies?n.wrap():n,f)}this._applyUpdatedTransform(s),this._fireMoveEvents(i)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,r={}){this._moving=!0,i||r.moving||this.fire(new e.k("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.elevation=e.z.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const e=t.clone(),{center:i,zoom:r,pitch:s,bearing:n,elevation:a}=this.transformCameraUpdate(e);i&&(e.center=i),void 0!==r&&(e.zoom=r),void 0!==s&&(e.pitch=s),void 0!==n&&(e.bearing=n),void 0!==a&&(e.elevation=a),this.transform.apply(e)}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,s=this._rotating,n=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.k("zoomend",t)),s&&this.fire(new e.k("rotateend",t)),n&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t))}flyTo(t,i){var r;if(!t.essential&&n.prefersReducedMotion){const r=e.L(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b8},t);const s=this._getTransformForUpdate(),a=this.getZoom(),o=this.getBearing(),l=this.getPitch(),c=this.getPadding(),h="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:l,d="padding"in t?t.padding:s.padding,p=e.P.convert(t.offset);let f=s.centerPoint.add(p);const m=s.pointLocation(f),{center:g,zoom:_}=s.getConstrained(e.M.convert(t.center||m),null!==(r=t.zoom)&&void 0!==r?r:a);this._normalizeCenter(g);const y=s.zoomScale(_-a),x=s.project(m),v=s.project(g).sub(x);let b=t.curve;const w=Math.max(s.width,s.height),I=w/y,T=v.mag();if("minZoom"in t){const i=e.ac(Math.min(t.minZoom,a,_),s.minZoom,s.maxZoom),r=w/s.zoomScale(i-a);b=Math.sqrt(r/T*2)}const S=b*b;function A(t){const e=(I*I-w*w+(t?-1:1)*S*S*T*T)/(2*(t?I:w)*S*T);return Math.log(Math.sqrt(e*e+1)-e)}function E(t){return(Math.exp(t)-Math.exp(-t))/2}function P(t){return(Math.exp(t)+Math.exp(-t))/2}const C=A(!1);let M=function(t){return P(C)/P(C+b*t)},k=function(t){return w*((P(C)*(E(e=C+b*t)/P(e))-E(C))/S)/T;var e},z=(A(!0)-C)/b;if(Math.abs(T)<1e-6||!isFinite(z)){if(Math.abs(w-I)<1e-6)return this.easeTo(t,i);const e=I0,M=t=>Math.exp(e*b*t)}return t.duration="duration"in t?+t.duration:1e3*z/("screenSpeed"in t?+t.screenSpeed/b:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=o!==h,this._pitching=u!==l,this._padding=!s.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g),this._ease((r=>{const n=r*z,m=1/M(n);s.zoom=1===r?_:a+s.scaleZoom(m),this._rotating&&(s.bearing=e.z.number(o,h,r)),this._pitching&&(s.pitch=e.z.number(l,u,r)),this._padding&&(s.interpolatePadding(c,d,r),f=s.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(r);const y=1===r?g:s.unproject(x.add(v.mult(k(n))).mult(m));s.setLocationAtPoint(s.renderWorldCopies?y.wrap():y,f),this._applyUpdatedTransform(s),this._fireMoveEvents(i)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=n.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){t=e.b2(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.M.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const ms={compact:!0,customAttribution:'MapLibre'};class gs{constructor(t=ms){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const i in e){const r=e[i];if(r.used||r.usedForTerrain){const e=r.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class _s{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=a.create("div","maplibregl-ctrl");const e=a.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class ys{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var xs=e.X([{name:"a_pos3d",type:"Int16",components:3}]);class vs extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];const r={};for(const s of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))r[s.key]=!0,this._renderableTilesKeys.push(s.key),this._tiles[s.key]||(s.posMatrix=new Float64Array(16),e.aO(s.posMatrix,0,e.W,0,e.W,0,1),this._tiles[s.key]=new at(s,this.tileSize));for(const t in this._tiles)r[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const i={};for(const r of this._renderableTilesKeys){const s=this._tiles[r].tileID;if(s.canonical.equals(t.canonical)){const s=t.clone();s.posMatrix=new Float64Array(16),e.aO(s.posMatrix,0,e.W,0,e.W,0,1),i[r]=s}else if(s.canonical.isChildOf(t.canonical)){const n=t.clone();n.posMatrix=new Float64Array(16);const a=s.canonical.z-t.canonical.z,o=s.canonical.x-(s.canonical.x>>a<>a<>a;e.aO(n.posMatrix,0,c,0,c,0,1),e.H(n.posMatrix,n.posMatrix,[-o*c,-l*c,0]),i[r]=n}else if(t.canonical.isChildOf(s.canonical)){const n=t.clone();n.posMatrix=new Float64Array(16);const a=t.canonical.z-s.canonical.z,o=t.canonical.x-(t.canonical.x>>a<>a<>a;e.aO(n.posMatrix,0,e.W,0,e.W,0,1),e.H(n.posMatrix,n.posMatrix,[o*c,l*c,0]),e.J(n.posMatrix,n.posMatrix,[1/2**a,1/2**a,0]),i[r]=n}}return i}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!s||!s.dem);)s=this.sourceCache.getTileByID(t.scaledTo(r--).key);return s}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeAdded>=t))}}class bs{constructor(t,e,i){this.painter=t,this.sourceCache=new vs(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,r,s=e.W){var n;if(!(i>=0&&i=0&&rt.canonical.z&&(t.canonical.z>=r?s=t.canonical.z-r:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const n=t.canonical.x-(t.canonical.x>>s<>s<>8<<4|t>>8,i[e+3]=0;const r=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),s=new b(t,r,t.gl.RGBA,{premultiply:!1});return s.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=s,s}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,s=r.gl,n=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),a=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),o=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),s.readPixels(n,o-a-1,1,1,s.RGBA,s.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),h=this.coordsIndex[255-i[3]],u=h&&this.sourceCache.getTileByID(h);if(!u)return null;const d=this._coordsTextureSize,p=(1<t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse))}}const Is={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ts{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new ws(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsDescendingInv={};for(const e in t.sourceCaches){this._coordsDescendingInv[e]={};const i=t.sourceCaches[e].getVisibleCoordinates();for(const t of i){const i=this.terrain.sourceCache.getTerrainCoords(t);for(const t in i)this._coordsDescendingInv[e][t]||(this._coordsDescendingInv[e][t]=[]),this._coordsDescendingInv[e][t].push(i[t])}}this._coordsDescendingInvStr={};for(const e of t._order){const i=t._layers[e],r=i.source;if(Is[i.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}for(const t of this._renderableTiles)for(const e in this._coordsDescendingInvStr){const i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const i=t.type,r=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Is[i]&&(this._prevType&&Is[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!s))return!0;if(Is[this._prevType]||Is[i]&&s){this._prevType=i;const t=this._stacks.length-1,s=this._stacks[t]||[];for(const i of this._renderableTiles){if(this.pool.isFull()&&(lr(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[t]){const e=this.pool.getObjectForId(i.rtt[t].id);if(e.stamp===i.rtt[t].stamp){this.pool.useObject(e);continue}}const n=this.pool.getOrCreateFreeObject();this.pool.useObject(n),this.pool.stampObject(n),i.rtt[t]={id:n.id,stamp:n.stamp},r.context.bindFramebuffer.set(n.fbo.framebuffer),r.context.clear({color:e.aP.transparent,stencil:0}),r.currentStencilSource=void 0;for(let t=0;t{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},Cs={showCompass:!0,showZoom:!0,visualizePitch:!1};class Ms{constructor(t,i,r=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),a.mousePos(this.element,t)),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,a.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),a.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const s=t.dragRotate._mouseRotate.getClickTolerance(),n=t.dragRotate._mousePitch.getClickTolerance();this.element=i,this.mouseRotate=jr({clickTolerance:s,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>{const r=new Vr;return new Fr({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:r,enable:t,assignEvents:Ps})})({clickTolerance:s,enable:!0}),this.map=t,r&&(this.mousePitch=Ur({clickTolerance:n,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>{const r=new Vr;return new Fr({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:r,enable:t,assignEvents:Ps})})({clickTolerance:n,enable:!0})),a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),a.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),a.disableDrag()}moveMouse(t,e){const i=this.map,{bearingDelta:r}=this.mouseRotate.dragMove(t,e)||{};if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const{pitchDelta:r}=this.mousePitch.dragMove(t,e)||{};r&&i.setPitch(i.getPitch()+r)}}moveTouch(t,e){const i=this.map,{bearingDelta:r}=this.touchRotate.dragMove(t,e)||{};if(r&&i.setBearing(i.getBearing()+r),this.touchPitch){const{pitchDelta:r}=this.touchPitch.dragMove(t,e)||{};r&&i.setPitch(i.getPitch()+r)}}off(){const t=this.element;a.removeEventListener(t,"mousedown",this.mousedown),a.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend),a.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup),a.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),a.removeEventListener(window,"touchend",this.touchend)}}let ks;function zs(t,i,r){const s=new e.M(t.lng,t.lat);if(t=new e.M(t.lng,t.lat),i){const s=new e.M(t.lng-360,t.lat),n=new e.M(t.lng+360,t.lat),a=r.locationPoint(t).distSqr(i);r.locationPoint(s).distSqr(i)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t.lng!==s.lng&&r.locationPoint(t).y>r.height/2-r.getHorizon()?t:s}const Ds={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Rs(t,e,i){const r=t.classList;for(const t in Ds)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}class Ls extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{var e;if(!this._map)return;const i=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!i)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?zs(this._lngLat,this._flatPos,this._map.transform):null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let r="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?r=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(r=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let s="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?s="rotateX(0deg)":"map"===this._pitchAlignment&&(s=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),a.setTransform(this._element,`${Ds[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${s} ${r}`),n.frameAsync(new AbortController).then((()=>{this._updateOpacity(t&&"moveend"===t.type)})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=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&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=a.create("div"),this._element.setAttribute("aria-label","Map marker");const i=a.createNS("http://www.w3.org/2000/svg","svg"),r=41,s=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${s}px`),i.setAttributeNS(null,"viewBox",`0 0 ${s} ${r}`);const n=a.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");const o=a.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill-rule","nonzero");const l=a.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"transform","translate(3.0, 29.0)"),l.setAttributeNS(null,"fill","#000000");const c=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of c){const e=a.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),l.appendChild(e)}const h=a.createNS("http://www.w3.org/2000/svg","g");h.setAttributeNS(null,"fill",this._color);const u=a.createNS("http://www.w3.org/2000/svg","path");u.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),h.appendChild(u);const d=a.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=a.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=a.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=a.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=a.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=a.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),o.appendChild(l),o.appendChild(h),o.appendChild(d),o.appendChild(f),o.appendChild(m),i.appendChild(o),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",s*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),Rs(this._element,this._anchor,"marker"),t&&t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),a.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[r,-1*(e-i+r)],"bottom-right":[-r,-1*(e-i+r)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,r;if(!(null===(i=this._map)||void 0===i?void 0:i.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const s=this._map,n=s.terrain.depthAtPoint(this._pos),a=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,a)-n<.006)return void(this._element.style.opacity=this._opacity);const o=-this._offset.y/s.transform._pixelPerMeter,l=Math.sin(s.getPitch()*Math.PI/180)*o,c=s.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),h=s.transform.lngLatToCameraDepth(this._lngLat,a+l)-c>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&h&&this._popup.remove(),this._element.style.opacity=h?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}const Fs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Bs=0,Os=!1;const Vs={maxWidth:100,unit:"metric"};function Ns(t,e,i){const r=i&&i.maxWidth||100,s=t._container.clientHeight/2,n=t.unproject([0,s]),a=t.unproject([r,s]),o=n.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*o;i>5280?js(e,r,i/5280,t._getUIString("ScaleControl.Miles")):js(e,r,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?js(e,r,o/1852,t._getUIString("ScaleControl.NauticalMiles")):o>=1e3?js(e,r,o/1e3,t._getUIString("ScaleControl.Kilometers")):js(e,r,o,t._getUIString("ScaleControl.Meters"))}function js(t,e,i,r){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s} ${r}`}const Us={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},$s=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function qs(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return qs(new e.P(0,0))}const Zs=i;t.AJAXError=e.bf,t.Evented=e.E,t.LngLat=e.M,t.MercatorCoordinate=e.Y,t.Point=e.P,t.addProtocol=e.bg,t.config=e.a,t.removeProtocol=e.bh,t.AttributionControl=gs,t.BoxZoomHandler=kr,t.CanvasSource=Q,t.CooperativeGesturesHandler=cs,t.DoubleClickZoomHandler=rs,t.DragPanHandler=as,t.DragRotateHandler=os,t.EdgeInsets=dr,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},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.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){a.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=a.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);a.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},t.GeoJSONSource=X,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const i=new e.M(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,s=this._map.getBearing(),n=e.e({bearing:s},this.options.fitBoundsOptions),a=q.fromLngLat(i,r);this._map.fitBounds(a,n,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const i=new e.M(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()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Os)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=a.create("button","maplibregl-ctrl-geolocate",this._container),a.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!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.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=a.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ls({element:this._dotElement}),this._circleElement=a.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ls({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",(t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")))}))}},this.options=e.e({},Fs,t)}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==ks&&!t)return ks;if(void 0===window.navigator.permissions)return ks=!!window.navigator.geolocation,ks;try{const t=yield window.navigator.permissions.query({name:"geolocation"});ks="denied"!==t.state}catch(t){ks=!!window.navigator.geolocation}return ks}))}().then((t=>this._setupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),a.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Bs=0,Os=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),r=e.distanceTo(i),s=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${s}px`,this._circleElement.style.height=`${s}px`}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.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Bs--,Os=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Bs++,Bs>1?(t={maximumAge:6e5,timeout:0},Os=!0):(t=this.options.positionOptions,Os=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},t.Hash=gr,t.ImageSource=J,t.KeyboardHandler=Qr,t.LngLatBounds=q,t.LogoControl=_s,t.Map=class extends fs{constructor(t){if(e.bd.mark(e.be.create),null!=(t=e.e({},Es,t)).minZoom&&null!=t.maxZoom&&t.minZoom>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(super(new fr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,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._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new ys,this._controls=[],this._mapId=e.a3(),this._locale=e.e({},Ss,t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming,this._imageQueueHandle=p.addThrottleControl((()=>this.isMoving())),this._requestManager=new f(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once("idle",(()=>{this._idleTriggered=!0})),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1;const e=mr((t=>{this._trackResize&&!this._removed&&this.resize(t)._update()}),50);this._resizeObserver=new ResizeObserver((i=>{t?e(i):t=!0})),this._resizeObserver.observe(this._container)}this.handlers=new ps(this,t),this._hash=t.hash&&new gr("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new gs("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new _s,t.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.k(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.k("sourcedataabort",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.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const s=this._controlPositions[i];return-1!==i.indexOf("bottom")?s.insertBefore(r,s.firstChild):s.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(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(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,r)}resize(t){var i;const r=this._containerDimensions(),s=r[0],n=r[1],a=this._getClampedPixelRatio(s,n);if(this._resizeCanvas(s,n,a),this.painter.resize(s,n,a),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const e=this._getClampedPixelRatio(s,n);this._resizeCanvas(s,n,e),this.painter.resize(s,n,e)}this.transform.resize(s,n),null===(i=this._requestedCameraState)||void 0===i||i.resize(s,n);const o=!this._moving;return o&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),o&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){const{0:i,1:r}=this._maxCanvasSize,s=this.getPixelRatio(),n=t*s,a=e*s;return Math.min(n>i?i/n:1,a>r?r/a:1)*s}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(q.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-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;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<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;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.M.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;const s=s=>{const n=this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[];n.length?r||(r=!0,i.call(this,new Sr(t,this,s.originalEvent,{features:n}))):r=!1};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;const s=s=>{(this.getLayer(e)?this.queryRenderedFeatures(s.point,{layers:[e]}):[]).length?r=!0:r&&(r=!1,i.call(this,new Sr(t,this,s.originalEvent)))},n=e=>{r&&(r=!1,i.call(this,new Sr(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:s,mouseout:n}}}{const r=t=>{const r=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:r}}}}on(t,e,i){if(void 0===i)return super.on(t,e);const r=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(r);for(const t in r.delegates)this.on(t,r.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);const r=this._createDelegatedListener(t,e,i);for(const t in r.delegates)this.once(t,r.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(r=>{const s=this._delegatedListeners[t];for(let t=0;tthis._updateStyle(t,e)));const i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new ce(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new ce(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){const r=this._requestManager.transformRequest(t,"Style");e.h(r,new AbortController).then((t=>{this._updateDiff(t.data,i)})).catch((t=>{t&&this.fire(new e.j(t))}))}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(r){e.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}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.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.j(new Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.sourceCaches[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new bs(this.painter,i,t),this.painter.renderToTexture=new Ts(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){const t=this.style&&this.style.sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,i,r={}){const{pixelRatio:s=1,sdf:a=!1,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:n,data:d}=i,p=i;return this.style.addImage(t,{data:new e.R({width:r,height:n},new Uint8Array(d)),pixelRatio:s,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0,userImage:p}),p.onAdd&&p.onAdd(this,t),this}}{const{width:r,height:d,data:p}=n.getImageData(i);this.style.addImage(t,{data:new e.R({width:r,height:d},p),pixelRatio:s,stretchX:o,stretchY:l,content:c,textFitWidth:h,textFitHeight:u,sdf:a,version:0})}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return this.fire(new e.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=i instanceof HTMLImageElement||e.b(i)?n.getImageData(i):i,{width:a,height:o,data:l}=s;if(void 0===a||void 0===o)return this.fire(new e.j(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!==r.data.width||o!==r.data.height)return this.fire(new e.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||e.b(i));return r.data.replace(l,c),this.style.updateImage(t,r),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return p.getImage(this._requestManager.transformRequest(t,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,r={}){return this.style.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=a.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=a.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const s=this._controlContainer=a.create("div","maplibregl-control-container",t),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{n[t]=a.create("div",`maplibregl-ctrl-${t} `,s)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)}),{once:!0});const i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new cr(i,this.transform),o.testSupport(i)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){const i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,s=n.now();this.style.zoomHistory.update(t,s);const a=new e.a8(t,{now:s,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=a.crossFadingFactor();1===o&&o===this._crossFadingFactor||(r=!0,this._crossFadingFactor=o),this.style.update(a)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,i,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding}),this.fire(new e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.bd.mark(e.be.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,e.bd.mark(e.be.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),p.removeThrottleControl(this._imageQueueHandle),null===(t=this._resizeObserver)||void 0===t||t.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");i&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),a.remove(this._canvasContainer),a.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.bd.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,n.frameAsync(this._frameRequest).then((t=>{e.bd.frame(t),this._frameRequest=null,this._render(t)})).catch((()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return As}getCameraTargetElevation(){return this.transform.elevation}},t.MapMouseEvent=Sr,t.MapTouchEvent=Ar,t.MapWheelEvent=Er,t.Marker=Ls,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},Cs,t),this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),a.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),a.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=a.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ms(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){a.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=a.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this.remove=()=>(this._content&&a.remove(this._content),this._container&&(a.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var e;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=a.create("div","maplibregl-popup",this._map.getContainer()),this._tip=a.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?zs(this._lngLat,this._flatPos,this._map.transform):null===(e=this._lngLat)||void 0===e?void 0:e.wrap(),this._trackPointer&&!t)return;const i=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let r=this.options.anchor;const s=qs(this.options.offset);if(!r){const t=this._container.offsetWidth,e=this._container.offsetHeight;let n;n=i.y+s.bottom.ythis._map.transform.height-e?["bottom"]:[],i.xthis._map.transform.width-t/2&&n.push("right"),r=0===n.length?"bottom":n.join("-")}let n=i.add(s[r]);this.options.subpixelPositioning||(n=n.round()),a.setTransform(this._container,`${Ds[r]} translate(${n.x}px,${n.y}px)`),Rs(this._container,r,"popup")},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(Us),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=t;r=i.firstChild,r;)e.appendChild(r);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=a.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=a.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector($s);t&&t.focus()}},t.RasterDEMTileSource=H,t.RasterTileSource=W,t.ScaleControl=class{constructor(t){this._onMove=()=>{Ns(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Ns(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Vs),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){a.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=is,t.Style=ce,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=a.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=a.create("button","maplibregl-ctrl-terrain",this._container),a.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){a.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=Jr,t.TwoFingersTouchRotateHandler=Xr,t.TwoFingersTouchZoomHandler=Wr,t.TwoFingersTouchZoomRotateHandler=ls,t.VectorTileSource=G,t.VideoSource=Y,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,(function*(){if(et(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{tt[t]=e})(t,i)})),t.clearPrewarmedResources=function(){const t=L;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(z),L=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return nt().getRTLTextPluginStatus()},t.getVersion=function(){return Zs},t.getWorkerCount=function(){return D.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return V().broadcast("IS",t)},t.prewarm=function(){B().acquire(z)},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setRTLTextPlugin=function(t,e){return nt().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){D.workerCount=t},t.setWorkerUrl=function(t){e.a.WORKER_URL=t}}));var r=t;return r}();var J=X(K.exports);class Y{constructor(t,e,i){this.type=t,this.feature=e,this.originalEvent=i}}class Q{constructor(t,e){var i;this._sourceIds=[],this._layerIds=[],this.id=(null!==(i=e.id)&&void 0!==i?i:`feature-${Date.now()}`).toString(),(t.getFeatures()||[]).forEach((t=>{if(t.id===this.id)throw new Error(`RadarMapFeature: feature with id ${this.id} already exists.`)})),this.geometry=e.geometry,this.properties=e.properties||{},this._feature=e,this._map=t}remove(){this._layerIds.forEach((t=>{this._map.getLayer(t)&&this._map.removeLayer(t)})),this._sourceIds.forEach((t=>{this._map.getSource(t)&&this._map.removeSource(t)})),this._map._features=this._map._features.filter((t=>t.id!==this.id))}on(t,e){this._map.on(t,this.id,(i=>{e(new Y(t,this,i))})),"click"===t&&(this._map.on("mouseenter",this.id,(()=>{this._map.getCanvas().style.cursor="pointer"})),this._map.on("mouseleave",this.id,(()=>{this._map.getCanvas().style.cursor=""})))}}const tt=t=>{const e={};return Object.entries(t).forEach((([t,i])=>{void 0!==i&&(e[t]=i)})),e},et=(t,e={})=>{let i=Object.assign({},t);for(const r in e)e[r]instanceof Object&&!Array.isArray(e[r])&&r in t?i[r]=et(t[r],e[r]):Array.isArray(e[r])&&Array.isArray(t[r])?i[r]=t[r].concat(e[r]):i[r]=e[r];return i},it={paint:{"line-cap":"round","line-color":"#000257","line-width":4,"border-color":"#FFFFFF","border-width":2}};class rt extends Q{constructor(t,e,i){super(t,e);const r=this.id,s=et(it,i),n=()=>{if(s.paint=s.paint||{},t.addSource(r,{type:"geojson",data:e}),this._sourceIds.push(r),s.paint["line-width"]&&s.paint["border-width"]){const e=`${r}-border`,i=s.paint["line-width"]+s.paint["border-width"];t.addLayer({id:e,source:r,type:"line",layout:{"line-cap":s.paint["line-cap"]},paint:tt({"line-color":s.paint["border-color"],"line-opacity":s.paint["border-opacity"],"line-width":i})}),this._layerIds.push(e)}t.addLayer({id:r,source:r,type:"line",layout:{"line-cap":s.paint["line-cap"]},paint:tt({"line-color":s.paint["line-color"],"line-width":s.paint["line-width"],"line-opacity":s.paint["line-opacity"],"line-offset":s.paint["line-offset"],"line-blur":s.paint["line-blur"],"line-dasharray":s.paint["line-dasharray"],"line-gap-width":s.paint["line-gap-width"],"line-gradient":s.paint["line-gradient"]})}),this._layerIds.push(r)};return t.loaded()?n():t.once("data",(()=>{n()})),this}static fromPolyline(t,e,i){const r={id:(null==i?void 0:i.id)||`polyline-feature-${Date.now()}`,type:"Feature",geometry:{type:"LineString",coordinates:((t,e=6)=>{let i,r,s=0,n=0,a=0,o=[],l=0,c=0,h=null,u=Math.pow(10,e||6);for(;s=32);i=1&c?~(c>>1):c>>1,l=c=0;do{h=t.charCodeAt(s++)-63,c|=(31&h)<=32);r=1&c?~(c>>1):c>>1,n+=i,a+=r,o.push([a/u,n/u])}return o})(e,null==i?void 0:i.precision)},properties:(null==i?void 0:i.properties)||{}};return new rt(t,r,i)}}const st={paint:{"fill-color":"#FF6F00","fill-opacity":.3,"border-color":"#FF6F00","border-opacity":1,"border-width":2}};class nt extends Q{constructor(t,e,i){super(t,e);const r=this.id,s=et(st,i),n=()=>{if(s.paint=s.paint||{},t.addSource(r,{type:"geojson",data:e}),this._sourceIds.push(r),t.addLayer({id:r,source:r,type:"fill",layout:{},paint:tt({"fill-color":s.paint["fill-color"],"fill-opacity":s.paint["fill-opacity"]})}),this._layerIds.push(r),s.paint["border-color"]&&s.paint["border-width"]&&s.paint["border-opacity"]){let e=`${r}-border`;t.addLayer({id:e,source:r,type:"line",layout:{},paint:tt({"line-color":s.paint["border-color"],"line-opacity":s.paint["border-opacity"],"line-width":s.paint["border-width"]})}),this._layerIds.push(e)}};return t.loaded()?n():t.once("data",(()=>{n()})),this}}class at{onAdd(){const t=document.createElement("img");return t.src="https://api.radar.io/maps/static/images/logo.svg",t.alt="Radar Maps Platform",this.link=document.createElement("a"),this.link.id="radar-map-logo",this.link.href="https://radar.com?ref=powered_by_radar",this.link.target="_blank",this.link.style.pointerEvents="auto",this.link.appendChild(t),this.link}onRemove(){var t;null===(t=this.link)||void 0===t||t.remove()}}const ot=(t,e)=>{e.forEach((e=>{t.push(e)}))},lt=t=>{const e=[];return(t||[]).forEach((t=>{const i=(t=>{const e=[],i=t.geometry;switch(i.type){case"Point":e.push(i.coordinates);break;case"MultiPoint":case"LineString":ot(e,i.coordinates);break;case"MultiLineString":case"Polygon":i.coordinates.forEach((t=>ot(e,t)));break;case"MultiPolygon":i.coordinates.forEach((t=>{t.forEach((t=>ot(e,t)))}));break;default:return e}return e})(t);i.forEach((t=>{e.push(t)}))})),e},ct=["radar-default-v1","radar-light-v1","radar-dark-v1"],ht={showZoomControls:!0},ut={minZoom:1,maxZoom:20,attributionControl:!1,dragRotate:!1,touchPitch:!1,maplibreLogo:!1},dt={padding:50},pt=(t,e)=>{const i=e.style||"radar-default-v1";let r=`${t.host}/maps/styles/${i}`;return e.language&&(r+=`?language=${e.language}`),r},ft=t=>!!ct.includes(t)||!/^(http:|https:)/.test(t);class mt extends J.Map{constructor(e){const i=t.get();i.publishableKey||r.warn("publishableKey not set. Call Radar.initialize() with key before creating a new map.");const s=((t,e)=>{const i=e.style;return!i||"string"==typeof i&&ft(i)?pt(t,e):e.style})(i,e),n=Object.assign({},ht,ut,e,{style:s});r.debug("map initailized with options",n),n.transformRequest=(t,e)=>{"Style"===e&&ft(t)&&(t=pt(i,Object.assign(Object.assign({},n),{style:t})));let r={Authorization:i.publishableKey,"X-Radar-Device-Type":"Web","X-Radar-SDK-Version":T};return"function"==typeof i.getRequestHeaders&&(r=Object.assign(r,i.getRequestHeaders())),{url:t,headers:r}},super(n),this._markers=[],this._features=[];const a=this.getContainer();a.style.width||a.style.height||r.warn('map container does not have a set "width" or "height"');const o=new at;this.addControl(o,"bottom-left");const l=new J.AttributionControl({compact:!1});this.addControl(l,"bottom-right");const c=new J.NavigationControl({showCompass:!1,showZoom:n.showZoomControls});this.addControl(c,"bottom-right");const h=()=>{const t=document.querySelector(".maplibregl-ctrl-attrib");if(t){this.getContainer().clientWidth<380?t.classList.add("hidden"):t.classList.remove("hidden")}};this.on("resize",h),this.on("load",h)}addMarker(t){this._markers.push(t)}removeMarker(t){this._markers=this._markers.filter((e=>e!==t))}getMarkers(){return this._markers}fitToMarkers(t={},e){const i=e||this.getMarkers();if(0===i.length)return;const r=new J.LngLatBounds;i.forEach((t=>{r.extend(t.getLngLat())}));const s=Object.assign(dt,t);this.fitBounds(r,s)}clearMarkers(){this._markers.forEach((t=>{t.remove()}))}getFeatures(){return this._features}fitToFeatures(t={},e){const i=(e||this._features).map((t=>t._feature)),r=lt(i);if(r.length>0){const e=new J.LngLatBounds;r.forEach((t=>{e.extend(t)})),this.fitBounds(e,t)}}clearFeatures(){this._features.forEach((t=>{t.remove()}))}addPolygon(t,e){const i=new nt(this,t,e);return this._features.push(i),i}addLine(t,e){const i=new rt(this,t,e);return this._features.push(i),i}addPolyline(t,e){const i=rt.fromPolyline(this,t,e);return this._features.push(i),i}}class gt{constructor(t,e,i){this.target=e,this.originalEvent=i,this.point=e._pos,this.lngLat=e.getLngLat(),this.type=t}}const _t=new Map,yt=(t,e=5e3)=>new Promise(((i,r)=>{if(!_t.has(t))return _t.set(t,"pending"),r("miss");const s=Date.now(),n=setInterval((()=>{const a=_t.get(t);"pending"===a?Date.now()-s>e&&(clearInterval(n),r("timed out")):"failed"===a?(clearInterval(n),r("failed")):void 0!==a&&(clearInterval(n),i(a))}),100)})),xt={color:"#000257"};class vt extends J.Marker{constructor(t){const e=Object.assign({},xt);if(t.color&&(e.color=t.color),t.element&&(e.element=t.element),t.scale&&(e.scale=t.scale),super(e),t.marker||t.url){const e=this._element.cloneNode(!0);this._element.childNodes.forEach((t=>{t.remove()}));const i=e=>{this._element.replaceChildren((t=>{const e=document.createElement("img");return e.src=t.url,t.width&&("number"==typeof t.width?e.width=t.width:e.style.width=t.width),t.height&&("number"==typeof t.height?e.height=t.height:e.style.height=t.height),t.width||t.height||(e.style.maxWidth="64px",e.style.maxHeight="64px",e.style.width="100%",e.style.height="100%"),e})({width:t.width,height:t.height,url:e}))},s=i=>{r.error(`Could not load marker: ${i.message} - falling back to default marker`),_t.set(t.url,"failed"),this._element.replaceChildren(...Array.from(e.childNodes))};if(t.url){const e=()=>{fetch(t.url).then((e=>{200===e.status?e.blob().then((e=>{const r=URL.createObjectURL(e);_t.set(t.url,r),i(r)})).catch(s):s(new Error(e.statusText))})).catch(s)};yt(t.url).then(i).catch((i=>{"miss"!==i&&r.debug(`RadarMarker: cache lookup for ${t.url}: ${i}`),e()}))}if(t.marker){const e=()=>{A.request({method:"GET",version:"maps",path:`markers/${t.marker}`,responseType:"blob"}).then((({data:e})=>{const r=URL.createObjectURL(e);_t.set(t.marker,r),i(r)})).catch(s)};yt(t.marker).then(i).catch((i=>{"miss"!==i&&r.debug(`RadarMarker: cache lookup for ${t.marker} ${i}`),e()}))}}if(t.text&&(r.warn('marker option "text" is deprecated, and will be removed in a future version. Use "popup.text".'),t.popup=t.popup||{},t.popup.text=t.text),t.html&&(r.warn('marker option "html" is deprecated, and will be removed in a future version. Use "popup.html".'),t.popup=t.popup||{},t.popup.html=t.html),t.popup){const e=new J.Popup(t.popup);t.popup.text&&e.setText(t.popup.text),t.popup.html&&e.setHTML(t.popup.html),t.popup.element&&e.setDOMContent(t.popup.element),this.setPopup(e)}const i=this.getElement();i&&i.addEventListener("click",(t=>{t.stopPropagation(),this.getPopup()&&((this._map.getMarkers()||[]).forEach((t=>{var e;(null===(e=t.getPopup())||void 0===e?void 0:e.isOpen())&&t.togglePopup()})),this.togglePopup()),this.fire("click",new gt("click",this,t))}))}addTo(t){return t.addMarker(this),super.addTo(t)}remove(){return this._map&&this._map.removeMarker(this),super.remove()}}class bt extends J.Popup{constructor(t){super(t),t.text&&this.setText(t.text),t.html&&this.setHTML(t.html),t.element&&this.setDOMContent(t.element)}}class wt{static getMapLibre(){return J}static createMap(t){return new mt(t)}static createMarker(t={}){return new vt(t)}static createPopup(t){return new bt(t)}}const It="radar-autocomplete-wrapper",Tt="radar-autocomplete-input",St="radar-autocomplete-search-icon",At="radar-autocomplete-results-list",Et="radar-autocomplete-results-item",Pt="radar-autocomplete-results-marker",Ct="radar-autocomplete-results-item-selected",Mt="radar-powered",kt="radar-no-results",zt={container:"autocomplete",debounceMS:200,minCharacters:3,limit:8,placeholder:"Search address",responsive:!0,disabled:!1,showMarkers:!0,hideResultsOnBlur:!0},Dt=t=>"number"==typeof t?`${t}px`:t,Rt=(t,e)=>{if(e.responsive)return t.style.width="100%",void(e.width&&(t.style.maxWidth=Dt(e.width)));t.style.width=Dt(e.width||400),t.style.removeProperty("max-width")},Lt=(t,e)=>{e.maxHeight&&(t.style.maxHeight=Dt(e.maxHeight),t.style.overflowY="auto")},Ft=(t="#ACBDC8")=>`data:image/svg+xml;charset=utf-8,${`\n \n `.trim()}`;class Bt{static createAutocomplete(t){return new Bt(t)}constructor(t={}){let e;if(this.config=Object.assign({},zt,t),this.isOpen=!1,this.debouncedFetchResults=this.debounce(this.fetchResults,this.config.debounceMS),this.results=[],this.highlightedIndex=-1,void 0!==this.config.threshold&&(this.config.minCharacters=this.config.threshold,r.warn('AutocompleteUI option "threshold" is deprecated, use "minCharacters" instead.')),t.near&&("string"==typeof t.near?this.near=t.near:this.near=`${t.near.latitude},${t.near.longitude}`),e="string"==typeof this.config.container?document.getElementById(this.config.container):this.config.container,!e)throw new v(`Could not find container element: ${this.config.container}`);if(this.container=e,this.wrapper=document.createElement("div"),this.wrapper.classList.add(It),this.wrapper.style.display=this.config.responsive?"block":"inline-block",Rt(this.wrapper,this.config),this.resultsList=document.createElement("ul"),this.resultsList.classList.add(At),this.resultsList.setAttribute("id",At),this.resultsList.setAttribute("role","listbox"),this.resultsList.setAttribute("aria-live","polite"),this.resultsList.setAttribute("aria-label","Search results"),Lt(this.resultsList,this.config),"INPUT"===e.nodeName)this.inputField=e,this.wrapper.appendChild(this.resultsList),e.parentNode.appendChild(this.wrapper);else{this.inputField=document.createElement("input"),this.inputField.classList.add(Tt),this.inputField.placeholder=this.config.placeholder,this.inputField.type="text",this.inputField.disabled=this.config.disabled;const t=document.createElement("div");t.classList.add(St),this.wrapper.appendChild(this.inputField),this.wrapper.appendChild(this.resultsList),this.wrapper.appendChild(t),this.container.appendChild(this.wrapper)}this.inputField.setAttribute("autocomplete","off"),this.inputField.setAttribute("role","combobox"),this.inputField.setAttribute("aria-controls",At),this.inputField.setAttribute("aria-expanded","false"),this.inputField.setAttribute("aria-haspopup","listbox"),this.inputField.setAttribute("aria-autocomplete","list"),this.inputField.setAttribute("aria-activedescendant",""),this.inputField.addEventListener("input",this.handleInput.bind(this)),this.inputField.addEventListener("keydown",this.handleKeyboardNavigation.bind(this)),this.config.hideResultsOnBlur&&this.inputField.addEventListener("blur",this.close.bind(this),!0),r.debug("AutocompleteUI initialized with options",this.config)}handleInput(){const t=this.inputField.value;t.length{const e=this.config.onResults;e&&e(t),this.displayResults(t)})).catch((t=>{r.warn(`Autocomplete ui error: ${t.message}`);const e=this.config.onError;e&&e(t)}))}debounce(t,e){let i,r,s;return(...n)=>(clearTimeout(i),i=setTimeout((()=>{const e=t.apply(this,n);e instanceof Promise&&e.then((t=>{r&&r(t)})).catch((t=>{s&&s(t)}))}),e),new Promise(((t,e)=>{r=t,s=e})))}fetchResults(t){return n(this,void 0,void 0,(function*(){const{limit:e,layers:i,countryCode:r,expandUnits:s,mailable:n,lang:a,postalCode:o,onRequest:l}=this.config,c={query:t,limit:e,layers:i,countryCode:r,expandUnits:s,mailable:n,lang:a,postalCode:o};this.near&&(c.near=this.near),l&&l(c);const{addresses:h}=yield F.autocomplete(c,"autocomplete-ui");return h}))}displayResults(t){let e;if(this.clearResultsList(),this.results=t,this.config.showMarkers&&(e=document.createElement("img"),e.classList.add(Pt),e.setAttribute("src",Ft(this.config.markerColor))),t.forEach(((t,i)=>{const r=document.createElement("li");let s;if(r.classList.add(Et),r.setAttribute("role","option"),r.setAttribute("id",`${Et}}-${i}`),t.formattedAddress.includes(t.addressLabel)&&"postalCode"!==t.layer){const e=new RegExp(`(${t.addressLabel}),?`);s=t.formattedAddress.replace(e,"$1")}else{s=`${t.placeLabel||t.addressLabel} ${t.formattedAddress}`}r.innerHTML=s,e&&r.prepend(e.cloneNode()),r.addEventListener("mousedown",(()=>{this.select(i)})),this.resultsList.appendChild(r)})),this.open(),t.length>0){const t=document.createElement("a");t.href="https://radar.com?ref=powered_by_radar",t.target="_blank",this.poweredByLink=t;const e=document.createElement("span");e.textContent="Powered by",t.appendChild(e);const i=document.createElement("span");i.id="radar-powered-logo",i.textContent="Radar",t.appendChild(i);const r=document.createElement("div");r.classList.add(Mt),r.appendChild(t),this.resultsList.appendChild(r)}else{const t=document.createElement("div");t.classList.add(kt),t.textContent="No results",this.resultsList.appendChild(t)}}open(){this.isOpen||(this.inputField.setAttribute("aria-expanded","true"),this.resultsList.removeAttribute("hidden"),this.isOpen=!0)}close(t){if(!this.isOpen)return;const e=t&&t.relatedTarget===this.poweredByLink;setTimeout((()=>{this.inputField.setAttribute("aria-expanded","false"),this.inputField.setAttribute("aria-activedescendant",""),this.resultsList.setAttribute("hidden",""),this.highlightedIndex=-1,this.isOpen=!1,this.clearResultsList()}),e?100:0)}goTo(t){if(!this.isOpen||!this.results.length)return;t<0?t=this.results.length-1:t>=this.results.length&&(t=0);const e=this.resultsList.getElementsByTagName("li");this.highlightedIndex>-1&&e[this.highlightedIndex].classList.remove(Ct),e[t].classList.add(Ct),this.inputField.setAttribute("aria-activedescendant",`${Et}-${t}`),this.highlightedIndex=t}handleKeyboardNavigation(t){let e=t.key;if(this.isOpen)switch("Tab"===e&&t.shiftKey&&(e="ArrowUp"),e){case"Tab":case"ArrowDown":t.preventDefault(),this.goTo(this.highlightedIndex+1);break;case"ArrowUp":t.preventDefault(),this.goTo(this.highlightedIndex-1);break;case"Enter":this.select(this.highlightedIndex);break;case"Esc":this.close()}}select(t){const e=this.results[t];if(!e)return void r.warn(`No autocomplete result found at index: ${t}`);let i;if(e.formattedAddress.includes(e.addressLabel))i=e.formattedAddress;else{i=`${e.placeLabel||e.addressLabel}, ${e.formattedAddress}`}this.inputField.value=i;const s=this.config.onSelection;s&&s(e),this.close()}clearResultsList(){this.resultsList.innerHTML="",this.results=[]}remove(){r.debug("AutocompleteUI removed."),this.inputField.remove(),this.resultsList.remove(),this.wrapper.remove()}setNear(t){return this.near=null==t?void 0:"string"==typeof t?t:`${t.latitude},${t.longitude}`,this}setPlaceholder(t){return this.config.placeholder=t,this.inputField.placeholder=t,this}setDisabled(t){return this.config.disabled=t,this.inputField.disabled=t,this}setResponsive(t){return this.config.responsive=t,Rt(this.wrapper,this.config),this}setWidth(t){return null===t?this.config.width=void 0:"string"!=typeof t&&"number"!=typeof t||(this.config.width=t),Rt(this.wrapper,this.config),this}setMaxHeight(t){return null===t?this.config.maxHeight=void 0:"string"!=typeof t&&"number"!=typeof t||(this.config.maxHeight=t),Lt(this.resultsList,this.config),this}setMinCharacters(t){return this.config.minCharacters=t,this.config.threshold=t,this}setLimit(t){return this.config.limit=t,this}setLang(t){return null===t?this.config.lang=void 0:"string"==typeof t&&(this.config.lang=t),this}setPostalCode(t){return null===t?this.config.postalCode=void 0:"string"==typeof t&&(this.config.postalCode=t),this}setShowMarkers(t){if(this.config.showMarkers=t,t){const t=document.createElement("img");t.classList.add(Pt),t.setAttribute("src",Ft(this.config.markerColor));const e=this.resultsList.getElementsByTagName("li");for(let i=0;i