react-three-map 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +105 -48
  3. package/dist/cjs/main.js.js +1318 -1
  4. package/dist/es/main.js10.mjs +56 -0
  5. package/dist/es/main.js10.mjs.map +1 -0
  6. package/dist/es/main.js11.mjs +9 -0
  7. package/dist/es/main.js11.mjs.map +1 -0
  8. package/dist/es/main.js2.mjs +23 -28
  9. package/dist/es/main.js2.mjs.map +1 -1
  10. package/dist/es/main.js3.mjs +6 -7
  11. package/dist/es/main.js3.mjs.map +1 -1
  12. package/dist/es/main.js4.mjs +28 -56
  13. package/dist/es/main.js4.mjs.map +1 -1
  14. package/dist/es/main.js5.mjs +23533 -12
  15. package/dist/es/main.js5.mjs.map +1 -1
  16. package/dist/es/main.js6.mjs +2 -53
  17. package/dist/es/main.js6.mjs.map +1 -1
  18. package/dist/es/main.js7.mjs +2 -6
  19. package/dist/es/main.js7.mjs.map +1 -1
  20. package/dist/es/main.js8.mjs +60 -0
  21. package/dist/es/main.js8.mjs.map +1 -0
  22. package/dist/es/main.js9.mjs +16 -0
  23. package/dist/es/main.js9.mjs.map +1 -0
  24. package/dist/maplibre/cjs/main.js.js +1 -0
  25. package/dist/maplibre/es/main.js.mjs +5 -0
  26. package/dist/maplibre/es/main.js.mjs.map +1 -0
  27. package/dist/maplibre/es/main.js2.mjs +34 -0
  28. package/dist/maplibre/es/main.js2.mjs.map +1 -0
  29. package/dist/maplibre/es/main.js3.mjs +10 -0
  30. package/dist/maplibre/es/main.js3.mjs.map +1 -0
  31. package/dist/maplibre/es/main.js4.mjs +31 -0
  32. package/dist/maplibre/es/main.js4.mjs.map +1 -0
  33. package/dist/maplibre/es/main.js5.mjs +60 -0
  34. package/dist/maplibre/es/main.js5.mjs.map +1 -0
  35. package/dist/maplibre/es/main.js6.mjs +16 -0
  36. package/dist/maplibre/es/main.js6.mjs.map +1 -0
  37. package/dist/maplibre/es/main.js7.mjs +56 -0
  38. package/dist/maplibre/es/main.js7.mjs.map +1 -0
  39. package/dist/maplibre/es/main.js8.mjs +9 -0
  40. package/dist/maplibre/es/main.js8.mjs.map +1 -0
  41. package/docs/basic-app.gif +0 -0
  42. package/maplibre/package.json +7 -0
  43. package/package.json +12 -5
  44. package/src/canvas/canvas-mapbox.tsx +32 -0
  45. package/src/canvas/canvas-maplibre.tsx +32 -0
  46. package/src/canvas/core/coords-to-matrix.ts +20 -0
  47. package/src/canvas/{create-events.ts → core/create-events.ts} +2 -2
  48. package/src/canvas/core/generic-map.test.ts +2 -0
  49. package/src/canvas/core/generic-map.ts +44 -0
  50. package/src/canvas/core/internal-canvas.tsx +43 -0
  51. package/src/canvas/{state-ref.ts → core/state-ref.ts} +2 -2
  52. package/src/canvas/{use-on-add.ts → core/use-on-add.ts} +30 -18
  53. package/src/canvas/core/use-render.ts +25 -0
  54. package/src/main-mapbox.ts +1 -0
  55. package/src/main-maplibre.ts +1 -0
  56. package/src/stories/canvas.basic.stories.tsx +63 -0
  57. package/src/stories/{canvas.stories.tsx → comparison.stories.tsx} +6 -4
  58. package/src/stories/html-on-top.stories.tsx +26 -0
  59. package/src/stories/my-scene.tsx +18 -11
  60. package/src/stories/render-on-demand.stories.tsx +9 -7
  61. package/src/stories/story-map.tsx +40 -0
  62. package/dist/cjs/vite.svg +0 -1
  63. package/dist/es/vite.svg +0 -1
  64. package/index.html +0 -13
  65. package/src/canvas/canvas.tsx +0 -49
  66. package/src/canvas/coords-to-matrix.ts +0 -19
  67. package/src/canvas/use-render.ts +0 -29
  68. package/src/main.ts +0 -1
  69. /package/src/canvas/{use-function.ts → core/use-function.ts} +0 -0
@@ -1 +1,1318 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),h=require("@react-three/fiber"),d=require("react"),M=require("react-map-gl/maplibre"),m=require("three"),E=require("maplibre-gl");function b(n){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(r,t,e.get?e:{enumerable:!0,get:()=>n[t]})}}return r.default=n,Object.freeze(r)}const j=b(m),x=new m.Quaternion,C=new m.Euler,y=new m.Vector3,w=new m.Vector3;function R({longitude:n,latitude:r,altitude:t}){const e=E.MercatorCoordinate.fromLngLat([n,r],t),o=e.meterInMercatorCoordinateUnits();return y.set(e.x,e.y,e.z||0),w.set(o,-o,o),x.setFromEuler(C.set(-Math.PI*.5,0,0)),new m.Matrix4().compose(y,x,w)}const g={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function z(){return n=>{const{handlePointer:r}=h.createEvents(n);return{priority:1,enabled:!0,compute(t,e){e.size.width=e.gl.domElement.width,e.size.height=e.gl.domElement.height,e.pointer.x=t.offsetX/(e.size.width/window.devicePixelRatio)*2-1,e.pointer.y=1-t.offsetY/(e.size.height/window.devicePixelRatio)*2,e.raycaster.camera=e.camera,e.raycaster.ray.origin.setScalar(0).applyMatrix4(e.camera.projectionMatrixInverse),e.raycaster.ray.direction.set(e.pointer.x,e.pointer.y,1).applyMatrix4(e.camera.projectionMatrixInverse).sub(e.raycaster.ray.origin).normalize()},connected:void 0,handlers:Object.keys(g).reduce((t,e)=>({...t,[e]:r(e)}),{}),update:()=>{var o;const{events:t,internal:e}=n.getState();(o=e.lastEvent)!=null&&o.current&&t.handlers&&t.handlers.onPointerMove(e.lastEvent.current)},connect:t=>{var s;const{set:e,events:o}=n.getState();(s=o.disconnect)==null||s.call(o),e(c=>({events:{...c.events,connected:t}})),Object.entries(o.handlers??[]).forEach(([c,i])=>{const[l,a]=g[c];t.addEventListener(l,i,{passive:a})})},disconnect:()=>{const{set:t,events:e}=n.getState();e.connected&&(Object.entries(e.handlers??[]).forEach(([o,s])=>{if(e&&e.connected instanceof HTMLElement){const[c]=g[o];e.connected.removeEventListener(c,s)}}),t(o=>({events:{...o.events,connected:void 0}})))}}}}const v=n=>{const r=d.useRef(n);return r.current=n,d.useCallback((...t)=>r.current(...t),[])};function S(n,r){const[t,e]=d.useState(!1),o=v((i,l)=>{const a=i.getCanvas(),u=h.createRoot(a);u.configure({frameloop:"demand",dpr:window.devicePixelRatio,shadows:!0,events:z(),...r,gl:{context:l,depth:!0,autoClear:!1,antialias:!0,...r==null?void 0:r.gl},onCreated:f=>{n.current={state:f,map:i,root:u},f.gl.forceContextLoss=()=>{}},camera:{matrixAutoUpdate:!1},size:{width:a.clientWidth,height:a.clientHeight,top:0,left:0,...r==null?void 0:r.size}}),n.current={map:i,root:u},i.on("resize",s),setTimeout(()=>e(!0))}),s=v(()=>{var u;if(!((u=n.current)!=null&&u.state))return;const i=n.current.state,a=n.current.map.getCanvas();i.setSize(a.width,a.height)}),c=v(i=>{setTimeout(()=>{n.current&&(n.current.root.unmount(),i.off(c))})});return{onAdd:o,onRemove:c,mounted:t}}function O(n,r){const t=M.useMap();return v((o,s)=>{var a;if(!t.current||!((a=r.current)!=null&&a.state))return;const c=r.current.state.camera,i=r.current.state.gl,l=r.current.state.advance;c.projectionMatrix.fromArray(s).multiply(n),c.projectionMatrixInverse.copy(c.projectionMatrix).invert(),i.resetState(),l(Date.now()*.001,!0),r.current.state.frameloop==="always"&&t.current.triggerRepaint()})}h.extend(j);const L=d.memo(({longitude:n,latitude:r,altitude:t=0,children:e,...o})=>{const s=d.useId(),c=d.useRef(),i=d.useMemo(()=>R({latitude:r,longitude:n,altitude:t}),[r,n,t]),{onAdd:l,onRemove:a,mounted:u}=S(c,o),f=O(i,c);return d.useEffect(()=>{u&&c.current&&c.current.root.render(p.jsx(p.Fragment,{children:e}))},[c,u,e]),p.jsx(M.Layer,{id:s,type:"custom",renderingMode:"3d",onAdd:l,onRemove:a,render:f})});exports.Canvas=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const zh=require("react/jsx-runtime"),dd=require("@react-three/fiber"),Fn=require("react"),vs=require("three"),Eg=require("react-map-gl");function Sg(St){const qt=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(St){for(const dt in St)if(dt!=="default"){const rt=Object.getOwnPropertyDescriptor(St,dt);Object.defineProperty(qt,dt,rt.get?rt:{enumerable:!0,get:()=>St[dt]})}}return qt.default=St,Object.freeze(qt)}const Mg=Sg(vs),$f=new vs.Quaternion,Ag=new vs.Euler,Zf=new vs.Vector3,qf=new vs.Vector3,Ig=new vs.Matrix4;function Cg({longitude:St,latitude:qt,altitude:dt,fromLngLat:rt}){const jt=rt([St,qt],dt),Kt=jt.meterInMercatorCoordinateUnits();return Zf.set(jt.x,jt.y,jt.z||0),qf.set(Kt,-Kt,Kt),$f.setFromEuler(Ag.set(-Math.PI*.5,0,0)),Ig.compose(Zf,$f,qf).toArray()}const ud={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function zg(){return St=>{const{handlePointer:qt}=dd.createEvents(St);return{priority:1,enabled:!0,compute(dt,rt){rt.size.width=rt.gl.domElement.width,rt.size.height=rt.gl.domElement.height,rt.pointer.x=dt.offsetX/(rt.size.width/window.devicePixelRatio)*2-1,rt.pointer.y=1-dt.offsetY/(rt.size.height/window.devicePixelRatio)*2,rt.raycaster.camera=rt.camera,rt.raycaster.ray.origin.setScalar(0).applyMatrix4(rt.camera.projectionMatrixInverse),rt.raycaster.ray.direction.set(rt.pointer.x,rt.pointer.y,1).applyMatrix4(rt.camera.projectionMatrixInverse).sub(rt.raycaster.ray.origin).normalize()},connected:void 0,handlers:Object.keys(ud).reduce((dt,rt)=>({...dt,[rt]:qt(rt)}),{}),update:()=>{var jt;const{events:dt,internal:rt}=St.getState();(jt=rt.lastEvent)!=null&&jt.current&&dt.handlers&&dt.handlers.onPointerMove(rt.lastEvent.current)},connect:dt=>{var Kt;const{set:rt,events:jt}=St.getState();(Kt=jt.disconnect)==null||Kt.call(jt),rt(Di=>({events:{...Di.events,connected:dt.parentNode}})),Object.entries(jt.handlers??[]).forEach(([Di,a])=>{const[ve,ui]=ud[Di];dt.addEventListener(ve,a,{passive:ui})})},disconnect:()=>{const{set:dt,events:rt}=St.getState();rt.connected&&(Object.entries(rt.handlers??[]).forEach(([jt,Kt])=>{if(rt&&rt.connected instanceof HTMLElement){const[Di]=ud[jt];rt.connected.removeEventListener(Di,Kt)}}),dt(jt=>({events:{...jt.events,connected:void 0}})))}}}}const Ph=St=>{const qt=Fn.useRef(St);return qt.current=St,Fn.useCallback((...dt)=>qt.current(...dt),[])};function Pg(St,{frameloop:qt,...dt}){const[rt,jt]=Fn.useState(!1),Kt=Ph((ve,ui)=>{const pi=ve.getCanvas(),Xe=dd.createRoot(pi);Xe.configure({dpr:window.devicePixelRatio,events:zg(),...dt,frameloop:"never",gl:{context:ui,depth:!0,autoClear:!1,antialias:!0,...dt==null?void 0:dt.gl},onCreated:nt=>{qt==="demand"&&nt.set({frameloop:qt,invalidate:()=>{ve.triggerRepaint()}}),St.current={state:nt,map:ve,root:Xe},nt.gl.forceContextLoss=()=>{},nt.camera.matrixAutoUpdate=!1},size:{width:pi.clientWidth,height:pi.clientHeight,top:0,left:0,...dt==null?void 0:dt.size}}),St.current={map:ve,root:Xe},ve.on("resize",Di),setTimeout(()=>jt(!0))}),Di=Ph(()=>{var Xe;if(!((Xe=St.current)!=null&&Xe.state))return;const ve=St.current.state,pi=St.current.map.getCanvas();ve.setSize(pi.width,pi.height)}),a=Ph(ve=>{setTimeout(()=>{St.current&&(St.current.root.unmount(),ve.off("resize",Di))})});return{onAdd:Kt,onRemove:a,mounted:rt}}const kg=new vs.Matrix4;function Dg(St,qt,dt){return Ph((jt,Kt)=>{var ui;if(!((ui=qt.current)!=null&&ui.state))return;const Di=qt.current.state.camera,a=qt.current.state.gl,ve=qt.current.state.advance;Di.projectionMatrix.fromArray(Kt).multiply(kg.fromArray(St)),Di.projectionMatrixInverse.copy(Di.projectionMatrix).invert(),a.resetState(),ve(Date.now()*.001,!0),dt==="always"&&qt.current.map.triggerRepaint()})}const Wf=Fn.memo(({m4:St,children:qt,frameloop:dt,...rt})=>{const jt=Fn.useId(),Kt=Fn.useRef(),{onAdd:Di,onRemove:a,mounted:ve}=Pg(Kt,{frameloop:dt,...rt}),ui=Dg(St,Kt,dt);return Fn.useEffect(()=>{ve&&Kt.current&&Kt.current.root.render(zh.jsx(zh.Fragment,{children:qt}))},[Kt,ve,qt]),zh.jsx(Eg.Layer,{id:jt,type:"custom",renderingMode:"3d",onAdd:Di,onRemove:a,render:ui})});Wf.displayName="InternalCanvas";var Lg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Xf={exports:{}};(function(St,qt){(function(dt,rt){St.exports=rt()})(Lg,function(){var dt,rt,jt;function Kt(a,ve){if(!dt)dt=ve;else if(!rt)rt=ve;else{var ui="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+dt+")(sharedChunk); ("+rt+")(sharedChunk); self.onerror = null;",pi={};dt(pi),jt=ve(pi),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(jt.workerUrl=window.URL.createObjectURL(new Blob([ui],{type:"text/javascript"})))}}Kt(["exports"],function(a){var ve=typeof self<"u"?self:{},ui="2.15.0";let pi;const Xe={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(pi==null){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{pi=process.env.API_URL_REGEX!=null?new RegExp(process.env.API_URL_REGEX):t}catch{pi=t}}return pi},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!Xe.API_URL)return null;try{const t=new URL(Xe.API_URL);return t.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":t.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},nt={supported:!1,testSupport:function(t){!Sr&&Li&&(Mr?Mo(t):Si=t)}};let Si,Li,Sr=!1,Mr=!1;function Mo(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Li),t.isContextLost())return;nt.supported=!0}catch{}t.deleteTexture(e),Sr=!0}ve.document&&(Li=ve.document.createElement("img"),Li.onload=function(){Si&&Mo(Si),Si=null,Mr=!0},Li.onerror=function(){Sr=!0,Si=null},Li.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Un="01";function or(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Vn=sr;function sr(t,e,i,n){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*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}sr.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(e===void 0&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var c=this.sampleCurveDerivativeX(i);if(Math.abs(c)<1e-6)break;i-=s/c}var u=0,p=1;for(i=t,n=0;n<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));n++)t>s?u=i:p=i,i=.5*(p-u)+u;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var pn=or(Vn),fn=ar;function ar(t,e){this.x=t,this.y=e}ar.prototype={clone:function(){return new ar(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),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),s=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=s,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},ar.convert=function(t){return t instanceof ar?t:Array.isArray(t)?new ar(t[0],t[1]):t};var Le=or(fn);const Sa=Math.PI/180,Ma=180/Math.PI;function ft(t){return t*Sa}function fi(t){return t*Ma}const Aa=[[0,0],[1,0],[1,1],[0,1]];function bs(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function Ao(t,e,i,n){const s=new pn(t,e,i,n);return function(c){return s.solve(c)}}const ws=Ao(.25,.1,.25,1);function ut(t,e,i){return Math.min(i,Math.max(e,t))}function Nn(t,e,i){return(i=ut((i-t)/(e-t),0,1))*i*(3-2*i)}function di(t,e,i){const n=i-e,s=((t-e)%n+n)%n+e;return s===e?i:s}function mi(t,e,i){if(!t.length)return i(null,[]);let n=t.length;const s=new Array(t.length);let c=null;t.forEach((u,p)=>{e(u,(m,_)=>{m&&(c=m),s[p]=_,--n==0&&i(c,s)})})}function Hr(t){const e=[];for(const i in t)e.push(t[i]);return e}function Qt(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}let Kr=1;function jn(){return Kr++}function Yr(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function Ar(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function Ts(t){return!!t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)}function mn(t,e){t.forEach(i=>{e[i]&&(e[i]=e[i].bind(e))})}function Gn(t,e){return t.indexOf(e,t.length-e.length)!==-1}function mt(t,e,i){const n={};for(const s in t)n[s]=e.call(i||this,t[s],s,t);return n}function $n(t,e,i){const n={};for(const s in t)e.call(i||this,t[s],s,t)&&(n[s]=t[s]);return n}function Gi(t){return Array.isArray(t)?t.map(Gi):typeof t=="object"&&t?mt(t,Gi):t}const Io={};function Gt(t){Io[t]||(typeof console<"u"&&console.warn(t),Io[t]=!0)}function Xi(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function Es(t){let e=0;for(let i,n,s=0,c=t.length,u=c-1;s<c;u=s++)i=t[s],n=t[u],e+=(n.x-i.x)*(i.y+n.y);return e}function Ir(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function $i(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(i,n,s,c)=>{const u=s||c;return e[n]=!u||u.toLowerCase(),""}),e["max-age"]){const i=parseInt(e["max-age"],10);isNaN(i)?delete e["max-age"]:e["max-age"]=i}return e}let Co=null;function Zn(t){if(Co==null){const e=t.navigator?t.navigator.userAgent:null;Co=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Co}function zo(t){try{const e=ve[t];return e.setItem("_mapbox_test_",1),e.removeItem("_mapbox_test_"),!0}catch{return!1}}function Jr(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const qn="mapbox-tiles";let Ss=500,Ms=50,Hi,Qr;function Po(){try{return ve.caches}catch{}}function _n(){Po()&&!Hi&&(Hi=ve.caches.open(qn))}function Wn(t){const e=t.indexOf("?");if(e<0)return t;const i=function(s){const c=s.indexOf("?");return c>0?s.slice(c+1).split("&"):[]}(t),n=i.filter(s=>{const c=s.split("=");return c[0]==="language"||c[0]==="worldview"});return n.length?`${t.slice(0,e)}?${n.join("&")}`:t.slice(0,e)}let ko=1/0;const gn={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(gn);class en extends Error{constructor(e,i,n){i===401&&ne(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=i,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const yn=Ir()?()=>self.worker&&self.worker.referrer:()=>(ve.location.protocol==="blob:"?ve.parent:ve).location.href,xn=function(t,e){if(!(/^file:/.test(i=t.url)||/^file:/.test(yn())&&!/^\w+:/.test(i))){if(ve.fetch&&ve.Request&&ve.AbortController&&ve.Request.prototype.hasOwnProperty("signal"))return function(n,s){const c=new ve.AbortController,u=new ve.Request(n.url,{method:n.method||"GET",body:n.body,credentials:n.credentials,headers:n.headers,referrer:yn(),referrerPolicy:n.referrerPolicy,signal:c.signal});let p=!1,m=!1;const _=(x=u.url).indexOf("sku=")>0&&ne(x);var x;n.type==="json"&&u.headers.set("Accept","application/json");const b=(S,M,C)=>{if(m)return;if(S&&S.message!=="SecurityError"&&Gt(S.toString()),M&&C)return w(M);const D=Date.now();ve.fetch(u).then(U=>{if(U.ok){const q=_?U.clone():null;return w(U,q,D)}return s(new en(U.statusText,U.status,n.url))}).catch(U=>{U.name!=="AbortError"&&s(new Error(`${U.message} ${n.url}`))})},w=(S,M,C)=>{(n.type==="arrayBuffer"?S.arrayBuffer():n.type==="json"?S.json():S.text()).then(D=>{m||(M&&C&&function(U,q,V){if(_n(),!Hi)return;const $={status:q.status,statusText:q.statusText,headers:new ve.Headers};q.headers.forEach((ce,se)=>$.headers.set(se,ce));const X=$i(q.headers.get("Cache-Control")||"");if(X["no-store"])return;X["max-age"]&&$.headers.set("Expires",new Date(V+1e3*X["max-age"]).toUTCString());const W=$.headers.get("Expires");W&&(new Date(W).getTime()-V<42e4||function(ce,se){if(Qr===void 0)try{new Response(new ReadableStream),Qr=!0}catch{Qr=!1}Qr?se(ce.body):ce.blob().then(se)}(q,ce=>{const se=new ve.Response(ce,$);_n(),Hi&&Hi.then(me=>me.put(Wn(U.url),se)).catch(me=>Gt(me.message))}))}(u,M,C),p=!0,s(null,D,S.headers.get("Cache-Control"),S.headers.get("Expires")))}).catch(D=>{m||s(new Error(D.message))})};return _?function(S,M){if(_n(),!Hi)return M(null);const C=Wn(S.url);Hi.then(D=>{D.match(C).then(U=>{const q=function(V){if(!V)return!1;const $=new Date(V.headers.get("Expires")||0),X=$i(V.headers.get("Cache-Control")||"");return $>Date.now()&&!X["no-cache"]}(U);D.delete(C),q&&D.put(C,U.clone()),M(null,U,q)}).catch(M)}).catch(M)}(u,b):b(null,null),{cancel:()=>{m=!0,p||c.abort()}}}(t,e);if(Ir()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,e,void 0,!0)}var i;return function(n,s){const c=new ve.XMLHttpRequest;c.open(n.method||"GET",n.url,!0),n.type==="arrayBuffer"&&(c.responseType="arraybuffer");for(const u in n.headers)c.setRequestHeader(u,n.headers[u]);return n.type==="json"&&(c.responseType="text",c.setRequestHeader("Accept","application/json")),c.withCredentials=n.credentials==="include",c.onerror=()=>{s(new Error(c.statusText))},c.onload=()=>{if((c.status>=200&&c.status<300||c.status===0)&&c.response!==null){let u=c.response;if(n.type==="json")try{u=JSON.parse(c.response)}catch(p){return s(p)}s(null,u,c.getResponseHeader("Cache-Control"),c.getResponseHeader("Expires"))}else s(new en(c.statusText,c.status,n.url))},c.send(n.body),{cancel:()=>c.abort()}}(t,e)},Xn=function(t,e){return xn(Qt(t,{type:"arrayBuffer"}),e)};function As(t){const e=ve.document.createElement("a");return e.href=t,e.protocol===ve.document.location.protocol&&e.host===ve.document.location.host}const Z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let z,P;z=[],P=0;const G=function(t,e){if(nt.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),P>=Xe.MAX_PARALLEL_IMAGE_REQUESTS){const c={requestParameters:t,callback:e,cancelled:!1,cancel(){this.cancelled=!0}};return z.push(c),c}P++;let i=!1;const n=()=>{if(!i)for(i=!0,P--;z.length&&P<Xe.MAX_PARALLEL_IMAGE_REQUESTS;){const c=z.shift(),{requestParameters:u,callback:p,cancelled:m}=c;m||(c.cancel=G(u,p).cancel)}},s=Xn(t,(c,u,p,m)=>{n(),c?e(c):u&&(ve.createImageBitmap?function(_,x){const b=new ve.Blob([new Uint8Array(_)],{type:"image/png"});ve.createImageBitmap(b).then(w=>{x(null,w)}).catch(w=>{x(new Error(`Could not load image because of ${w.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(u,(_,x)=>e(_,x,p,m)):function(_,x){const b=new ve.Image,w=ve.URL;b.onload=()=>{x(null,b),w.revokeObjectURL(b.src),b.onload=null,ve.requestAnimationFrame(()=>{b.src=Z})},b.onerror=()=>x(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 ve.Blob([new Uint8Array(_)],{type:"image/png"});b.src=_.byteLength?w.createObjectURL(S):Z}(u,(_,x)=>e(_,x,p,m)))});return{cancel:()=>{s.cancel(),n()}}},H="NO_ACCESS_TOKEN";function ee(t){return t.indexOf("mapbox:")===0}function ne(t){return Xe.API_URL_REGEX.test(t)}function re(t){return Xe.API_CDN_URL_REGEX.test(t)}function Q(t){return Xe.API_STYLE_REGEX.test(t)&&!de(t)}function de(t){return Xe.API_SPRITE_REGEX.test(t)}const Pe=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ke(t){const e=t.match(Pe);if(!e)throw new Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function Ie(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const Qe="mapbox.eventData";function ot(t){if(!t)return null;const e=t.split(".");if(!e||e.length!==3)return null;try{return JSON.parse(decodeURIComponent(ve.atob(e[1]).split("").map(i=>"%"+("00"+i.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class et{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const i=ot(Xe.ACCESS_TOKEN);let n="";return n=i&&i.u?ve.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,(s,c)=>String.fromCharCode(+("0x"+c)))):Xe.ACCESS_TOKEN||"",e?`${Qe}.${e}:${n}`:`${Qe}:${n}`}fetchEventData(){const e=zo("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{const s=ve.localStorage.getItem(i);s&&(this.eventData=JSON.parse(s));const c=ve.localStorage.getItem(n);c&&(this.anonId=c)}catch{Gt("Unable to read from LocalStorage")}}saveEventData(){const e=zo("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(e)try{ve.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&ve.localStorage.setItem(i,JSON.stringify(this.eventData))}catch{Gt("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,i,n,s){if(!Xe.EVENTS_URL)return;const c=ke(Xe.EVENTS_URL);c.params.push(`access_token=${s||Xe.ACCESS_TOKEN||""}`);const u={event:this.type,created:new Date(e).toISOString()},p=i?Qt(u,i):u,m={url:Ie(c),headers:{"Content-Type":"text/plain"},body:JSON.stringify([p])};this.pendingRequest=function(_,x){return xn(Qt(_,{method:"POST"}),x)}(m,_=>{this.pendingRequest=null,n(_),this.saveEventData(),this.processRequests(s)})}queueRequest(e,i){this.queue.push(e),this.processRequests(i)}}const st=new class extends et{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){Xe.EVENTS_URL&&Xe.ACCESS_TOKEN&&Array.isArray(t)&&t.some(i=>ee(i)||ne(i))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=ot(Xe.ACCESS_TOKEN),i=e?e.u:Xe.ACCESS_TOKEN;let n=i!==this.eventData.tokenU;Ts(this.anonId)||(this.anonId=Yr(),n=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const c=new Date(this.eventData.lastSuccess),u=new Date(s),p=(s-this.eventData.lastSuccess)/864e5;n=n||p>=1||p<-1||c.getDate()!==u.getDate()}else n=!0;n?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:ui,skuId:Un,"enabled.telemetry":!1,userId:this.anonId},c=>{c||(this.eventData.lastSuccess=s,this.eventData.tokenU=i)},t):this.processRequests()}},_t=st.postTurnstileEvent.bind(st),$t=new class extends et{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,n){this.skuToken=e,this.errorCb=n,Xe.EVENTS_URL&&(i||Xe.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(H)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),Ts(this.anonId)||(this.anonId=Yr()),this.postEvent(i,{sdkIdentifier:"mapbox-gl-js",sdkVersion:ui,skuId:Un,skuToken:this.skuToken,userId:this.anonId},n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t))}},ei=$t.postMapLoadEvent.bind($t),Mi=new class extends et{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){Xe.EVENTS_URL&&(t||Xe.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:e,performanceData:i}=this.queue.shift(),n=function(s){const c=ve.performance.getEntriesByType("resource"),u=ve.performance.getEntriesByType("mark"),p=function(w){const S={};if(w){for(const M in w)if(M!=="other")for(const C of w[M]){const D=`${M}ResolveRangeMin`,U=`${M}ResolveRangeMax`,q=`${M}RequestCount`,V=`${M}RequestCachedCount`;S[D]=Math.min(S[D]||1/0,C.startTime),S[U]=Math.max(S[U]||-1/0,C.responseEnd);const $=X=>{S[X]===void 0&&(S[X]=0),++S[X]};C.transferSize!==void 0&&C.transferSize===0&&$(V),$(q)}}return S}(function(w,S){const M={};if(w)for(const C of w){const D=S(C);M[D]===void 0&&(M[D]=[]),M[D].push(C)}return M}(c,oc)),m=ve.devicePixelRatio,_=ve.navigator.connection||ve.navigator.mozConnection||ve.navigator.webkitConnection,x={counters:[],metadata:[],attributes:[]},b=(w,S,M)=>{M!=null&&w.push({name:S,value:M.toString()})};for(const w in p)b(x.counters,w,p[w]);if(s.interactionRange[0]!==1/0&&s.interactionRange[1]!==-1/0&&(b(x.counters,"interactionRangeMin",s.interactionRange[0]),b(x.counters,"interactionRangeMax",s.interactionRange[1])),u)for(const w of Object.keys(Hn)){const S=Hn[w],M=u.find(C=>C.name===S);M&&b(x.counters,S,M.startTime)}return b(x.counters,"visibilityHidden",s.visibilityHidden),b(x.attributes,"style",function(w){if(w)for(const S of w){const M=S.name.split("?")[0];if(Q(M)){const C=M.split("/").slice(-2);if(C.length===2)return`mapbox://styles/${C[0]}/${C[1]}`}}}(c)),b(x.attributes,"terrainEnabled",s.terrainEnabled?"true":"false"),b(x.attributes,"fogEnabled",s.fogEnabled?"true":"false"),b(x.attributes,"projection",s.projection),b(x.attributes,"zoom",s.zoom),b(x.metadata,"devicePixelRatio",m),b(x.metadata,"connectionEffectiveType",_?_.effectiveType:void 0),b(x.metadata,"navigatorUserAgent",ve.navigator.userAgent),b(x.metadata,"screenWidth",ve.screen.width),b(x.metadata,"screenHeight",ve.screen.height),b(x.metadata,"windowWidth",ve.innerWidth),b(x.metadata,"windowHeight",ve.innerHeight),b(x.metadata,"mapWidth",s.width/m),b(x.metadata,"mapHeight",s.height/m),b(x.metadata,"webglRenderer",s.renderer),b(x.metadata,"webglVendor",s.vendor),b(x.metadata,"sdkVersion",ui),b(x.metadata,"sdkIdentifier","mapbox-gl-js"),x}(i);for(const s of n.metadata);for(const s of n.counters);for(const s of n.attributes);this.postEvent(e,n,()=>{},t)}},ci=Mi.postPerformanceEvent.bind(Mi),fr=new class extends et{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,n){if(!Xe.API_URL||!Xe.SESSION_PATH)return;const s=ke(Xe.API_URL+Xe.SESSION_PATH);s.params.push(`sku=${e||""}`),s.params.push(`access_token=${n||Xe.ACCESS_TOKEN||""}`);const c={url:Ie(s),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(u,p){return xn(Qt(u,{method:"GET"}),p)}(c,u=>{this.pendingRequest=null,i(u),this.saveEventData(),this.processRequests(n)})}getSessionAPI(t,e,i,n){this.skuToken=e,this.errorCb=n,Xe.SESSION_PATH&&Xe.API_URL&&(i||Xe.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(H)))}processRequests(t){if(this.pendingRequest||this.queue.length===0)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,n=>{n?this.errorCb(n):e&&(this.success[e]=!0)},t)}},_i=fr.getSessionAPI.bind(fr),Pi=new Set,Hn={create:"create",load:"load",fullLoad:"fullLoad"},kh={mark(t){ve.performance.mark(t)},measure(t,e,i){ve.performance.measure(t,e,i)}};function oc(t){const e=t.name.split("?")[0];return re(e)&&e.includes("mapbox-gl.js")?"javascript":re(e)&&e.includes("mapbox-gl.css")?"css":function(i){return Xe.API_FONTS_REGEX.test(i)}(e)?"fontRange":de(e)?"sprite":Q(e)?"style":function(i){return Xe.API_TILEJSON_REGEX.test(i)}(e)?"tilejson":"other"}const wt=ve.performance;function Ia(t){const e=t?t.url.toString():void 0;return wt.getEntriesByName(e)}let Do,Ca,Is,mr;const Cr={now:()=>Is!==void 0?Is:ve.performance.now(),setNow(t){Is=t},restoreNow(){Is=void 0},frame(t){const e=ve.requestAnimationFrame(t);return{cancel:()=>ve.cancelAnimationFrame(e)}},getImageData(t,e=0){const{width:i,height:n}=t;mr||(mr=ve.document.createElement("canvas"));const s=mr.getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("failed to create canvas 2d context");return(i>mr.width||n>mr.height)&&(mr.width=i,mr.height=n),s.clearRect(-e,-e,i+2*e,n+2*e),s.drawImage(t,0,0,i,n),s.getImageData(-e,-e,i+2*e,n+2*e)},resolveURL:t=>(Do||(Do=ve.document.createElement("a")),Do.href=t,Do.href),get devicePixelRatio(){return ve.devicePixelRatio},get prefersReducedMotion(){return!!ve.matchMedia&&(Ca==null&&(Ca=ve.matchMedia("(prefers-reduced-motion: reduce)")),Ca.matches)}};function za(t,e,i){i[t]&&i[t].indexOf(e)!==-1||(i[t]=i[t]||[],i[t].push(e))}function Pa(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);n!==-1&&i[t].splice(n,1)}}class vn{constructor(e,i={}){Qt(this,i),this.type=e}}class zr extends vn{constructor(e,i={}){super("error",Qt({error:e},i))}}class Lo{on(e,i){return this._listeners=this._listeners||{},za(e,i,this._listeners),this}off(e,i){return Pa(e,i,this._listeners),Pa(e,i,this._oneTimeListeners),this}once(e,i){return i?(this._oneTimeListeners=this._oneTimeListeners||{},za(e,i,this._oneTimeListeners),this):new Promise(n=>this.once(e,n))}fire(e,i){typeof e=="string"&&(e=new vn(e,i||{}));const n=e.type;if(this.listens(n)){e.target=this;const s=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const p of s)p.call(this,e);const c=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const p of c)Pa(n,p,this._oneTimeListeners),p.call(this,e);const u=this._eventedParent;u&&(Qt(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),u.fire(e))}else e instanceof zr&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,i){return this._eventedParent=e,this._eventedParentData=i,this}}var fe=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"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"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"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":true,"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":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"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":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"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_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"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":true,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"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":true,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"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":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"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_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"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":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"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"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Pr(t,...e){for(const i of e)for(const n in i)t[n]=i[n];return t}function ti(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function gi(t){if(Array.isArray(t))return t.map(gi);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=gi(t[i]);return e}return ti(t)}class sc extends Error{constructor(e,i){super(i),this.message=i,this.key=e}}var _r=sc;class ka{constructor(e,i=[]){this.parent=e,this.bindings={};for(const[n,s]of i)this.bindings[n]=s}concat(e){return new ka(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var ac=ka;const Kn={kind:"null"},Oe={kind:"number"},pt={kind:"string"},lt={kind:"boolean"},Zi={kind:"color"},lr={kind:"object"},ct={kind:"value"},qi={kind:"collator"},Ro={kind:"formatted"},bn={kind:"resolvedImage"};function Ki(t,e){return{kind:"array",itemType:t,N:e}}function Vt(t){if(t.kind==="array"){const e=Vt(t.itemType);return typeof t.N=="number"?`array<${e}, ${t.N}>`:t.itemType.kind==="value"?"array":`array<${e}>`}return t.kind}const lc=[Kn,Oe,pt,lt,Zi,Ro,lr,Ki(ct),bn];function kr(t,e){if(e.kind==="error")return null;if(t.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!kr(t.itemType,e.itemType))&&(typeof t.N!="number"||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if(t.kind==="value"){for(const i of lc)if(!kr(i,e))return null}}return`Expected ${Vt(t)} but found ${Vt(e)} instead.`}function Bo(t,e){return e.some(i=>i.kind===t.kind)}function Oo(t,e){return e.some(i=>i==="null"?t===null:i==="array"?Array.isArray(t):i==="object"?t&&!Array.isArray(t)&&typeof t=="object":i===typeof t)}var Da,cc={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Fo(t){return(t=Math.round(t))<0?0:t>255?255:t}function Uo(t){return Fo(t[t.length-1]==="%"?parseFloat(t)/100*255:parseInt(t))}function Cs(t){return(e=t[t.length-1]==="%"?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Yn(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Da={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in cc)return cc[i].slice();if(i[0]==="#")return i.length===4?(e=parseInt(i.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:i.length===7&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),s=i.indexOf(")");if(n!==-1&&s+1===i.length){var c=i.substr(0,n),u=i.substr(n+1,s-(n+1)).split(","),p=1;switch(c){case"rgba":if(u.length!==4)return null;p=Cs(u.pop());case"rgb":return u.length!==3?null:[Uo(u[0]),Uo(u[1]),Uo(u[2]),p];case"hsla":if(u.length!==4)return null;p=Cs(u.pop());case"hsl":if(u.length!==3)return null;var m=(parseFloat(u[0])%360+360)%360/360,_=Cs(u[1]),x=Cs(u[2]),b=x<=.5?x*(_+1):x+_-x*_,w=2*x-b;return[Fo(255*Yn(w,b,m+1/3)),Fo(255*Yn(w,b,m)),Fo(255*Yn(w,b,m-1/3)),p];default:return null}}return null}}catch{}class Ri{constructor(e,i,n,s=1){this.r=e,this.g=i,this.b=n,this.a=s}static parse(e){if(!e)return;if(e instanceof Ri)return e;if(typeof e!="string")return;const i=Da(e);return i?new Ri(i[0]/255*i[3],i[1]/255*i[3],i[2]/255*i[3],i[3]):void 0}toString(){const[e,i,n,s]=this.toArray();return`rgba(${Math.round(e)},${Math.round(i)},${Math.round(n)},${s})`}toArray(){const{r:e,g:i,b:n,a:s}=this;return s===0?[0,0,0,0]:[255*e/s,255*i/s,255*n/s,s]}toArray01(){const{r:e,g:i,b:n,a:s}=this;return s===0?[0,0,0,0]:[e/s,i/s,n/s,s]}toArray01PremultipliedAlpha(){const{r:e,g:i,b:n,a:s}=this;return[e,i,n,s]}}Ri.black=new Ri(0,0,0,1),Ri.white=new Ri(1,1,1,1),Ri.transparent=new Ri(0,0,0,0),Ri.red=new Ri(1,0,0,1),Ri.blue=new Ri(0,0,1,1);var Yt=Ri;class La{constructor(e,i,n){this.sensitivity=e?i?"variant":"case":i?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,i){return this.collator.compare(e,i)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Ra{constructor(e,i,n,s,c){this.text=e.normalize?e.normalize():e,this.image=i,this.scale=n,this.fontStack=s,this.textColor=c}}class Bi{constructor(e){this.sections=e}static fromString(e){return new Bi([new Ra(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Bi?e:Bi.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const i of this.sections){if(i.image){e.push(["image",i.image.name]);continue}e.push(i.text);const n={};i.fontStack&&(n["text-font"]=["literal",i.fontStack.split(",")]),i.scale&&(n["font-scale"]=i.scale),i.textColor&&(n["text-color"]=["rgba"].concat(i.textColor.toArray())),e.push(n)}return e}}class Yi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new Yi({name:e,available:!1}):null}serialize(){return["image",this.name]}}function hc(t,e,i,n){return typeof t=="number"&&t>=0&&t<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof i=="number"&&i>=0&&i<=255?n===void 0||typeof n=="number"&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof n=="number"?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Vo(t){if(t===null||typeof t=="string"||typeof t=="boolean"||typeof t=="number"||t instanceof Yt||t instanceof La||t instanceof Bi||t instanceof Yi)return!0;if(Array.isArray(t)){for(const e of t)if(!Vo(e))return!1;return!0}if(typeof t=="object"){for(const e in t)if(!Vo(t[e]))return!1;return!0}return!1}function Xt(t){if(t===null)return Kn;if(typeof t=="string")return pt;if(typeof t=="boolean")return lt;if(typeof t=="number")return Oe;if(t instanceof Yt)return Zi;if(t instanceof La)return qi;if(t instanceof Bi)return Ro;if(t instanceof Yi)return bn;if(Array.isArray(t)){const e=t.length;let i;for(const n of t){const s=Xt(n);if(i){if(i===s)continue;i=ct;break}i=s}return Ki(i||ct,e)}return lr}function No(t){const e=typeof t;return t===null?"":e==="string"||e==="number"||e==="boolean"?String(t):t instanceof Yt||t instanceof Bi||t instanceof Yi?t.toString():JSON.stringify(t)}class Ba{constructor(e,i){this.type=e,this.value=i}static parse(e,i){if(e.length!==2)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Vo(e[1]))return i.error("invalid value");const n=e[1];let s=Xt(n);const c=i.expectedType;return s.kind!=="array"||s.N!==0||!c||c.kind!=="array"||typeof c.N=="number"&&c.N!==0||(s=c),new Ba(s,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof Yt?["rgba"].concat(this.value.toArray()):this.value instanceof Bi?this.value.serialize():this.value}}var wn=Ba,wi=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Oa={string:pt,number:Oe,boolean:lt,object:lr};class Fa{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let n,s=1;const c=e[0];if(c==="array"){let p,m;if(e.length>2){const _=e[1];if(typeof _!="string"||!(_ in Oa)||_==="object")return i.error('The item type argument of "array" must be one of string, number, boolean',1);p=Oa[_],s++}else p=ct;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);m=e[2],s++}n=Ki(p,m)}else n=Oa[c];const u=[];for(;s<e.length;s++){const p=i.parse(e[s],s,ct);if(!p)return null;u.push(p)}return new Fa(n,u)}evaluate(e){for(let i=0;i<this.args.length;i++){const n=this.args[i].evaluate(e);if(!kr(this.type,Xt(n)))return n;if(i===this.args.length-1)throw new wi(`Expected value to be of type ${Vt(this.type)}, but found ${Vt(Xt(n))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,i=[e.kind];if(e.kind==="array"){const n=e.itemType;if(n.kind==="string"||n.kind==="number"||n.kind==="boolean"){i.push(n.kind);const s=e.N;(typeof s=="number"||this.args.length>1)&&i.push(s)}}return i.concat(this.args.map(n=>n.serialize()))}}var Dr=Fa;class tn{constructor(e){this.type=Ro,this.sections=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&typeof n=="object")return i.error("First argument must be an image or text section.");const s=[];let c=!1;for(let u=1;u<=e.length-1;++u){const p=e[u];if(c&&typeof p=="object"&&!Array.isArray(p)){c=!1;let m=null;if(p["font-scale"]&&(m=i.parse(p["font-scale"],1,Oe),!m))return null;let _=null;if(p["text-font"]&&(_=i.parse(p["text-font"],1,Ki(pt)),!_))return null;let x=null;if(p["text-color"]&&(x=i.parse(p["text-color"],1,Zi),!x))return null;const b=s[s.length-1];b.scale=m,b.font=_,b.textColor=x}else{const m=i.parse(e[u],1,ct);if(!m)return null;const _=m.type.kind;if(_!=="string"&&_!=="value"&&_!=="null"&&_!=="resolvedImage")return i.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");c=!0,s.push({content:m,scale:null,font:null,textColor:null})}}return new tn(s)}evaluate(e){return new Bi(this.sections.map(i=>{const n=i.content.evaluate(e);return Xt(n)===bn?new Ra("",n,null,null,null):new Ra(No(n),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)}))}eachChild(e){for(const i of this.sections)e(i.content),i.scale&&e(i.scale),i.font&&e(i.font),i.textColor&&e(i.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const i of this.sections){e.push(i.content.serialize());const n={};i.scale&&(n["font-scale"]=i.scale.serialize()),i.font&&(n["text-font"]=i.font.serialize()),i.textColor&&(n["text-color"]=i.textColor.serialize()),e.push(n)}return e}}class zs{constructor(e){this.type=bn,this.input=e}static parse(e,i){if(e.length!==2)return i.error("Expected two arguments.");const n=i.parse(e[1],1,pt);return n?new zs(n):i.error("No image name provided.")}evaluate(e){const i=this.input.evaluate(e),n=Yi.fromString(i);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(i)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Dh={"to-boolean":lt,"to-color":Zi,"to-number":Oe,"to-string":pt};class Ua{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");const n=e[0];if((n==="to-boolean"||n==="to-string")&&e.length!==2)return i.error("Expected one argument.");const s=Dh[n],c=[];for(let u=1;u<e.length;u++){const p=i.parse(e[u],u,ct);if(!p)return null;c.push(p)}return new Ua(s,c)}evaluate(e){if(this.type.kind==="boolean")return!!this.args[0].evaluate(e);if(this.type.kind==="color"){let i,n;for(const s of this.args){if(i=s.evaluate(e),n=null,i instanceof Yt)return i;if(typeof i=="string"){const c=e.parseColor(i);if(c)return c}else if(Array.isArray(i)&&(n=i.length<3||i.length>4?`Invalid rbga value ${JSON.stringify(i)}: expected an array containing either three or four numeric values.`:hc(i[0],i[1],i[2],i[3]),!n))return new Yt(i[0]/255,i[1]/255,i[2]/255,i[3])}throw new wi(n||`Could not parse color from value '${typeof i=="string"?i:String(JSON.stringify(i))}'`)}if(this.type.kind==="number"){let i=null;for(const n of this.args){if(i=n.evaluate(e),i===null)return 0;const s=Number(i);if(!isNaN(s))return s}throw new wi(`Could not convert ${JSON.stringify(i)} to number.`)}return this.type.kind==="formatted"?Bi.fromString(No(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?Yi.fromString(No(this.args[0].evaluate(e))):No(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new tn([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new zs(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(i=>{e.push(i.serialize())}),e}}var Jn=Ua;const gr=["Unknown","Point","LineString","Polygon"];var Va=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?gr[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||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Yt.parse(t)),e}};class Tn{constructor(e,i,n,s){this.name=e,this.type=i,this._evaluate=n,this.args=s}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,i){const n=e[0],s=Tn.definitions[n];if(!s)return i.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const c=Array.isArray(s)?s[0]:s.type,u=Array.isArray(s)?[[s[1],s[2]]]:s.overloads,p=u.filter(([_])=>!Array.isArray(_)||_.length===e.length-1);let m=null;for(const[_,x]of p){m=new qa(i.registry,i.path,null,i.scope);const b=[];let w=!1;for(let S=1;S<e.length;S++){const M=e[S],C=Array.isArray(_)?_[S-1]:_.type,D=m.parse(M,1+b.length,C);if(!D){w=!0;break}b.push(D)}if(!w)if(Array.isArray(_)&&_.length!==b.length)m.error(`Expected ${_.length} arguments, but found ${b.length} instead.`);else{for(let S=0;S<b.length;S++){const M=Array.isArray(_)?_[S]:_.type,C=b[S];m.concat(S+1).checkSubtype(M,C.type)}if(m.errors.length===0)return new Tn(n,c,x,b)}}if(p.length===1)i.errors.push(...m.errors);else{const _=(p.length?p:u).map(([b])=>{return w=b,Array.isArray(w)?`(${w.map(Vt).join(", ")})`:`(${Vt(w.type)}...)`;var w}).join(" | "),x=[];for(let b=1;b<e.length;b++){const w=i.parse(e[b],1+x.length);if(!w)return null;x.push(Vt(w.type))}i.error(`Expected arguments of type ${_}, but found (${x.join(", ")}) instead.`)}return null}static register(e,i){Tn.definitions=i;for(const n in i)e[n]=Tn}}var Lr=Tn;class jo{constructor(e,i,n){this.type=qi,this.locale=n,this.caseSensitive=e,this.diacriticSensitive=i}static parse(e,i){if(e.length!==2)return i.error("Expected one argument.");const n=e[1];if(typeof n!="object"||Array.isArray(n))return i.error("Collator options argument must be an object.");const s=i.parse(n["case-sensitive"]!==void 0&&n["case-sensitive"],1,lt);if(!s)return null;const c=i.parse(n["diacritic-sensitive"]!==void 0&&n["diacritic-sensitive"],1,lt);if(!c)return null;let u=null;return n.locale&&(u=i.parse(n.locale,1,pt),!u)?null:new jo(s,c,u)}evaluate(e){return new La(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Rr=8192;function Ps(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 Qn(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function Go(t,e){const i=(180+t[0])/360,n=(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*Rr),Math.round(n*s*Rr)]}function uc(t,e,i){const n=t[0]-e[0],s=t[1]-e[1],c=t[0]-i[0],u=t[1]-i[1];return n*u-c*s==0&&n*c<=0&&s*u<=0}function ks(t,e){let i=!1;for(let u=0,p=e.length;u<p;u++){const m=e[u];for(let _=0,x=m.length;_<x-1;_++){if(uc(t,m[_],m[_+1]))return!1;(s=m[_])[1]>(n=t)[1]!=(c=m[_+1])[1]>n[1]&&n[0]<(c[0]-s[0])*(n[1]-s[1])/(c[1]-s[1])+s[0]&&(i=!i)}}var n,s,c;return i}function Na(t,e){for(let i=0;i<e.length;i++)if(ks(t,e[i]))return!0;return!1}function ja(t,e,i,n){const s=n[0]-i[0],c=n[1]-i[1],u=(t[0]-i[0])*c-s*(t[1]-i[1]),p=(e[0]-i[0])*c-s*(e[1]-i[1]);return u>0&&p<0||u<0&&p>0}function eo(t,e,i){for(const _ of i)for(let x=0;x<_.length-1;++x)if((p=[(u=_[x+1])[0]-(c=_[x])[0],u[1]-c[1]])[0]*(m=[(s=e)[0]-(n=t)[0],s[1]-n[1]])[1]-p[1]*m[0]!=0&&ja(n,s,c,u)&&ja(c,u,n,s))return!0;var n,s,c,u,p,m;return!1}function Tt(t,e){for(let i=0;i<t.length;++i)if(!ks(t[i],e))return!1;for(let i=0;i<t.length-1;++i)if(eo(t[i],t[i+1],e))return!1;return!0}function Lh(t,e){for(let i=0;i<e.length;i++)if(Tt(t,e[i]))return!0;return!1}function Ga(t,e,i){const n=[];for(let s=0;s<t.length;s++){const c=[];for(let u=0;u<t[s].length;u++){const p=Go(t[s][u],i);Ps(e,p),c.push(p)}n.push(c)}return n}function dc(t,e,i){const n=[];for(let s=0;s<t.length;s++){const c=Ga(t[s],e,i);n.push(c)}return n}function $a(t,e,i,n){if(t[0]<i[0]||t[0]>i[2]){const s=.5*n;let c=t[0]-i[0]>s?-n:i[0]-t[0]>s?n:0;c===0&&(c=t[0]-i[2]>s?-n:i[2]-t[0]>s?n:0),t[0]+=c}Ps(e,t)}function pc(t,e,i,n){const s=Math.pow(2,n.z)*Rr,c=[n.x*Rr,n.y*Rr],u=[];if(!t)return u;for(const p of t)for(const m of p){const _=[m.x+c[0],m.y+c[1]];$a(_,e,i,s),u.push(_)}return u}function Za(t,e,i,n){const s=Math.pow(2,n.z)*Rr,c=[n.x*Rr,n.y*Rr],u=[];if(!t)return u;for(const m of t){const _=[];for(const x of m){const b=[x.x+c[0],x.y+c[1]];Ps(e,b),_.push(b)}u.push(_)}if(e[2]-e[0]<=s/2){(p=e)[0]=p[1]=1/0,p[2]=p[3]=-1/0;for(const m of u)for(const _ of m)$a(_,e,i,s)}var p;return u}class to{constructor(e,i){this.type=lt,this.geojson=e,this.geometries=i}static parse(e,i){if(e.length!==2)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Vo(e[1])){const n=e[1];if(n.type==="FeatureCollection")for(let s=0;s<n.features.length;++s){const c=n.features[s].geometry.type;if(c==="Polygon"||c==="MultiPolygon")return new to(n,n.features[s].geometry)}else if(n.type==="Feature"){const s=n.geometry.type;if(s==="Polygon"||s==="MultiPolygon")return new to(n,n.geometry)}else if(n.type==="Polygon"||n.type==="MultiPolygon")return new to(n,n)}return i.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(i,n){const s=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(n.type==="Polygon"){const p=Ga(n.coordinates,c,u),m=pc(i.geometry(),s,c,u);if(!Qn(s,c))return!1;for(const _ of m)if(!ks(_,p))return!1}if(n.type==="MultiPolygon"){const p=dc(n.coordinates,c,u),m=pc(i.geometry(),s,c,u);if(!Qn(s,c))return!1;for(const _ of m)if(!Na(_,p))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(i,n){const s=[1/0,1/0,-1/0,-1/0],c=[1/0,1/0,-1/0,-1/0],u=i.canonicalID();if(!u)return!1;if(n.type==="Polygon"){const p=Ga(n.coordinates,c,u),m=Za(i.geometry(),s,c,u);if(!Qn(s,c))return!1;for(const _ of m)if(!Tt(_,p))return!1}if(n.type==="MultiPolygon"){const p=dc(n.coordinates,c,u),m=Za(i.geometry(),s,c,u);if(!Qn(s,c))return!1;for(const _ of m)if(!Lh(_,p))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var Ds=to;function io(t){if(t instanceof Lr&&(t.name==="get"&&t.args.length===1||t.name==="feature-state"||t.name==="has"&&t.args.length===1||t.name==="properties"||t.name==="geometry-type"||t.name==="id"||/^filter-/.test(t.name))||t instanceof Ds)return!1;let e=!0;return t.eachChild(i=>{e&&!io(i)&&(e=!1)}),e}function Br(t){if(t instanceof Lr&&t.name==="feature-state")return!1;let e=!0;return t.eachChild(i=>{e&&!Br(i)&&(e=!1)}),e}function En(t,e){if(t instanceof Lr&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild(n=>{i&&!En(n,e)&&(i=!1)}),i}class Ls{constructor(e,i){this.type=i.type,this.name=e,this.boundExpression=i}static parse(e,i){if(e.length!==2||typeof e[1]!="string")return i.error("'var' expression requires exactly one string literal argument.");const n=e[1];return i.scope.has(n)?new Ls(n,i.scope.get(n)):i.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var fc=Ls;class $o{constructor(e,i=[],n,s=new ac,c=[]){this.registry=e,this.path=i,this.key=i.map(u=>`[${u}]`).join(""),this.scope=s,this.errors=c,this.expectedType=n}parse(e,i,n,s,c={}){return i?this.concat(i,n,s)._parse(e,c):this._parse(e,c)}_parse(e,i){function n(s,c,u){return u==="assert"?new Dr(c,[s]):u==="coerce"?new Jn(c,[s]):s}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const s=e[0];if(typeof s!="string")return this.error(`Expression name must be a string, but found ${typeof s} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const c=this.registry[s];if(c){let u=c.parse(e,this);if(!u)return null;if(this.expectedType){const p=this.expectedType,m=u.type;if(p.kind!=="string"&&p.kind!=="number"&&p.kind!=="boolean"&&p.kind!=="object"&&p.kind!=="array"||m.kind!=="value")if(p.kind!=="color"&&p.kind!=="formatted"&&p.kind!=="resolvedImage"||m.kind!=="value"&&m.kind!=="string"){if(this.checkSubtype(p,m))return null}else u=n(u,p,i.typeAnnotation||"coerce");else u=n(u,p,i.typeAnnotation||"assert")}if(!(u instanceof wn)&&u.type.kind!=="resolvedImage"&&Wa(u)){const p=new Va;try{u=new wn(u.type,u.evaluate(p))}catch(m){return this.error(m.message),null}}return u}return this.error(`Unknown expression "${s}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,i,n){const s=typeof e=="number"?this.path.concat(e):this.path,c=n?this.scope.concat(n):this.scope;return new $o(this.registry,s,i||null,c,this.errors)}error(e,...i){const n=`${this.key}${i.map(s=>`[${s}]`).join("")}`;this.errors.push(new _r(n,e))}checkSubtype(e,i){const n=kr(e,i);return n&&this.error(n),n}}var qa=$o;function Wa(t){if(t instanceof fc)return Wa(t.boundExpression);if(t instanceof Lr&&t.name==="error"||t instanceof jo||t instanceof Ds)return!1;const e=t instanceof Jn||t instanceof Dr;let i=!0;return t.eachChild(n=>{i=e?i&&Wa(n):i&&n instanceof wn}),!!i&&io(t)&&En(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Rs(t,e){const i=t.length-1;let n,s,c=0,u=i,p=0;for(;c<=u;)if(p=Math.floor((c+u)/2),n=t[p],s=t[p+1],n<=e){if(p===i||e<s)return p;c=p+1}else{if(!(n>e))throw new wi("Input is not a number.");u=p-1}return 0}class Bs{constructor(e,i,n){this.type=e,this.input=i,this.labels=[],this.outputs=[];for(const[s,c]of n)this.labels.push(s),this.outputs.push(c)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");const n=i.parse(e[1],1,Oe);if(!n)return null;const s=[];let c=null;i.expectedType&&i.expectedType.kind!=="value"&&(c=i.expectedType);for(let u=1;u<e.length;u+=2){const p=u===1?-1/0:e[u],m=e[u+1],_=u,x=u+1;if(typeof p!="number")return i.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',_);if(s.length&&s[s.length-1][0]>=p)return i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',_);const b=i.parse(m,x,c);if(!b)return null;c=c||b.type,s.push([p,b])}return new Bs(c,n,s)}evaluate(e){const i=this.labels,n=this.outputs;if(i.length===1)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=i[0])return n[0].evaluate(e);const c=i.length;return s>=i[c-1]?n[c-1].evaluate(e):n[Rs(i,s)].evaluate(e)}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let i=0;i<this.labels.length;i++)i>0&&e.push(this.labels[i]),e.push(this.outputs[i].serialize());return e}}var Xa=Bs;function gt(t,e,i){return t*(1-i)+e*i}var Zo=Object.freeze({__proto__:null,array:function(t,e,i){return t.map((n,s)=>gt(n,e[s],i))},color:function(t,e,i){return new Yt(gt(t.r,e.r,i),gt(t.g,e.g,i),gt(t.b,e.b,i),gt(t.a,e.a,i))},number:gt});const mc=.95047,Ha=1.08883,_c=4/29,Sn=6/29,Ka=3*Sn*Sn,Rh=Sn*Sn*Sn,Bh=Math.PI/180,Oh=180/Math.PI;function Ya(t){return t>Rh?Math.pow(t,1/3):t/Ka+_c}function Ja(t){return t>Sn?t*t*t:Ka*(t-_c)}function Qa(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Os(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function gc(t){const e=Os(t.r),i=Os(t.g),n=Os(t.b),s=Ya((.4124564*e+.3575761*i+.1804375*n)/mc),c=Ya((.2126729*e+.7151522*i+.072175*n)/1);return{l:116*c-16,a:500*(s-c),b:200*(c-Ya((.0193339*e+.119192*i+.9503041*n)/Ha)),alpha:t.a}}function yc(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Ja(e),i=mc*Ja(i),n=Ha*Ja(n),new Yt(Qa(3.2404542*i-1.5371385*e-.4985314*n),Qa(-.969266*i+1.8760108*e+.041556*n),Qa(.0556434*i-.2040259*e+1.0572252*n),t.alpha)}function Fh(t,e,i){const n=e-t;return t+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const qo={forward:gc,reverse:yc,interpolate:function(t,e,i){return{l:gt(t.l,e.l,i),a:gt(t.a,e.a,i),b:gt(t.b,e.b,i),alpha:gt(t.alpha,e.alpha,i)}}},ro={forward:function(t){const{l:e,a:i,b:n}=gc(t),s=Math.atan2(n,i)*Oh;return{h:s<0?s+360:s,c:Math.sqrt(i*i+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Bh,i=t.c;return yc({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Fh(t.h,e.h,i),c:gt(t.c,e.c,i),l:gt(t.l,e.l,i),alpha:gt(t.alpha,e.alpha,i)}}};var el=Object.freeze({__proto__:null,hcl:ro,lab:qo});class Wo{constructor(e,i,n,s,c){this.type=e,this.operator=i,this.interpolation=n,this.input=s,this.labels=[],this.outputs=[];for(const[u,p]of c)this.labels.push(u),this.outputs.push(p)}static interpolationFactor(e,i,n,s){let c=0;if(e.name==="exponential")c=tl(i,e.base,n,s);else if(e.name==="linear")c=tl(i,1,n,s);else if(e.name==="cubic-bezier"){const u=e.controlPoints;c=new pn(u[0],u[1],u[2],u[3]).solve(tl(i,1,n,s))}return c}static parse(e,i){let[n,s,c,...u]=e;if(!Array.isArray(s)||s.length===0)return i.error("Expected an interpolation type expression.",1);if(s[0]==="linear")s={name:"linear"};else if(s[0]==="exponential"){const _=s[1];if(typeof _!="number")return i.error("Exponential interpolation requires a numeric base.",1,1);s={name:"exponential",base:_}}else{if(s[0]!=="cubic-bezier")return i.error(`Unknown interpolation type ${String(s[0])}`,1,0);{const _=s.slice(1);if(_.length!==4||_.some(x=>typeof x!="number"||x<0||x>1))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);s={name:"cubic-bezier",controlPoints:_}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(c=i.parse(c,2,Oe),!c)return null;const p=[];let m=null;n==="interpolate-hcl"||n==="interpolate-lab"?m=Zi:i.expectedType&&i.expectedType.kind!=="value"&&(m=i.expectedType);for(let _=0;_<u.length;_+=2){const x=u[_],b=u[_+1],w=_+3,S=_+4;if(typeof x!="number")return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',w);if(p.length&&p[p.length-1][0]>=x)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',w);const M=i.parse(b,S,m);if(!M)return null;m=m||M.type,p.push([x,M])}return m.kind==="number"||m.kind==="color"||m.kind==="array"&&m.itemType.kind==="number"&&typeof m.N=="number"?new Wo(m,n,s,c,p):i.error(`Type ${Vt(m)} is not interpolatable.`)}evaluate(e){const i=this.labels,n=this.outputs;if(i.length===1)return n[0].evaluate(e);const s=this.input.evaluate(e);if(s<=i[0])return n[0].evaluate(e);const c=i.length;if(s>=i[c-1])return n[c-1].evaluate(e);const u=Rs(i,s),p=Wo.interpolationFactor(this.interpolation,s,i[u],i[u+1]),m=n[u].evaluate(e),_=n[u+1].evaluate(e);return this.operator==="interpolate"?Zo[this.type.kind.toLowerCase()](m,_,p):this.operator==="interpolate-hcl"?ro.reverse(ro.interpolate(ro.forward(m),ro.forward(_),p)):qo.reverse(qo.interpolate(qo.forward(m),qo.forward(_),p))}eachChild(e){e(this.input);for(const i of this.outputs)e(i)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const i=[this.operator,e,this.input.serialize()];for(let n=0;n<this.labels.length;n++)i.push(this.labels[n],this.outputs[n].serialize());return i}}function tl(t,e,i,n){const s=n-i,c=t-i;return s===0?0:e===1?c/s:(Math.pow(e,c)-1)/(Math.pow(e,s)-1)}var yr=Wo;class Fs{constructor(e,i){this.type=e,this.args=i}static parse(e,i){if(e.length<2)return i.error("Expectected at least one argument.");let n=null;const s=i.expectedType;s&&s.kind!=="value"&&(n=s);const c=[];for(const p of e.slice(1)){const m=i.parse(p,1+c.length,n,void 0,{typeAnnotation:"omit"});if(!m)return null;n=n||m.type,c.push(m)}const u=s&&c.some(p=>kr(s,p.type));return new Fs(u?ct:n,c)}evaluate(e){let i,n=null,s=0;for(const c of this.args){if(s++,n=c.evaluate(e),n&&n instanceof Yi&&!n.available&&(i||(i=n),n=null,s===this.args.length))return i;if(n!==null)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var il=Fs;class Us{constructor(e,i){this.type=i.type,this.bindings=[].concat(e),this.result=i}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const i of this.bindings)e(i[1]);e(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const n=[];for(let c=1;c<e.length-1;c+=2){const u=e[c];if(typeof u!="string")return i.error(`Expected string, but found ${typeof u} instead.`,c);if(/[^a-zA-Z0-9_]/.test(u))return i.error("Variable names must contain only alphanumeric characters or '_'.",c);const p=i.parse(e[c+1],c+1);if(!p)return null;n.push([u,p])}const s=i.parse(e[e.length-1],e.length-1,i.expectedType,n);return s?new Us(n,s):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[i,n]of this.bindings)e.push(i,n.serialize());return e.push(this.result.serialize()),e}}var xc=Us;class rl{constructor(e,i,n){this.type=e,this.index=i,this.input=n}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,Oe),s=i.parse(e[2],2,Ki(i.expectedType||ct));return n&&s?new rl(s.type.itemType,n,s):null}evaluate(e){const i=this.index.evaluate(e),n=this.input.evaluate(e);if(i<0)throw new wi(`Array index out of bounds: ${i} < 0.`);if(i>=n.length)throw new wi(`Array index out of bounds: ${i} > ${n.length-1}.`);if(i!==Math.floor(i))throw new wi(`Array index must be an integer, but found ${i} instead.`);return n[i]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Uh=rl;class nl{constructor(e,i){this.type=lt,this.needle=e,this.haystack=i}static parse(e,i){if(e.length!==3)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,ct),s=i.parse(e[2],2,ct);return n&&s?Bo(n.type,[lt,pt,Oe,Kn,ct])?new nl(n,s):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vt(n.type)} instead`):null}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(n==null)return!1;if(!Oo(i,["boolean","string","number","null"]))throw new wi(`Expected first argument to be of type boolean, string, number or null, but found ${Vt(Xt(i))} instead.`);if(!Oo(n,["string","array"]))throw new wi(`Expected second argument to be of type array or string, but found ${Vt(Xt(n))} instead.`);return n.indexOf(i)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Vs=nl;class Xo{constructor(e,i,n){this.type=Oe,this.needle=e,this.haystack=i,this.fromIndex=n}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,ct),s=i.parse(e[2],2,ct);if(!n||!s)return null;if(!Bo(n.type,[lt,pt,Oe,Kn,ct]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Vt(n.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Oe);return c?new Xo(n,s,c):null}return new Xo(n,s)}evaluate(e){const i=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!Oo(i,["boolean","string","number","null"]))throw new wi(`Expected first argument to be of type boolean, string, number or null, but found ${Vt(Xt(i))} instead.`);if(!Oo(n,["string","array"]))throw new wi(`Expected second argument to be of type array or string, but found ${Vt(Xt(n))} instead.`);if(this.fromIndex){const s=this.fromIndex.evaluate(e);return n.indexOf(i,s)}return n.indexOf(i)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var vc=Xo;class ol{constructor(e,i,n,s,c,u){this.inputType=e,this.type=i,this.input=n,this.cases=s,this.outputs=c,this.otherwise=u}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let n,s;i.expectedType&&i.expectedType.kind!=="value"&&(s=i.expectedType);const c={},u=[];for(let _=2;_<e.length-1;_+=2){let x=e[_];const b=e[_+1];Array.isArray(x)||(x=[x]);const w=i.concat(_);if(x.length===0)return w.error("Expected at least one branch label.");for(const M of x){if(typeof M!="number"&&typeof M!="string")return w.error("Branch labels must be numbers or strings.");if(typeof M=="number"&&Math.abs(M)>Number.MAX_SAFE_INTEGER)return w.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof M=="number"&&Math.floor(M)!==M)return w.error("Numeric branch labels must be integer values.");if(n){if(w.checkSubtype(n,Xt(M)))return null}else n=Xt(M);if(c[String(M)]!==void 0)return w.error("Branch labels must be unique.");c[String(M)]=u.length}const S=i.parse(b,_,s);if(!S)return null;s=s||S.type,u.push(S)}const p=i.parse(e[1],1,ct);if(!p)return null;const m=i.parse(e[e.length-1],e.length-1,s);return m?p.type.kind!=="value"&&i.concat(1).checkSubtype(n,p.type)?null:new ol(n,s,p,c,u,m):null}evaluate(e){const i=this.input.evaluate(e);return(Xt(i)===this.inputType&&this.outputs[this.cases[i]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],i=Object.keys(this.cases).sort(),n=[],s={};for(const u of i){const p=s[this.cases[u]];p===void 0?(s[this.cases[u]]=n.length,n.push([this.cases[u],[u]])):n[p][1].push(u)}const c=u=>this.inputType.kind==="number"?Number(u):u;for(const[u,p]of n)e.push(p.length===1?c(p[0]):p.map(c)),e.push(this.outputs[u].serialize());return e.push(this.otherwise.serialize()),e}}var Vh=ol;class sl{constructor(e,i,n){this.type=e,this.branches=i,this.otherwise=n}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let n;i.expectedType&&i.expectedType.kind!=="value"&&(n=i.expectedType);const s=[];for(let u=1;u<e.length-1;u+=2){const p=i.parse(e[u],u,lt);if(!p)return null;const m=i.parse(e[u+1],u+1,n);if(!m)return null;s.push([p,m]),n=n||m.type}const c=i.parse(e[e.length-1],e.length-1,n);return c?new sl(n,s,c):null}evaluate(e){for(const[i,n]of this.branches)if(i.evaluate(e))return n.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[i,n]of this.branches)e(i),e(n);e(this.otherwise)}outputDefined(){return this.branches.every(([e,i])=>i.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(i=>{e.push(i.serialize())}),e}}var bc=sl;class Ho{constructor(e,i,n,s){this.type=e,this.input=i,this.beginIndex=n,this.endIndex=s}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=i.parse(e[1],1,ct),s=i.parse(e[2],2,Oe);if(!n||!s)return null;if(!Bo(n.type,[Ki(ct),pt,ct]))return i.error(`Expected first argument to be of type array or string, but found ${Vt(n.type)} instead`);if(e.length===4){const c=i.parse(e[3],3,Oe);return c?new Ho(n.type,n,s,c):null}return new Ho(n.type,n,s)}evaluate(e){const i=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!Oo(i,["string","array"]))throw new wi(`Expected first argument to be of type array or string, but found ${Vt(Xt(i))} instead.`);if(this.endIndex){const s=this.endIndex.evaluate(e);return i.slice(n,s)}return i.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var wc=Ho;function Ns(t,e){return t==="=="||t==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Tc(t,e,i,n){return n.compare(e,i)===0}function no(t,e,i){const n=t!=="=="&&t!=="!=";return class Hf{constructor(c,u,p){this.type=lt,this.lhs=c,this.rhs=u,this.collator=p,this.hasUntypedArgument=c.type.kind==="value"||u.type.kind==="value"}static parse(c,u){if(c.length!==3&&c.length!==4)return u.error("Expected two or three arguments.");const p=c[0];let m=u.parse(c[1],1,ct);if(!m)return null;if(!Ns(p,m.type))return u.concat(1).error(`"${p}" comparisons are not supported for type '${Vt(m.type)}'.`);let _=u.parse(c[2],2,ct);if(!_)return null;if(!Ns(p,_.type))return u.concat(2).error(`"${p}" comparisons are not supported for type '${Vt(_.type)}'.`);if(m.type.kind!==_.type.kind&&m.type.kind!=="value"&&_.type.kind!=="value")return u.error(`Cannot compare types '${Vt(m.type)}' and '${Vt(_.type)}'.`);n&&(m.type.kind==="value"&&_.type.kind!=="value"?m=new Dr(_.type,[m]):m.type.kind!=="value"&&_.type.kind==="value"&&(_=new Dr(m.type,[_])));let x=null;if(c.length===4){if(m.type.kind!=="string"&&_.type.kind!=="string"&&m.type.kind!=="value"&&_.type.kind!=="value")return u.error("Cannot use collator to compare non-string types.");if(x=u.parse(c[3],3,qi),!x)return null}return new Hf(m,_,x)}evaluate(c){const u=this.lhs.evaluate(c),p=this.rhs.evaluate(c);if(n&&this.hasUntypedArgument){const m=Xt(u),_=Xt(p);if(m.kind!==_.kind||m.kind!=="string"&&m.kind!=="number")throw new wi(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${m.kind}, ${_.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const m=Xt(u),_=Xt(p);if(m.kind!=="string"||_.kind!=="string")return e(c,u,p)}return this.collator?i(c,u,p,this.collator.evaluate(c)):e(c,u,p)}eachChild(c){c(this.lhs),c(this.rhs),this.collator&&c(this.collator)}outputDefined(){return!0}serialize(){const c=[t];return this.eachChild(u=>{c.push(u.serialize())}),c}}}const Nh=no("==",function(t,e,i){return e===i},Tc),jh=no("!=",function(t,e,i){return e!==i},function(t,e,i,n){return!Tc(0,e,i,n)}),Gh=no("<",function(t,e,i){return e<i},function(t,e,i,n){return n.compare(e,i)<0}),$h=no(">",function(t,e,i){return e>i},function(t,e,i,n){return n.compare(e,i)>0}),Zh=no("<=",function(t,e,i){return e<=i},function(t,e,i,n){return n.compare(e,i)<=0}),Ec=no(">=",function(t,e,i){return e>=i},function(t,e,i,n){return n.compare(e,i)>=0});class js{constructor(e,i,n,s,c,u){this.type=pt,this.number=e,this.locale=i,this.currency=n,this.unit=s,this.minFractionDigits=c,this.maxFractionDigits=u}static parse(e,i){if(e.length!==3)return i.error("Expected two arguments.");const n=i.parse(e[1],1,Oe);if(!n)return null;const s=e[2];if(typeof s!="object"||Array.isArray(s))return i.error("NumberFormat options argument must be an object.");let c=null;if(s.locale&&(c=i.parse(s.locale,1,pt),!c))return null;let u=null;if(s.currency&&(u=i.parse(s.currency,1,pt),!u))return null;let p=null;if(s.unit&&(p=i.parse(s.unit,1,pt),!p))return null;let m=null;if(s["min-fraction-digits"]&&(m=i.parse(s["min-fraction-digits"],1,Oe),!m))return null;let _=null;return s["max-fraction-digits"]&&(_=i.parse(s["max-fraction-digits"],1,Oe),!_)?null:new js(n,c,u,p,m,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class oo{constructor(e){this.type=Oe,this.input=e}static parse(e,i){if(e.length!==2)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=i.parse(e[1],1);return n?n.type.kind!=="array"&&n.type.kind!=="string"&&n.type.kind!=="value"?i.error(`Expected argument of type string or array, but found ${Vt(n.type)} instead.`):new oo(n):null}evaluate(e){const i=this.input.evaluate(e);if(typeof i=="string"||Array.isArray(i))return i.length;throw new wi(`Expected value to be of type string or array, but found ${Vt(Xt(i))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(i=>{e.push(i.serialize())}),e}}const Sc={"==":Nh,"!=":jh,">":$h,"<":Gh,">=":Ec,"<=":Zh,array:Dr,at:Uh,boolean:Dr,case:bc,coalesce:il,collator:jo,format:tn,image:zs,in:Vs,"index-of":vc,interpolate:yr,"interpolate-hcl":yr,"interpolate-lab":yr,length:oo,let:xc,literal:wn,match:Vh,number:Dr,"number-format":js,object:Dr,slice:wc,step:Xa,string:Dr,"to-boolean":Jn,"to-color":Jn,"to-number":Jn,"to-string":Jn,var:fc,within:Ds};function Mc(t,[e,i,n,s]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const c=s?s.evaluate(t):1,u=hc(e,i,n,c);if(u)throw new wi(u);return new Yt(e/255*c,i/255*c,n/255*c,c)}function Or(t,e){return t in e}function Gs(t,e){const i=e[t];return i===void 0?null:i}function Ji(t){return{type:t}}Lr.register(Sc,{error:[{kind:"error"},[pt],(t,[e])=>{throw new wi(e.evaluate(t))}],typeof:[pt,[ct],(t,[e])=>Vt(Xt(e.evaluate(t)))],"to-rgba":[Ki(Oe,4),[Zi],(t,[e])=>e.evaluate(t).toArray()],rgb:[Zi,[Oe,Oe,Oe],Mc],rgba:[Zi,[Oe,Oe,Oe,Oe],Mc],has:{type:lt,overloads:[[[pt],(t,[e])=>Or(e.evaluate(t),t.properties())],[[pt,lr],(t,[e,i])=>Or(e.evaluate(t),i.evaluate(t))]]},get:{type:ct,overloads:[[[pt],(t,[e])=>Gs(e.evaluate(t),t.properties())],[[pt,lr],(t,[e,i])=>Gs(e.evaluate(t),i.evaluate(t))]]},"feature-state":[ct,[pt],(t,[e])=>Gs(e.evaluate(t),t.featureState||{})],properties:[lr,[],t=>t.properties()],"geometry-type":[pt,[],t=>t.geometryType()],id:[ct,[],t=>t.id()],zoom:[Oe,[],t=>t.globals.zoom],pitch:[Oe,[],t=>t.globals.pitch||0],"distance-from-center":[Oe,[],t=>t.distanceFromCenter()],"heatmap-density":[Oe,[],t=>t.globals.heatmapDensity||0],"line-progress":[Oe,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Oe,[],t=>t.globals.skyRadialProgress||0],accumulated:[ct,[],t=>t.globals.accumulated===void 0?null:t.globals.accumulated],"+":[Oe,Ji(Oe),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Oe,Ji(Oe),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Oe,overloads:[[[Oe,Oe],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Oe],(t,[e])=>-e.evaluate(t)]]},"/":[Oe,[Oe,Oe],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Oe,[Oe,Oe],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Oe,[],()=>Math.LN2],pi:[Oe,[],()=>Math.PI],e:[Oe,[],()=>Math.E],"^":[Oe,[Oe,Oe],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Oe,[Oe],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Oe,[Oe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Oe,[Oe],(t,[e])=>Math.log(e.evaluate(t))],log2:[Oe,[Oe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Oe,[Oe],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Oe,[Oe],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Oe,[Oe],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Oe,[Oe],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Oe,[Oe],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Oe,[Oe],(t,[e])=>Math.atan(e.evaluate(t))],min:[Oe,Ji(Oe),(t,e)=>Math.min(...e.map(i=>i.evaluate(t)))],max:[Oe,Ji(Oe),(t,e)=>Math.max(...e.map(i=>i.evaluate(t)))],abs:[Oe,[Oe],(t,[e])=>Math.abs(e.evaluate(t))],round:[Oe,[Oe],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Oe,[Oe],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Oe,[Oe],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[lt,[pt,ct],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[lt,[ct],(t,[e])=>t.id()===e.value],"filter-type-==":[lt,[pt],(t,[e])=>t.geometryType()===e.value],"filter-<":[lt,[pt,ct],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<s}],"filter-id-<":[lt,[ct],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<n}],"filter->":[lt,[pt,ct],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>s}],"filter-id->":[lt,[ct],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[lt,[pt,ct],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[lt,[ct],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[lt,[pt,ct],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[lt,[ct],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[lt,[ct],(t,[e])=>e.value in t.properties()],"filter-has-id":[lt,[],t=>t.id()!==null&&t.id()!==void 0],"filter-type-in":[lt,[Ki(pt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[lt,[Ki(ct)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[lt,[pt,Ki(ct)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[lt,[pt,Ki(ct)],(t,[e,i])=>function(n,s,c,u){for(;c<=u;){const p=c+u>>1;if(s[p]===n)return!0;s[p]>n?u=p-1:c=p+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:lt,overloads:[[[lt,lt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Ji(lt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:lt,overloads:[[[lt,lt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Ji(lt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[lt,[lt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[lt,[pt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[pt,[pt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[pt,[pt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[pt,Ji(ct),(t,e)=>e.map(i=>No(i.evaluate(t))).join("")],"resolved-locale":[pt,[qi],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Ko=Sc;function Ac(t){return{result:"success",value:t}}function Mn(t){return{result:"error",value:t}}function so(t){return t["property-type"]==="data-driven"}function $s(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Zs(t){return!!t.expression&&t.expression.interpolated}function yt(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":t===null?"null":typeof t}function Yo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ic(t){return t}function qs(t,e){const i=e.type==="color",n=t.stops&&typeof t.stops[0][0]=="object",s=n||!(n||t.property!==void 0),c=t.type||(Zs(e)?"exponential":"interval");if(i&&((t=Pr({},t)).stops&&(t.stops=t.stops.map(_=>[_[0],Yt.parse(_[1])])),t.default=Yt.parse(t.default?t.default:e.default)),t.colorSpace&&t.colorSpace!=="rgb"&&!el[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let u,p,m;if(c==="exponential")u=Fr;else if(c==="interval")u=Ws;else if(c==="categorical"){u=Cc,p=Object.create(null);for(const _ of t.stops)p[_[0]]=_[1];m=typeof t.stops[0][0]}else{if(c!=="identity")throw new Error(`Unknown function type "${c}"`);u=zc}if(n){const _={},x=[];for(let S=0;S<t.stops.length;S++){const M=t.stops[S],C=M[0].zoom;_[C]===void 0&&(_[C]={zoom:C,type:t.type,property:t.property,default:t.default,stops:[]},x.push(C)),_[C].stops.push([M[0].value,M[1]])}const b=[];for(const S of x)b.push([_[S].zoom,qs(_[S],e)]);const w={name:"linear"};return{kind:"composite",interpolationType:w,interpolationFactor:yr.interpolationFactor.bind(void 0,w),zoomStops:b.map(S=>S[0]),evaluate:({zoom:S},M)=>Fr({stops:b,base:t.base},e,S).evaluate(S,M)}}if(s){const _=c==="exponential"?{name:"exponential",base:t.base!==void 0?t.base:1}:null;return{kind:"camera",interpolationType:_,interpolationFactor:yr.interpolationFactor.bind(void 0,_),zoomStops:t.stops.map(x=>x[0]),evaluate:({zoom:x})=>u(t,e,x,p,m)}}return{kind:"source",evaluate(_,x){const b=x&&x.properties?x.properties[t.property]:void 0;return b===void 0?ao(t.default,e.default):u(t,e,b,p,m)}}}function ao(t,e,i){return t!==void 0?t:e!==void 0?e:i!==void 0?i:void 0}function Cc(t,e,i,n,s){return ao(typeof i===s?n[i]:void 0,t.default,e.default)}function Ws(t,e,i){if(yt(i)!=="number")return ao(t.default,e.default);const n=t.stops.length;if(n===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=Rs(t.stops.map(c=>c[0]),i);return t.stops[s][1]}function Fr(t,e,i){const n=t.base!==void 0?t.base:1;if(yt(i)!=="number")return ao(t.default,e.default);const s=t.stops.length;if(s===1||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const c=Rs(t.stops.map(x=>x[0]),i),u=function(x,b,w,S){const M=S-w,C=x-w;return M===0?0:b===1?C/M:(Math.pow(b,C)-1)/(Math.pow(b,M)-1)}(i,n,t.stops[c][0],t.stops[c+1][0]),p=t.stops[c][1],m=t.stops[c+1][1];let _=Zo[e.type]||Ic;if(t.colorSpace&&t.colorSpace!=="rgb"){const x=el[t.colorSpace];_=(b,w)=>x.reverse(x.interpolate(x.forward(b),x.forward(w),u))}return typeof p.evaluate=="function"?{evaluate(...x){const b=p.evaluate.apply(void 0,x),w=m.evaluate.apply(void 0,x);if(b!==void 0&&w!==void 0)return _(b,w,u)}}:_(p,m,u)}function zc(t,e,i){return e.type==="color"?i=Yt.parse(i):e.type==="formatted"?i=Bi.fromString(i.toString()):e.type==="resolvedImage"?i=Yi.fromString(i.toString()):yt(i)===e.type||e.type==="enum"&&e.values[i]||(i=void 0),ao(i,t.default,e.default)}class Xs{constructor(e,i){this.expression=e,this._warningHistory={},this._evaluator=new Va,this._defaultValue=i?function(n){return n.type==="color"&&(Yo(n.default)||Array.isArray(n.default))?new Yt(0,0,0,0):n.type==="color"?Yt.parse(n.default)||null:n.default===void 0?null:n.default}(i):null,this._enumValues=i&&i.type==="enum"?i.values:null}evaluateWithoutErrorHandling(e,i,n,s,c,u,p,m){return this._evaluator.globals=e,this._evaluator.feature=i,this._evaluator.featureState=n,this._evaluator.canonical=s||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null,this.expression.evaluate(this._evaluator)}evaluate(e,i,n,s,c,u,p,m){this._evaluator.globals=e,this._evaluator.feature=i||null,this._evaluator.featureState=n||null,this._evaluator.canonical=s||null,this._evaluator.availableImages=c||null,this._evaluator.formattedSection=u||null,this._evaluator.featureTileCoord=p||null,this._evaluator.featureDistanceData=m||null;try{const _=this.expression.evaluate(this._evaluator);if(_==null||typeof _=="number"&&_!=_)return this._defaultValue;if(this._enumValues&&!(_ in this._enumValues))throw new wi(`Expected value to be one of ${Object.keys(this._enumValues).map(x=>JSON.stringify(x)).join(", ")}, but found ${JSON.stringify(_)} instead.`);return _}catch(_){return this._warningHistory[_.message]||(this._warningHistory[_.message]=!0,typeof console<"u"&&console.warn(_.message)),this._defaultValue}}}function lo(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"&&t[0]in Ko}function co(t,e){const i=new qa(Ko,[],e?function(s){const c={color:Zi,string:pt,number:Oe,enum:pt,boolean:lt,formatted:Ro,resolvedImage:bn};return s.type==="array"?Ki(c[s.value]||ct,s.length):c[s.type]}(e):void 0),n=i.parse(t,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return n?Ac(new Xs(n,e)):Mn(i.errors)}class al{constructor(e,i){this.kind=e,this._styleExpression=i,this.isStateDependent=e!=="constant"&&!Br(i.expression)}evaluateWithoutErrorHandling(e,i,n,s,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,s,c,u)}evaluate(e,i,n,s,c,u){return this._styleExpression.evaluate(e,i,n,s,c,u)}}class Jo{constructor(e,i,n,s){this.kind=e,this.zoomStops=n,this._styleExpression=i,this.isStateDependent=e!=="camera"&&!Br(i.expression),this.interpolationType=s}evaluateWithoutErrorHandling(e,i,n,s,c,u){return this._styleExpression.evaluateWithoutErrorHandling(e,i,n,s,c,u)}evaluate(e,i,n,s,c,u){return this._styleExpression.evaluate(e,i,n,s,c,u)}interpolationFactor(e,i,n){return this.interpolationType?yr.interpolationFactor(this.interpolationType,e,i,n):0}}function Qo(t,e){if((t=co(t,e)).result==="error")return t;const i=t.value.expression,n=io(i);if(!n&&!so(e))return Mn([new _r("","data expressions not supported")]);const s=En(i,["zoom","pitch","distance-from-center"]);if(!s&&!$s(e))return Mn([new _r("","zoom expressions not supported")]);const c=Ks(i);return c||s?c instanceof _r?Mn([c]):c instanceof yr&&!Zs(e)?Mn([new _r("",'"interpolate" expressions cannot be used with this property')]):Ac(c?new Jo(n?"camera":"composite",t.value,c.labels,c instanceof yr?c.interpolation:void 0):new al(n?"constant":"source",t.value)):Mn([new _r("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Hs{constructor(e,i){this._parameters=e,this._specification=i,Pr(this,qs(this._parameters,this._specification))}static deserialize(e){return new Hs(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Ks(t){let e=null;if(t instanceof xc)e=Ks(t.result);else if(t instanceof il){for(const i of t.args)if(e=Ks(i),e)break}else(t instanceof Xa||t instanceof yr)&&t.input instanceof Lr&&t.input.name==="zoom"&&(e=t);return e instanceof _r||t.eachChild(i=>{const n=Ks(i);n instanceof _r?e=n:!e&&n?e=new _r("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&n&&e!==n&&(e=new _r("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}class Fe{constructor(e,i,n,s){this.message=(e?`${e}: `:"")+n,s&&(this.identifier=s),i!=null&&i.__line__&&(this.line=i.__line__)}}function cr(t){const e=t.key,i=t.value,n=t.valueSpec||{},s=t.objectElementValidators||{},c=t.style,u=t.styleSpec;let p=[];const m=yt(i);if(m!=="object")return[new Fe(e,i,`object expected, ${m} found`)];for(const _ in i){const x=_.split(".")[0];let b;s[x]?b=s[x]:n[x]?b=Ai:s["*"]?b=s["*"]:n["*"]&&(b=Ai),b?p=p.concat(b({key:(e&&`${e}.`)+_,value:i[_],valueSpec:n[x]||n["*"],style:c,styleSpec:u,object:i,objectKey:_},i)):p.push(new Fe(e,i[_],`unknown property "${_}"`))}for(const _ in n)s[_]||n[_].required&&n[_].default===void 0&&i[_]===void 0&&p.push(new Fe(e,i,`missing required property "${_}"`));return p}function Pc(t){const e=t.value,i=t.valueSpec,n=t.style,s=t.styleSpec,c=t.key,u=t.arrayElementValidator||Ai;if(yt(e)!=="array")return[new Fe(c,e,`array expected, ${yt(e)} found`)];if(i.length&&e.length!==i.length)return[new Fe(c,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.length<i["min-length"])return[new Fe(c,e,`array length at least ${i["min-length"]} expected, length ${e.length} found`)];let p={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum,function:void 0};s.$version<7&&(p.function=i.function),yt(i.value)==="object"&&(p=i.value);let m=[];for(let _=0;_<e.length;_++)m=m.concat(u({array:e,arrayIndex:_,value:e[_],valueSpec:p,style:n,styleSpec:s,key:`${c}[${_}]`}));return m}function es(t){const e=t.key,i=t.value,n=t.valueSpec;let s=yt(i);if(s==="number"&&i!=i&&(s="NaN"),s!=="number")return[new Fe(e,i,`number expected, ${s} found`)];if("minimum"in n){let c=n.minimum;if(yt(n.minimum)==="array"&&(c=n.minimum[t.arrayIndex]),i<c)return[new Fe(e,i,`${i} is less than the minimum value ${c}`)]}if("maximum"in n){let c=n.maximum;if(yt(n.maximum)==="array"&&(c=n.maximum[t.arrayIndex]),i>c)return[new Fe(e,i,`${i} is greater than the maximum value ${c}`)]}return[]}function ts(t){const e=t.valueSpec,i=ti(t.value.type);let n,s,c,u={};const p=i!=="categorical"&&t.value.property===void 0,m=!p,_=yt(t.value.stops)==="array"&&yt(t.value.stops[0])==="array"&&yt(t.value.stops[0][0])==="object",x=cr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(S){if(i==="identity")return[new Fe(S.key,S.value,'identity function may not have a "stops" property')];let M=[];const C=S.value;return M=M.concat(Pc({key:S.key,value:C,valueSpec:S.valueSpec,style:S.style,styleSpec:S.styleSpec,arrayElementValidator:b})),yt(C)==="array"&&C.length===0&&M.push(new Fe(S.key,C,"array must have at least one stop")),M},default:function(S){return Ai({key:S.key,value:S.value,valueSpec:e,style:S.style,styleSpec:S.styleSpec})}}});return i==="identity"&&p&&x.push(new Fe(t.key,t.value,'missing required property "property"')),i==="identity"||t.value.stops||x.push(new Fe(t.key,t.value,'missing required property "stops"')),i==="exponential"&&t.valueSpec.expression&&!Zs(t.valueSpec)&&x.push(new Fe(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(m&&!so(t.valueSpec)?x.push(new Fe(t.key,t.value,"property functions not supported")):p&&!$s(t.valueSpec)&&x.push(new Fe(t.key,t.value,"zoom functions not supported"))),i!=="categorical"&&!_||t.value.property!==void 0||x.push(new Fe(t.key,t.value,'"property" property is required')),x;function b(S){let M=[];const C=S.value,D=S.key;if(yt(C)!=="array")return[new Fe(D,C,`array expected, ${yt(C)} found`)];if(C.length!==2)return[new Fe(D,C,`array length 2 expected, length ${C.length} found`)];if(_){if(yt(C[0])!=="object")return[new Fe(D,C,`object expected, ${yt(C[0])} found`)];if(C[0].zoom===void 0)return[new Fe(D,C,"object stop key must have zoom")];if(C[0].value===void 0)return[new Fe(D,C,"object stop key must have value")];const U=ti(C[0].zoom);if(typeof U!="number")return[new Fe(D,C[0].zoom,"stop zoom values must be numbers")];if(c&&c>U)return[new Fe(D,C[0].zoom,"stop zoom values must appear in ascending order")];U!==c&&(c=U,s=void 0,u={}),M=M.concat(cr({key:`${D}[0]`,value:C[0],valueSpec:{zoom:{}},style:S.style,styleSpec:S.styleSpec,objectElementValidators:{zoom:es,value:w}}))}else M=M.concat(w({key:`${D}[0]`,value:C[0],valueSpec:{},style:S.style,styleSpec:S.styleSpec},C));return lo(gi(C[1]))?M.concat([new Fe(`${D}[1]`,C[1],"expressions are not allowed in function stops.")]):M.concat(Ai({key:`${D}[1]`,value:C[1],valueSpec:e,style:S.style,styleSpec:S.styleSpec}))}function w(S,M){const C=yt(S.value),D=ti(S.value),U=S.value!==null?S.value:M;if(n){if(C!==n)return[new Fe(S.key,U,`${C} stop domain type must match previous stop domain type ${n}`)]}else n=C;if(C!=="number"&&C!=="string"&&C!=="boolean"&&typeof D!="number"&&typeof D!="string"&&typeof D!="boolean")return[new Fe(S.key,U,"stop domain value must be a number, string, or boolean")];if(C!=="number"&&i!=="categorical"){let q=`number expected, ${C} found`;return so(e)&&i===void 0&&(q+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Fe(S.key,U,q)]}return i!=="categorical"||C!=="number"||typeof D=="number"&&isFinite(D)&&Math.floor(D)===D?i!=="categorical"&&C==="number"&&typeof D=="number"&&typeof s=="number"&&s!==void 0&&D<s?[new Fe(S.key,U,"stop domain values must appear in ascending order")]:(s=D,i==="categorical"&&D in u?[new Fe(S.key,U,"stop domain values must be unique")]:(u[D]=!0,[])):[new Fe(S.key,U,`integer expected, found ${String(D)}`)]}}function yi(t){const e=(t.expressionContext==="property"?Qo:co)(gi(t.value),t.valueSpec);if(e.result==="error")return e.value.map(n=>new Fe(`${t.key}${n.key}`,t.value,n.message));const i=e.value.expression||e.value._styleExpression.expression;if(t.expressionContext==="property"&&t.propertyKey==="text-font"&&!i.outputDefined())return[new Fe(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if(t.expressionContext==="property"&&t.propertyType==="layout"&&!Br(i))return[new Fe(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if(t.expressionContext==="filter")return is(i,t);if(t.expressionContext&&t.expressionContext.indexOf("cluster")===0){if(!En(i,["zoom","feature-state"]))return[new Fe(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(t.expressionContext==="cluster-initial"&&!io(i))return[new Fe(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function is(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const s of e.valueSpec.expression.parameters)i.delete(s);if(i.size===0)return[];const n=[];return t instanceof Lr&&i.has(t.name)?[new Fe(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild(s=>{n.push(...is(s,e))}),n)}function Ys(t){const e=t.key,i=t.value,n=t.valueSpec,s=[];return Array.isArray(n.values)?n.values.indexOf(ti(i))===-1&&s.push(new Fe(e,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):Object.keys(n.values).indexOf(ti(i))===-1&&s.push(new Fe(e,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function ll(t){if(t===!0||t===!1)return!0;if(!Array.isArray(t)||t.length===0)return!1;switch(t[0]){case"has":return t.length>=2&&t[1]!=="$id"&&t[1]!=="$type";case"in":return t.length>=3&&(typeof t[1]!="string"||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return t.length!==3||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!ll(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function Js(t,e="fill"){if(t==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ll(t)||(t=uo(t));const i=t;let n=!0;try{n=function(_){if(!ho(_))return _;let x=gi(_);return Qs(x),x=kc(x),x}(i)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
2
+ This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
3
+ and paste the contents of this message in the report.
4
+ Thank you!
5
+ Filter Expression:
6
+ ${JSON.stringify(i,null,2)}
7
+ `)}const s=fe[`filter_${e}`],c=co(n,s);let u=null;if(c.result==="error")throw new Error(c.value.map(_=>`${_.key}: ${_.message}`).join(", "));u=(_,x,b)=>c.value.evaluate(_,x,{},b);let p=null,m=null;if(n!==i){const _=co(i,s);if(_.result==="error")throw new Error(_.value.map(x=>`${x.key}: ${x.message}`).join(", "));p=(x,b,w,S,M)=>_.value.evaluate(x,b,{},w,void 0,void 0,S,M),m=!io(_.value.expression)}return{filter:u,dynamicFilter:p||void 0,needGeometry:Dc(n),needFeature:!!m}}function kc(t){if(!Array.isArray(t))return t;const e=function(i){if(cl.has(i[0])){for(let n=1;n<i.length;n++)if(ho(i[n]))return!0}return i}(t);return e===!0?e:e.map(i=>kc(i))}function Qs(t){let e=!1;const i=[];if(t[0]==="case"){for(let n=1;n<t.length-1;n+=2)e=e||ho(t[n]),i.push(t[n+1]);i.push(t[t.length-1])}else if(t[0]==="match"){e=e||ho(t[1]);for(let n=2;n<t.length-1;n+=2)i.push(t[n+1]);i.push(t[t.length-1])}else if(t[0]==="step"){e=e||ho(t[1]);for(let n=1;n<t.length-1;n+=2)i.push(t[n+1])}e&&(t.length=0,t.push("any",...i));for(let n=1;n<t.length;n++)Qs(t[n])}function ho(t){if(!Array.isArray(t))return!1;if((e=t[0])==="pitch"||e==="distance-from-center")return!0;var e;for(let i=1;i<t.length;i++)if(ho(t[i]))return!0;return!1}const cl=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function qh(t,e){return t<e?-1:t>e?1:0}function Dc(t){if(!Array.isArray(t))return!1;if(t[0]==="within")return!0;for(let e=1;e<t.length;e++)if(Dc(t[e]))return!0;return!1}function uo(t){if(!t)return!0;const e=t[0];return t.length<=1?e!=="any":e==="=="?hl(t[1],t[2],"=="):e==="!="?ea(hl(t[1],t[2],"==")):e==="<"||e===">"||e==="<="||e===">="?hl(t[1],t[2],e):e==="any"?(i=t.slice(1),["any"].concat(i.map(uo))):e==="all"?["all"].concat(t.slice(1).map(uo)):e==="none"?["all"].concat(t.slice(1).map(uo).map(ea)):e==="in"?ul(t[1],t.slice(2)):e==="!in"?ea(ul(t[1],t.slice(2))):e==="has"?dl(t[1]):e==="!has"?ea(dl(t[1])):e!=="within"||t;var i}function hl(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 ul(t,e){if(e.length===0)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(i=>typeof i!=typeof e[0])?["filter-in-large",t,["literal",e.sort(qh)]]:["filter-in-small",t,["literal",e]]}}function dl(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ea(t){return["!",t]}function rs(t){return ll(gi(t.value))?yi(Pr({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):ns(t)}function ns(t){const e=t.value,i=t.key;if(yt(e)!=="array")return[new Fe(i,e,`array expected, ${yt(e)} found`)];const n=t.styleSpec;let s,c=[];if(e.length<1)return[new Fe(i,e,"filter array must have at least 1 element")];switch(c=c.concat(Ys({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),ti(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&ti(e[1])==="$type"&&c.push(new Fe(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&c.push(new Fe(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=yt(e[1]),s!=="string"&&c.push(new Fe(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let u=2;u<e.length;u++)s=yt(e[u]),ti(e[1])==="$type"?c=c.concat(Ys({key:`${i}[${u}]`,value:e[u],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):s!=="string"&&s!=="number"&&s!=="boolean"&&c.push(new Fe(`${i}[${u}]`,e[u],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let u=1;u<e.length;u++)c=c.concat(ns({key:`${i}[${u}]`,value:e[u],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":s=yt(e[1]),e.length!==2?c.push(new Fe(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="string"&&c.push(new Fe(`${i}[1]`,e[1],`string expected, ${s} found`));break;case"within":s=yt(e[1]),e.length!==2?c.push(new Fe(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):s!=="object"&&c.push(new Fe(`${i}[1]`,e[1],`object expected, ${s} found`))}return c}function pl(t,e){const i=t.key,n=t.style,s=t.styleSpec,c=t.value,u=t.objectKey,p=s[`${e}_${t.layerType}`];if(!p)return[];const m=u.match(/^(.*)-transition$/);if(e==="paint"&&m&&p[m[1]]&&p[m[1]].transition)return Ai({key:i,value:c,valueSpec:s.transition,style:n,styleSpec:s});const _=t.valueSpec||p[u];if(!_)return[new Fe(i,c,`unknown property "${u}"`)];let x;if(yt(c)==="string"&&so(_)&&!_.tokens&&(x=/^{([^}]+)}$/.exec(c))){const w=`\`{ "type": "identity", "property": ${x?JSON.stringify(x[1]):'"_"'} }\``;return[new Fe(i,c,`"${u}" does not support interpolation syntax
8
+ Use an identity property function instead: ${w}.`)]}const b=[];return t.layerType==="symbol"&&(u==="text-field"&&n&&!n.glyphs&&b.push(new Fe(i,c,'use of "text-field" requires a style "glyphs" property')),u==="text-font"&&Yo(gi(c))&&ti(c.type)==="identity"&&b.push(new Fe(i,c,'"text-font" does not support identity functions'))),b.concat(Ai({key:t.key,value:c,valueSpec:_,style:n,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:u}))}function Lc(t){return pl(t,"paint")}function fl(t){return pl(t,"layout")}function Rc(t){let e=[];const i=t.value,n=t.key,s=t.style,c=t.styleSpec;i.type||i.ref||e.push(new Fe(n,i,'either "type" or "ref" is required'));let u=ti(i.type);const p=ti(i.ref);if(i.id){const m=ti(i.id);for(let _=0;_<t.arrayIndex;_++){const x=s.layers[_];ti(x.id)===m&&e.push(new Fe(n,i.id,`duplicate layer id "${i.id}", previously used at line ${x.id.__line__}`))}}if("ref"in i){let m;["type","source","source-layer","filter","layout"].forEach(_=>{_ in i&&e.push(new Fe(n,i[_],`"${_}" is prohibited for ref layers`))}),s.layers.forEach(_=>{ti(_.id)===p&&(m=_)}),m?m.ref?e.push(new Fe(n,i.ref,"ref cannot reference another ref layer")):u=ti(m.type):typeof p=="string"&&e.push(new Fe(n,i.ref,`ref layer "${p}" not found`))}else if(u!=="background"&&u!=="sky")if(i.source){const m=s.sources&&s.sources[i.source],_=m&&ti(m.type);m?_==="vector"&&u==="raster"?e.push(new Fe(n,i.source,`layer "${i.id}" requires a raster source`)):_==="raster"&&u!=="raster"?e.push(new Fe(n,i.source,`layer "${i.id}" requires a vector source`)):_!=="vector"||i["source-layer"]?_==="raster-dem"&&u!=="hillshade"?e.push(new Fe(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):u!=="line"||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||_==="geojson"&&m.lineMetrics||e.push(new Fe(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new Fe(n,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new Fe(n,i.source,`source "${i.source}" not found`))}else e.push(new Fe(n,i,'missing required property "source"'));return e=e.concat(cr({key:n,value:i,valueSpec:c.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Ai({key:`${n}.type`,value:i.type,valueSpec:c.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:m=>rs(Pr({layerType:u},m)),layout:m=>cr({layer:i,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":_=>fl(Pr({layerType:u},_))}}),paint:m=>cr({layer:i,key:m.key,value:m.value,valueSpec:{},style:m.style,styleSpec:m.styleSpec,objectElementValidators:{"*":_=>Lc(Pr({layerType:u},_))}})}})),e}function rn(t){const e=t.value,i=t.key,n=yt(e);return n!=="string"?[new Fe(i,e,`string expected, ${n} found`)]:[]}const Bc={promoteId:function({key:t,value:e}){if(yt(e)==="string")return rn({key:t,value:e});{const i=[];for(const n in e)i.push(...rn({key:`${t}.${n}`,value:e[n]}));return i}}};function Oc(t){const e=t.value,i=t.key,n=t.styleSpec,s=t.style;if(!e.type)return[new Fe(i,e,'"type" is required')];const c=ti(e.type);let u;switch(c){case"vector":case"raster":case"raster-dem":return u=cr({key:i,value:e,valueSpec:n[`source_${c.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Bc}),u;case"geojson":if(u=cr({key:i,value:e,valueSpec:n.source_geojson,style:s,styleSpec:n,objectElementValidators:Bc}),e.cluster)for(const p in e.clusterProperties){const[m,_]=e.clusterProperties[p],x=typeof m=="string"?[m,["accumulated"],["get",p]]:m;u.push(...yi({key:`${i}.${p}.map`,value:_,expressionContext:"cluster-map"})),u.push(...yi({key:`${i}.${p}.reduce`,value:x,expressionContext:"cluster-reduce"}))}return u;case"video":return cr({key:i,value:e,valueSpec:n.source_video,style:s,styleSpec:n});case"image":return cr({key:i,value:e,valueSpec:n.source_image,style:s,styleSpec:n});case"canvas":return[new Fe(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Ys({key:`${i}.type`,value:e.type,valueSpec:{values:Wh(n)},style:s,styleSpec:n})}}function Wh(t){return t.source.reduce((e,i)=>{const n=t[i];return n.type.type==="enum"&&(e=e.concat(Object.keys(n.type.values))),e},[])}function Fc(t){const e=t.value,i=t.styleSpec,n=i.light,s=t.style;let c=[];const u=yt(e);if(e===void 0)return c;if(u!=="object")return c=c.concat([new Fe("light",e,`object expected, ${u} found`)]),c;for(const p in e){const m=p.match(/^(.*)-transition$/);c=c.concat(m&&n[m[1]]&&n[m[1]].transition?Ai({key:p,value:e[p],valueSpec:i.transition,style:s,styleSpec:i}):n[p]?Ai({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:i}):[new Fe(p,e[p],`unknown property "${p}"`)])}return c}function ml(t){const e=t.value,i=t.key,n=t.style,s=t.styleSpec,c=s.terrain;let u=[];const p=yt(e);if(e===void 0)return u;if(p!=="object")return u=u.concat([new Fe("terrain",e,`object expected, ${p} found`)]),u;for(const m in e){const _=m.match(/^(.*)-transition$/);u=u.concat(_&&c[_[1]]&&c[_[1]].transition?Ai({key:m,value:e[m],valueSpec:s.transition,style:n,styleSpec:s}):c[m]?Ai({key:m,value:e[m],valueSpec:c[m],style:n,styleSpec:s}):[new Fe(m,e[m],`unknown property "${m}"`)])}if(e.source){const m=n.sources&&n.sources[e.source],_=m&&ti(m.type);m?_!=="raster-dem"&&u.push(new Fe(i,e.source,`terrain cannot be used with a source of type ${String(_)}, it only be used with a "raster-dem" source type`)):u.push(new Fe(i,e.source,`source "${e.source}" not found`))}else u.push(new Fe(i,e,'terrain is missing required property "source"'));return u}function Uc(t){const e=t.value,i=t.style,n=t.styleSpec,s=n.fog;let c=[];const u=yt(e);if(e===void 0)return c;if(u!=="object")return c=c.concat([new Fe("fog",e,`object expected, ${u} found`)]),c;for(const p in e){const m=p.match(/^(.*)-transition$/);c=c.concat(m&&s[m[1]]&&s[m[1]].transition?Ai({key:p,value:e[p],valueSpec:n.transition,style:i,styleSpec:n}):s[p]?Ai({key:p,value:e[p],valueSpec:s[p],style:i,styleSpec:n}):[new Fe(p,e[p],`unknown property "${p}"`)])}return c}const Vc={"*":()=>[],array:Pc,boolean:function(t){const e=t.value,i=t.key,n=yt(e);return n!=="boolean"?[new Fe(i,e,`boolean expected, ${n} found`)]:[]},number:es,color:function(t){const e=t.key,i=t.value,n=yt(i);return n!=="string"?[new Fe(e,i,`color expected, ${n} found`)]:Da(i)===null?[new Fe(e,i,`color expected, "${i}" found`)]:[]},enum:Ys,filter:rs,function:ts,layer:Rc,object:cr,source:Oc,light:Fc,terrain:ml,fog:Uc,string:rn,formatted:function(t){return rn(t).length===0?[]:yi(t)},resolvedImage:function(t){return rn(t).length===0?[]:yi(t)},projection:function(t){const e=t.value,i=t.styleSpec,n=i.projection,s=t.style;let c=[];const u=yt(e);if(u==="object")for(const p in e)c=c.concat(Ai({key:p,value:e[p],valueSpec:n[p],style:s,styleSpec:i}));else u!=="string"&&(c=c.concat([new Fe("projection",e,`object or string expected, ${u} found`)]));return c}};function Ai(t){const e=t.value,i=t.valueSpec,n=t.styleSpec;return i.expression&&Yo(ti(e))?ts(t):i.expression&&lo(gi(e))?yi(t):i.type&&Vc[i.type]?Vc[i.type](t):cr(Pr({},t,{valueSpec:i.type?n[i.type]:i}))}function Xh(t){const e=t.value,i=t.key,n=rn(t);return n.length||(e.indexOf("{fontstack}")===-1&&n.push(new Fe(i,e,'"glyphs" url must include a "{fontstack}" token')),e.indexOf("{range}")===-1&&n.push(new Fe(i,e,'"glyphs" url must include a "{range}" token'))),n}function Nc(t,e=fe){return Qi(Ai({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:Xh,"*":()=>[]}}))}const Hh=t=>Qi(Lc(t)),Kh=t=>Qi(fl(t));function Qi(t){return t.slice().sort((e,i)=>e.line&&i.line?e.line-i.line:0)}function jc(t,e){let i=!1;if(e&&e.length)for(const n of e)t.fire(new zr(new Error(n.message))),i=!0;return i}var Yh=xr,hr=3;function xr(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(var c=0;c<this.d*this.d;c++){var u=s[hr+c],p=s[hr+c+1];n.push(u===p?null:s.subarray(u,p))}var m=s[hr+n.length+1];this.keys=s.subarray(s[hr+n.length],m),this.bboxes=s.subarray(m),this.insert=this._insertReadonly}else{this.d=e+2*i;for(var _=0;_<this.d*this.d;_++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;var x=i/e*t;this.min=-x,this.max=t+x}xr.prototype.insert=function(t,e,i,n,s){this._forEachCell(e,i,n,s,this._insertCell,this.uid++),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(s)},xr.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},xr.prototype._insertCell=function(t,e,i,n,s,c){this.cells[s].push(c)},xr.prototype.query=function(t,e,i,n,s){var c=this.min,u=this.max;if(t<=c&&e<=c&&u<=i&&u<=n&&!s)return Array.prototype.slice.call(this.keys);var p=[];return this._forEachCell(t,e,i,n,this._queryCell,p,{},s),p},xr.prototype._queryCell=function(t,e,i,n,s,c,u,p){var m=this.cells[s];if(m!==null)for(var _=this.keys,x=this.bboxes,b=0;b<m.length;b++){var w=m[b];if(u[w]===void 0){var S=4*w;(p?p(x[S+0],x[S+1],x[S+2],x[S+3]):t<=x[S+2]&&e<=x[S+3]&&i>=x[S+0]&&n>=x[S+1])?(u[w]=!0,c.push(_[w])):u[w]=!1}}},xr.prototype._forEachCell=function(t,e,i,n,s,c,u,p){for(var m=this._convertToCellCoord(t),_=this._convertToCellCoord(e),x=this._convertToCellCoord(i),b=this._convertToCellCoord(n),w=m;w<=x;w++)for(var S=_;S<=b;S++){var M=this.d*S+w;if((!p||p(this._convertFromCellCoord(w),this._convertFromCellCoord(S),this._convertFromCellCoord(w+1),this._convertFromCellCoord(S+1)))&&s.call(this,t,e,i,n,M,c,u,p))return}},xr.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},xr.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},xr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=hr+this.cells.length+1+1,i=0,n=0;n<this.cells.length;n++)i+=this.cells[n].length;var s=new Int32Array(e+i+this.keys.length+this.bboxes.length);s[0]=this.extent,s[1]=this.n,s[2]=this.padding;for(var c=e,u=0;u<t.length;u++){var p=t[u];s[hr+u]=c,s.set(p,c),c+=p.length}return s[hr+t.length]=c,s.set(this.keys,c),s[hr+t.length+1]=c+=this.keys.length,s.set(this.bboxes,c),c+=this.bboxes.length,s.buffer};var An=or(Yh);const ta={};function Ue(t,e,i={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),ta[e]={klass:t,omit:i.omit||[]}}Ue(Object,"Object"),An.serialize=function(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}},An.deserialize=function(t){return new An(t.buffer)},Object.defineProperty(An,"name",{value:"Grid"}),Ue(An,"Grid"),Ue(Yt,"Color"),Ue(Error,"Error"),Ue(en,"AJAXError"),Ue(Yi,"ResolvedImage"),Ue(Hs,"StylePropertyFunction"),Ue(Xs,"StyleExpression",{omit:["_evaluator"]}),Ue(Jo,"ZoomDependentExpression"),Ue(al,"ZoomConstantExpression"),Ue(Lr,"CompoundExpression",{omit:["_evaluate"]});for(const t in Ko)ta[Ko[t]._classRegistryKey]||Ue(Ko[t],`Expression${t}`);function _l(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||t.constructor&&t.constructor.name==="ArrayBuffer")}function gl(t){return ve.ImageBitmap&&t instanceof ve.ImageBitmap}function po(t,e){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp)return t;if(_l(t)||gl(t))return e&&e.push(t),t;if(ArrayBuffer.isView(t)){const i=t;return e&&e.push(i.buffer),i}if(t instanceof ve.ImageData)return e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const n of t)i.push(po(n,e));return i}if(typeof t=="object"){const i=t.constructor,n=i._classRegistryKey;if(!n)throw new Error(`can't serialize object of unregistered class ${n}`);const s=i.serialize?i.serialize(t,e):{};if(!i.serialize){for(const c in t)t.hasOwnProperty(c)&&(ta[n].omit.indexOf(c)>=0||(s[c]=po(t[c],e)));t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return n!=="Object"&&(s.$name=n),s}throw new Error("can't serialize object of type "+typeof t)}function In(t){if(t==null||typeof t=="boolean"||typeof t=="number"||typeof t=="string"||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||_l(t)||gl(t)||ArrayBuffer.isView(t)||t instanceof ve.ImageData)return t;if(Array.isArray(t))return t.map(In);if(typeof t=="object"){const e=t.$name||"Object",{klass:i}=ta[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const s of Object.keys(t))s!=="$name"&&(n[s]=In(t[s]));return n}throw new Error("can't deserialize object of type "+typeof t)}const Be={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function yl(t){for(const e of t)if(xl(e.charCodeAt(0)))return!0;return!1}function Jh(t){for(const e of t)if(!Gc(e.charCodeAt(0)))return!1;return!0}function Gc(t){return!(Be.Arabic(t)||Be["Arabic Supplement"](t)||Be["Arabic Extended-A"](t)||Be["Arabic Presentation Forms-A"](t)||Be["Arabic Presentation Forms-B"](t))}function xl(t){return!(t!==746&&t!==747&&(t<4352||!(Be["Bopomofo Extended"](t)||Be.Bopomofo(t)||Be["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||Be["CJK Compatibility Ideographs"](t)||Be["CJK Compatibility"](t)||Be["CJK Radicals Supplement"](t)||Be["CJK Strokes"](t)||!(!Be["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||t===12336)||Be["CJK Unified Ideographs Extension A"](t)||Be["CJK Unified Ideographs"](t)||Be["Enclosed CJK Letters and Months"](t)||Be["Hangul Compatibility Jamo"](t)||Be["Hangul Jamo Extended-A"](t)||Be["Hangul Jamo Extended-B"](t)||Be["Hangul Jamo"](t)||Be["Hangul Syllables"](t)||Be.Hiragana(t)||Be["Ideographic Description Characters"](t)||Be.Kanbun(t)||Be["Kangxi Radicals"](t)||Be["Katakana Phonetic Extensions"](t)||Be.Katakana(t)&&t!==12540||!(!Be["Halfwidth and Fullwidth Forms"](t)||t===65288||t===65289||t===65293||t>=65306&&t<=65310||t===65339||t===65341||t===65343||t>=65371&&t<=65503||t===65507||t>=65512&&t<=65519)||!(!Be["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||Be["Unified Canadian Aboriginal Syllabics"](t)||Be["Unified Canadian Aboriginal Syllabics Extended"](t)||Be["Vertical Forms"](t)||Be["Yijing Hexagram Symbols"](t)||Be["Yi Syllables"](t)||Be["Yi Radicals"](t))))}function $c(t){return!(xl(t)||function(e){return!!(Be["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Be["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Be["Letterlike Symbols"](e)||Be["Number Forms"](e)||Be["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Be["Control Pictures"](e)&&e!==9251||Be["Optical Character Recognition"](e)||Be["Enclosed Alphanumerics"](e)||Be["Geometric Shapes"](e)||Be["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Be["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Be["CJK Symbols and Punctuation"](e)||Be.Katakana(e)||Be["Private Use Area"](e)||Be["CJK Compatibility Forms"](e)||Be["Small Form Variants"](e)||Be["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(t))}function Zc(t){return t>=1424&&t<=2303||Be["Arabic Presentation Forms-A"](t)||Be["Arabic Presentation Forms-B"](t)}function Qh(t,e){return!(!e&&Zc(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||Be.Khmer(t))}function eu(t){for(const e of t)if(Zc(e.charCodeAt(0)))return!0;return!1}const vl="deferred",bl="loading",wl="loaded";let fo=null,l="unavailable",r=null;const o=function(t){t&&typeof t=="string"&&t.indexOf("NetworkError")>-1&&(l="error"),fo&&fo(t)};function h(){d.fire(new vn("pluginStateChange",{pluginStatus:l,pluginURL:r}))}const d=new Lo,f=function(){return l},g=function(){if(l!==vl||!r)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");l=bl,h(),r&&Xn({url:r},t=>{t?o(t):(l=wl,h())})},y={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>l===wl||y.applyArabicShaping!=null,isLoading:()=>l===bl,setState(t){l=t.pluginStatus,r=t.pluginURL},isParsed:()=>y.applyArabicShaping!=null&&y.processBidirectionalText!=null&&y.processStyledBidirectionalText!=null,getPluginURL:()=>r};class v{constructor(e,i){this.zoom=e,i?(this.now=i.now,this.fadeDuration=i.fadeDuration,this.transition=i.transition,this.pitch=i.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(i,n){for(const s of i)if(!Qh(s.charCodeAt(0),n))return!1;return!0}(e,y.isLoaded())}}class E{constructor(e,i){this.property=e,this.value=i,this.expression=function(n,s){if(Yo(n))return new Hs(n,s);if(lo(n)){const c=Qo(n,s);if(c.result==="error")throw new Error(c.value.map(u=>`${u.key}: ${u.message}`).join(", "));return c.value}{let c=n;return typeof n=="string"&&s.type==="color"&&(c=Yt.parse(n)),{kind:"constant",evaluate:()=>c}}}(i===void 0?e.specification.default:i,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,i,n){return this.property.possiblyEvaluate(this,e,i,n)}}class T{constructor(e){this.property=e,this.value=new E(e,void 0)}transitioned(e,i){return new k(this.property,this.value,i,Qt({},e.transition,this.transition),e.now)}untransitioned(){return new k(this.property,this.value,null,{},0)}}class A{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return Gi(this._values[e].value.value)}setValue(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new T(this._values[e].property)),this._values[e].value=new E(this._values[e].property,i===null?void 0:Gi(i))}getTransition(e){return Gi(this._values[e].transition)}setTransition(e,i){this._values.hasOwnProperty(e)||(this._values[e]=new T(this._values[e].property)),this._values[e].transition=Gi(i)||void 0}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);n!==void 0&&(e[i]=n);const s=this.getTransition(i);s!==void 0&&(e[`${i}-transition`]=s)}return e}transitioned(e,i){const n=new R(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].transitioned(e,i._values[s]);return n}untransitioned(){const e=new R(this._properties);for(const i of Object.keys(this._values))e._values[i]=this._values[i].untransitioned();return e}}class k{constructor(e,i,n,s,c){const u=s.delay||0,p=s.duration||0;c=c||0,this.property=e,this.value=i,this.begin=c+u,this.end=this.begin+p,e.specification.transition&&(s.delay||s.duration)&&(this.prior=n)}possiblyEvaluate(e,i,n){const s=e.now||0,c=this.value.possiblyEvaluate(e,i,n),u=this.prior;if(u){if(s>this.end)return this.prior=null,c;if(this.value.isDataDriven())return this.prior=null,c;if(s<this.begin)return u.possiblyEvaluate(e,i,n);{const p=(s-this.begin)/(this.end-this.begin);return this.property.interpolate(u.possiblyEvaluate(e,i,n),c,bs(p))}}return c}}class R{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,i,n){const s=new F(this._properties);for(const c of Object.keys(this._values))s._values[c]=this._values[c].possiblyEvaluate(e,i,n);return s}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class O{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return Gi(this._values[e].value)}setValue(e,i){this._values[e]=new E(this._values[e].property,i===null?void 0:Gi(i))}serialize(){const e={};for(const i of Object.keys(this._values)){const n=this.getValue(i);n!==void 0&&(e[i]=n)}return e}possiblyEvaluate(e,i,n){const s=new F(this._properties);for(const c of Object.keys(this._values))s._values[c]=this._values[c].possiblyEvaluate(e,i,n);return s}}class B{constructor(e,i,n){this.property=e,this.value=i,this.parameters=n}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,i,n,s){return this.property.evaluate(this.value,this.parameters,e,i,n,s)}}class F{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class I{constructor(e){this.specification=e}possiblyEvaluate(e,i){return e.expression.evaluate(i)}interpolate(e,i,n){const s=Zo[this.specification.type];return s?s(e,i,n):e}}class L{constructor(e,i){this.specification=e,this.overrides=i}possiblyEvaluate(e,i,n,s){return new B(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(i,null,{},n,s)}:e.expression,i)}interpolate(e,i,n){if(e.value.kind!=="constant"||i.value.kind!=="constant")return e;if(e.value.value===void 0||i.value.value===void 0)return new B(this,{kind:"constant",value:void 0},e.parameters);const s=Zo[this.specification.type];return s?new B(this,{kind:"constant",value:s(e.value.value,i.value.value,n)},e.parameters):e}evaluate(e,i,n,s,c,u){return e.kind==="constant"?e.value:e.evaluate(i,n,s,c,u)}}class N{constructor(e){this.specification=e}possiblyEvaluate(e,i,n,s){return!!e.expression.evaluate(i,null,{},n,s)}interpolate(){return!1}}class j{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const i=new v(0,{});for(const n in e){const s=e[n];s.specification.overridable&&this.overridableProperties.push(n);const c=this.defaultPropertyValues[n]=new E(s,void 0),u=this.defaultTransitionablePropertyValues[n]=new T(s);this.defaultTransitioningPropertyValues[n]=u.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=c.possiblyEvaluate(i)}}}function K(t,e){return 256*(t=ut(Math.floor(t),0,255))+ut(Math.floor(e),0,255)}Ue(L,"DataDrivenProperty"),Ue(I,"DataConstantProperty"),Ue(N,"ColorRampProperty");const J={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Y{constructor(e,i){this._structArray=e,this._pos1=i*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ie{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,i){return e._trim(),i&&(e.isTransferred=!0,i.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const i=Object.create(this.prototype);return i.arrayBuffer=e.arrayBuffer,i.length=e.length,i.capacity=e.arrayBuffer.byteLength/i.bytesPerElement,i._refreshViews(),i}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const i=this.uint8;this._refreshViews(),i&&this.uint8.set(i)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function te(t,e=1){let i=0,n=0;return{members:t.map(s=>{const c=J[s.type].BYTES_PER_ELEMENT,u=i=le(i,Math.max(e,c)),p=s.components||1;return n=Math.max(n,c),i+=c*p,{name:s.name,type:s.type,components:p,offset:u}}),size:le(i,Math.max(n,e)),alignment:e}}function le(t,e){return Math.ceil(t/e)*e}class Ee extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.int16[s+0]=i,this.int16[s+1]=n,e}}Ee.prototype.bytesPerElement=4,Ue(Ee,"StructArrayLayout2i4");class oe extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const c=3*e;return this.int16[c+0]=i,this.int16[c+1]=n,this.int16[c+2]=s,e}}oe.prototype.bytesPerElement=6,Ue(oe,"StructArrayLayout3i6");class ge extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,s)}emplace(e,i,n,s,c){const u=4*e;return this.int16[u+0]=i,this.int16[u+1]=n,this.int16[u+2]=s,this.int16[u+3]=c,e}}ge.prototype.bytesPerElement=8,Ue(ge,"StructArrayLayout4i8");class he extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,c,u,p)}emplace(e,i,n,s,c,u,p,m){const _=6*e,x=12*e,b=3*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.uint8[x+4]=s,this.uint8[x+5]=c,this.uint8[x+6]=u,this.uint8[x+7]=p,this.float32[b+2]=m,e}}he.prototype.bytesPerElement=12,Ue(he,"StructArrayLayout2i4ub1f12");class Te extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,s)}emplace(e,i,n,s,c){const u=4*e;return this.float32[u+0]=i,this.float32[u+1]=n,this.float32[u+2]=s,this.float32[u+3]=c,e}}Te.prototype.bytesPerElement=16,Ue(Te,"StructArrayLayout4f16");class ae extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,c)}emplace(e,i,n,s,c,u){const p=6*e,m=3*e;return this.uint16[p+0]=i,this.uint16[p+1]=n,this.uint16[p+2]=s,this.uint16[p+3]=c,this.float32[m+2]=u,e}}ae.prototype.bytesPerElement=12,Ue(ae,"StructArrayLayout4ui1f12");class _e extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,s)}emplace(e,i,n,s,c){const u=4*e;return this.uint16[u+0]=i,this.uint16[u+1]=n,this.uint16[u+2]=s,this.uint16[u+3]=c,e}}_e.prototype.bytesPerElement=8,Ue(_e,"StructArrayLayout4ui8");class Me extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,s,c,u)}emplace(e,i,n,s,c,u,p){const m=6*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=s,this.int16[m+3]=c,this.int16[m+4]=u,this.int16[m+5]=p,e}}Me.prototype.bytesPerElement=12,Ue(Me,"StructArrayLayout6i12");class be extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p,m,_,x,b,w){const S=this.length;return this.resize(S+1),this.emplace(S,e,i,n,s,c,u,p,m,_,x,b,w)}emplace(e,i,n,s,c,u,p,m,_,x,b,w,S){const M=12*e;return this.int16[M+0]=i,this.int16[M+1]=n,this.int16[M+2]=s,this.int16[M+3]=c,this.uint16[M+4]=u,this.uint16[M+5]=p,this.uint16[M+6]=m,this.uint16[M+7]=_,this.int16[M+8]=x,this.int16[M+9]=b,this.int16[M+10]=w,this.int16[M+11]=S,e}}be.prototype.bytesPerElement=24,Ue(be,"StructArrayLayout4i4ui4i24");class Ae extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u){const p=this.length;return this.resize(p+1),this.emplace(p,e,i,n,s,c,u)}emplace(e,i,n,s,c,u,p){const m=10*e,_=5*e;return this.int16[m+0]=i,this.int16[m+1]=n,this.int16[m+2]=s,this.float32[_+2]=c,this.float32[_+3]=u,this.float32[_+4]=p,e}}Ae.prototype.bytesPerElement=20,Ue(Ae,"StructArrayLayout3i3f20");class Ge extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint32[1*e+0]=i,e}}Ge.prototype.bytesPerElement=4,Ue(Ge,"StructArrayLayout1ul4");class He extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p,m,_,x,b,w,S){const M=this.length;return this.resize(M+1),this.emplace(M,e,i,n,s,c,u,p,m,_,x,b,w,S)}emplace(e,i,n,s,c,u,p,m,_,x,b,w,S,M){const C=20*e,D=10*e;return this.int16[C+0]=i,this.int16[C+1]=n,this.int16[C+2]=s,this.int16[C+3]=c,this.int16[C+4]=u,this.float32[D+3]=p,this.float32[D+4]=m,this.float32[D+5]=_,this.float32[D+6]=x,this.int16[C+14]=b,this.uint32[D+8]=w,this.uint16[C+18]=S,this.uint16[C+19]=M,e}}He.prototype.bytesPerElement=40,Ue(He,"StructArrayLayout5i4f1i1ul2ui40");class Ve extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,i,n,s,c,u,p)}emplace(e,i,n,s,c,u,p,m){const _=8*e;return this.int16[_+0]=i,this.int16[_+1]=n,this.int16[_+2]=s,this.int16[_+4]=c,this.int16[_+5]=u,this.int16[_+6]=p,this.int16[_+7]=m,e}}Ve.prototype.bytesPerElement=16,Ue(Ve,"StructArrayLayout3i2i2i16");class qe extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,c)}emplace(e,i,n,s,c,u){const p=4*e,m=8*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=s,this.int16[m+6]=c,this.int16[m+7]=u,e}}qe.prototype.bytesPerElement=16,Ue(qe,"StructArrayLayout2f1f2i16");class ht extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,s)}emplace(e,i,n,s,c){const u=12*e,p=3*e;return this.uint8[u+0]=i,this.uint8[u+1]=n,this.float32[p+1]=s,this.float32[p+2]=c,e}}ht.prototype.bytesPerElement=12,Ue(ht,"StructArrayLayout2ub2f12");class at extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const c=3*e;return this.float32[c+0]=i,this.float32[c+1]=n,this.float32[c+2]=s,e}}at.prototype.bytesPerElement=12,Ue(at,"StructArrayLayout3f12");class je extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,e,i,n)}emplace(e,i,n,s){const c=3*e;return this.uint16[c+0]=i,this.uint16[c+1]=n,this.uint16[c+2]=s,e}}je.prototype.bytesPerElement=6,Ue(je,"StructArrayLayout3ui6");class Et extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X){const W=this.length;return this.resize(W+1),this.emplace(W,e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X)}emplace(e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X,W){const ce=30*e,se=15*e,me=60*e;return this.int16[ce+0]=i,this.int16[ce+1]=n,this.int16[ce+2]=s,this.float32[se+2]=c,this.float32[se+3]=u,this.uint16[ce+8]=p,this.uint16[ce+9]=m,this.uint32[se+5]=_,this.uint32[se+6]=x,this.uint32[se+7]=b,this.uint16[ce+16]=w,this.uint16[ce+17]=S,this.uint16[ce+18]=M,this.float32[se+10]=C,this.float32[se+11]=D,this.uint8[me+48]=U,this.uint8[me+49]=q,this.uint8[me+50]=V,this.uint32[se+13]=$,this.int16[ce+28]=X,this.uint8[me+58]=W,e}}Et.prototype.bytesPerElement=60,Ue(Et,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Mt extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X,W,ce,se,me,Se,ue,ye,xe,we){const Ce=this.length;return this.resize(Ce+1),this.emplace(Ce,e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X,W,ce,se,me,Se,ue,ye,xe,we)}emplace(e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D,U,q,V,$,X,W,ce,se,me,Se,ue,ye,xe,we,Ce){const pe=38*e,De=19*e;return this.int16[pe+0]=i,this.int16[pe+1]=n,this.int16[pe+2]=s,this.float32[De+2]=c,this.float32[De+3]=u,this.int16[pe+8]=p,this.int16[pe+9]=m,this.int16[pe+10]=_,this.int16[pe+11]=x,this.int16[pe+12]=b,this.int16[pe+13]=w,this.uint16[pe+14]=S,this.uint16[pe+15]=M,this.uint16[pe+16]=C,this.uint16[pe+17]=D,this.uint16[pe+18]=U,this.uint16[pe+19]=q,this.uint16[pe+20]=V,this.uint16[pe+21]=$,this.uint16[pe+22]=X,this.uint16[pe+23]=W,this.uint16[pe+24]=ce,this.uint16[pe+25]=se,this.uint16[pe+26]=me,this.uint16[pe+27]=Se,this.uint16[pe+28]=ue,this.uint32[De+15]=ye,this.float32[De+16]=xe,this.float32[De+17]=we,this.float32[De+18]=Ce,e}}Mt.prototype.bytesPerElement=76,Ue(Mt,"StructArrayLayout3i2f6i15ui1ul3f76");class At extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.float32[1*e+0]=i,e}}At.prototype.bytesPerElement=4,Ue(At,"StructArrayLayout1f4");class It extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i,n,s,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,i,n,s,c)}emplace(e,i,n,s,c,u){const p=5*e;return this.float32[p+0]=i,this.float32[p+1]=n,this.float32[p+2]=s,this.float32[p+3]=c,this.float32[p+4]=u,e}}It.prototype.bytesPerElement=20,Ue(It,"StructArrayLayout5f20");class Ii extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i,n,s){const c=this.length;return this.resize(c+1),this.emplace(c,e,i,n,s)}emplace(e,i,n,s,c){const u=6*e;return this.uint32[3*e+0]=i,this.uint16[u+2]=n,this.uint16[u+3]=s,this.uint16[u+4]=c,e}}Ii.prototype.bytesPerElement=12,Ue(Ii,"StructArrayLayout1ul3ui12");class xi extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.uint16[s+0]=i,this.uint16[s+1]=n,e}}xi.prototype.bytesPerElement=4,Ue(xi,"StructArrayLayout2ui4");class er extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const i=this.length;return this.resize(i+1),this.emplace(i,e)}emplace(e,i){return this.uint16[1*e+0]=i,e}}er.prototype.bytesPerElement=2,Ue(er,"StructArrayLayout1ui2");class vr extends ie{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,i){const n=this.length;return this.resize(n+1),this.emplace(n,e,i)}emplace(e,i,n){const s=2*e;return this.float32[s+0]=i,this.float32[s+1]=n,e}}vr.prototype.bytesPerElement=8,Ue(vr,"StructArrayLayout2f8");class Nt extends Y{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}Nt.prototype.size=40;class Ct extends He{get(e){return new Nt(this,e)}}Ue(Ct,"CollisionBoxArray");class vt extends Y{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(e){this._structArray.uint8[this._pos1+49]=e}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(e){this._structArray.uint8[this._pos1+50]=e}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(e){this._structArray.uint32[this._pos4+13]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(e){this._structArray.uint8[this._pos1+58]=e}}vt.prototype.size=60;class ii extends Et{get(e){return new vt(this,e)}}Ue(ii,"PlacedSymbolArray");class ki extends Y{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}ki.prototype.size=76;class Ut extends Mt{get(e){return new ki(this,e)}}Ue(Ut,"SymbolInstanceArray");class Oi extends At{getoffsetX(e){return this.float32[1*e+0]}}Ue(Oi,"GlyphOffsetArray");class ia extends Ee{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}Ue(ia,"SymbolLineVertexArray");class Cn extends Y{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Cn.prototype.size=12;class os extends Ii{get(e){return new Cn(this,e)}}Ue(os,"FeatureIndexArray");class Ur extends xi{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}Ue(Ur,"FillExtrusionCentroidArray");const nn=te([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),zn=te([{name:"a_dash",components:4,type:"Uint16"}]);var ra={exports:{}},ss={exports:{}};ss.exports=function(t,e){var i,n,s,c,u,p,m,_;for(n=t.length-(i=3&t.length),s=e,u=3432918353,p=461845907,_=0;_<n;)m=255&t.charCodeAt(_)|(255&t.charCodeAt(++_))<<8|(255&t.charCodeAt(++_))<<16|(255&t.charCodeAt(++_))<<24,++_,s=27492+(65535&(c=5*(65535&(s=(s^=m=(65535&(m=(m=(65535&m)*u+(((m>>>16)*u&65535)<<16)&4294967295)<<15|m>>>17))*p+(((m>>>16)*p&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(c>>>16)&65535)<<16);switch(m=0,i){case 3:m^=(255&t.charCodeAt(_+2))<<16;case 2:m^=(255&t.charCodeAt(_+1))<<8;case 1:s^=m=(65535&(m=(m=(65535&(m^=255&t.charCodeAt(_)))*u+(((m>>>16)*u&65535)<<16)&4294967295)<<15|m>>>17))*p+(((m>>>16)*p&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 Tl=ss.exports,pd={exports:{}};pd.exports=function(t,e){for(var i,n=t.length,s=e^n,c=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(c)|(255&t.charCodeAt(++c))<<8|(255&t.charCodeAt(++c))<<16|(255&t.charCodeAt(++c))<<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)),n-=4,++c;switch(n){case 3:s^=(255&t.charCodeAt(c+2))<<16;case 2:s^=(255&t.charCodeAt(c+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(c)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0};var fd=Tl,Kf=pd.exports;ra.exports=fd,ra.exports.murmur3=fd,ra.exports.murmur2=Kf;var tu=or(ra.exports);class qc{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,i,n,s){this.ids.push(md(e)),this.positions.push(i,n,s)}getPositions(e){const i=md(e);let n=0,s=this.ids.length-1;for(;n<s;){const u=n+s>>1;this.ids[u]>=i?s=u:n=u+1}const c=[];for(;this.ids[n]===i;)c.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return c}static serialize(e,i){const n=new Float64Array(e.ids),s=new Uint32Array(e.positions);return iu(n,s,0,n.length-1),i&&i.push(n.buffer,s.buffer),{ids:n,positions:s}}static deserialize(e){const i=new qc;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}}function md(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:tu(String(t))}function iu(t,e,i,n){for(;i<n;){const s=t[i+n>>1];let c=i-1,u=n+1;for(;;){do c++;while(t[c]<s);do u--;while(t[u]>s);if(c>=u)break;Wc(t,c,u),Wc(e,3*c,3*u),Wc(e,3*c+1,3*u+1),Wc(e,3*c+2,3*u+2)}u-i<n-u?(iu(t,e,i,u),i=u+1):(iu(t,e,u+1,n),n=u)}}function Wc(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}Ue(qc,"FeaturePositionMap");class Pn{constructor(e){this.gl=e.gl,this.initialized=!1}fetchUniformLocation(e,i){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(e,i),this.initialized=!0),!!this.location}}class Xc extends Pn{constructor(e){super(e),this.current=0}set(e,i,n){this.fetchUniformLocation(e,i)&&this.current!==n&&(this.current=n,this.gl.uniform1f(this.location,n))}}class _d extends Pn{constructor(e){super(e),this.current=[0,0,0,0]}set(e,i,n){this.fetchUniformLocation(e,i)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]&&n[3]===this.current[3]||(this.current=n,this.gl.uniform4f(this.location,n[0],n[1],n[2],n[3])))}}class gd extends Pn{constructor(e){super(e),this.current=Yt.transparent}set(e,i,n){this.fetchUniformLocation(e,i)&&(n.r===this.current.r&&n.g===this.current.g&&n.b===this.current.b&&n.a===this.current.a||(this.current=n,this.gl.uniform4f(this.location,n.r,n.g,n.b,n.a)))}}const Yf=new Float32Array(16),Jf=new Float32Array(9),Qf=new Float32Array(4);function ru(t){return[K(255*t.r,255*t.g),K(255*t.b,255*t.a)]}class El{constructor(e,i,n){this.value=e,this.uniformNames=i.map(s=>`u_${s}`),this.type=n}setUniform(e,i,n,s,c){i.set(e,c,s.constantOr(this.value))}getBinding(e,i){return this.type==="color"?new gd(e):new Xc(e)}}class na{constructor(e,i){this.uniformNames=i.map(n=>`u_${n}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,i,n,s,c){const u=c==="u_pattern"||c==="u_dash"?this.pattern:c==="u_pixel_ratio"?this.pixelRatio:null;u&&i.set(e,c,u)}getBinding(e,i){return i==="u_pattern"||i==="u_dash"?new _d(e):new Xc(e)}}class kn{constructor(e,i,n,s){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=i.map(c=>({name:`a_${c}`,type:"Float32",components:n==="color"?2:1,offset:0})),this.paintVertexArray=new s}populatePaintArray(e,i,n,s,c,u){const p=this.paintVertexArray.length,m=this.expression.evaluate(new v(0),i,{},c,s,u);this.paintVertexArray.resize(e),this._setPaintValue(p,e,m)}updatePaintArray(e,i,n,s,c){const u=this.expression.evaluate({zoom:0},n,s,void 0,c);this._setPaintValue(e,i,u)}_setPaintValue(e,i,n){if(this.type==="color"){const s=ru(n);for(let c=e;c<i;c++)this.paintVertexArray.emplace(c,s[0],s[1])}else{for(let s=e;s<i;s++)this.paintVertexArray.emplace(s,n);this.maxValue=Math.max(this.maxValue,Math.abs(n))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Vr{constructor(e,i,n,s,c,u){this.expression=e,this.uniformNames=i.map(p=>`u_${p}_t`),this.type=n,this.useIntegerZoom=s,this.zoom=c,this.maxValue=0,this.paintVertexAttributes=i.map(p=>({name:`a_${p}`,type:"Float32",components:n==="color"?4:2,offset:0})),this.paintVertexArray=new u}populatePaintArray(e,i,n,s,c,u){const p=this.expression.evaluate(new v(this.zoom),i,{},c,s,u),m=this.expression.evaluate(new v(this.zoom+1),i,{},c,s,u),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,p,m)}updatePaintArray(e,i,n,s,c){const u=this.expression.evaluate({zoom:this.zoom},n,s,void 0,c),p=this.expression.evaluate({zoom:this.zoom+1},n,s,void 0,c);this._setPaintValue(e,i,u,p)}_setPaintValue(e,i,n,s){if(this.type==="color"){const c=ru(n),u=ru(s);for(let p=e;p<i;p++)this.paintVertexArray.emplace(p,c[0],c[1],u[0],u[1])}else{for(let c=e;c<i;c++)this.paintVertexArray.emplace(c,n,s);this.maxValue=Math.max(this.maxValue,Math.abs(n),Math.abs(s))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,i,n,s,c){const u=this.useIntegerZoom?Math.floor(n.zoom):n.zoom,p=ut(this.expression.interpolationFactor(u,this.zoom,this.zoom+1),0,1);i.set(e,c,p)}getBinding(e,i){return new Xc(e)}}class mo{constructor(e,i,n,s,c){this.expression=e,this.layerId=c,this.paintVertexAttributes=(n==="array"?zn:nn).members;for(let u=0;u<i.length;++u);this.paintVertexArray=new s}populatePaintArray(e,i,n){const s=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValues(s,e,i.patterns&&i.patterns[this.layerId],n)}updatePaintArray(e,i,n,s,c,u){this._setPaintValues(e,i,n.patterns&&n.patterns[this.layerId],u)}_setPaintValues(e,i,n,s){if(!s||!n)return;const c=s[n];if(!c)return;const{tl:u,br:p,pixelRatio:m}=c;for(let _=e;_<i;_++)this.paintVertexArray.emplace(_,u[0],u[1],p[0],p[1],m)}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class _o{constructor(e,i,n=()=>!0){this.binders={},this._buffers=[];const s=[];for(const c in e.paint._values){if(!n(c))continue;const u=e.paint.get(c);if(!(u instanceof B&&so(u.property.specification)))continue;const p=tm(c,e.type),m=u.value,_=u.property.specification.type,x=!!u.property.useIntegerZoom,b=c==="line-dasharray"||c.endsWith("pattern"),w=c==="line-dasharray"&&e.layout.get("line-cap").value.kind!=="constant";if(m.kind!=="constant"||w)if(m.kind==="source"||w||b){const S=yd(c,_,"source");this.binders[c]=b?new mo(m,p,_,S,e.id):new kn(m,p,_,S),s.push(`/a_${c}`)}else{const S=yd(c,_,"composite");this.binders[c]=new Vr(m,p,_,x,i,S),s.push(`/z_${c}`)}else this.binders[c]=b?new na(m.value,p):new El(m.value,p,_),s.push(`/u_${c}`)}this.cacheKey=s.sort().join("")}getMaxValue(e){const i=this.binders[e];return i instanceof kn||i instanceof Vr?i.maxValue:0}populatePaintArrays(e,i,n,s,c,u){for(const p in this.binders){const m=this.binders[p];(m instanceof kn||m instanceof Vr||m instanceof mo)&&m.populatePaintArray(e,i,n,s,c,u)}}setConstantPatternPositions(e){for(const i in this.binders){const n=this.binders[i];n instanceof na&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,i,n,s,c,u){let p=!1;for(const m in e){const _=i.getPositions(m);for(const x of _){const b=n.feature(x.index);for(const w in this.binders){const S=this.binders[w];if((S instanceof kn||S instanceof Vr||S instanceof mo)&&S.expression.isStateDependent===!0){const M=s.paint.get(w);S.expression=M.value,S.updatePaintArray(x.start,x.end,b,e[m],c,u),p=!0}}}}return p}defines(){const e=[];for(const i in this.binders){const n=this.binders[i];(n instanceof El||n instanceof na)&&e.push(...n.uniformNames.map(s=>`#define HAS_UNIFORM_${s}`))}return e}getBinderAttributes(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof kn||n instanceof Vr||n instanceof mo)for(let s=0;s<n.paintVertexAttributes.length;s++)e.push(n.paintVertexAttributes[s].name)}return e}getBinderUniforms(){const e=[];for(const i in this.binders){const n=this.binders[i];if(n instanceof El||n instanceof na||n instanceof Vr)for(const s of n.uniformNames)e.push(s)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e){const i=[];for(const n in this.binders){const s=this.binders[n];if(s instanceof El||s instanceof na||s instanceof Vr)for(const c of s.uniformNames)i.push({name:c,property:n,binding:s.getBinding(e,c)})}return i}setUniforms(e,i,n,s,c){for(const{name:u,property:p,binding:m}of n)this.binders[p].setUniform(e,m,c,s.get(p),u)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const i=this.binders[e];(i instanceof kn||i instanceof Vr||i instanceof mo)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const i in this.binders){const n=this.binders[i];(n instanceof kn||n instanceof Vr||n instanceof mo)&&n.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const i=this.binders[e];(i instanceof kn||i instanceof Vr||i instanceof mo)&&i.destroy()}}}class as{constructor(e,i,n=()=>!0){this.programConfigurations={};for(const s of e)this.programConfigurations[s.id]=new _o(s,i,n);this.needsUpload=!1,this._featureMap=new qc,this._bufferOffset=0}populatePaintArrays(e,i,n,s,c,u,p){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,i,s,c,u,p);i.id!==void 0&&this._featureMap.add(i.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,i,n,s,c){for(const u of n)this.needsUpload=this.programConfigurations[u.id].updatePaintArrays(e,this._featureMap,i,u,s,c)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const i in this.programConfigurations)this.programConfigurations[i].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}const em={"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function tm(t,e){return em[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const im={"line-pattern":{source:ae,composite:ae},"fill-pattern":{source:ae,composite:ae},"fill-extrusion-pattern":{source:ae,composite:ae},"line-dasharray":{source:_e,composite:_e}},rm={color:{source:vr,composite:Te},number:{source:At,composite:vr}};function yd(t,e,i){const n=im[t];return n&&n[i]||rm[e][i]}Ue(El,"ConstantBinder"),Ue(na,"PatternConstantBinder"),Ue(kn,"SourceExpressionBinder"),Ue(mo,"PatternCompositeBinder"),Ue(Vr,"CompositeExpressionBinder"),Ue(_o,"ProgramConfiguration",{omit:["_buffers"]}),Ue(as,"ProgramConfigurationSet");const xd="-transition";class Nr extends Lo{constructor(e,i){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&e.type!=="sky"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),i.layout&&(this._unevaluatedLayout=new O(i.layout)),i.paint)){this._transitionablePaint=new A(i.paint);for(const n in e.paint)this.setPaintProperty(n,e.paint[n],{validate:!1});for(const n in e.layout)this.setLayoutProperty(n,e.layout[n],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new F(i.paint)}}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,i,n={}){i!=null&&this._validate(Kh,`layers.${this.id}.layout.${e}`,e,i,n)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,i):this.visibility=i)}getPaintProperty(e){return Gn(e,xd)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,i,n={}){if(i!=null&&this._validate(Hh,`layers.${this.id}.paint.${e}`,e,i,n))return!1;if(Gn(e,xd))return this._transitionablePaint.setTransition(e.slice(0,-11),i||void 0),!1;{const s=this._transitionablePaint._values[e],c=s.value.isDataDriven(),u=s.value;this._transitionablePaint.setValue(e,i),this._handleSpecialPaintPropertyUpdate(e);const p=this._transitionablePaint._values[e].value,m=p.isDataDriven(),_=Gn(e,"pattern")||e==="line-dasharray";return m||c||_||this._handleOverridablePaintPropertyUpdate(e,u,p)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,i,n){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||!!(this.maxzoom&&e>=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,i){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,i)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,i)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),$n(e,(i,n)=>!(i===void 0||n==="layout"&&!Object.keys(i).length||n==="paint"&&!Object.keys(i).length))}_validate(e,i,n,s,c={}){return(!c||c.validate!==!1)&&jc(this,e.call(Nc,{key:i,layerType:this.type,objectKey:n,value:s,styleSpec:fe,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const i=this.paint.get(e);if(i instanceof B&&so(i.property.specification)&&(i.value.kind==="source"||i.value.kind==="composite")&&i.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Js(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const nm=te([{name:"a_pos",components:2,type:"Int16"}],4),om=te([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ri{constructor(e=[]){this.segments=e}prepareSegment(e,i,n,s){let c=this.segments[this.segments.length-1];return e>ri.MAX_VERTEX_ARRAY_LENGTH&&Gt(`Max vertices per segment is ${ri.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!c||c.vertexLength+e>ri.MAX_VERTEX_ARRAY_LENGTH||c.sortKey!==s)&&(c={vertexOffset:i.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},s!==void 0&&(c.sortKey=s),this.segments.push(c)),c}get(){return this.segments}destroy(){for(const e of this.segments)for(const i in e.vaos)e.vaos[i].destroy()}static simpleSegment(e,i,n,s){return new ri([{vertexOffset:e,primitiveOffset:i,vertexLength:n,primitiveLength:s,vaos:{},sortKey:0}])}}ri.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ue(ri,"SegmentVector");var Ze=8192;class go{constructor(e,i){e&&(i?this.setSouthWest(e).setNorthEast(i):e.length===4?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof zt?new zt(e.lng,e.lat):zt.convert(e),this}setSouthWest(e){return this._sw=e instanceof zt?new zt(e.lng,e.lat):zt.convert(e),this}extend(e){const i=this._sw,n=this._ne;let s,c;if(e instanceof zt)s=e,c=e;else{if(!(e instanceof go))return Array.isArray(e)?e.length===4||e.every(Array.isArray)?this.extend(go.convert(e)):this.extend(zt.convert(e)):typeof e=="object"&&e!==null&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(zt.convert(e)):this;if(s=e._sw,c=e._ne,!s||!c)return this}return i||n?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),n.lng=Math.max(c.lng,n.lng),n.lat=Math.max(c.lat,n.lat)):(this._sw=new zt(s.lng,s.lat),this._ne=new zt(c.lng,c.lat)),this}getCenter(){return new zt((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 zt(this.getWest(),this.getNorth())}getSouthEast(){return new zt(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:i,lat:n}=zt.convert(e);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<=n&&n<=this._ne.lat&&s}static convert(e){return!e||e instanceof go?e:new go(e)}}var Hc=1e-6,tr=typeof Float32Array<"u"?Float32Array:Array;function vd(){var t=new tr(9);return tr!=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}function bd(t,e,i){var n=e[0],s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],w=i[0],S=i[1],M=i[2],C=i[3],D=i[4],U=i[5],q=i[6],V=i[7],$=i[8];return t[0]=w*n+S*u+M*_,t[1]=w*s+S*p+M*x,t[2]=w*c+S*m+M*b,t[3]=C*n+D*u+U*_,t[4]=C*s+D*p+U*x,t[5]=C*c+D*m+U*b,t[6]=q*n+V*u+$*_,t[7]=q*s+V*p+$*x,t[8]=q*c+V*m+$*b,t}function jr(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function nu(t,e){var i=e[0],n=e[1],s=e[2],c=e[3],u=e[4],p=e[5],m=e[6],_=e[7],x=e[8],b=e[9],w=e[10],S=e[11],M=e[12],C=e[13],D=e[14],U=e[15],q=i*p-n*u,V=i*m-s*u,$=i*_-c*u,X=n*m-s*p,W=n*_-c*p,ce=s*_-c*m,se=x*C-b*M,me=x*D-w*M,Se=x*U-S*M,ue=b*D-w*C,ye=b*U-S*C,xe=w*U-S*D,we=q*xe-V*ye+$*ue+X*Se-W*me+ce*se;return we?(t[0]=(p*xe-m*ye+_*ue)*(we=1/we),t[1]=(s*ye-n*xe-c*ue)*we,t[2]=(C*ce-D*W+U*X)*we,t[3]=(w*W-b*ce-S*X)*we,t[4]=(m*Se-u*xe-_*me)*we,t[5]=(i*xe-s*Se+c*me)*we,t[6]=(D*$-M*ce-U*V)*we,t[7]=(x*ce-w*$+S*V)*we,t[8]=(u*ye-p*Se+_*se)*we,t[9]=(n*Se-i*ye-c*se)*we,t[10]=(M*W-C*$+U*q)*we,t[11]=(b*$-x*W-S*q)*we,t[12]=(p*me-u*ue-m*se)*we,t[13]=(i*ue-n*me+s*se)*we,t[14]=(C*V-M*X-D*q)*we,t[15]=(x*X-b*V+w*q)*we,t):null}function ls(t,e,i){var n=e[0],s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],w=e[9],S=e[10],M=e[11],C=e[12],D=e[13],U=e[14],q=e[15],V=i[0],$=i[1],X=i[2],W=i[3];return t[0]=V*n+$*p+X*b+W*C,t[1]=V*s+$*m+X*w+W*D,t[2]=V*c+$*_+X*S+W*U,t[3]=V*u+$*x+X*M+W*q,t[4]=(V=i[4])*n+($=i[5])*p+(X=i[6])*b+(W=i[7])*C,t[5]=V*s+$*m+X*w+W*D,t[6]=V*c+$*_+X*S+W*U,t[7]=V*u+$*x+X*M+W*q,t[8]=(V=i[8])*n+($=i[9])*p+(X=i[10])*b+(W=i[11])*C,t[9]=V*s+$*m+X*w+W*D,t[10]=V*c+$*_+X*S+W*U,t[11]=V*u+$*x+X*M+W*q,t[12]=(V=i[12])*n+($=i[13])*p+(X=i[14])*b+(W=i[15])*C,t[13]=V*s+$*m+X*w+W*D,t[14]=V*c+$*_+X*S+W*U,t[15]=V*u+$*x+X*M+W*q,t}function Sl(t,e,i){var n,s,c,u,p,m,_,x,b,w,S,M,C=i[0],D=i[1],U=i[2];return e===t?(t[12]=e[0]*C+e[4]*D+e[8]*U+e[12],t[13]=e[1]*C+e[5]*D+e[9]*U+e[13],t[14]=e[2]*C+e[6]*D+e[10]*U+e[14],t[15]=e[3]*C+e[7]*D+e[11]*U+e[15]):(s=e[1],c=e[2],u=e[3],p=e[4],m=e[5],_=e[6],x=e[7],b=e[8],w=e[9],S=e[10],M=e[11],t[0]=n=e[0],t[1]=s,t[2]=c,t[3]=u,t[4]=p,t[5]=m,t[6]=_,t[7]=x,t[8]=b,t[9]=w,t[10]=S,t[11]=M,t[12]=n*C+p*D+b*U+e[12],t[13]=s*C+m*D+w*U+e[13],t[14]=c*C+_*D+S*U+e[14],t[15]=u*C+x*D+M*U+e[15]),t}function cs(t,e,i){var n=i[0],s=i[1],c=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*c,t[9]=e[9]*c,t[10]=e[10]*c,t[11]=e[11]*c,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ou(t,e,i){var n=Math.sin(i),s=Math.cos(i),c=e[4],u=e[5],p=e[6],m=e[7],_=e[8],x=e[9],b=e[10],w=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=c*s+_*n,t[5]=u*s+x*n,t[6]=p*s+b*n,t[7]=m*s+w*n,t[8]=_*s-c*n,t[9]=x*s-u*n,t[10]=b*s-p*n,t[11]=w*s-m*n,t}function Kc(t,e,i){var n=Math.sin(i),s=Math.cos(i),c=e[0],u=e[1],p=e[2],m=e[3],_=e[8],x=e[9],b=e[10],w=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=c*s-_*n,t[1]=u*s-x*n,t[2]=p*s-b*n,t[3]=m*s-w*n,t[8]=c*n+_*s,t[9]=u*n+x*s,t[10]=p*n+b*s,t[11]=m*n+w*s,t}function wd(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Td(t,e,i){var n,s,c,u=i[0],p=i[1],m=i[2],_=Math.hypot(u,p,m);return _<Hc?null:(u*=_=1/_,p*=_,m*=_,n=Math.sin(e),s=Math.cos(e),t[0]=u*u*(c=1-s)+s,t[1]=p*u*c+m*n,t[2]=m*u*c-p*n,t[3]=0,t[4]=u*p*c-m*n,t[5]=p*p*c+s,t[6]=m*p*c+u*n,t[7]=0,t[8]=u*m*c+p*n,t[9]=p*m*c-u*n,t[10]=m*m*c+s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var sm=ls;function su(){var t=new tr(3);return tr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Ed(t){var e=new tr(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ml(t){return Math.hypot(t[0],t[1],t[2])}function oa(t,e,i){var n=new tr(3);return n[0]=t,n[1]=e,n[2]=i,n}function Dn(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function au(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Sd(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t}function Al(t,e,i){return t[0]=Math.min(e[0],i[0]),t[1]=Math.min(e[1],i[1]),t[2]=Math.min(e[2],i[2]),t}function Il(t,e,i){return t[0]=Math.max(e[0],i[0]),t[1]=Math.max(e[1],i[1]),t[2]=Math.max(e[2],i[2]),t}function ur(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function Cl(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t}function Fi(t,e){var i=e[0],n=e[1],s=e[2],c=i*i+n*n+s*s;return c>0&&(c=1/Math.sqrt(c)),t[0]=e[0]*c,t[1]=e[1]*c,t[2]=e[2]*c,t}function br(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function lu(t,e,i){var n=e[0],s=e[1],c=e[2],u=i[0],p=i[1],m=i[2];return t[0]=s*m-c*p,t[1]=c*u-n*m,t[2]=n*p-s*u,t}function Jt(t,e,i){var n=e[0],s=e[1],c=e[2],u=i[3]*n+i[7]*s+i[11]*c+i[15];return t[0]=(i[0]*n+i[4]*s+i[8]*c+i[12])/(u=u||1),t[1]=(i[1]*n+i[5]*s+i[9]*c+i[13])/u,t[2]=(i[2]*n+i[6]*s+i[10]*c+i[14])/u,t}function Md(t,e,i){var n=i[0],s=i[1],c=i[2],u=e[0],p=e[1],m=e[2],_=s*m-c*p,x=c*u-n*m,b=n*p-s*u,w=s*b-c*x,S=c*_-n*b,M=n*x-s*_,C=2*i[3];return x*=C,b*=C,S*=2,M*=2,t[0]=u+(_*=C)+(w*=2),t[1]=p+x+S,t[2]=m+b+M,t}var zl,Gr=au,am=Sd,lm=Ml;function Ad(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Id(t,e){var i=e[0],n=e[1],s=e[2],c=e[3],u=i*i+n*n+s*s+c*c;return u>0&&(u=1/Math.sqrt(u)),t[0]=i*u,t[1]=n*u,t[2]=s*u,t[3]=c*u,t}function hs(t,e,i){var n=e[0],s=e[1],c=e[2],u=e[3];return t[0]=i[0]*n+i[4]*s+i[8]*c+i[12]*u,t[1]=i[1]*n+i[5]*s+i[9]*c+i[13]*u,t[2]=i[2]*n+i[6]*s+i[10]*c+i[14]*u,t[3]=i[3]*n+i[7]*s+i[11]*c+i[15]*u,t}function Cd(){var t=new tr(4);return tr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function zd(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Pd(t,e,i){i*=.5;var n=e[0],s=e[1],c=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m+u*p,t[1]=s*m+c*p,t[2]=c*m-s*p,t[3]=u*m-n*p,t}function kd(t,e,i){i*=.5;var n=e[0],s=e[1],c=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m-c*p,t[1]=s*m+u*p,t[2]=c*m+n*p,t[3]=u*m-s*p,t}su(),zl=new tr(4),tr!=Float32Array&&(zl[0]=0,zl[1]=0,zl[2]=0,zl[3]=0);var cm=Id;su(),oa(1,0,0),oa(0,1,0),Cd(),Cd(),vd();const hm=te([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Dd}=hm,Ld=te([{name:"a_pos_3",components:3,type:"Int16"}]);var Pl=te([{name:"a_pos",type:"Int16",components:2}]);class cu{constructor(e,i){this.pos=e,this.dir=i}intersectsPlane(e,i,n){const s=br(i,this.dir);if(Math.abs(s)<1e-6)return!1;const c=((e[0]-this.pos[0])*i[0]+(e[1]-this.pos[1])*i[1]+(e[2]-this.pos[2])*i[2])/s;return n[0]=this.pos[0]+this.dir[0]*c,n[1]=this.pos[1]+this.dir[1]*c,n[2]=this.pos[2]+this.dir[2]*c,!0}closestPointOnSphere(e,i,n){if(function(S,M){var C=S[0],D=S[1],U=S[2],q=M[0],V=M[1],$=M[2];return Math.abs(C-q)<=Hc*Math.max(1,Math.abs(C),Math.abs(q))&&Math.abs(D-V)<=Hc*Math.max(1,Math.abs(D),Math.abs(V))&&Math.abs(U-$)<=Hc*Math.max(1,Math.abs(U),Math.abs($))}(this.pos,e)||i===0)return n[0]=n[1]=n[2]=0,!1;const[s,c,u]=this.dir,p=this.pos[0]-e[0],m=this.pos[1]-e[1],_=this.pos[2]-e[2],x=s*s+c*c+u*u,b=2*(p*s+m*c+_*u),w=b*b-4*x*(p*p+m*m+_*_-i*i);if(w<0){const S=Math.max(-b/2,0),M=p+s*S,C=m+c*S,D=_+u*S,U=Math.hypot(M,C,D);return n[0]=M*i/U,n[1]=C*i/U,n[2]=D*i/U,!1}{const S=(-b-Math.sqrt(w))/(2*x);if(S<0){const M=Math.hypot(p,m,_);return n[0]=p*i/M,n[1]=m*i/M,n[2]=_*i/M,!1}return n[0]=p+s*S,n[1]=m+c*S,n[2]=_+u*S,!0}}}class hu{constructor(e,i,n,s,c){this.TL=e,this.TR=i,this.BR=n,this.BL=s,this.horizon=c}static fromInvProjectionMatrix(e,i,n){const s=[-1,1,1],c=[1,1,1],u=[1,-1,1],p=[-1,-1,1],m=Jt(s,s,e),_=Jt(c,c,e),x=Jt(u,u,e),b=Jt(p,p,e);return new hu(m,_,x,b,i/n)}}class uu{constructor(e,i){this.points=e,this.planes=i}static fromInvProjectionMatrix(e,i,n,s){const c=Math.pow(2,n),u=[[-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(m=>{const _=hs([],m,e),x=1/_[3]/i*c;return function(b,w,S){return b[0]=w[0]*S[0],b[1]=w[1]*S[1],b[2]=w[2]*S[2],b[3]=w[3]*S[3],b}(_,_,[x,x,s?1/_[3]:x,x])}),p=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(m=>{const _=Fi([],lu([],Gr([],u[m[0]],u[m[1]]),Gr([],u[m[2]],u[m[1]]))),x=-br(_,u[m[1]]);return _.concat(x)});return new uu(u,p)}}class Ui{static fromPoints(e){const i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const s of e)Al(i,i,s),Il(n,n,s);return new Ui(i,n)}static applyTransform(e,i){const n=e.getCorners();for(let s=0;s<n.length;++s)Jt(n[s],n[s],i);return Ui.fromPoints(n)}constructor(e,i){this.min=e,this.max=i,this.center=ur([],Dn([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],n=Ed(this.min),s=Ed(this.max);for(let c=0;c<i.length;c++)n[c]=i[c]?this.min[c]:this.center[c],s[c]=i[c]?this.center[c]:this.max[c];return s[2]=this.max[2],new Ui(n,s)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,i=this.max;return[[e[0],e[1],e[2]],[i[0],e[1],e[2]],[i[0],i[1],e[2]],[e[0],i[1],e[2]],[e[0],e[1],i[2]],[i[0],e[1],i[2]],[i[0],i[1],i[2]],[e[0],i[1],i[2]]]}intersects(e){const i=this.getCorners();let n=!0;for(let s=0;s<e.planes.length;s++){const c=e.planes[s];let u=0;for(let p=0;p<i.length;p++)u+=br(c,i[p])+c[3]>=0;if(u===0)return 0;u!==i.length&&(n=!1)}if(n)return 2;for(let s=0;s<3;s++){let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(let p=0;p<e.points.length;p++){const m=e.points[p][s]-this.min[s];c=Math.min(c,m),u=Math.max(u,m)}if(u<0||c>this.max[s]-this.min[s])return 0}return 1}}const du=5,Rd=6,on=Ze/Math.PI/2,um=16383,us=64,kl=[us,32,16],wr=-on,Tr=on,dm=[new Ui([wr,wr,wr],[Tr,Tr,Tr]),new Ui([wr,wr,wr],[0,0,Tr]),new Ui([0,wr,wr],[Tr,0,Tr]),new Ui([wr,0,wr],[0,Tr,Tr]),new Ui([0,0,wr],[Tr,Tr,Tr])];function Yc(t){return t*on/Rl}function Bd(t,e,i,n=!0){const s=ur([],t._camera.position,t.worldSize),c=[e,i,1,1];hs(c,c,t.pixelMatrixInverse),Ad(c,c,1/c[3]);const u=Fi([],Gr([],c,s)),p=t.globeMatrix,m=[p[12],p[13],p[14]],_=Gr([],m,s),x=Ml(_),b=Fi([],_),w=t.worldSize/(2*Math.PI),S=br(b,u),M=Math.asin(w/x);if(M<Math.acos(S)){if(!n)return null;const Se=[],ue=[];ur(Se,u,x/S),Fi(ue,Gr(ue,Se,_)),Fi(u,Dn(u,_,ur(u,ue,Math.tan(M)*x)))}const C=[];new cu(s,u).closestPointOnSphere(m,w,C);const D=Fi([],Jr(p,0)),U=Fi([],Jr(p,1)),q=Fi([],Jr(p,2)),V=br(D,C),$=br(U,C),X=br(q,C),W=fi(Math.asin(-$/w));let ce=fi(Math.atan2(V,X));ce=t.center.lng+function(Se,ue){const ye=(ue-Se+180)%360-180;return ye<-180?ye+360:ye}(t.center.lng,ce);const se=an(ce),me=ut(ln(W),0,1);return new ca(se,me)}class pm{constructor(e,i,n){this.a=Gr([],e,n),this.b=Gr([],i,n),this.center=n;const s=Fi([],this.a),c=Fi([],this.b);this.angle=Math.acos(br(s,c))}}function pu(t,e){if(t.angle===0)return null;let i;return i=t.a[e]===0?1/t.angle*.5*Math.PI:1/t.angle*Math.atan(t.b[e]/t.a[e]/Math.sin(t.angle)-1/Math.tan(t.angle)),i<0||i>1?null:function(n,s,c,u){const p=Math.sin(c);return n*(Math.sin((1-u)*c)/p)+s*(Math.sin(u*c)/p)}(t.a[e],t.b[e],t.angle,ut(i,0,1))+t.center[e]}function sn(t){if(t.z<=1)return dm[t.z+2*t.y+t.x];const e=fu(Jc(t));return Ui.fromPoints(e)}function ds(t,e,i){return ur(t,t,1-i),Cl(t,t,e,i)}function Od(t,e){const i=la(e.zoom);if(i===0)return sn(t);const n=Jc(t),s=fu(n),c=an(n.getWest())*e.worldSize,u=an(n.getEast())*e.worldSize,p=ln(n.getNorth())*e.worldSize,m=ln(n.getSouth())*e.worldSize,_=[c,p,0],x=[u,p,0],b=[c,m,0],w=[u,m,0],S=nu([],e.globeMatrix);return Jt(_,_,S),Jt(x,x,S),Jt(b,b,S),Jt(w,w,S),s[0]=ds(s[0],b,i),s[1]=ds(s[1],w,i),s[2]=ds(s[2],x,i),s[3]=ds(s[3],_,i),Ui.fromPoints(s)}function Fd(t,e,i){for(const n of t)Jt(n,n,e),ur(n,n,i)}function fm(t,e,i){const n=e/t.worldSize,s=t.globeMatrix;if(i.z<=1){const se=sn(i).getCorners();return Fd(se,s,n),Ui.fromPoints(se)}const c=Jc(i),u=fu(c);Fd(u,s,n);const p=Number.MAX_VALUE,m=[-p,-p,-p],_=[p,p,p];if(c.contains(t.center)){for(const Se of u)Al(_,_,Se),Il(m,m,Se);m[2]=0;const se=t.point,me=[se.x*n,se.y*n,0];return Al(_,_,me),Il(m,m,me),new Ui(_,m)}const x=[s[12]*n,s[13]*n,s[14]*n],b=c.getCenter(),w=ut(t.center.lat,-zi,zi),S=ut(b.lat,-zi,zi),M=an(t.center.lng),C=ln(w);let D=M-an(b.lng);const U=C-ln(S);D>.5?D-=1:D<-.5&&(D+=1);let q=0;Math.abs(D)>Math.abs(U)?q=D>=0?1:3:(q=U>=0?0:2,Cl(x,x,[s[4]*n,s[5]*n,s[6]*n],-Math.sin(ft(U>=0?c.getSouth():c.getNorth()))*on));const V=u[q],$=u[(q+1)%4],X=new pm(V,$,x),W=[pu(X,0)||V[0],pu(X,1)||V[1],pu(X,2)||V[2]],ce=la(t.zoom);if(ce>0){const se=function({x:Se,y:ue,z:ye},xe,we,Ce,pe){const De=1/(1<<ye);let Ne=Se*De,Re=Ne+De,Ke=ue*De,ze=Ke+De,$e=0;const Ye=(Ne+Re)/2-Ce;return Ye>.5?$e=-1:Ye<-.5&&($e=1),Ne=((Ne+$e)*xe-(Ce*=xe))*we+Ce,Re=((Re+$e)*xe-Ce)*we+Ce,Ke=(Ke*xe-(pe*=xe))*we+pe,ze=(ze*xe-pe)*we+pe,[[Ne,ze,0],[Re,ze,0],[Re,Ke,0],[Ne,Ke,0]]}(i,e,t._pixelsPerMercatorPixel,M,C);for(let Se=0;Se<u.length;Se++)ds(u[Se],se[Se],ce);const me=Dn([],se[q],se[(q+1)%4]);ur(me,me,.5),ds(W,me,ce)}for(const se of u)Al(_,_,se),Il(m,m,se);return _[2]=Math.min(V[2],$[2]),Al(_,_,W),Il(m,m,W),new Ui(_,m)}function Jc({x:t,y:e,z:i}){const n=1/(1<<i),s=new zt(dr(t*n),Ci((e+1)*n)),c=new zt(dr((t+1)*n),Ci(e*n));return new go(s,c)}function fu(t){const e=ft(t.getNorth()),i=ft(t.getSouth()),n=Math.cos(e),s=Math.cos(i),c=Math.sin(e),u=Math.sin(i),p=t.getWest(),m=t.getEast();return[sa(s,u,p),sa(s,u,m),sa(n,c,m),sa(n,c,p)]}function sa(t,e,i,n=on){return i=ft(i),[t*Math.sin(i)*n,-e*n,t*Math.cos(i)*n]}function aa(t,e,i){return sa(Math.cos(ft(t)),Math.sin(ft(t)),e,i)}function Dl(t,e,i,n){const s=1<<i.z,c=(t/Ze+i.x)/s;return aa(Ci((e/Ze+i.y)/s),dr(c),n)}function Qc({min:t,max:e}){return um/Math.max(e[0]-t[0],e[1]-t[1],e[2]-t[2])}const Ud=new Float64Array(16);function Ll(t){const e=Qc(t),i=wd(Ud,[e,e,e]);return Sl(i,i,((n=[])[0]=-(s=t.min)[0],n[1]=-s[1],n[2]=-s[2],n));var n,s}function mu(t){const e=(n=t.min,(i=Ud)[0]=1,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=1,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=1,i[11]=0,i[12]=n[0],i[13]=n[1],i[14]=n[2],i[15]=1,i);var i,n;const s=1/Qc(t);return cs(e,e,[s,s,s])}function Vd(t,e,i,n,s){const c=function(m){const _=Ze/(2*Math.PI);return m/(2*Math.PI)/_}(i),u=[t,e,-i/(2*Math.PI)],p=jr(new Float64Array(16));return Sl(p,p,u),cs(p,p,[c,c,c]),ou(p,p,ft(-s)),Kc(p,p,ft(-n)),p}function la(t){return Nn(du,Rd,t)}function Nd(t,e){const i=aa(e.lat,e.lng),n=function(M){const C=aa(M._center.lat,M._center.lng);let D=lu([],oa(0,1,0),C);const U=Td([],-M.angle,C);D=Jt(D,D,U),Td(U,-M._pitch,D);const q=Fi([],C);return ur(q,q,Yc(M.cameraToCenterDistance/M.pixelsPerMeter)),Jt(q,q,U),Dn([],C,q)}(t);return u=(s=au([],n,i))[0],p=s[1],m=s[2],_=(c=i)[0],x=c[1],b=c[2],S=(w=Math.sqrt(u*u+p*p+m*m)*Math.sqrt(_*_+x*x+b*b))&&br(s,c)/w,Math.acos(Math.min(Math.max(S,-1),1));var s,c,u,p,m,_,x,b,w,S}function _u(t,e){return Nd(t,e)>Math.PI/2*1.01}const jd=ft(85),mm=Math.cos(jd),_m=Math.sin(jd),Rl=63710088e-1,Gd=2*Math.PI*Rl;class yo{constructor(e,i){if(isNaN(e)||isNaN(i))throw new Error(`Invalid LngLat object: (${e}, ${i})`);if(this.lng=+e,this.lat=+i,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new yo(di(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const i=Math.PI/180,n=this.lat*i,s=e.lat*i,c=Math.sin(n)*Math.sin(s)+Math.cos(n)*Math.cos(s)*Math.cos((e.lng-this.lng)*i);return Rl*Math.acos(Math.min(c,1))}toBounds(e=0){const i=360*e/40075017,n=i/Math.cos(Math.PI/180*this.lat);return new go(new yo(this.lng-n,this.lat-i),new yo(this.lng+n,this.lat+i))}toEcef(e){const i=Yc(e);return aa(this.lat,this.lng,on+i)}static convert(e){if(e instanceof yo)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new yo(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new yo(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}var zt=yo;function gu(t){return Gd*Math.cos(t*Math.PI/180)}function an(t){return(180+t)/360}function ln(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function $r(t,e){return t/gu(e)}function dr(t){return 360*t-180}function Ci(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function $d(t,e){return t*gu(Ci(e))}const zi=85.051129;function Zd(t){return 1/Math.cos(t*Math.PI/180)}class ca{constructor(e,i,n=0){this.x=+e,this.y=+i,this.z=+n}static fromLngLat(e,i=0){const n=zt.convert(e);return new ca(an(n.lng),ln(n.lat),$r(i,n.lat))}toLngLat(){return new zt(dr(this.x),Ci(this.y))}toAltitude(){return $d(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Gd*Zd(Ci(this.y))}}function yu(t,e,i,n,s,c,u,p,m){const _=(e+n)/2,x=(i+s)/2,b=new Le(_,x);p(b),function(w,S,M,C,D,U){const q=M-D,V=C-U;return Math.abs((C-S)*q-(M-w)*V)/Math.hypot(q,V)}(b.x,b.y,c.x,c.y,u.x,u.y)>=m?(yu(t,e,i,_,x,c,b,p,m),yu(t,_,x,n,s,b,u,p,m)):t.push(u)}function qd(t,e,i){let n=t[0],s=n.x,c=n.y;e(n);const u=[n];for(let p=1;p<t.length;p++){const m=t[p],{x:_,y:x}=m;e(m),yu(u,s,c,_,x,n,m,e,i),s=_,c=x,n=m}return u}function xu(t,e,i,n){if(n(e,i)){const s=e.add(i)._mult(.5);xu(t,e,s,n),xu(t,s,i,n)}else t.push(i)}function gm(t,e){let i=t[0];const n=[i];for(let s=1;s<t.length;s++){const c=t[s];xu(n,i,c,e),i=c}return n}const vu=Math.pow(2,14)-1,Wd=-vu-1;function ym(t,e){const i=Math.round(t.x*e),n=Math.round(t.y*e);return t.x=ut(i,Wd,vu),t.y=ut(n,Wd,vu),(i<t.x||i>t.x+1||n<t.y||n>t.y+1)&&Gt("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function Ln(t,e,i){const n=t.loadGeometry(),s=t.extent,c=Ze/s;if(e&&i&&i.projection.isReprojectedInTileSpace){const u=1<<e.z,{scale:p,x:m,y:_,projection:x}=i,b=w=>{const S=dr((e.x+w.x/s)/u),M=Ci((e.y+w.y/s)/u),C=x.project(S,M);w.x=(C.x*p-m)*s,w.y=(C.y*p-_)*s};for(let w=0;w<n.length;w++)if(t.type!==1)n[w]=qd(n[w],b,1);else{const S=[];for(const M of n[w])M.x<0||M.x>=s||M.y<0||M.y>=s||(b(M),S.push(M));n[w]=S}}for(const u of n)for(const p of u)ym(p,c);return n}function ps(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ln(t):[]}}function eh(t,e,i,n,s){t.emplaceBack(2*e+(n+1)/2,2*i+(s+1)/2)}function th(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class bu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Ee,this.indexArray=new je,this.segments=new ri,this.programConfigurations=new as(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,s){const c=this.layers[0],u=[];let p=null;c.type==="circle"&&(p=c.layout.get("circle-sort-key"));for(const{feature:_,id:x,index:b,sourceLayerIndex:w}of e){const S=this.layers[0]._featureFilter.needGeometry,M=ps(_,S);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),M,n))continue;const C=p?p.evaluate(M,{},n):void 0,D={id:x,properties:_.properties,type:_.type,sourceLayerIndex:w,index:b,geometry:S?M.geometry:Ln(_,n,s),patterns:{},sortKey:C};u.push(D)}p&&u.sort((_,x)=>_.sortKey-x.sortKey);let m=null;s.projection.name==="globe"&&(this.globeExtVertexArray=new Me,m=s.projection);for(const _ of u){const{geometry:x,index:b,sourceLayerIndex:w}=_,S=e[b].feature;this.addFeature(_,x,b,i.availableImages,n,m),i.featureIndex.insert(S,x,b,w,this.index)}}update(e,i,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nm.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,om.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,i,n,s,c,u){for(const p of i)for(const m of p){const _=m.x,x=m.y;if(_<0||_>=Ze||x<0||x>=Ze)continue;if(u){const S=u.projectTilePoint(_,x,c),M=u.upVector(c,_,x),C=this.globeExtVertexArray;th(C,S,M),th(C,S,M),th(C,S,M),th(C,S,M)}const b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),w=b.vertexLength;eh(this.layoutVertexArray,_,x,-1,-1),eh(this.layoutVertexArray,_,x,1,-1),eh(this.layoutVertexArray,_,x,1,1),eh(this.layoutVertexArray,_,x,-1,1),this.indexArray.emplaceBack(w,w+1,w+2),this.indexArray.emplaceBack(w,w+2,w+3),b.vertexLength+=4,b.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},s,c)}}function Xd(t,e){for(let i=0;i<t.length;i++)if(fs(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(fs(t,e[i]))return!0;return!!wu(t,e)}function xm(t,e,i){return!!fs(t,e)||!!Tu(e,t,i)}function Hd(t,e){if(t.length===1)return Yd(e,t[0]);for(let i=0;i<e.length;i++){const n=e[i];for(let s=0;s<n.length;s++)if(fs(t,n[s]))return!0}for(let i=0;i<t.length;i++)if(Yd(e,t[i]))return!0;for(let i=0;i<e.length;i++)if(wu(t,e[i]))return!0;return!1}function vm(t,e,i){if(t.length>1){if(wu(t,e))return!0;for(let n=0;n<e.length;n++)if(Tu(e[n],t,i))return!0}for(let n=0;n<t.length;n++)if(Tu(t[n],e,i))return!0;return!1}function wu(t,e){if(t.length===0||e.length===0)return!1;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];for(let c=0;c<e.length-1;c++)if(bm(n,s,e[c],e[c+1]))return!0}return!1}function bm(t,e,i,n){return Xi(t,i,n)!==Xi(e,i,n)&&Xi(t,e,i)!==Xi(t,e,n)}function Tu(t,e,i){const n=i*i;if(e.length===1)return t.distSqr(e[0])<n;for(let s=1;s<e.length;s++)if(Kd(t,e[s-1],e[s])<n)return!0;return!1}function Kd(t,e,i){const n=e.distSqr(i);if(n===0)return t.distSqr(e);const s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function Yd(t,e){let i,n,s,c=!1;for(let u=0;u<t.length;u++){i=t[u];for(let p=0,m=i.length-1;p<i.length;m=p++)n=i[p],s=i[m],n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(c=!c)}return c}function fs(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const c=t[n],u=t[s];c.y>e.y!=u.y>e.y&&e.x<(u.x-c.x)*(e.y-c.y)/(u.y-c.y)+c.x&&(i=!i)}return i}function Jd(t,e,i,n,s){for(const u of t)if(e<=u.x&&i<=u.y&&n>=u.x&&s>=u.y)return!0;const c=[new Le(e,i),new Le(e,s),new Le(n,s),new Le(n,i)];if(t.length>2){for(const u of c)if(fs(t,u))return!0}for(let u=0;u<t.length-1;u++)if(wm(t[u],t[u+1],c))return!0;return!1}function wm(t,e,i){const n=i[0],s=i[2];if(t.x<n.x&&e.x<n.x||t.x>s.x&&e.x>s.x||t.y<n.y&&e.y<n.y||t.y>s.y&&e.y>s.y)return!1;const c=Xi(t,e,i[0]);return c!==Xi(t,e,i[1])||c!==Xi(t,e,i[2])||c!==Xi(t,e,i[3])}function ha(t,e,i){const n=e.paint.get(t).value;return n.kind==="constant"?n.value:i.programConfigurations.get(e.id).getMaxValue(t)}function ih(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Qd(t,e,i,n,s){if(!e[0]&&!e[1])return t;const c=Le.convert(e)._mult(s);i==="viewport"&&c._rotate(-n);const u=[];for(let p=0;p<t.length;p++)u.push(t[p].sub(c));return u}function ep(t,e,i,n){const s=Le.convert(t)._mult(n);return e==="viewport"&&s._rotate(-i),s}Ue(bu,"CircleBucket",{omit:["layers"]});const Tm=new j({"circle-sort-key":new L(fe.layout_circle["circle-sort-key"])});var Em={paint:new j({"circle-radius":new L(fe.paint_circle["circle-radius"]),"circle-color":new L(fe.paint_circle["circle-color"]),"circle-blur":new L(fe.paint_circle["circle-blur"]),"circle-opacity":new L(fe.paint_circle["circle-opacity"]),"circle-translate":new I(fe.paint_circle["circle-translate"]),"circle-translate-anchor":new I(fe.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new I(fe.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new I(fe.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new L(fe.paint_circle["circle-stroke-width"]),"circle-stroke-color":new L(fe.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new L(fe.paint_circle["circle-stroke-opacity"])}),layout:Tm};function tp(t,e,i,n,s,c,u,p,m){if(c&&t.queryGeometry.isAboveHorizon)return!1;c&&(m*=t.pixelToTileUnitsFactor);const _=t.tileID.canonical,x=i.projection.upVectorScale(_,i.center.lat,i.worldSize).metersToTile;for(const b of e)for(const w of b){const S=w.add(p),M=s&&i.elevation?i.elevation.exaggeration()*s.getElevationAt(S.x,S.y,!0):0,C=i.projection.projectTilePoint(S.x,S.y,_);if(M>0){const V=i.projection.upVector(_,S.x,S.y);C.x+=V[0]*x*M,C.y+=V[1]*x*M,C.z+=V[2]*x*M}const D=c?S:Sm(C.x,C.y,C.z,n),U=c?t.tilespaceRays.map(V=>Am(V,M)):t.queryGeometry.screenGeometry,q=hs([],[C.x,C.y,C.z,1],n);if(!u&&c?m*=q[3]/i.cameraToCenterDistance:u&&!c&&(m*=i.cameraToCenterDistance/q[3]),c){const V=Ci((w.y/Ze+_.y)/(1<<_.z));m/=i.projection.pixelsPerMeter(V,1)/$r(1,V)}if(xm(U,D,m))return!0}return!1}function Sm(t,e,i,n){const s=hs([],[t,e,i,1],n);return new Le(s[0]/s[3],s[1]/s[3])}const ip=oa(0,0,0),Mm=oa(0,0,1);function Am(t,e){const i=su();return ip[2]=e,t.intersectsPlane(ip,Mm,i),new Le(i[0],i[1])}class rp extends bu{}function np(t,{width:e,height:i},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*n)throw new RangeError("mismatched image size")}else s=new Uint8Array(e*i*n);return t.width=e,t.height=i,t.data=s,t}function op(t,e,i){const{width:n,height:s}=e;n===t.width&&s===t.height||(Eu(t,e,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,s)},i),t.width=n,t.height=s,t.data=e.data)}function Eu(t,e,i,n,s,c){if(s.width===0||s.height===0)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||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const u=t.data,p=e.data;for(let m=0;m<s.height;m++){const _=((i.y+m)*t.width+i.x)*c,x=((n.y+m)*e.width+n.x)*c;for(let b=0;b<s.width*c;b++)p[x+b]=u[_+b]}return e}Ue(rp,"HeatmapBucket",{omit:["layers"]});class Rn{constructor(e,i){np(this,e,1,i)}resize(e){op(this,new Rn(e),1)}clone(){return new Rn({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,s,c){Eu(e,i,n,s,c,1)}}class ir{constructor(e,i){np(this,e,4,i)}resize(e){op(this,new ir(e),4)}replace(e,i){i?this.data.set(e):this.data=e instanceof Uint8ClampedArray?new Uint8Array(e.buffer):e}clone(){return new ir({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,i,n,s,c){Eu(e,i,n,s,c,4)}}Ue(Rn,"AlphaImage"),Ue(ir,"RGBAImage");var Im={paint:new j({"heatmap-radius":new L(fe.paint_heatmap["heatmap-radius"]),"heatmap-weight":new L(fe.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new I(fe.paint_heatmap["heatmap-intensity"]),"heatmap-color":new N(fe.paint_heatmap["heatmap-color"]),"heatmap-opacity":new I(fe.paint_heatmap["heatmap-opacity"])})};function Su(t){const e={},i=t.resolution||256,n=t.clips?t.clips.length:1,s=t.image||new ir({width:i,height:n}),c=(u,p,m)=>{e[t.evaluationKey]=m;const _=t.expression.evaluate(e);s.data[u+p+0]=Math.floor(255*_.r/_.a),s.data[u+p+1]=Math.floor(255*_.g/_.a),s.data[u+p+2]=Math.floor(255*_.b/_.a),s.data[u+p+3]=Math.floor(255*_.a)};if(t.clips)for(let u=0,p=0;u<n;++u,p+=4*i)for(let m=0,_=0;m<i;m++,_+=4){const x=m/(i-1),{start:b,end:w}=t.clips[u];c(p,_,b*(1-x)+w*x)}else for(let u=0,p=0;u<i;u++,p+=4)c(0,p,u/(i-1));return s}var Cm={paint:new j({"hillshade-illumination-direction":new I(fe.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new I(fe.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new I(fe.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new I(fe.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new I(fe.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new I(fe.paint_hillshade["hillshade-accent-color"])})};const zm=te([{name:"a_pos",components:2,type:"Int16"}],4),{members:Pm}=zm;var Mu={exports:{}};function rh(t,e,i){i=i||2;var n,s,c,u,p,m,_,x=e&&e.length,b=x?e[0]*i:t.length,w=sp(t,0,b,i,!0),S=[];if(!w||w.next===w.prev)return S;if(x&&(w=function(C,D,U,q){var V,$,X,W=[];for(V=0,$=D.length;V<$;V++)(X=sp(C,D[V]*q,V<$-1?D[V+1]*q:C.length,q,!1))===X.next&&(X.steiner=!0),W.push(Um(X));for(W.sort(Bm),V=0;V<W.length;V++)U=Om(W[V],U);return U}(t,e,w,i)),t.length>80*i){n=c=t[0],s=u=t[1];for(var M=i;M<b;M+=i)(p=t[M])<n&&(n=p),(m=t[M+1])<s&&(s=m),p>c&&(c=p),m>u&&(u=m);_=(_=Math.max(c-n,u-s))!==0?32767/_:0}return Bl(w,S,i,n,s,_,0),S}function sp(t,e,i,n,s){var c,u;if(s===Cu(t,e,i,n)>0)for(c=e;c<i;c+=n)u=cp(c,t[c],t[c+1],u);else for(c=i-n;c>=e;c-=n)u=cp(c,t[c],t[c+1],u);return u&&nh(u,u.next)&&(Fl(u),u=u.next),u}function ms(t,e){if(!t)return t;e||(e=t);var i,n=t;do if(i=!1,n.steiner||!nh(n,n.next)&&ni(n.prev,n,n.next)!==0)n=n.next;else{if(Fl(n),(n=e=n.prev)===n.next)break;i=!0}while(i||n!==e);return e}function Bl(t,e,i,n,s,c,u){if(t){!u&&c&&function(x,b,w,S){var M=x;do M.z===0&&(M.z=Au(M.x,M.y,b,w,S)),M.prevZ=M.prev,M.nextZ=M.next,M=M.next;while(M!==x);M.prevZ.nextZ=null,M.prevZ=null,function(C){var D,U,q,V,$,X,W,ce,se=1;do{for(U=C,C=null,$=null,X=0;U;){for(X++,q=U,W=0,D=0;D<se&&(W++,q=q.nextZ);D++);for(ce=se;W>0||ce>0&&q;)W!==0&&(ce===0||!q||U.z<=q.z)?(V=U,U=U.nextZ,W--):(V=q,q=q.nextZ,ce--),$?$.nextZ=V:C=V,V.prevZ=$,$=V;U=q}$.nextZ=null,se*=2}while(X>1)}(M)}(t,n,s,c);for(var p,m,_=t;t.prev!==t.next;)if(p=t.prev,m=t.next,c?Dm(t,n,s,c):km(t))e.push(p.i/i|0),e.push(t.i/i|0),e.push(m.i/i|0),Fl(t),t=m.next,_=m.next;else if((t=m)===_){u?u===1?Bl(t=Lm(ms(t),e,i),e,i,n,s,c,2):u===2&&Rm(t,e,i,n,s,c):Bl(ms(t),e,i,n,s,c,1);break}}}function km(t){var e=t.prev,i=t,n=t.next;if(ni(e,i,n)>=0)return!1;for(var s=e.x,c=i.x,u=n.x,p=e.y,m=i.y,_=n.y,x=s<c?s<u?s:u:c<u?c:u,b=p<m?p<_?p:_:m<_?m:_,w=s>c?s>u?s:u:c>u?c:u,S=p>m?p>_?p:_:m>_?m:_,M=n.next;M!==e;){if(M.x>=x&&M.x<=w&&M.y>=b&&M.y<=S&&ua(s,p,c,m,u,_,M.x,M.y)&&ni(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function Dm(t,e,i,n){var s=t.prev,c=t,u=t.next;if(ni(s,c,u)>=0)return!1;for(var p=s.x,m=c.x,_=u.x,x=s.y,b=c.y,w=u.y,S=p<m?p<_?p:_:m<_?m:_,M=x<b?x<w?x:w:b<w?b:w,C=p>m?p>_?p:_:m>_?m:_,D=x>b?x>w?x:w:b>w?b:w,U=Au(S,M,e,i,n),q=Au(C,D,e,i,n),V=t.prevZ,$=t.nextZ;V&&V.z>=U&&$&&$.z<=q;){if(V.x>=S&&V.x<=C&&V.y>=M&&V.y<=D&&V!==s&&V!==u&&ua(p,x,m,b,_,w,V.x,V.y)&&ni(V.prev,V,V.next)>=0||(V=V.prevZ,$.x>=S&&$.x<=C&&$.y>=M&&$.y<=D&&$!==s&&$!==u&&ua(p,x,m,b,_,w,$.x,$.y)&&ni($.prev,$,$.next)>=0))return!1;$=$.nextZ}for(;V&&V.z>=U;){if(V.x>=S&&V.x<=C&&V.y>=M&&V.y<=D&&V!==s&&V!==u&&ua(p,x,m,b,_,w,V.x,V.y)&&ni(V.prev,V,V.next)>=0)return!1;V=V.prevZ}for(;$&&$.z<=q;){if($.x>=S&&$.x<=C&&$.y>=M&&$.y<=D&&$!==s&&$!==u&&ua(p,x,m,b,_,w,$.x,$.y)&&ni($.prev,$,$.next)>=0)return!1;$=$.nextZ}return!0}function Lm(t,e,i){var n=t;do{var s=n.prev,c=n.next.next;!nh(s,c)&&ap(s,n,n.next,c)&&Ol(s,c)&&Ol(c,s)&&(e.push(s.i/i|0),e.push(n.i/i|0),e.push(c.i/i|0),Fl(n),Fl(n.next),n=t=c),n=n.next}while(n!==t);return ms(n)}function Rm(t,e,i,n,s,c){var u=t;do{for(var p=u.next.next;p!==u.prev;){if(u.i!==p.i&&Vm(u,p)){var m=lp(u,p);return u=ms(u,u.next),m=ms(m,m.next),Bl(u,e,i,n,s,c,0),void Bl(m,e,i,n,s,c,0)}p=p.next}u=u.next}while(u!==t)}function Bm(t,e){return t.x-e.x}function Om(t,e){var i=function(s,c){var u,p=c,m=s.x,_=s.y,x=-1/0;do{if(_<=p.y&&_>=p.next.y&&p.next.y!==p.y){var b=p.x+(_-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(b<=m&&b>x&&(x=b,u=p.x<p.next.x?p:p.next,b===m))return u}p=p.next}while(p!==c);if(!u)return null;var w,S=u,M=u.x,C=u.y,D=1/0;p=u;do m>=p.x&&p.x>=M&&m!==p.x&&ua(_<C?m:x,_,M,C,_<C?x:m,_,p.x,p.y)&&(w=Math.abs(_-p.y)/(m-p.x),Ol(p,s)&&(w<D||w===D&&(p.x>u.x||p.x===u.x&&Fm(u,p)))&&(u=p,D=w)),p=p.next;while(p!==S);return u}(t,e);if(!i)return e;var n=lp(i,t);return ms(n,n.next),ms(i,i.next)}function Fm(t,e){return ni(t.prev,t,e.prev)<0&&ni(e.next,t,t.next)<0}function Au(t,e,i,n,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-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Um(t){var e=t,i=t;do(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next;while(e!==t);return i}function ua(t,e,i,n,s,c,u,p){return(s-u)*(e-p)>=(t-u)*(c-p)&&(t-u)*(n-p)>=(i-u)*(e-p)&&(i-u)*(c-p)>=(s-u)*(n-p)}function Vm(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(i,n){var s=i;do{if(s.i!==i.i&&s.next.i!==i.i&&s.i!==n.i&&s.next.i!==n.i&&ap(s,s.next,i,n))return!0;s=s.next}while(s!==i);return!1}(t,e)&&(Ol(t,e)&&Ol(e,t)&&function(i,n){var s=i,c=!1,u=(i.x+n.x)/2,p=(i.y+n.y)/2;do s.y>p!=s.next.y>p&&s.next.y!==s.y&&u<(s.next.x-s.x)*(p-s.y)/(s.next.y-s.y)+s.x&&(c=!c),s=s.next;while(s!==i);return c}(t,e)&&(ni(t.prev,t,e.prev)||ni(t,e.prev,e))||nh(t,e)&&ni(t.prev,t,t.next)>0&&ni(e.prev,e,e.next)>0)}function ni(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function nh(t,e){return t.x===e.x&&t.y===e.y}function ap(t,e,i,n){var s=sh(ni(t,e,i)),c=sh(ni(t,e,n)),u=sh(ni(i,n,t)),p=sh(ni(i,n,e));return s!==c&&u!==p||!(s!==0||!oh(t,i,e))||!(c!==0||!oh(t,n,e))||!(u!==0||!oh(i,t,n))||!(p!==0||!oh(i,e,n))}function oh(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 sh(t){return t>0?1:t<0?-1:0}function Ol(t,e){return ni(t.prev,t,t.next)<0?ni(t,e,t.next)>=0&&ni(t,t.prev,e)>=0:ni(t,e,t.prev)<0||ni(t,t.next,e)<0}function lp(t,e){var i=new Iu(t.i,t.x,t.y),n=new Iu(e.i,e.x,e.y),s=t.next,c=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,c.next=n,n.prev=c,n}function cp(t,e,i,n){var s=new Iu(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Fl(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 Iu(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 Cu(t,e,i,n){for(var s=0,c=e,u=i-n;c<i;c+=n)s+=(t[u]-t[c])*(t[c+1]+t[u+1]),u=c;return s}Mu.exports=rh,Mu.exports.default=rh,rh.deviation=function(t,e,i,n){var s=e&&e.length,c=Math.abs(Cu(t,0,s?e[0]*i:t.length,i));if(s)for(var u=0,p=e.length;u<p;u++)c-=Math.abs(Cu(t,e[u]*i,u<p-1?e[u+1]*i:t.length,i));var m=0;for(u=0;u<n.length;u+=3){var _=n[u]*i,x=n[u+1]*i,b=n[u+2]*i;m+=Math.abs((t[_]-t[b])*(t[x+1]-t[_+1])-(t[_]-t[x])*(t[b+1]-t[_+1]))}return c===0&&m===0?0:Math.abs((m-c)/c)},rh.flatten=function(t){for(var e=t[0][0].length,i={vertices:[],holes:[],dimensions:e},n=0,s=0;s<t.length;s++){for(var c=0;c<t[s].length;c++)for(var u=0;u<e;u++)i.vertices.push(t[s][c][u]);s>0&&i.holes.push(n+=t[s-1].length)}return i};var zu=or(Mu.exports);function Nm(t,e,i,n,s){hp(t,e,i||0,n||t.length-1,s||jm)}function hp(t,e,i,n,s){for(;n>i;){if(n-i>600){var c=n-i+1,u=e-i+1,p=Math.log(c),m=.5*Math.exp(2*p/3),_=.5*Math.sqrt(p*m*(c-m)/c)*(u-c/2<0?-1:1);hp(t,e,Math.max(i,Math.floor(e-u*m/c+_)),Math.min(n,Math.floor(e+(c-u)*m/c+_)),s)}var x=t[e],b=i,w=n;for(Ul(t,i,e),s(t[n],x)>0&&Ul(t,i,n);b<w;){for(Ul(t,b,w),b++,w--;s(t[b],x)<0;)b++;for(;s(t[w],x)>0;)w--}s(t[i],x)===0?Ul(t,i,w):Ul(t,++w,n),w<=e&&(i=w+1),e<=w&&(n=w-1)}}function Ul(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function jm(t,e){return t<e?-1:t>e?1:0}function Pu(t,e){const i=t.length;if(i<=1)return[t];const n=[];let s,c;for(let u=0;u<i;u++){const p=Es(t[u]);p!==0&&(t[u].area=Math.abs(p),c===void 0&&(c=p<0),c===p<0?(s&&n.push(s),s=[t[u]]):s.push(t[u]))}if(s&&n.push(s),e>1)for(let u=0;u<n.length;u++)n[u].length<=e||(Nm(n[u],e,1,n[u].length-1,Gm),n[u]=n[u].slice(0,e));return n}function Gm(t,e){return e.area-t.area}function ku(t,e,i){const n=i.patternDependencies;let s=!1;for(const c of e){const u=c.paint.get(`${t}-pattern`);u.isConstant()||(s=!0);const p=u.constantOr(null);p&&(s=!0,n[p]=!0)}return s}function Du(t,e,i,n,s){const c=s.patternDependencies;for(const u of e){const p=u.paint.get(`${t}-pattern`).value;if(p.kind!=="constant"){let m=p.evaluate({zoom:n},i,{},s.availableImages);m=m&&m.name?m.name:m,c[m]=!0,i.patterns[u.id]=m}}return i}class ah{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ee,this.indexArray=new je,this.indexArray2=new xi,this.programConfigurations=new as(e.layers,e.zoom),this.segments=new ri,this.segments2=new ri,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.projection=e.projection}populate(e,i,n,s){this.hasPattern=ku("fill",this.layers,i);const c=this.layers[0].layout.get("fill-sort-key"),u=[];for(const{feature:p,id:m,index:_,sourceLayerIndex:x}of e){const b=this.layers[0]._featureFilter.needGeometry,w=ps(p,b);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),w,n))continue;const S=c?c.evaluate(w,{},n,i.availableImages):void 0,M={id:m,properties:p.properties,type:p.type,sourceLayerIndex:x,index:_,geometry:b?w.geometry:Ln(p,n,s),patterns:{},sortKey:S};u.push(M)}c&&u.sort((p,m)=>p.sortKey-m.sortKey);for(const p of u){const{geometry:m,index:_,sourceLayerIndex:x}=p;if(this.hasPattern){const b=Du("fill",this.layers,p,this.zoom,i);this.patternFeatures.push(b)}else this.addFeature(p,m,_,n,{},i.availableImages);i.featureIndex.insert(e[_].feature,m,_,x,this.index)}}update(e,i,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,s)}addFeatures(e,i,n,s,c){for(const u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,i,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Pm),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,i,n,s,c,u=[]){for(const p of Pu(i,500)){let m=0;for(const M of p)m+=M.length;const _=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),x=_.vertexLength,b=[],w=[];for(const M of p){if(M.length===0)continue;M!==p[0]&&w.push(b.length/2);const C=this.segments2.prepareSegment(M.length,this.layoutVertexArray,this.indexArray2),D=C.vertexLength;this.layoutVertexArray.emplaceBack(M[0].x,M[0].y),this.indexArray2.emplaceBack(D+M.length-1,D),b.push(M[0].x),b.push(M[0].y);for(let U=1;U<M.length;U++)this.layoutVertexArray.emplaceBack(M[U].x,M[U].y),this.indexArray2.emplaceBack(D+U-1,D+U),b.push(M[U].x),b.push(M[U].y);C.vertexLength+=M.length,C.primitiveLength+=M.length}const S=zu(b,w);for(let M=0;M<S.length;M+=3)this.indexArray.emplaceBack(x+S[M],x+S[M+1],x+S[M+2]);_.vertexLength+=m,_.primitiveLength+=S.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}}Ue(ah,"FillBucket",{omit:["layers","patternFeatures"]});const $m=new j({"fill-sort-key":new L(fe.layout_fill["fill-sort-key"])});var Zm={paint:new j({"fill-antialias":new I(fe.paint_fill["fill-antialias"]),"fill-opacity":new L(fe.paint_fill["fill-opacity"]),"fill-color":new L(fe.paint_fill["fill-color"]),"fill-outline-color":new L(fe.paint_fill["fill-outline-color"]),"fill-translate":new I(fe.paint_fill["fill-translate"]),"fill-translate-anchor":new I(fe.paint_fill["fill-translate-anchor"]),"fill-pattern":new L(fe.paint_fill["fill-pattern"])}),layout:$m};const qm=te([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),Wm=te([{name:"a_centroid_pos",components:2,type:"Uint16"}]),Xm=te([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:Hm}=qm;var lh={},Km=fn,up=da;function da(t,e,i,n,s){this.properties={},this.extent=i,this.type=0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=s,t.readFields(Ym,this,e)}function Ym(t,e,i){t==1?e.id=i.readVarint():t==2?function(n,s){for(var c=n.readVarint()+n.pos;n.pos<c;){var u=s._keys[n.readVarint()],p=s._values[n.readVarint()];s.properties[u]=p}}(i,e):t==3?e.type=i.readVarint():t==4&&(e._geometry=i.pos)}function Jm(t){for(var e,i,n=0,s=0,c=t.length,u=c-1;s<c;u=s++)n+=((i=t[u]).x-(e=t[s]).x)*(e.y+i.y);return n}da.types=["Unknown","Point","LineString","Polygon"],da.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,i=t.readVarint()+t.pos,n=1,s=0,c=0,u=0,p=[];t.pos<i;){if(s<=0){var m=t.readVarint();n=7&m,s=m>>3}if(s--,n===1||n===2)c+=t.readSVarint(),u+=t.readSVarint(),n===1&&(e&&p.push(e),e=[]),e.push(new Km(c,u));else{if(n!==7)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&p.push(e),p},da.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,s=0,c=0,u=1/0,p=-1/0,m=1/0,_=-1/0;t.pos<e;){if(n<=0){var x=t.readVarint();i=7&x,n=x>>3}if(n--,i===1||i===2)(s+=t.readSVarint())<u&&(u=s),s>p&&(p=s),(c+=t.readSVarint())<m&&(m=c),c>_&&(_=c);else if(i!==7)throw new Error("unknown command "+i)}return[u,m,p,_]},da.prototype.toGeoJSON=function(t,e,i){var n,s,c=this.extent*Math.pow(2,i),u=this.extent*t,p=this.extent*e,m=this.loadGeometry(),_=da.types[this.type];function x(S){for(var M=0;M<S.length;M++){var C=S[M];S[M]=[360*(C.x+u)/c-180,360/Math.PI*Math.atan(Math.exp((180-360*(C.y+p)/c)*Math.PI/180))-90]}}switch(this.type){case 1:var b=[];for(n=0;n<m.length;n++)b[n]=m[n][0];x(m=b);break;case 2:for(n=0;n<m.length;n++)x(m[n]);break;case 3:for(m=function(S){var M=S.length;if(M<=1)return[S];for(var C,D,U=[],q=0;q<M;q++){var V=Jm(S[q]);V!==0&&(D===void 0&&(D=V<0),D===V<0?(C&&U.push(C),C=[S[q]]):C.push(S[q]))}return C&&U.push(C),U}(m),n=0;n<m.length;n++)for(s=0;s<m[n].length;s++)x(m[n][s])}m.length===1?m=m[0]:_="Multi"+_;var w={type:"Feature",geometry:{type:_,coordinates:m},properties:this.properties};return"id"in this&&(w.id=this.id),w};var Qm=up,dp=pp;function pp(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(e_,this,e),this.length=this._features.length}function e_(t,e,i){t===15?e.version=i.readVarint():t===1?e.name=i.readString():t===5?e.extent=i.readVarint():t===2?e._features.push(i.pos):t===3?e._keys.push(i.readString()):t===4&&e._values.push(function(n){for(var s=null,c=n.readVarint()+n.pos;n.pos<c;){var u=n.readVarint()>>3;s=u===1?n.readString():u===2?n.readFloat():u===3?n.readDouble():u===4?n.readVarint64():u===5?n.readVarint():u===6?n.readSVarint():u===7?n.readBoolean():null}return s}(i))}pp.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 Qm(this._pbf,e,this.extent,this._keys,this._values)};var t_=dp;function i_(t,e,i){if(t===3){var n=new t_(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var Lu=lh.VectorTile=function(t,e){this.layers=t.readFields(i_,{},e)},ch=lh.VectorTileFeature=up;function hh(t,e,i,n){const s=[],c=n===0?(u,p,m,_,x,b)=>{u.push(new Le(b,m+(b-p)/(_-p)*(x-m)))}:(u,p,m,_,x,b)=>{u.push(new Le(p+(b-m)/(x-m)*(_-p),b))};for(const u of t){const p=[];for(const m of u){if(m.length<=2)continue;const _=[];for(let w=0;w<m.length-1;w++){const S=m[w].x,M=m[w].y,C=m[w+1].x,D=m[w+1].y,U=n===0?S:M,q=n===0?C:D;U<e?q>e&&c(_,S,M,C,D,e):U>i?q<i&&c(_,S,M,C,D,i):_.push(m[w]),q<e&&U>=e&&c(_,S,M,C,D,e),q>i&&U<=i&&c(_,S,M,C,D,i)}let x=m[m.length-1];const b=n===0?x.x:x.y;b>=e&&b<=i&&_.push(x),_.length&&(x=_[_.length-1],_[0].x===x.x&&_[0].y===x.y||_.push(_[0]),p.push(_))}p.length&&s.push(p)}return s}lh.VectorTileLayer=dp;const r_=ch.types,n_=Math.pow(2,13);function Vl(t,e,i,n,s,c,u,p){t.emplaceBack((e<<1)+u,(i<<1)+c,(Math.floor(n*n_)<<1)+s,Math.round(p))}function Nl(t,e,i){t.emplaceBack(e.x,e.y,e.z,i[0]*16384,i[1]*16384,i[2]*16384)}class fp{constructor(){this.acc=new Le(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new Le(e.x,e.y),this.max=new Le(e.x,e.y))}append(e,i){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,s=this.max;e.x<n.x?n.x=e.x:e.x>s.x&&(s.x=e.x),e.y<n.y?n.y=e.y:e.y>s.y&&(s.y=e.y),((e.x===0||e.x===Ze)&&e.x===i.x)!=((e.y===0||e.y===Ze)&&e.y===i.y)&&this.processBorderOverlap(e,i),i.x<0!=e.x<0&&this.addBorderIntersection(0,gt(i.y,e.y,(0-i.x)/(e.x-i.x))),i.x>Ze!=e.x>Ze&&this.addBorderIntersection(1,gt(i.y,e.y,(Ze-i.x)/(e.x-i.x))),i.y<0!=e.y<0&&this.addBorderIntersection(2,gt(i.x,e.x,(0-i.y)/(e.y-i.y))),i.y>Ze!=e.y>Ze&&this.addBorderIntersection(3,gt(i.x,e.x,(Ze-i.y)/(e.y-i.y)))}addBorderIntersection(e,i){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const n=this.borders[e];i<n[0]&&(n[0]=i),i>n[1]&&(n[1]=i)}processBorderOverlap(e,i){if(e.x===i.x){if(e.y===i.y)return;const n=e.x===0?0:1;this.addBorderIntersection(n,i.y),this.addBorderIntersection(n,e.y)}else{const n=e.y===0?2:3;this.addBorderIntersection(n,i.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((i,n)=>i+n.edges,0);return e!==0?this.acc.div(e)._round():new Le(0,0)}span(){return new Le(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,i)=>e+ +(i[0]!==Number.MAX_VALUE),0)}}class jl{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new ge,this.centroidVertexArray=new Ur,this.indexArray=new je,this.programConfigurations=new as(e.layers,e.zoom),this.segments=new ri,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id),this.enableTerrain=e.enableTerrain}populate(e,i,n,s){this.features=[],this.hasPattern=ku("fill-extrusion",this.layers,i),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(c){const u=Math.exp(Math.PI*(1-c.y/(1<<c.z)*2));return 80150034*u/(u*u+1)/Ze/(1<<c.z)}(n),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:c,id:u,index:p,sourceLayerIndex:m}of e){const _=this.layers[0]._featureFilter.needGeometry,x=ps(c,_);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),x,n))continue;const b={id:u,sourceLayerIndex:m,index:p,geometry:_?x.geometry:Ln(c,n,s),properties:c.properties,type:c.type,patterns:{}},w=this.layoutVertexArray.length;this.hasPattern?this.features.push(Du("fill-extrusion",this.layers,b,this.zoom,i)):this.addFeature(b,b.geometry,p,n,{},i.availableImages,s),i.featureIndex.insert(c,b.geometry,p,m,this.index,w)}this.sortBorders()}addFeatures(e,i,n,s,c){for(const u of this.features){const{geometry:p}=u;this.addFeature(u,p,u.index,i,n,s,c)}this.sortBorders()}update(e,i,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Hm),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Xm.members,!0))),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,Wm.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,i,n,s,c,u,p){const m=[new Le(0,0),new Le(Ze,Ze)],_=p.projection,x=_.name==="globe",b=this.enableTerrain&&!x?new fp:null,w=r_[e.type]==="Polygon";x&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Me);const S=Pu(i,500);for(let U=S.length-1;U>=0;U--){const q=S[U];(q.length===0||(M=q[0]).every(V=>V.x<=0)||M.every(V=>V.x>=Ze)||M.every(V=>V.y<=0)||M.every(V=>V.y>=Ze))&&S.splice(U,1)}var M;let C;if(x)C=bp(S,m,s);else{C=[];for(const U of S)C.push({polygon:U,bounds:m})}const D=w?this.edgeRadius:0;for(const{polygon:U,bounds:q}of C){let V=0,$=0;for(const W of U)w&&!W[0].equals(W[W.length-1])&&W.push(W[0]),$+=w?W.length-1:W.length;const X=this.segments.prepareSegment((w?5:4)*$,this.layoutVertexArray,this.indexArray);if(w){const W=[],ce=[];V=X.vertexLength;for(const me of U){let Se,ue;me.length&&me!==U[0]&&ce.push(W.length/2),Se=me[1].sub(me[0])._perp()._unit();for(let ye=1;ye<me.length;ye++){const xe=me[ye],we=me[ye===me.length-1?1:ye+1];let{x:Ce,y:pe}=xe;if(D){ue=we.sub(xe)._perp()._unit();const De=Se.add(ue)._unit(),Ne=D*Math.min(4,1/(Se.x*De.x+Se.y*De.y));Ce+=Ne*De.x,pe+=Ne*De.y,Se=ue}Vl(this.layoutVertexArray,Ce,pe,0,0,1,1,0),X.vertexLength++,W.push(xe.x,xe.y),x&&Nl(this.layoutVertexExtArray,_.projectTilePoint(Ce,pe,s),_.upVector(s,Ce,pe))}}const se=zu(W,ce);for(let me=0;me<se.length;me+=3)this.indexArray.emplaceBack(V+se[me],V+se[me+2],V+se[me+1]),X.primitiveLength++}for(const W of U){b&&W.length&&b.startRing(W[0]);let ce,se,me,Se=W.length>4&&yp(W[W.length-2],W[0],W[1]),ue=D?o_(W[W.length-2],W[0],W[1],D):0;se=W[1].sub(W[0])._perp()._unit();let ye=!0;for(let xe=1,we=0;xe<W.length;xe++){let Ce=W[xe-1],pe=W[xe];const De=W[xe===W.length-1?1:xe+1];if(b&&w&&b.currentPolyCount.top++,gp(pe,Ce,q)){D&&(se=De.sub(pe)._perp()._unit(),ye=!ye);continue}b&&b.append(pe,Ce);const Ne=pe.sub(Ce)._perp(),Re=Ne.x/(Math.abs(Ne.x)+Math.abs(Ne.y)),Ke=Ne.y>0?1:0,ze=Ce.dist(pe);if(we+ze>32768&&(we=0),D){me=De.sub(pe)._perp()._unit();let Je=_p(Ce,pe,De,mp(se,me),D);isNaN(Je)&&(Je=0);const We=pe.sub(Ce)._unit();Ce=Ce.add(We.mult(ue))._round(),pe=pe.add(We.mult(-Je))._round(),ue=Je,se=me}const $e=X.vertexLength,Ye=W.length>4&&yp(Ce,pe,De);let xt=xp(we,Se,ye);if(Vl(this.layoutVertexArray,Ce.x,Ce.y,Re,Ke,0,0,xt),Vl(this.layoutVertexArray,Ce.x,Ce.y,Re,Ke,0,1,xt),we+=ze,xt=xp(we,Ye,!ye),Se=Ye,Vl(this.layoutVertexArray,pe.x,pe.y,Re,Ke,0,0,xt),Vl(this.layoutVertexArray,pe.x,pe.y,Re,Ke,0,1,xt),X.vertexLength+=4,this.indexArray.emplaceBack($e+0,$e+1,$e+2),this.indexArray.emplaceBack($e+1,$e+3,$e+2),X.primitiveLength+=2,D){const Je=V+(xe===1?W.length-2:xe-2),We=xe===1?V:Je+1;if(this.indexArray.emplaceBack($e+1,Je,$e+3),this.indexArray.emplaceBack(Je,We,$e+3),X.primitiveLength+=2,ce===void 0&&(ce=$e),!gp(De,W[xe],q)){const Ft=xe===W.length-1?ce:X.vertexLength;this.indexArray.emplaceBack($e+2,$e+3,Ft),this.indexArray.emplaceBack($e+3,Ft+1,Ft),this.indexArray.emplaceBack($e+3,We,Ft+1),X.primitiveLength+=3}ye=!ye}if(x){const Je=this.layoutVertexExtArray,We=_.projectTilePoint(Ce.x,Ce.y,s),Ft=_.projectTilePoint(pe.x,pe.y,s),tt=_.upVector(s,Ce.x,Ce.y),it=_.upVector(s,pe.x,pe.y);Nl(Je,We,tt),Nl(Je,We,tt),Nl(Je,Ft,it),Nl(Je,Ft,it)}}w&&(V+=W.length-1)}}if(b&&b.polyCount.length>0){if(b.borders){b.vertexArrayOffset=this.centroidVertexArray.length;const U=b.borders,q=this.featuresOnBorder.push(b)-1;for(let V=0;V<4;V++)U[V][0]!==Number.MAX_VALUE&&this.borders[V].push(q)}this.encodeCentroid(b.borders?void 0:b.centroid(),b)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((i,n)=>this.featuresOnBorder[i].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,i,n=!0){let s,c;if(e)if(e.y!==0){const p=i.span()._mult(this.tileToMeter);s=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(p.x/10)),c=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(p.y/10))}else s=Math.ceil(7*(e.x+450)),c=0;else s=0,c=+n;let u=n?this.centroidVertexArray.length:i.vertexArrayOffset;for(const p of i.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*p.edges+p.top);for(let m=0;m<p.top;m++)this.centroidVertexArray.emplace(u++,s,c);for(let m=0;m<2*p.edges;m++)this.centroidVertexArray.emplace(u++,0,c),this.centroidVertexArray.emplace(u++,s,c)}}}function mp(t,e){const i=t.add(e)._unit();return t.x*i.x+t.y*i.y}function o_(t,e,i,n){const s=e.sub(t)._perp()._unit(),c=i.sub(e)._perp()._unit();return _p(t,e,i,mp(s,c),n)}function _p(t,e,i,n,s){const c=Math.sqrt(1-n*n);return Math.min(t.dist(e)/3,e.dist(i)/3,s*c/n)}function gp(t,e,i){return t.x<i[0].x&&e.x<i[0].x||t.x>i[1].x&&e.x>i[1].x||t.y<i[0].y&&e.y<i[0].y||t.y>i[1].y&&e.y>i[1].y}function yp(t,e,i){if(t.x<0||t.x>=Ze||e.x<0||e.x>=Ze||i.x<0||i.x>=Ze)return!1;const n=i.sub(e),s=n.perp(),c=t.sub(e);return(n.x*c.x+n.y*c.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(c.x*c.x+c.y*c.y))>-.866&&s.x*c.x+s.y*c.y<0}function xp(t,e,i){const n=e?2|t:-3&t;return i?1|n:-2&n}function vp(){const t=Math.PI/32,e=Math.tan(t),i=Rl;return i*Math.sqrt(1+2*e*e)-i}function bp(t,e,i){const n=1<<i.z,s=dr(i.x/n),c=dr((i.x+1)/n),u=Ci(i.y/n),p=Ci((i.y+1)/n);return function(m,_,x,b,w=0,S){const M=[];if(!m.length||!x||!b)return M;const C=(W,ce)=>{for(const se of W)M.push({polygon:se,bounds:ce})},D=Math.ceil(Math.log2(x)),U=Math.ceil(Math.log2(b)),q=D-U,V=[];for(let W=0;W<Math.abs(q);W++)V.push(q>0?0:1);for(let W=0;W<Math.min(D,U);W++)V.push(0),V.push(1);let $=m;if($=hh($,_[0].y-w,_[1].y+w,1),$=hh($,_[0].x-w,_[1].x+w,0),!$.length)return M;const X=[];for(V.length?X.push({polygons:$,bounds:_,depth:0}):C($,_);X.length;){const W=X.pop(),ce=W.depth,se=V[ce],me=W.bounds[0],Se=W.bounds[1],ue=se===0?me.x:me.y,ye=se===0?Se.x:Se.y,xe=S?S(se,ue,ye):.5*(ue+ye),we=hh(W.polygons,ue-w,xe+w,se),Ce=hh(W.polygons,xe-w,ye+w,se);if(we.length){const pe=[me,new Le(se===0?xe:Se.x,se===1?xe:Se.y)];V.length>ce+1?X.push({polygons:we,bounds:pe,depth:ce+1}):C(we,pe)}if(Ce.length){const pe=[new Le(se===0?xe:me.x,se===1?xe:me.y),Se];V.length>ce+1?X.push({polygons:Ce,bounds:pe,depth:ce+1}):C(Ce,pe)}}return M}(t,e,Math.ceil((c-s)/11.25),Math.ceil((u-p)/11.25),1,(m,_,x)=>{if(m===0)return .5*(_+x);{const b=Ci((i.y+_/Ze)/n);return(ln(.5*(Ci((i.y+x/Ze)/n)+b))*n-i.y)*Ze}})}Ue(jl,"FillExtrusionBucket",{omit:["layers","features"]}),Ue(fp,"PartMetadata");const s_=new j({"fill-extrusion-edge-radius":new I(fe["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var a_={paint:new j({"fill-extrusion-opacity":new I(fe["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new L(fe["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new I(fe["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new I(fe["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new L(fe["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new L(fe["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new L(fe["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new I(fe["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new I(fe["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new I(fe["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new I(fe["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:s_};function wp(t,e,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class uh{constructor(e,i,n){this.z=e,this.x=i,this.y=n,this.key=Gl(0,e,e,i,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,i){const n=function(c,u,p){var m=wp(256*c,256*(u=Math.pow(2,p)-u-1),p),_=wp(256*(c+1),256*(u+1),p);return m[0]+","+m[1]+","+_[0]+","+_[1]}(this.x,this.y,this.z),s=function(c,u,p){let m,_="";for(let x=c;x>0;x--)m=1<<x-1,_+=(u&m?1:0)+(p&m?2:0);return _}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(i==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",s).replace("{bbox-epsg-3857}",n)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Tp{constructor(e,i){this.wrap=e,this.canonical=i,this.key=Gl(e,i.z,i.z,i.x,i.y)}}class Vi{constructor(e,i,n,s,c){this.overscaledZ=e,this.wrap=i,this.canonical=new uh(n,+s,+c),this.key=i===0&&e===n?this.canonical.key:Gl(i,e,n,s,c)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const i=this.canonical.z-e;return e>this.canonical.z?new Vi(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Vi(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}calculateScaledKey(e,i=!0){if(this.overscaledZ===e&&i)return this.key;if(e>this.canonical.z)return Gl(this.wrap*+i,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return Gl(this.wrap*+i,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const i=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>i&&e.canonical.y===this.canonical.y>>i}children(e){if(this.overscaledZ>=e)return[new Vi(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const i=this.canonical.z+1,n=2*this.canonical.x,s=2*this.canonical.y;return[new Vi(i,this.wrap,i,n,s),new Vi(i,this.wrap,i,n+1,s),new Vi(i,this.wrap,i,n,s+1),new Vi(i,this.wrap,i,n+1,s+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Vi(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Vi(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Tp(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Gl(t,e,i,n,s){const c=1<<Math.min(i,22);let u=c*(s%c)+n%c;return t&&i<22&&(u+=c*c*((t<0?-2*t-1:2*t)%(1<<2*(22-i)))),16*(32*u+i)+(e-i)}Ue(uh,"CanonicalTileID"),Ue(Vi,"OverscaledTileID",{omit:["projMatrix"]});class pa extends Le{constructor(e,i,n){super(e,i),this.z=n}}function $l(t,e){return t.x*e.x+t.y*e.y}function Ep(t,e){if(t.length===1){let i=0;const n=e[i++];let s;for(;!s||n.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){const c=e[i],u=t[0],p=s.sub(n),m=c.sub(n),_=u.sub(n),x=$l(p,p),b=$l(p,m),w=$l(m,m),S=$l(_,p),M=$l(_,m),C=x*w-b*b,D=(w*S-b*M)/C,U=(x*M-b*S)/C,q=n.z*(1-D-U)+s.z*D+c.z*U;if(isFinite(q))return q}return 1/0}{let i=1/0;for(const n of e)i=Math.min(i,n.z);return i}}function Sp(t,e,i,n,s,c,u,p){const m=u*s.getElevationAt(t,e,!0,!0),_=c[0]!==0,x=_?c[1]===0?u*(c[0]/7-450):u*function(b,w,S){const M=Math.floor(w[0]/8),C=Math.floor(w[1]/8),D=10*(w[0]-8*M),U=10*(w[1]-8*C),q=b.getElevationAt(M,C,!0,!0),V=b.getMeterToDEM(S),$=Math.floor(.5*(D*V-1)),X=Math.floor(.5*(U*V-1)),W=b.tileCoordToPixel(M,C),ce=2*$+1,se=2*X+1,me=function(Ce,pe,De,Ne,Re){return[Ce.getElevationAtPixel(pe,De,!0),Ce.getElevationAtPixel(pe+Re,De,!0),Ce.getElevationAtPixel(pe,De+Re,!0),Ce.getElevationAtPixel(pe+Ne,De+Re,!0)]}(b,W.x-$,W.y-X,ce,se),Se=Math.abs(me[0]-me[1]),ue=Math.abs(me[2]-me[3]),ye=Math.abs(me[0]-me[2])+Math.abs(me[1]-me[3]),xe=Math.min(.25,.5*V*(Se+ue)/ce),we=Math.min(.25,.5*V*ye/se);return q+Math.max(xe*D,we*U)}(s,c,p):m;return{base:m+(i===0)?-1:i,top:_?Math.max(x+n,m+i+2):m+n}}const l_=te([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:c_}=l_,h_=te([{name:"a_packed",components:4,type:"Float32"}]),{members:u_}=h_,d_=ch.types,p_=Math.cos(Math.PI/180*37.5);class dh{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(i=>i.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(i=>{this.gradients[i.id]={}}),this.layoutVertexArray=new he,this.layoutVertexArray2=new Te,this.indexArray=new je,this.programConfigurations=new as(e.layers,e.zoom),this.segments=new ri,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(i=>i.isStateDependent()).map(i=>i.id)}populate(e,i,n,s){this.hasPattern=ku("line",this.layers,i);const c=this.layers[0].layout.get("line-sort-key"),u=[];for(const{feature:x,id:b,index:w,sourceLayerIndex:S}of e){const M=this.layers[0]._featureFilter.needGeometry,C=ps(x,M);if(!this.layers[0]._featureFilter.filter(new v(this.zoom),C,n))continue;const D=c?c.evaluate(C,{},n):void 0,U={id:b,properties:x.properties,type:x.type,sourceLayerIndex:S,index:w,geometry:M?C.geometry:Ln(x,n,s),patterns:{},sortKey:D};u.push(U)}c&&u.sort((x,b)=>x.sortKey-b.sortKey);const{lineAtlas:p,featureIndex:m}=i,_=this.addConstantDashes(p);for(const x of u){const{geometry:b,index:w,sourceLayerIndex:S}=x;if(_&&this.addFeatureDashes(x,p),this.hasPattern){const M=Du("line",this.layers,x,this.zoom,i);this.patternFeatures.push(M)}else this.addFeature(x,b,w,n,p.positions,i.availableImages);m.insert(e[w].feature,b,w,S,this.index)}}addConstantDashes(e){let i=!1;for(const n of this.layers){const s=n.paint.get("line-dasharray").value,c=n.layout.get("line-cap").value;if(s.kind!=="constant"||c.kind!=="constant")i=!0;else{const u=c.value,p=s.value;if(!p)continue;e.addDash(p,u)}}return i}addFeatureDashes(e,i){const n=this.zoom;for(const s of this.layers){const c=s.paint.get("line-dasharray").value,u=s.layout.get("line-cap").value;if(c.kind==="constant"&&u.kind==="constant")continue;let p,m;if(c.kind==="constant"){if(p=c.value,!p)continue}else p=c.evaluate({zoom:n},e);m=u.kind==="constant"?u.value:u.evaluate({zoom:n},e),i.addDash(p,m),e.patterns[s.id]=i.getKey(p,m)}}update(e,i,n,s){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,i,this.stateDependentLayers,n,s)}addFeatures(e,i,n,s,c){for(const u of this.patternFeatures)this.addFeature(u,u.geometry,u.index,i,n,s)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,u_)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,c_),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,i,n,s,c,u){const p=this.layers[0].layout,m=p.get("line-join").evaluate(e,{}),_=p.get("line-cap").evaluate(e,{}),x=p.get("line-miter-limit"),b=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const w of i)this.addLine(w,e,m,_,x,b);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,c,u,s)}addLine(e,i,n,s,c,u){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let U=0;U<e.length-1;U++)this.totalDistance+=e[U].dist(e[U+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const p=d_[i.type]==="Polygon";let m=e.length;for(;m>=2&&e[m-1].equals(e[m-2]);)m--;let _=0;for(;_<m-1&&e[_].equals(e[_+1]);)_++;if(m<(p?3:2))return;n==="bevel"&&(c=1.05);const x=this.overscaling<=16?15*Ze/(512*this.overscaling):0,b=this.segments.prepareSegment(10*m,this.layoutVertexArray,this.indexArray);let w,S,M,C,D;this.e1=this.e2=-1,p&&(w=e[m-2],D=e[_].sub(w)._unit()._perp());for(let U=_;U<m;U++){if(M=U===m-1?p?e[_+1]:void 0:e[U+1],M&&e[U].equals(M))continue;D&&(C=D),w&&(S=w),w=e[U],D=M?M.sub(w)._unit()._perp():C,C=C||D;let q=C.add(D);q.x===0&&q.y===0||q._unit();const V=C.x*D.x+C.y*D.y,$=q.x*D.x+q.y*D.y,X=$!==0?1/$:1/0,W=2*Math.sqrt(2-2*$),ce=$<p_&&S&&M,se=C.x*D.y-C.y*D.x>0;if(ce&&U>_){const ue=w.dist(S);if(ue>2*x){const ye=w.sub(w.sub(S)._mult(x/ue)._round());this.updateDistance(S,ye),this.addCurrentVertex(ye,C,0,0,b),S=ye}}const me=S&&M;let Se=me?n:p?"butt":s;if(me&&Se==="round"&&(X<u?Se="miter":X<=2&&(Se="fakeround")),Se==="miter"&&X>c&&(Se="bevel"),Se==="bevel"&&(X>2&&(Se="flipbevel"),X<c&&(Se="miter")),S&&this.updateDistance(S,w),Se==="miter")q._mult(X),this.addCurrentVertex(w,q,0,0,b);else if(Se==="flipbevel"){if(X>100)q=D.mult(-1);else{const ue=X*C.add(D).mag()/C.sub(D).mag();q._perp()._mult(ue*(se?-1:1))}this.addCurrentVertex(w,q,0,0,b),this.addCurrentVertex(w,q.mult(-1),0,0,b)}else if(Se==="bevel"||Se==="fakeround"){const ue=-Math.sqrt(X*X-1),ye=se?ue:0,xe=se?0:ue;if(S&&this.addCurrentVertex(w,C,ye,xe,b),Se==="fakeround"){const we=Math.round(180*W/Math.PI/20);for(let Ce=1;Ce<we;Ce++){let pe=Ce/we;if(pe!==.5){const Ne=pe-.5;pe+=pe*Ne*(pe-1)*((1.0904+V*(V*(3.55645-1.43519*V)-3.2452))*Ne*Ne+(.848013+V*(.215638*V-1.06021)))}const De=D.sub(C)._mult(pe)._add(C)._unit()._mult(se?-1:1);this.addHalfVertex(w,De.x,De.y,!1,se,0,b)}}M&&this.addCurrentVertex(w,D,-ye,-xe,b)}else if(Se==="butt")this.addCurrentVertex(w,q,0,0,b);else if(Se==="square"){const ue=S?1:-1;S||this.addCurrentVertex(w,q,ue,ue,b),this.addCurrentVertex(w,q,0,0,b),S&&this.addCurrentVertex(w,q,ue,ue,b)}else Se==="round"&&(S&&(this.addCurrentVertex(w,C,0,0,b),this.addCurrentVertex(w,C,1,1,b,!0)),M&&(this.addCurrentVertex(w,D,-1,-1,b,!0),this.addCurrentVertex(w,D,0,0,b)));if(ce&&U<m-1){const ue=w.dist(M);if(ue>2*x){const ye=w.add(M.sub(w)._mult(x/ue)._round());this.updateDistance(w,ye),this.addCurrentVertex(ye,D,0,0,b),w=ye}}}}addCurrentVertex(e,i,n,s,c,u=!1){const p=i.y*s-i.x,m=-i.y-i.x*s;this.addHalfVertex(e,i.x+i.y*n,i.y-i.x*n,u,!1,n,c),this.addHalfVertex(e,p,m,u,!0,-s,c)}addHalfVertex({x:e,y:i},n,s,c,u,p,m){this.layoutVertexArray.emplaceBack((e<<1)+(c?1:0),(i<<1)+(u?1:0),Math.round(63*n)+128,Math.round(63*s)+128,1+(p===0?0:p<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const _=m.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,_),m.primitiveLength++),u?this.e2=_:this.e1=_}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,i){this.distance+=e.dist(i),this.updateScaledDistance()}}Ue(dh,"LineBucket",{omit:["layers","patternFeatures"]});const f_=new j({"line-cap":new L(fe.layout_line["line-cap"]),"line-join":new L(fe.layout_line["line-join"]),"line-miter-limit":new I(fe.layout_line["line-miter-limit"]),"line-round-limit":new I(fe.layout_line["line-round-limit"]),"line-sort-key":new L(fe.layout_line["line-sort-key"])});var Mp={paint:new j({"line-opacity":new L(fe.paint_line["line-opacity"]),"line-color":new L(fe.paint_line["line-color"]),"line-translate":new I(fe.paint_line["line-translate"]),"line-translate-anchor":new I(fe.paint_line["line-translate-anchor"]),"line-width":new L(fe.paint_line["line-width"]),"line-gap-width":new L(fe.paint_line["line-gap-width"]),"line-offset":new L(fe.paint_line["line-offset"]),"line-blur":new L(fe.paint_line["line-blur"]),"line-dasharray":new L(fe.paint_line["line-dasharray"]),"line-pattern":new L(fe.paint_line["line-pattern"]),"line-gradient":new N(fe.paint_line["line-gradient"]),"line-trim-offset":new I(fe.paint_line["line-trim-offset"])}),layout:f_};const Ap=new class extends L{possiblyEvaluate(t,e){return e=new v(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=Qt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}(Mp.paint.properties["line-width"].specification);function Ip(t,e){return e>0?e+2*t:t}Ap.useIntegerZoom=!0;const m_=te([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),__=te([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),g_=te([{name:"a_projected_pos",components:4,type:"Float32"}],4);te([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const y_=te([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),x_=te([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);te([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Cp=te([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),v_=te([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);te([{name:"triangle",components:3,type:"Uint16"}]),te([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),te([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),te([{type:"Float32",name:"offsetX"}]),te([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Ti=24;const Zr=128;function Ru(t,e){const{expression:i}=e;if(i.kind==="constant")return{kind:"constant",layoutSize:i.evaluate(new v(t+1))};if(i.kind==="source")return{kind:"source"};{const{zoomStops:n,interpolationType:s}=i;let c=0;for(;c<n.length&&n[c]<=t;)c++;c=Math.max(0,c-1);let u=c;for(;u<n.length&&n[u]<t+1;)u++;u=Math.min(n.length-1,u);const p=n[c],m=n[u];return i.kind==="composite"?{kind:"composite",minZoom:p,maxZoom:m,interpolationType:s}:{kind:"camera",minZoom:p,maxZoom:m,minSize:i.evaluate(new v(p)),maxSize:i.evaluate(new v(m)),interpolationType:s}}}function ph(t,{uSize:e,uSizeT:i},{lowerSize:n,upperSize:s}){return t.kind==="source"?n/Zr:t.kind==="composite"?gt(n/Zr,s/Zr,i):e}function fa(t,e){let i=0,n=0;if(t.kind==="constant")n=t.layoutSize;else if(t.kind!=="source"){const{interpolationType:s,minZoom:c,maxZoom:u}=t,p=s?ut(yr.interpolationFactor(s,e,c,u),0,1):0;t.kind==="camera"?n=gt(t.minSize,t.maxSize,p):i=p}return{uSizeT:i,uSize:n}}var b_=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:Zr,evaluateSizeForFeature:ph,evaluateSizeForZoom:fa,getSizeData:Ru});function w_(t,e,i){return t.sections.forEach(n=>{n.text=function(s,c,u){const p=c.layout.get("text-transform").evaluate(u,{});return p==="uppercase"?s=s.toLocaleUpperCase():p==="lowercase"&&(s=s.toLocaleLowerCase()),y.applyArabicShaping&&(s=y.applyArabicShaping(s)),s}(n.text,e,i)}),t}const Zl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function T_(t){return t==="︶"||t==="﹈"||t==="︸"||t==="﹄"||t==="﹂"||t==="︾"||t==="︼"||t==="︺"||t==="︘"||t==="﹀"||t==="︐"||t==="︓"||t==="︔"||t==="`"||t===" ̄"||t==="︑"||t==="︒"}function E_(t){return t==="︵"||t==="﹇"||t==="︷"||t==="﹃"||t==="﹁"||t==="︽"||t==="︻"||t==="︹"||t==="︗"||t==="︿"}var zp=Lt,Pp=function(t,e,i,n,s){var c,u,p=8*s-n-1,m=(1<<p)-1,_=m>>1,x=-7,b=i?s-1:0,w=i?-1:1,S=t[e+b];for(b+=w,c=S&(1<<-x)-1,S>>=-x,x+=p;x>0;c=256*c+t[e+b],b+=w,x-=8);for(u=c&(1<<-x)-1,c>>=-x,x+=n;x>0;u=256*u+t[e+b],b+=w,x-=8);if(c===0)c=1-_;else{if(c===m)return u?NaN:1/0*(S?-1:1);u+=Math.pow(2,n),c-=_}return(S?-1:1)*u*Math.pow(2,c-n)},kp=function(t,e,i,n,s,c){var u,p,m,_=8*c-s-1,x=(1<<_)-1,b=x>>1,w=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,S=n?0:c-1,M=n?1:-1,C=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,u=x):(u=Math.floor(Math.log(e)/Math.LN2),e*(m=Math.pow(2,-u))<1&&(u--,m*=2),(e+=u+b>=1?w/m:w*Math.pow(2,1-b))*m>=2&&(u++,m/=2),u+b>=x?(p=0,u=x):u+b>=1?(p=(e*m-1)*Math.pow(2,s),u+=b):(p=e*Math.pow(2,b-1)*Math.pow(2,s),u=0));s>=8;t[i+S]=255&p,S+=M,p/=256,s-=8);for(u=u<<s|p,_+=s;_>0;t[i+S]=255&u,S+=M,u/=256,_-=8);t[i+S-M]|=128*C};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function Lt(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Lt.Varint=0,Lt.Fixed64=1,Lt.Bytes=2,Lt.Fixed32=5;var Bu=4294967296,Dp=1/Bu,Lp=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function Bn(t){return t.type===Lt.Bytes?t.readVarint()+t.pos:t.pos+1}function ma(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Rp(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var s=i.pos-1;s>=t;s--)i.buf[s+n]=i.buf[s]}function S_(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function M_(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function A_(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function I_(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function C_(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function z_(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function P_(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function k_(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function D_(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function fh(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function _a(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Bp(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Lt.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),s=n>>3,c=this.pos;this.type=7&n,t(s,e,this),this.pos===c&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=fh(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Bp(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=fh(this.buf,this.pos)+fh(this.buf,this.pos+4)*Bu;return this.pos+=8,t},readSFixed64:function(){var t=fh(this.buf,this.pos)+Bp(this.buf,this.pos+4)*Bu;return this.pos+=8,t},readFloat:function(){var t=Pp(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Pp(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(s,c,u){var p,m,_=u.buf;if(p=(112&(m=_[u.pos++]))>>4,m<128||(p|=(127&(m=_[u.pos++]))<<3,m<128)||(p|=(127&(m=_[u.pos++]))<<10,m<128)||(p|=(127&(m=_[u.pos++]))<<17,m<128)||(p|=(127&(m=_[u.pos++]))<<24,m<128)||(p|=(1&(m=_[u.pos++]))<<31,m<128))return ma(s,p,c);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Lp?function(i,n,s){return Lp.decode(i.subarray(n,s))}(this.buf,e,t):function(i,n,s){for(var c="",u=n;u<s;){var p,m,_,x=i[u],b=null,w=x>239?4:x>223?3:x>191?2:1;if(u+w>s)break;w===1?x<128&&(b=x):w===2?(192&(p=i[u+1]))==128&&(b=(31&x)<<6|63&p)<=127&&(b=null):w===3?(m=i[u+2],(192&(p=i[u+1]))==128&&(192&m)==128&&((b=(15&x)<<12|(63&p)<<6|63&m)<=2047||b>=55296&&b<=57343)&&(b=null)):w===4&&(m=i[u+2],_=i[u+3],(192&(p=i[u+1]))==128&&(192&m)==128&&(192&_)==128&&((b=(15&x)<<18|(63&p)<<12|(63&m)<<6|63&_)<=65535||b>=1114112)&&(b=null)),b===null?(b=65533,w=1):b>65535&&(b-=65536,c+=String.fromCharCode(b>>>10&1023|55296),b=56320|1023&b),c+=String.fromCharCode(b),u+=w}return c}(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!==Lt.Bytes)return t.push(this.readVarint(e));var i=Bn(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==Lt.Bytes)return t.push(this.readSVarint());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Lt.Bytes)return t.push(this.readBoolean());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Lt.Bytes)return t.push(this.readFloat());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Lt.Bytes)return t.push(this.readDouble());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Lt.Bytes)return t.push(this.readFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Lt.Bytes)return t.push(this.readSFixed32());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Lt.Bytes)return t.push(this.readFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Lt.Bytes)return t.push(this.readSFixed64());var e=Bn(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===Lt.Varint)for(;this.buf[this.pos++]>127;);else if(e===Lt.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Lt.Fixed32)this.pos+=4;else{if(e!==Lt.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;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),_a(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),_a(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),_a(this.buf,-1&t,this.pos),_a(this.buf,Math.floor(t*Dp),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),_a(this.buf,-1&t,this.pos),_a(this.buf,Math.floor(t*Dp),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(e,i){var n,s;if(e>=0?(n=e%4294967296|0,s=e/4294967296|0):(s=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,s=s+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(c,u,p){p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,c>>>=7,p.buf[p.pos++]=127&c|128,p.buf[p.pos]=127&(c>>>=7)}(n,0,i),function(c,u){var p=(7&c)<<4;u.buf[u.pos++]|=p|((c>>>=3)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c|((c>>>=7)?128:0),c&&(u.buf[u.pos++]=127&c)))))}(s,i)}(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(!!t)},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(n,s,c){for(var u,p,m=0;m<s.length;m++){if((u=s.charCodeAt(m))>55295&&u<57344){if(!p){u>56319||m+1===s.length?(n[c++]=239,n[c++]=191,n[c++]=189):p=u;continue}if(u<56320){n[c++]=239,n[c++]=191,n[c++]=189,p=u;continue}u=p-55296<<10|u-56320|65536,p=null}else p&&(n[c++]=239,n[c++]=191,n[c++]=189,p=null);u<128?n[c++]=u:(u<2048?n[c++]=u>>6|192:(u<65536?n[c++]=u>>12|224:(n[c++]=u>>18|240,n[c++]=u>>12&63|128),n[c++]=u>>6&63|128),n[c++]=63&u|128)}return c}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&Rp(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),kp(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),kp(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<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&Rp(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,Lt.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,S_,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,M_,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,C_,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,A_,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,I_,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,z_,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,P_,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,k_,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,D_,e)},writeBytesField:function(t,e){this.writeTag(t,Lt.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Lt.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Lt.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Lt.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Lt.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Lt.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Lt.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Lt.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Lt.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Lt.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,!!e)}};var mh=or(zp);const Ou=3;function L_(t,e,i){e.glyphs=[],t===1&&i.readMessage(R_,e)}function R_(t,e,i){if(t===3){const{id:n,bitmap:s,width:c,height:u,left:p,top:m,advance:_}=i.readMessage(B_,{});e.glyphs.push({id:n,bitmap:new Rn({width:c+2*Ou,height:u+2*Ou},s),metrics:{width:c,height:u,left:p,top:m,advance:_}})}else t===4?e.ascender=i.readSVarint():t===5&&(e.descender=i.readSVarint())}function B_(t,e,i){t===1?e.id=i.readVarint():t===2?e.bitmap=i.readBytes():t===3?e.width=i.readVarint():t===4?e.height=i.readVarint():t===5?e.left=i.readSVarint():t===6?e.top=i.readSVarint():t===7&&(e.advance=i.readVarint())}const Op=Ou;function Fu(t){let e=0,i=0;for(const u of t)e+=u.w*u.h,i=Math.max(i,u.w);t.sort((u,p)=>p.h-u.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,c=0;for(const u of t)for(let p=n.length-1;p>=0;p--){const m=n[p];if(!(u.w>m.w||u.h>m.h)){if(u.x=m.x,u.y=m.y,c=Math.max(c,u.y+u.h),s=Math.max(s,u.x+u.w),u.w===m.w&&u.h===m.h){const _=n.pop();p<n.length&&(n[p]=_)}else u.h===m.h?(m.x+=u.w,m.w-=u.w):u.w===m.w?(m.y+=u.h,m.h-=u.h):(n.push({x:m.x+u.w,y:m.y,w:m.w-u.w,h:u.h}),m.y+=u.h,m.h-=u.h);break}}return{w:s,h:c,fill:e/(s*c)||0}}const Wi=1;class Uu{constructor(e,{pixelRatio:i,version:n,stretchX:s,stretchY:c,content:u}){this.paddedRect=e,this.pixelRatio=i,this.stretchX=s,this.stretchY=c,this.content=u,this.version=n}get tl(){return[this.paddedRect.x+Wi,this.paddedRect.y+Wi]}get br(){return[this.paddedRect.x+this.paddedRect.w-Wi,this.paddedRect.y+this.paddedRect.h-Wi]}get displaySize(){return[(this.paddedRect.w-2*Wi)/this.pixelRatio,(this.paddedRect.h-2*Wi)/this.pixelRatio]}}class Fp{constructor(e,i){const n={},s={};this.haveRenderCallbacks=[];const c=[];this.addImages(e,n,c),this.addImages(i,s,c);const{w:u,h:p}=Fu(c),m=new ir({width:u||1,height:p||1});for(const _ in e){const x=e[_],b=n[_].paddedRect;ir.copy(x.data,m,{x:0,y:0},{x:b.x+Wi,y:b.y+Wi},x.data)}for(const _ in i){const x=i[_],b=s[_].paddedRect,w=b.x+Wi,S=b.y+Wi,M=x.data.width,C=x.data.height;ir.copy(x.data,m,{x:0,y:0},{x:w,y:S},x.data),ir.copy(x.data,m,{x:0,y:C-1},{x:w,y:S-1},{width:M,height:1}),ir.copy(x.data,m,{x:0,y:0},{x:w,y:S+C},{width:M,height:1}),ir.copy(x.data,m,{x:M-1,y:0},{x:w-1,y:S},{width:1,height:C}),ir.copy(x.data,m,{x:0,y:0},{x:w+M,y:S},{width:1,height:C})}this.image=m,this.iconPositions=n,this.patternPositions=s}addImages(e,i,n){for(const s in e){const c=e[s],u={x:0,y:0,w:c.data.width+2*Wi,h:c.data.height+2*Wi};n.push(u),i[s]=new Uu(u,c),c.hasRenderCallback&&this.haveRenderCallbacks.push(s)}}patchUpdatedImages(e,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(n=>e.hasImage(n)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),i),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),i)}patchUpdatedImage(e,i,n){if(!e||!i||e.version===i.version)return;e.version=i.version;const[s,c]=e.tl;n.update(i.data,void 0,{x:s,y:c})}}Ue(Uu,"ImagePosition"),Ue(Fp,"ImageAtlas");const pr={horizontal:1,vertical:2,horizontalOnly:3},Up=-17;class ql{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,i){const n=new ql;return n.scale=e||1,n.fontStack=i,n}static forImage(e){const i=new ql;return i.imageName=e,i}}class ga{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,i){const n=new ga;for(let s=0;s<e.sections.length;s++){const c=e.sections[s];c.image?n.addImageSection(c):n.addTextSection(c,i)}return n}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(i,n){let s="";for(let c=0;c<i.length;c++){const u=i.charCodeAt(c+1)||null,p=i.charCodeAt(c-1)||null;s+=!n&&(u&&$c(u)&&!Zl[i[c+1]]||p&&$c(p)&&!Zl[i[c-1]])||!Zl[i[c]]?i[c]:Zl[i[c]]}return s}(this.text,e)}trim(){let e=0;for(let n=0;n<this.text.length&&_h[this.text.charCodeAt(n)];n++)e++;let i=this.text.length;for(let n=this.text.length-1;n>=0&&n>=e&&_h[this.text.charCodeAt(n)];n--)i--;this.text=this.text.substring(e,i),this.sectionIndex=this.sectionIndex.slice(e,i)}substring(e,i){const n=new ga;return n.text=this.text.substring(e,i),n.sectionIndex=this.sectionIndex.slice(e,i),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,i)=>Math.max(e,this.sections[i].scale),0)}addTextSection(e,i){this.text+=e.text,this.sections.push(ql.forText(e.scale,e.fontStack||i));const n=this.sections.length-1;for(let s=0;s<e.text.length;++s)this.sectionIndex.push(n)}addImageSection(e){const i=e.image?e.image.name:"";if(i.length===0)return void Gt("Can't add FormattedSection with an empty image.");const n=this.getNextImageSectionCharCode();n?(this.text+=String.fromCharCode(n),this.sections.push(ql.forImage(i)),this.sectionIndex.push(this.sections.length-1)):Gt("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Vu(t,e,i,n,s,c,u,p,m,_,x,b,w,S,M){const C=ga.fromFeature(t,s);b===pr.vertical&&C.verticalizePunctuation(w);let D=[];const U=function(W,ce,se,me,Se,ue){if(!W)return[];const ye=[],xe=function(De,Ne,Re,Ke,ze,$e){let Ye=0;for(let xt=0;xt<De.length();xt++){const Je=De.getSection(xt);Ye+=Vp(De.getCharCode(xt),Je,Ke,ze,Ne,$e)}return Ye/Math.max(1,Math.ceil(Ye/Re))}(W,ce,se,me,Se,ue),we=W.text.indexOf("​")>=0;let Ce=0;for(let De=0;De<W.length();De++){const Ne=W.getSection(De),Re=W.getCharCode(De);if(_h[Re]||(Ce+=Vp(Re,Ne,me,Se,ce,ue)),De<W.length()-1){const Ke=!((pe=Re)<11904||!(Be["Bopomofo Extended"](pe)||Be.Bopomofo(pe)||Be["CJK Compatibility Forms"](pe)||Be["CJK Compatibility Ideographs"](pe)||Be["CJK Compatibility"](pe)||Be["CJK Radicals Supplement"](pe)||Be["CJK Strokes"](pe)||Be["CJK Symbols and Punctuation"](pe)||Be["CJK Unified Ideographs Extension A"](pe)||Be["CJK Unified Ideographs"](pe)||Be["Enclosed CJK Letters and Months"](pe)||Be["Halfwidth and Fullwidth Forms"](pe)||Be.Hiragana(pe)||Be["Ideographic Description Characters"](pe)||Be["Kangxi Radicals"](pe)||Be["Katakana Phonetic Extensions"](pe)||Be.Katakana(pe)||Be["Vertical Forms"](pe)||Be["Yi Radicals"](pe)||Be["Yi Syllables"](pe)));(O_[Re]||Ke||Ne.imageName)&&ye.push(jp(De+1,Ce,xe,ye,F_(Re,W.getCharCode(De+1),Ke&&we),!1))}}var pe;return Gp(jp(W.length(),Ce,xe,ye,0,!0))}(C,_,c,e,n,S),{processBidirectionalText:q,processStyledBidirectionalText:V}=y;if(q&&C.sections.length===1){const W=q(C.toString(),U);for(const ce of W){const se=new ga;se.text=ce,se.sections=C.sections;for(let me=0;me<ce.length;me++)se.sectionIndex.push(0);D.push(se)}}else if(V){const W=V(C.text,C.sectionIndex,U);for(const ce of W){const se=new ga;se.text=ce[0],se.sectionIndex=ce[1],se.sections=C.sections,D.push(se)}}else D=function(W,ce){const se=[],me=W.text;let Se=0;for(const ue of ce)se.push(W.substring(Se,ue)),Se=ue;return Se<me.length&&se.push(W.substring(Se,me.length)),se}(C,U);const $=[],X={positionedLines:$,text:C.toString(),top:x[1],bottom:x[1],left:x[0],right:x[0],writingMode:b,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(W,ce,se,me,Se,ue,ye,xe,we,Ce,pe,De){let Ne=0,Re=0,Ke=0;const ze=xe==="right"?1:xe==="left"?0:.5;let $e=!1;for(const tt of Se){const it=tt.getSections();for(const Pt of it){if(Pt.imageName)continue;const Rt=ce[Pt.fontStack];if(Rt&&($e=Rt.ascender!==void 0&&Rt.descender!==void 0,!$e))break}if(!$e)break}let Ye=0;for(const tt of Se){tt.trim();const it=tt.getMaxScale(),Pt=(it-1)*Ti,Rt={positionedGlyphs:[],lineOffset:0};W.positionedLines[Ye]=Rt;const Bt=Rt.positionedGlyphs;let kt=0;if(!tt.length()){Re+=ue,++Ye;continue}let Zt=0,Ht=0;for(let Dt=0;Dt<tt.length();Dt++){const hi=tt.getSection(Dt),si=tt.getSectionIndex(Dt),Wt=tt.getCharCode(Dt);let bt=hi.scale,ai=null,Ot=null,Ni=null,li=Ti,Ei=0;const vi=!(we===pr.horizontal||!pe&&!xl(Wt)||pe&&(_h[Wt]||(xt=Wt,Be.Arabic(xt)||Be["Arabic Supplement"](xt)||Be["Arabic Extended-A"](xt)||Be["Arabic Presentation Forms-A"](xt)||Be["Arabic Presentation Forms-B"](xt))));if(hi.imageName){const ji=me[hi.imageName];if(!ji)continue;Ni=hi.imageName,W.iconsInText=W.iconsInText||!0,Ot=ji.paddedRect;const bi=ji.displaySize;bt=bt*Ti/De,ai={width:bi[0],height:bi[1],left:Wi,top:-Op,advance:vi?bi[1]:bi[0],localGlyph:!1},Ei=$e?-ai.height*bt:Up+it*Ti-bi[1]*bt,li=ai.advance;const Xr=(vi?bi[0]:bi[1])*bt-Ti*it;Xr>0&&Xr>kt&&(kt=Xr)}else{const ji=se[hi.fontStack];if(!ji)continue;ji[Wt]&&(Ot=ji[Wt]);const bi=ce[hi.fontStack];if(!bi)continue;const Xr=bi.glyphs[Wt];if(!Xr)continue;if(ai=Xr.metrics,li=Wt!==8203?Ti:0,$e){const Ea=bi.ascender!==void 0?Math.abs(bi.ascender):0,ic=bi.descender!==void 0?Math.abs(bi.descender):0,rc=(Ea+ic)*bt;Zt<rc&&(Zt=rc,Ht=(Ea-ic)/2*bt),Ei=-Ea*bt}else Ei=Up+(it-bt)*Ti}vi?(W.verticalizable=!0,Bt.push({glyph:Wt,imageName:Ni,x:Ne,y:Re+Ei,vertical:vi,scale:bt,localGlyph:ai.localGlyph,fontStack:hi.fontStack,sectionIndex:si,metrics:ai,rect:Ot}),Ne+=li*bt+Ce):(Bt.push({glyph:Wt,imageName:Ni,x:Ne,y:Re+Ei,vertical:vi,scale:bt,localGlyph:ai.localGlyph,fontStack:hi.fontStack,sectionIndex:si,metrics:ai,rect:Ot}),Ne+=ai.advance*bt+Ce)}Bt.length!==0&&(Ke=Math.max(Ne-Ce,Ke),$e?$p(Bt,ze,kt,Ht,ue*it/2):$p(Bt,ze,kt,0,ue/2)),Ne=0;const oi=ue*it+kt;Rt.lineOffset=Math.max(kt,Pt),Re+=oi,++Ye}var xt;const Je=Re,{horizontalAlign:We,verticalAlign:Ft}=Nu(ye);(function(tt,it,Pt,Rt,Bt,kt){const Zt=(it-Pt)*Bt,Ht=-kt*Rt;for(const oi of tt)for(const Dt of oi.positionedGlyphs)Dt.x+=Zt,Dt.y+=Ht})(W.positionedLines,ze,We,Ft,Ke,Je),W.top+=-Ft*Je,W.bottom=W.top+Je,W.left+=-We*Ke,W.right=W.left+Ke,W.hasBaseline=$e}(X,e,i,n,D,u,p,m,b,_,w,M),!function(W){for(const ce of W)if(ce.positionedGlyphs.length!==0)return!1;return!0}($)&&X}const _h={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},O_={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 Vp(t,e,i,n,s,c){if(e.imageName){const u=n[e.imageName];return u?u.displaySize[0]*e.scale*Ti/c+s:0}{const u=i[e.fontStack],p=u&&u.glyphs[t];return p?p.metrics.advance*e.scale+s:0}}function Np(t,e,i,n){const s=Math.pow(t-e,2);return n?t<e?s/2:2*s:s+Math.abs(i)*i}function F_(t,e,i){let n=0;return t===10&&(n-=1e4),i&&(n+=150),t!==40&&t!==65288||(n+=50),e!==41&&e!==65289||(n+=50),n}function jp(t,e,i,n,s,c){let u=null,p=Np(e,i,s,c);for(const m of n){const _=Np(e-m.x,i,s,c)+m.badness;_<=p&&(u=m,p=_)}return{index:t,x:e,priorBreak:u,badness:p}}function Gp(t){return t?Gp(t.priorBreak).concat(t.index):[]}function Nu(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function $p(t,e,i,n,s){if(!(e||i||n||s))return;const c=t.length-1,u=t[c],p=(u.x+u.metrics.advance*u.scale)*e;for(let m=0;m<=c;m++)t[m].x-=p,t[m].y+=i+n+s}function U_(t,e,i){const{horizontalAlign:n,verticalAlign:s}=Nu(i),c=e[0]-t.displaySize[0]*n,u=e[1]-t.displaySize[1]*s;return{image:t,top:u,bottom:u+t.displaySize[1],left:c,right:c+t.displaySize[0]}}function Zp(t,e,i,n,s,c){const u=t.image;let p;if(u.content){const D=u.content,U=u.pixelRatio||1;p=[D[0]/U,D[1]/U,u.displaySize[0]-D[2]/U,u.displaySize[1]-D[3]/U]}const m=e.left*c,_=e.right*c;let x,b,w,S;i==="width"||i==="both"?(S=s[0]+m-n[3],b=s[0]+_+n[1]):(S=s[0]+(m+_-u.displaySize[0])/2,b=S+u.displaySize[0]);const M=e.top*c,C=e.bottom*c;return i==="height"||i==="both"?(x=s[1]+M-n[0],w=s[1]+C+n[2]):(x=s[1]+(M+C-u.displaySize[1])/2,w=x+u.displaySize[1]),{image:u,top:x,right:b,bottom:w,left:S,collisionPadding:p}}class On extends Le{constructor(e,i,n,s,c){super(e,i),this.angle=s,this.z=n,c!==void 0&&(this.segment=c)}clone(){return new On(this.x,this.y,this.z,this.angle,this.segment)}}function qp(t,e,i,n,s){if(e.segment===void 0)return!0;let c=e,u=e.segment+1,p=0;for(;p>-i/2;){if(u--,u<0)return!1;p-=t[u].dist(c),c=t[u]}p+=t[u].dist(t[u+1]),u++;const m=[];let _=0;for(;p<i/2;){const x=t[u],b=t[u+1];if(!b)return!1;let w=t[u-1].angleTo(x)-x.angleTo(b);for(w=Math.abs((w+3*Math.PI)%(2*Math.PI)-Math.PI),m.push({distance:p,angleDelta:w}),_+=w;p-m[0].distance>n;)_-=m.shift().angleDelta;if(_>s)return!1;u++,p+=x.dist(b)}return!0}function Wp(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function Xp(t,e,i){return t?.6*e*i:0}function Hp(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function V_(t,e,i,n,s,c){const u=Xp(i,s,c),p=Hp(i,n)*c;let m=0;const _=Wp(t)/2;for(let x=0;x<t.length-1;x++){const b=t[x],w=t[x+1],S=b.dist(w);if(m+S>_){const M=(_-m)/S,C=gt(b.x,w.x,M),D=gt(b.y,w.y,M),U=new On(C,D,0,w.angleTo(b),x);return!u||qp(t,U,p,u,e)?U:void 0}m+=S}}function N_(t,e,i,n,s,c,u,p,m){const _=Xp(n,c,u),x=Hp(n,s),b=x*u,w=t[0].x===0||t[0].x===m||t[0].y===0||t[0].y===m;return e-b<e/4&&(e=b+e/4),Kp(t,w?e/2*p%e:(x/2+2*c)*u*p%e,e,_,i,b,w,!1,m)}function Kp(t,e,i,n,s,c,u,p,m){const _=c/2,x=Wp(t);let b=0,w=e-i,S=[];for(let M=0;M<t.length-1;M++){const C=t[M],D=t[M+1],U=C.dist(D),q=D.angleTo(C);for(;w+i<b+U;){w+=i;const V=(w-b)/U,$=gt(C.x,D.x,V),X=gt(C.y,D.y,V);if($>=0&&$<m&&X>=0&&X<m&&w-_>=0&&w+_<=x){const W=new On($,X,0,q,M);W._round(),n&&!qp(t,W,c,n,s)||S.push(W)}}b+=U}return p||S.length||u||(S=Kp(t,b/2,i,n,s,c,u,!0,m)),S}function Yp(t,e,i,n,s){const c=[];for(let u=0;u<t.length;u++){const p=t[u];let m;for(let _=0;_<p.length-1;_++){let x=p[_],b=p[_+1];x.x<e&&b.x<e||(x.x<e?x=new Le(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x<e&&(b=new Le(e,x.y+(e-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y<i&&b.y<i||(x.y<i?x=new Le(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round():b.y<i&&(b=new Le(x.x+(i-x.y)/(b.y-x.y)*(b.x-x.x),i)._round()),x.x>=n&&b.x>=n||(x.x>=n?x=new Le(n,x.y+(n-x.x)/(b.x-x.x)*(b.y-x.y))._round():b.x>=n&&(b=new Le(n,x.y+(n-x.x)/(b.x-x.x)*(b.y-x.y))._round()),x.y>=s&&b.y>=s||(x.y>=s?x=new Le(x.x+(s-x.y)/(b.y-x.y)*(b.x-x.x),s)._round():b.y>=s&&(b=new Le(x.x+(s-x.y)/(b.y-x.y)*(b.x-x.x),s)._round()),m&&x.equals(m[m.length-1])||(m=[x],c.push(m)),m.push(b)))))}}return c}Ue(On,"Anchor");const Wl=1e20;function Jp(t,e,i,n,s,c,u,p,m){for(let _=e;_<e+n;_++)Qp(t,i*c+_,c,s,u,p,m);for(let _=i;_<i+s;_++)Qp(t,_*c+e,1,n,u,p,m)}function Qp(t,e,i,n,s,c,u){c[0]=0,u[0]=-Wl,u[1]=Wl,s[0]=t[e];for(let p=1,m=0,_=0;p<n;p++){s[p]=t[e+p*i];const x=p*p;do{const b=c[m];_=(s[p]-s[b]+x-b*b)/(p-b)/2}while(_<=u[m]&&--m>-1);m++,c[m]=p,u[m]=_,u[m+1]=Wl}for(let p=0,m=0;p<n;p++){for(;u[m+1]<p;)m++;const _=c[m],x=p-_;t[e+p*i]=s[_]+x*x}}const qr=2,ju={none:0,ideographs:1,all:2};class ya{constructor(e,i,n){this.requestManager=e,this.localGlyphMode=i,this.localFontFamily=n,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,i){const n=[];for(const s in e)for(const c of e[s])n.push({stack:s,id:c});mi(n,({stack:s,id:c},u)=>{let p=this.entries[s];p||(p=this.entries[s]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let m=p.glyphs[c];if(m!==void 0)return void u(null,{stack:s,id:c,glyph:m});if(m=this._tinySDF(p,s,c),m)return p.glyphs[c]=m,void u(null,{stack:s,id:c,glyph:m});const _=Math.floor(c/256);if(256*_>65535)return void u(new Error("glyphs > 65535 not supported"));if(p.ranges[_])return void u(null,{stack:s,id:c,glyph:m});let x=p.requests[_];x||(x=p.requests[_]=[],ya.loadGlyphRange(s,_,this.url,this.requestManager,(b,w)=>{if(w){p.ascender=w.ascender,p.descender=w.descender;for(const S in w.glyphs)this._doesCharSupportLocalGlyph(+S)||(p.glyphs[+S]=w.glyphs[+S]);p.ranges[_]=!0}for(const S of x)S(b,w);delete p.requests[_]})),x.push((b,w)=>{b?u(b):w&&u(null,{stack:s,id:c,glyph:w.glyphs[c]||null})})},(s,c)=>{if(s)i(s);else if(c){const u={};for(const{stack:p,id:m,glyph:_}of c)u[p]===void 0&&(u[p]={}),u[p].glyphs===void 0&&(u[p].glyphs={}),u[p].glyphs[m]=_&&{id:_.id,bitmap:_.bitmap.clone(),metrics:_.metrics},u[p].ascender=this.entries[p].ascender,u[p].descender=this.entries[p].descender;i(null,u)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==ju.none&&(this.localGlyphMode===ju.all?!!this.localFontFamily:!!this.localFontFamily&&(Be["CJK Unified Ideographs"](e)||Be["Hangul Syllables"](e)||Be.Hiragana(e)||Be.Katakana(e)||Be["CJK Symbols and Punctuation"](e)))}_tinySDF(e,i,n){const s=this.localFontFamily;if(!s||!this._doesCharSupportLocalGlyph(n))return;let c=e.tinySDF;if(!c){let C="400";/bold/i.test(i)?C="900":/medium/i.test(i)?C="500":/light/i.test(i)&&(C="200"),c=e.tinySDF=new ya.TinySDF({fontFamily:s,fontWeight:C,fontSize:24*qr,buffer:3*qr,radius:8*qr}),c.fontWeight=C}if(this.localGlyphs[c.fontWeight][n])return this.localGlyphs[c.fontWeight][n];const u=String.fromCharCode(n),{data:p,width:m,height:_,glyphWidth:x,glyphHeight:b,glyphLeft:w,glyphTop:S,glyphAdvance:M}=c.draw(u);return this.localGlyphs[c.fontWeight][n]={id:n,bitmap:new Rn({width:m,height:_},p),metrics:{width:x/qr,height:b/qr,left:w/qr,top:S/qr-27,advance:M/qr,localGlyph:!0}}}}ya.loadGlyphRange=function(t,e,i,n,s){const c=256*e,u=c+255,p=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${c}-${u}`),gn.Glyphs);Xn(p,(m,_)=>{if(m)s(m);else if(_){const x={},b=function(w){return new mh(w).readFields(L_,{})}(_);for(const w of b.glyphs)x[w.id]=w;s(null,{glyphs:x,ascender:b.ascender,descender:b.descender})}})},ya.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:c="normal",fontStyle:u="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const p=this.size=t+4*e,m=this._createCanvas(p),_=this.ctx=m.getContext("2d",{willReadFrequently:!0});_.font=`${u} ${c} ${t}px ${s}`,_.textBaseline="alphabetic",_.textAlign="left",_.fillStyle="black",this.gridOuter=new Float64Array(p*p),this.gridInner=new Float64Array(p*p),this.f=new Float64Array(p),this.z=new Float64Array(p+1),this.v=new Uint16Array(p)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:c}=this.ctx.measureText(t),u=Math.ceil(i),p=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(c-s))),m=Math.min(this.size-this.buffer,u+Math.ceil(n)),_=p+2*this.buffer,x=m+2*this.buffer,b=Math.max(_*x,0),w=new Uint8ClampedArray(b),S={data:w,width:_,height:x,glyphWidth:p,glyphHeight:m,glyphTop:u,glyphLeft:0,glyphAdvance:e};if(p===0||m===0)return S;const{ctx:M,buffer:C,gridInner:D,gridOuter:U}=this;M.clearRect(C,C,p,m),M.fillText(t,C,C+u);const q=M.getImageData(C,C,p,m);U.fill(Wl,0,b),D.fill(0,0,b);for(let V=0;V<m;V++)for(let $=0;$<p;$++){const X=q.data[4*(V*p+$)+3]/255;if(X===0)continue;const W=(V+C)*_+$+C;if(X===1)U[W]=0,D[W]=Wl;else{const ce=.5-X;U[W]=ce>0?ce*ce:0,D[W]=ce<0?ce*ce:0}}Jp(U,0,0,_,x,_,this.f,this.v,this.z),Jp(D,C,C,p,m,_,this.f,this.v,this.z);for(let V=0;V<b;V++){const $=Math.sqrt(U[V])-Math.sqrt(D[V]);w[V]=Math.round(255-255*($/this.radius+this.cutoff))}return S}};const xa=Wi;function ef(t,e,i,n){const s=[],c=t.image,u=c.pixelRatio,p=c.paddedRect.w-2*xa,m=c.paddedRect.h-2*xa,_=t.right-t.left,x=t.bottom-t.top,b=c.stretchX||[[0,p]],w=c.stretchY||[[0,m]],S=(ue,ye)=>ue+ye[1]-ye[0],M=b.reduce(S,0),C=w.reduce(S,0),D=p-M,U=m-C;let q=0,V=M,$=0,X=C,W=0,ce=D,se=0,me=U;if(c.content&&n){const ue=c.content;q=gh(b,0,ue[0]),$=gh(w,0,ue[1]),V=gh(b,ue[0],ue[2]),X=gh(w,ue[1],ue[3]),W=ue[0]-q,se=ue[1]-$,ce=ue[2]-ue[0]-V,me=ue[3]-ue[1]-X}const Se=(ue,ye,xe,we)=>{const Ce=yh(ue.stretch-q,V,_,t.left),pe=xh(ue.fixed-W,ce,ue.stretch,M),De=yh(ye.stretch-$,X,x,t.top),Ne=xh(ye.fixed-se,me,ye.stretch,C),Re=yh(xe.stretch-q,V,_,t.left),Ke=xh(xe.fixed-W,ce,xe.stretch,M),ze=yh(we.stretch-$,X,x,t.top),$e=xh(we.fixed-se,me,we.stretch,C),Ye=new Le(Ce,De),xt=new Le(Re,De),Je=new Le(Re,ze),We=new Le(Ce,ze),Ft=new Le(pe/u,Ne/u),tt=new Le(Ke/u,$e/u),it=e*Math.PI/180;if(it){const Bt=Math.sin(it),kt=Math.cos(it),Zt=[kt,-Bt,Bt,kt];Ye._matMult(Zt),xt._matMult(Zt),We._matMult(Zt),Je._matMult(Zt)}const Pt=ue.stretch+ue.fixed,Rt=ye.stretch+ye.fixed;return{tl:Ye,tr:xt,bl:We,br:Je,tex:{x:c.paddedRect.x+xa+Pt,y:c.paddedRect.y+xa+Rt,w:xe.stretch+xe.fixed-Pt,h:we.stretch+we.fixed-Rt},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Ft,pixelOffsetBR:tt,minFontScaleX:ce/u/_,minFontScaleY:me/u/x,isSDF:i}};if(n&&(c.stretchX||c.stretchY)){const ue=tf(b,D,M),ye=tf(w,U,C);for(let xe=0;xe<ue.length-1;xe++){const we=ue[xe],Ce=ue[xe+1];for(let pe=0;pe<ye.length-1;pe++)s.push(Se(we,ye[pe],Ce,ye[pe+1]))}}else s.push(Se({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:p+1},{fixed:0,stretch:m+1}));return s}function gh(t,e,i){let n=0;for(const s of t)n+=Math.max(e,Math.min(i,s[1]))-Math.max(e,Math.min(i,s[0]));return n}function tf(t,e,i){const n=[{fixed:-xa,stretch:0}];for(const[s,c]of t){const u=n[n.length-1];n.push({fixed:s-u.stretch,stretch:u.stretch}),n.push({fixed:s-u.stretch,stretch:u.stretch+(c-s)})}return n.push({fixed:e+xa,stretch:i}),n}function yh(t,e,i,n){return t/e*i+n}function xh(t,e,i,n){return t-e*i/n}function j_(t,e,i,n){const s=e+t.positionedLines[n].lineOffset;return n===0?i+s/2:i+(s+(e+t.positionedLines[n-1].lineOffset))/2}class G_{constructor(e=[],i=$_){if(this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],i=this.data.pop();return this.length--,this.length>0&&(this.data[0]=i,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:i,compare:n}=this,s=i[e];for(;e>0;){const c=e-1>>1,u=i[c];if(n(s,u)>=0)break;i[e]=u,e=c}i[e]=s}_down(e){const{data:i,compare:n}=this,s=this.length>>1,c=i[e];for(;e<s;){let u=1+(e<<1),p=i[u];const m=u+1;if(m<this.length&&n(i[m],p)<0&&(u=m,p=i[m]),n(p,c)>=0)break;i[e]=p,e=u}i[e]=c}}function $_(t,e){return t<e?-1:t>e?1:0}function Z_(t,e=1,i=!1){let n=1/0,s=1/0,c=-1/0,u=-1/0;const p=t[0];for(let S=0;S<p.length;S++){const M=p[S];(!S||M.x<n)&&(n=M.x),(!S||M.y<s)&&(s=M.y),(!S||M.x>c)&&(c=M.x),(!S||M.y>u)&&(u=M.y)}const m=Math.min(c-n,u-s);let _=m/2;const x=new G_([],q_);if(m===0)return new Le(n,s);for(let S=n;S<c;S+=m)for(let M=s;M<u;M+=m)x.push(new va(S+_,M+_,_,t));let b=function(S){let M=0,C=0,D=0;const U=S[0];for(let q=0,V=U.length,$=V-1;q<V;$=q++){const X=U[q],W=U[$],ce=X.x*W.y-W.x*X.y;C+=(X.x+W.x)*ce,D+=(X.y+W.y)*ce,M+=3*ce}return new va(C/M,D/M,0,S)}(t),w=x.length;for(;x.length;){const S=x.pop();(S.d>b.d||!b.d)&&(b=S,i&&console.log("found best %d after %d probes",Math.round(1e4*S.d)/1e4,w)),S.max-b.d<=e||(_=S.h/2,x.push(new va(S.p.x-_,S.p.y-_,_,t)),x.push(new va(S.p.x+_,S.p.y-_,_,t)),x.push(new va(S.p.x-_,S.p.y+_,_,t)),x.push(new va(S.p.x+_,S.p.y+_,_,t)),w+=4)}return i&&(console.log(`num probes: ${w}`),console.log(`best distance: ${b.d}`)),b.p}function q_(t,e){return e.max-t.max}class va{constructor(e,i,n,s){this.p=new Le(e,i),this.h=n,this.d=function(c,u){let p=!1,m=1/0;for(let _=0;_<u.length;_++){const x=u[_];for(let b=0,w=x.length,S=w-1;b<w;S=b++){const M=x[b],C=x[S];M.y>c.y!=C.y>c.y&&c.x<(C.x-M.x)*(c.y-M.y)/(C.y-M.y)+M.x&&(p=!p),m=Math.min(m,Kd(c,M,C))}}return(p?1:-1)*Math.sqrt(m)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}const ba=7,Gu=Number.POSITIVE_INFINITY,W_=Math.sqrt(2);function rf(t,[e,i]){let n=0,s=0;if(i===Gu){e<0&&(e=0);const c=e/W_;switch(t){case"top-right":case"top-left":s=c-ba;break;case"bottom-right":case"bottom-left":s=-c+ba;break;case"bottom":s=-e+ba;break;case"top":s=e-ba}switch(t){case"top-right":case"bottom-right":n=-c;break;case"top-left":case"bottom-left":n=c;break;case"left":n=e;break;case"right":n=-e}}else{switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-ba;break;case"bottom-right":case"bottom-left":case"bottom":s=-i+ba}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,s]}function X_(t,e,i,n,s,c,u,p,m,_){t.createArrays(),t.tilePixelRatio=Ze/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const x=t.layers[0].layout,b=t.layers[0]._unevaluatedLayout._values,w={};if(t.textSizeData.kind==="composite"){const{minZoom:C,maxZoom:D}=t.textSizeData;w.compositeTextSizes=[b["text-size"].possiblyEvaluate(new v(C),p),b["text-size"].possiblyEvaluate(new v(D),p)]}if(t.iconSizeData.kind==="composite"){const{minZoom:C,maxZoom:D}=t.iconSizeData;w.compositeIconSizes=[b["icon-size"].possiblyEvaluate(new v(C),p),b["icon-size"].possiblyEvaluate(new v(D),p)]}w.layoutTextSize=b["text-size"].possiblyEvaluate(new v(m+1),p),w.layoutIconSize=b["icon-size"].possiblyEvaluate(new v(m+1),p),w.textMaxSize=b["text-size"].possiblyEvaluate(new v(18),p);const S=x.get("text-rotation-alignment")==="map"&&x.get("symbol-placement")!=="point",M=x.get("text-size");for(const C of t.features){const D=x.get("text-font").evaluate(C,{},p).join(","),U=M.evaluate(C,{},p),q=w.layoutTextSize.evaluate(C,{},p),V=(w.layoutIconSize.evaluate(C,{},p),{horizontal:{},vertical:void 0}),$=C.text;let X,W=[0,0];if($){const me=$.toString(),Se=x.get("text-letter-spacing").evaluate(C,{},p)*Ti,ue=x.get("text-line-height").evaluate(C,{},p)*Ti,ye=Jh(me)?Se:0,xe=x.get("text-anchor").evaluate(C,{},p),we=x.get("text-variable-anchor");if(!we){const Re=x.get("text-radial-offset").evaluate(C,{},p);W=Re?rf(xe,[Re*Ti,Gu]):x.get("text-offset").evaluate(C,{},p).map(Ke=>Ke*Ti)}let Ce=S?"center":x.get("text-justify").evaluate(C,{},p);const pe=x.get("symbol-placement")==="point",De=pe?x.get("text-max-width").evaluate(C,{},p)*Ti:1/0,Ne=Re=>{t.allowVerticalPlacement&&yl(me)&&(V.vertical=Vu($,e,i,s,D,De,ue,xe,Re,ye,W,pr.vertical,!0,q,U))};if(!S&&we){const Re=Ce==="auto"?we.map(ze=>$u(ze)):[Ce];let Ke=!1;for(let ze=0;ze<Re.length;ze++){const $e=Re[ze];if(!V.horizontal[$e])if(Ke)V.horizontal[$e]=V.horizontal[0];else{const Ye=Vu($,e,i,s,D,De,ue,"center",$e,ye,W,pr.horizontal,!1,q,U);Ye&&(V.horizontal[$e]=Ye,Ke=Ye.positionedLines.length===1)}}Ne("left")}else{if(Ce==="auto"&&(Ce=$u(xe)),pe||x.get("text-writing-mode").indexOf("horizontal")>=0||!yl(me)){const Re=Vu($,e,i,s,D,De,ue,xe,Ce,ye,W,pr.horizontal,!1,q,U);Re&&(V.horizontal[Ce]=Re)}Ne(pe?"left":Ce)}}let ce=!1;if(C.icon&&C.icon.name){const me=n[C.icon.name];me&&(X=U_(s[C.icon.name],x.get("icon-offset").evaluate(C,{},p),x.get("icon-anchor").evaluate(C,{},p)),ce=me.sdf,t.sdfIcons===void 0?t.sdfIcons=me.sdf:t.sdfIcons!==me.sdf&&Gt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(me.pixelRatio!==t.pixelRatio||x.get("icon-rotate").constantOr(1)!==0)&&(t.iconsNeedLinear=!0))}const se=of(V.horizontal)||V.vertical;t.iconsInText||(t.iconsInText=!!se&&se.iconsInText),(se||X)&&H_(t,C,V,X,n,w,q,0,W,ce,u,p,_)}c&&t.generateCollisionDebugBuffers(m,t.collisionBoxArray)}function $u(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 H_(t,e,i,n,s,c,u,p,m,_,x,b,w){let S=c.textMaxSize.evaluate(e,{},b);S===void 0&&(S=u);const M=t.layers[0].layout,C=M.get("icon-offset").evaluate(e,{},b),D=of(i.horizontal)||i.vertical,U=w.name==="globe",q=Ti,V=u/q,$=t.tilePixelRatio*S/q,X=(xe=t.overscaling,t.zoom>18&&xe>2&&(xe>>=1),Math.max(Ze/(512*xe),1)*M.get("symbol-spacing")),W=M.get("text-padding")*t.tilePixelRatio,ce=M.get("icon-padding")*t.tilePixelRatio,se=ft(M.get("text-max-angle")),me=M.get("text-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",Se=M.get("icon-rotation-alignment")==="map"&&M.get("symbol-placement")!=="point",ue=M.get("symbol-placement"),ye=X/2;var xe;const we=M.get("icon-text-fit");let Ce;n&&we!=="none"&&(t.allowVerticalPlacement&&i.vertical&&(Ce=Zp(n,i.vertical,we,M.get("icon-text-fit-padding"),C,V)),D&&(n=Zp(n,D,we,M.get("icon-text-fit-padding"),C,V)));const pe=(De,Ne,Re)=>{if(Ne.x<0||Ne.x>=Ze||Ne.y<0||Ne.y>=Ze)return;let Ke=null;if(U){const{x:ze,y:$e,z:Ye}=w.projectTilePoint(Ne.x,Ne.y,Re);Ke={anchor:new On(ze,$e,Ye,0,void 0),up:w.upVector(Re,Ne.x,Ne.y)}}(function(ze,$e,Ye,xt,Je,We,Ft,tt,it,Pt,Rt,Bt,kt,Zt,Ht,oi,Dt,hi,si,Wt,bt,ai,Ot,Ni,li){const Ei=ze.addToLineVertexArray($e,xt);let vi,ji,bi,Xr,Ea,ic,rc,Ff=0,Uf=0,Vf=0,Nf=0,od=-1,sd=-1;const dn={};let jf=tu("");const ys=Ye?Ye.anchor:$e;let ad=0,ld=0;if(it._unevaluatedLayout.getValue("text-radial-offset")===void 0?[ad,ld]=it.layout.get("text-offset").evaluate(bt,{},li).map(rr=>rr*Ti):(ad=it.layout.get("text-radial-offset").evaluate(bt,{},li)*Ti,ld=Gu),ze.allowVerticalPlacement&&Je.vertical){const rr=Je.vertical;if(Ht)ic=Zu(rr),tt&&(rc=Zu(tt));else{const nr=it.layout.get("text-rotate").evaluate(bt,{},li)+90;bi=vh(Pt,ys,$e,Rt,Bt,kt,rr,Zt,nr,oi),tt&&(Xr=vh(Pt,ys,$e,Rt,Bt,kt,tt,hi,nr))}}if(We){const rr=it.layout.get("icon-rotate").evaluate(bt,{},li),nr=it.layout.get("icon-text-fit")!=="none",nc=ef(We,rr,Ot,nr),hd=tt?ef(tt,rr,Ot,nr):void 0;ji=vh(Pt,ys,$e,Rt,Bt,kt,We,hi,rr),Ff=4*nc.length;const Gf=ze.iconSizeData;let xs=null;Gf.kind==="source"?(xs=[Zr*it.layout.get("icon-size").evaluate(bt,{},li)],xs[0]>xo&&Gt(`${ze.layerIds[0]}: Value for "icon-size" is >= ${Xl}. Reduce your "icon-size".`)):Gf.kind==="composite"&&(xs=[Zr*ai.compositeIconSizes[0].evaluate(bt,{},li),Zr*ai.compositeIconSizes[1].evaluate(bt,{},li)],(xs[0]>xo||xs[1]>xo)&&Gt(`${ze.layerIds[0]}: Value for "icon-size" is >= ${Xl}. Reduce your "icon-size".`)),ze.addSymbols(ze.icon,nc,xs,Wt,si,bt,!1,Ye,$e,Ei.lineStartIndex,Ei.lineLength,-1,Ni,li),od=ze.icon.placedSymbolArray.length-1,hd&&(Uf=4*hd.length,ze.addSymbols(ze.icon,hd,xs,Wt,si,bt,pr.vertical,Ye,$e,Ei.lineStartIndex,Ei.lineLength,-1,Ni,li),sd=ze.icon.placedSymbolArray.length-1)}for(const rr in Je.horizontal){const nr=Je.horizontal[rr];vi||(jf=tu(nr.text),Ht?Ea=Zu(nr):vi=vh(Pt,ys,$e,Rt,Bt,kt,nr,Zt,it.layout.get("text-rotate").evaluate(bt,{},li),oi));const nc=nr.positionedLines.length===1;if(Vf+=nf(ze,Ye,$e,nr,Ft,it,Ht,bt,oi,Ei,Je.vertical?pr.horizontal:pr.horizontalOnly,nc?Object.keys(Je.horizontal):[rr],dn,od,ai,Ni,li),nc)break}Je.vertical&&(Nf+=nf(ze,Ye,$e,Je.vertical,Ft,it,Ht,bt,oi,Ei,pr.vertical,["vertical"],dn,sd,ai,Ni,li));let So=-1;const cd=(rr,nr)=>rr?Math.max(rr,nr):nr;So=cd(Ea,So),So=cd(ic,So),So=cd(rc,So);const Tg=So>-1?1:0;ze.glyphOffsetArray.length>=bo.MAX_GLYPHS&&Gt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),bt.sortKey!==void 0&&ze.addToSortKeyRanges(ze.symbolInstances.length,bt.sortKey),ze.symbolInstances.emplaceBack(ys.x,ys.y,ys.z,$e.x,$e.y,dn.right>=0?dn.right:-1,dn.center>=0?dn.center:-1,dn.left>=0?dn.left:-1,dn.vertical>=0?dn.vertical:-1,od,sd,jf,vi!==void 0?vi:ze.collisionBoxArray.length,vi!==void 0?vi+1:ze.collisionBoxArray.length,bi!==void 0?bi:ze.collisionBoxArray.length,bi!==void 0?bi+1:ze.collisionBoxArray.length,ji!==void 0?ji:ze.collisionBoxArray.length,ji!==void 0?ji+1:ze.collisionBoxArray.length,Xr||ze.collisionBoxArray.length,Xr?Xr+1:ze.collisionBoxArray.length,Rt,Vf,Nf,Ff,Uf,Tg,0,ad,ld,So)})(t,Ne,Ke,De,i,n,s,Ce,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,W,me,m,0,ce,Se,C,e,c,_,x,b)};if(ue==="line")for(const De of Yp(e.geometry,0,0,Ze,Ze)){const Ne=N_(De,X,se,i.vertical||D,n,q,$,t.overscaling,Ze);for(const Re of Ne)D&&K_(t,D.text,ye,Re)||pe(De,Re,b)}else if(ue==="line-center"){for(const De of e.geometry)if(De.length>1){const Ne=V_(De,se,i.vertical||D,n,q,$);Ne&&pe(De,Ne,b)}}else if(e.type==="Polygon")for(const De of Pu(e.geometry,0)){const Ne=Z_(De,16);pe(De[0],new On(Ne.x,Ne.y,0,0,void 0),b)}else if(e.type==="LineString")for(const De of e.geometry)pe(De,new On(De[0].x,De[0].y,0,0,void 0),b);else if(e.type==="Point")for(const De of e.geometry)for(const Ne of De)pe([Ne],new On(Ne.x,Ne.y,0,0,void 0),b)}const Xl=255,xo=Xl*Zr;function nf(t,e,i,n,s,c,u,p,m,_,x,b,w,S,M,C,D){const U=function($,X,W,ce,se,me,Se,ue){const ye=[];if(X.positionedLines.length===0)return ye;const xe=ce.layout.get("text-rotate").evaluate(me,{})*Math.PI/180,we=function(Re){const Ke=Re[0],ze=Re[1],$e=Ke*ze;return $e>0?[Ke,-ze]:$e<0?[-Ke,ze]:Ke===0?[ze,Ke]:[ze,-Ke]}(W);let Ce=Math.abs(X.top-X.bottom);for(const Re of X.positionedLines)Ce-=Re.lineOffset;const pe=X.positionedLines.length,De=Ce/pe;let Ne=X.top-W[1];for(let Re=0;Re<pe;++Re){const Ke=X.positionedLines[Re];Ne=j_(X,De,Ne,Re);for(const ze of Ke.positionedGlyphs){if(!ze.rect)continue;const $e=ze.rect||{};let Ye=Op+1,xt=!0,Je=1,We=0;if(ze.imageName){const Ot=Se[ze.imageName];if(!Ot)continue;if(Ot.sdf){Gt("SDF images are not supported in formatted text and will be ignored.");continue}xt=!1,Je=Ot.pixelRatio,Ye=Wi/Je}const Ft=(se||ue)&&ze.vertical,tt=ze.metrics.advance*ze.scale/2,it=ze.metrics,Pt=ze.rect;if(Pt===null)continue;ue&&X.verticalizable&&(We=ze.imageName?tt-ze.metrics.width*ze.scale/2:0);const Rt=se?[ze.x+tt,ze.y]:[0,0];let Bt=[0,0],kt=[0,0],Zt=!1;se||(Ft?(kt=[ze.x+tt+we[0],ze.y+we[1]-We],Zt=!0):Bt=[ze.x+tt+W[0],ze.y+W[1]-We]);const Ht=Pt.w*ze.scale/(Je*(ze.localGlyph?qr:1)),oi=Pt.h*ze.scale/(Je*(ze.localGlyph?qr:1));let Dt,hi,si,Wt;if(Ft){const Ot=ze.y-Ne,Ni=new Le(-tt,tt-Ot),li=-Math.PI/2,Ei=new Le(...kt);Dt=new Le(-tt+Bt[0],Bt[1]),Dt._rotateAround(li,Ni)._add(Ei),Dt.x+=-Ot+tt,Dt.y-=(it.left-Ye)*ze.scale;const vi=ze.imageName?it.advance*ze.scale:Ti*ze.scale,ji=String.fromCharCode(ze.glyph);T_(ji)?Dt.x+=(1-Ye)*ze.scale:E_(ji)?Dt.x+=vi-it.height*ze.scale+(-Ye-1)*ze.scale:Dt.x+=ze.imageName||it.width+2*Ye===Pt.w&&it.height+2*Ye===Pt.h?(vi-oi)/2:(vi-(it.height+2*Ye)*ze.scale)/2,hi=new Le(Dt.x,Dt.y-Ht),si=new Le(Dt.x+oi,Dt.y),Wt=new Le(Dt.x+oi,Dt.y-Ht)}else{const Ot=(it.left-Ye)*ze.scale-tt+Bt[0],Ni=(-it.top-Ye)*ze.scale+Bt[1],li=Ot+Ht,Ei=Ni+oi;Dt=new Le(Ot,Ni),hi=new Le(li,Ni),si=new Le(Ot,Ei),Wt=new Le(li,Ei)}if(xe){let Ot;Ot=se?new Le(0,0):Zt?new Le(we[0],we[1]):new Le(W[0],W[1]),Dt._rotateAround(xe,Ot),hi._rotateAround(xe,Ot),si._rotateAround(xe,Ot),Wt._rotateAround(xe,Ot)}const bt=new Le(0,0),ai=new Le(0,0);ye.push({tl:Dt,tr:hi,bl:si,br:Wt,tex:$e,writingMode:X.writingMode,glyphOffset:Rt,sectionIndex:ze.sectionIndex,isSDF:xt,pixelOffsetTL:bt,pixelOffsetBR:ai,minFontScaleX:0,minFontScaleY:0})}}return ye}(0,n,m,c,u,p,s,t.allowVerticalPlacement),q=t.textSizeData;let V=null;q.kind==="source"?(V=[Zr*c.layout.get("text-size").evaluate(p,{},D)],V[0]>xo&&Gt(`${t.layerIds[0]}: Value for "text-size" is >= ${Xl}. Reduce your "text-size".`)):q.kind==="composite"&&(V=[Zr*M.compositeTextSizes[0].evaluate(p,{},D),Zr*M.compositeTextSizes[1].evaluate(p,{},D)],(V[0]>xo||V[1]>xo)&&Gt(`${t.layerIds[0]}: Value for "text-size" is >= ${Xl}. Reduce your "text-size".`)),t.addSymbols(t.text,U,V,m,u,p,x,e,i,_.lineStartIndex,_.lineLength,S,C,D);for(const $ of b)w[$]=t.text.placedSymbolArray.length-1;return 4*U.length}function of(t){for(const e in t)return t[e];return null}function vh(t,e,i,n,s,c,u,p,m,_){let x=u.top,b=u.bottom,w=u.left,S=u.right;const M=u.collisionPadding;if(M&&(w-=M[0],x-=M[1],S+=M[2],b+=M[3]),m){const C=new Le(w,x),D=new Le(S,x),U=new Le(w,b),q=new Le(S,b),V=ft(m);let $=new Le(0,0);_&&($=new Le(_[0],_[1])),C._rotateAround(V,$),D._rotateAround(V,$),U._rotateAround(V,$),q._rotateAround(V,$),w=Math.min(C.x,D.x,U.x,q.x),S=Math.max(C.x,D.x,U.x,q.x),x=Math.min(C.y,D.y,U.y,q.y),b=Math.max(C.y,D.y,U.y,q.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,w,x,S,b,p,n,s,c),t.length-1}function Zu(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function K_(t,e,i,n){const s=t.compareText;if(e in s){const c=s[e];for(let u=c.length-1;u>=0;u--)if(n.dist(c[u])<i)return!0}else s[e]=[];return s[e].push(n),!1}function sf(t,e){const i=t.fovAboveCenter,n=t.elevation?t.elevation.getMinElevationBelowMSL()*e:0,s=(t._camera.position[2]*t.worldSize-n)/Math.cos(t._pitch),c=Math.sin(i)*s/Math.sin(Math.max(Math.PI/2-t._pitch-i,.01)),u=Math.sin(t._pitch)*c+s;return Math.min(1.01*u,s*(1/t._horizonShift))}function _s(t,e){if(!e.isReprojectedInTileSpace)return{scale:1<<t.z,x:t.x,y:t.y,x2:t.x+1,y2:t.y+1,projection:e};const i=Math.pow(2,-t.z),n=t.x*i,s=(t.x+1)*i,c=t.y*i,u=(t.y+1)*i,p=dr(n),m=dr(s),_=Ci(c),x=Ci(u),b=e.project(p,_),w=e.project(m,_),S=e.project(m,x),M=e.project(p,x);let C=Math.min(b.x,w.x,S.x,M.x),D=Math.min(b.y,w.y,S.y,M.y),U=Math.max(b.x,w.x,S.x,M.x),q=Math.max(b.y,w.y,S.y,M.y);const V=i/16;function $(W,ce,se,me,Se,ue){const ye=(se+Se)/2,xe=(me+ue)/2,we=e.project(dr(ye),Ci(xe)),Ce=Math.max(0,C-we.x,D-we.y,we.x-U,we.y-q);C=Math.min(C,we.x),U=Math.max(U,we.x),D=Math.min(D,we.y),q=Math.max(q,we.y),Ce>V&&($(W,we,se,me,ye,xe),$(we,ce,ye,xe,Se,ue))}$(b,w,n,c,s,c),$(w,S,s,c,s,u),$(S,M,s,u,n,u),$(M,b,n,u,n,c),C-=V,D-=V,U+=V,q+=V;const X=1/Math.max(U-C,q-D);return{scale:X,x:C*X,y:D*X,x2:U*X,y2:q*X,projection:e}}const Y_=jr(new Float32Array(16));class vo{constructor(e){this.spec=e,this.name=e.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(e,i){return{x:0,y:0,z:0}}unproject(e,i){return new zt(0,0)}projectTilePoint(e,i,n){return{x:e,y:i,z:0}}locationPoint(e,i,n=!0){return e._coordinatePoint(e.locationCoordinate(i),n)}pixelsPerMeter(e,i){return $r(1,e)*i}pixelSpaceConversion(e,i,n){return 1}farthestPixelDistance(e){return sf(e,e.pixelsPerMeter)}pointCoordinate(e,i,n,s){const c=e.horizonLineFromTop(!1),u=new Le(i,Math.max(c,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(u,s))}pointCoordinate3D(e,i,n){const s=new Le(i,n);if(e.elevation)return e.elevation.pointCoordinate(s);{const c=this.pointCoordinate(e,s.x,s.y,0);return[c.x,c.y,c.z]}}isPointAboveHorizon(e,i){if(e.elevation)return!this.pointCoordinate3D(e,i.x,i.y);const n=e.horizonLineFromTop();return i.y<n}createInversionMatrix(e,i){return Y_}createTileMatrix(e,i,n){let s,c,u;const p=n.canonical,m=jr(new Float64Array(16));if(this.isReprojectedInTileSpace){const _=_s(p,this);s=1,c=_.x+n.wrap*_.scale,u=_.y,cs(m,m,[s/_.scale,s/_.scale,e.pixelsPerMeter/i])}else s=i/e.zoomScale(p.z),c=(p.x+Math.pow(2,p.z)*n.wrap)*s,u=p.y*s;return Sl(m,m,[c,u,0]),cs(m,m,[s/Ze,s/Ze,1]),m}upVector(e,i,n){return[0,0,1]}upVectorScale(e,i,n){return{metersToTile:1}}}class J_ extends vo{constructor(e){super(e),this.range=[4,7],this.center=e.center||[-96,37.5];const[i,n]=this.parallels=e.parallels||[29.5,45.5],s=Math.sin(ft(i));this.n=(s+Math.sin(ft(n)))/2,this.c=1+s*(2*this.n-s),this.r0=Math.sqrt(this.c)/this.n}project(e,i){const{n,c:s,r0:c}=this,u=ft(e-this.center[0]),p=ft(i),m=Math.sqrt(s-2*n*Math.sin(p))/n;return{x:m*Math.sin(u*n),y:m*Math.cos(u*n)-c,z:0}}unproject(e,i){const{n,c:s,r0:c}=this,u=c+i;let p=Math.atan2(e,Math.abs(u))*Math.sign(u);u*n<0&&(p-=Math.PI*Math.sign(e)*Math.sign(u));const m=ft(this.center[0])*n;p=di(p,-Math.PI-m,Math.PI-m);const _=ut(fi(p/n)+this.center[0],-180,180),x=Math.asin(ut((s-(e*e+u*u)*n*n)/(2*n),-1,1)),b=ut(fi(x),-zi,zi);return new zt(_,b)}}const Hl=1.340264,Kl=-.081106,Yl=893e-6,Jl=.003796,bh=Math.sqrt(3)/2;class Q_ extends vo{project(e,i){i=i/180*Math.PI,e=e/180*Math.PI;const n=Math.asin(bh*Math.sin(i)),s=n*n,c=s*s*s;return{x:.5*(e*Math.cos(n)/(bh*(Hl+3*Kl*s+c*(7*Yl+9*Jl*s)))/Math.PI+.5),y:1-.5*(n*(Hl+Kl*s+c*(Yl+Jl*s))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,s=n*n,c=s*s*s;for(let x,b,w,S=0;S<12&&(b=n*(Hl+Kl*s+c*(Yl+Jl*s))-i,w=Hl+3*Kl*s+c*(7*Yl+9*Jl*s),x=b/w,n=ut(n-x,-Math.PI/3,Math.PI/3),s=n*n,c=s*s*s,!(Math.abs(x)<1e-12));++S);const u=bh*e*(Hl+3*Kl*s+c*(7*Yl+9*Jl*s))/Math.cos(n),p=Math.asin(Math.sin(n)/bh),m=ut(180*u/Math.PI,-180,180),_=ut(180*p/Math.PI,-zi,zi);return new zt(m,_)}}class eg extends vo{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){return{x:.5+e/360,y:.5-i/360,z:0}}unproject(e,i){const n=360*(e-.5),s=ut(360*(.5-i),-zi,zi);return new zt(n,s)}}const wa=Math.PI/2;function wh(t){return Math.tan((wa+t)/2)}class tg extends vo{constructor(e){super(e),this.center=e.center||[0,30];const[i,n]=this.parallels=e.parallels||[30,30];let s=ft(i),c=ft(n);this.southernCenter=s+c<0,this.southernCenter&&(s=-s,c=-c);const u=Math.cos(s),p=wh(s);this.n=s===c?Math.sin(s):Math.log(u/Math.cos(c))/Math.log(wh(c)/p),this.f=u*Math.pow(wh(s),this.n)/this.n}project(e,i){i=ft(i),this.southernCenter&&(i=-i),e=ft(e-this.center[0]);const n=1e-6,{n:s,f:c}=this;c>0?i<-wa+n&&(i=-wa+n):i>wa-n&&(i=wa-n);const u=c/Math.pow(wh(i),s);let p=u*Math.sin(s*e),m=c-u*Math.cos(s*e);return p=.5*(p/Math.PI+.5),m=.5*(m/Math.PI+.5),{x:p,y:this.southernCenter?m:1-m,z:0}}unproject(e,i){e=(2*e-.5)*Math.PI,this.southernCenter&&(i=1-i),i=(2*(1-i)-.5)*Math.PI;const{n,f:s}=this,c=s-i,u=Math.sign(c),p=Math.sign(n)*Math.sqrt(e*e+c*c);let m=Math.atan2(e,Math.abs(c))*u;c*n<0&&(m-=Math.PI*Math.sign(e)*u);const _=ut(fi(m/n)+this.center[0],-180,180),x=ut(fi(2*Math.atan(Math.pow(s/p,1/n))-wa),-zi,zi);return new zt(_,this.southernCenter?-x:x)}}class af extends vo{constructor(e){super(e),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(e,i){return{x:an(e),y:ln(i),z:0}}unproject(e,i){const n=dr(e),s=Ci(i);return new zt(n,s)}}const lf=ft(zi);class ig extends vo{project(e,i){const n=(i=ft(i))*i,s=n*n;return{x:.5*((e=ft(e))*(.8707-.131979*n+s*(s*(.003971*n-.001529*s)-.013791))/Math.PI+.5),y:1-.5*(i*(1.007226+n*(.015085+s*(.028874*n-.044475-.005916*s)))/Math.PI+1),z:0}}unproject(e,i){e=(2*e-.5)*Math.PI;let n=i=(2*(1-i)-1)*Math.PI,s=25,c=0,u=n*n;do{u=n*n;const _=u*u;c=(n*(1.007226+u*(.015085+_*(.028874*u-.044475-.005916*_)))-i)/(1.007226+u*(.045255+_*(.259866*u-.311325-.005916*11*_))),n=ut(n-c,-lf,lf)}while(Math.abs(c)>1e-6&&--s>0);u=n*n;const p=ut(fi(e/(.8707+u*(u*(u*u*u*(.003971-.001529*u)-.013791)-.131979))),-180,180),m=fi(n);return new zt(p,m)}}const cf=ft(zi);class rg extends vo{project(e,i){i=ft(i),e=ft(e);const n=Math.cos(i),s=2/Math.PI,c=Math.acos(n*Math.cos(e/2)),u=Math.sin(c)/c,p=.5*(e*s+2*n*Math.sin(e/2)/u)||0,m=.5*(i+Math.sin(i)/u)||0;return{x:.5*(p/Math.PI+.5),y:1-.5*(m/Math.PI+1),z:0}}unproject(e,i){let n=e=(2*e-.5)*Math.PI,s=i=(2*(1-i)-1)*Math.PI,c=25;const u=1e-6;let p=0,m=0;do{const _=Math.cos(s),x=Math.sin(s),b=2*x*_,w=x*x,S=_*_,M=Math.cos(n/2),C=Math.sin(n/2),D=2*M*C,U=C*C,q=1-S*M*M,V=q?1/q:0,$=q?Math.acos(_*M)*Math.sqrt(1/q):0,X=.5*(2*$*_*C+2*n/Math.PI)-e,W=.5*($*x+s)-i,ce=.5*V*(S*U+$*_*M*w)+1/Math.PI,se=V*(D*b/4-$*x*C),me=.125*V*(b*C-$*x*S*D),Se=.5*V*(w*M+$*U*_)+.5,ue=se*me-Se*ce;p=(W*se-X*Se)/ue,m=(X*me-W*ce)/ue,n=ut(n-p,-Math.PI,Math.PI),s=ut(s-m,-cf,cf)}while((Math.abs(p)>u||Math.abs(m)>u)&&--c>0);return new zt(fi(n),fi(s))}}class hf extends vo{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(ft(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,i){const{scale:n,cosPhi:s}=this;return{x:ft(e)*s*n+.5,y:-Math.sin(ft(i))/s*n+.5,z:0}}unproject(e,i){const{scale:n,cosPhi:s}=this,c=-(i-.5)/n,u=ut(fi((e-.5)/n)/s,-180,180),p=Math.asin(ut(c*s,-1,1)),m=ut(fi(p),-zi,zi);return new zt(u,m)}}class ng extends af{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(e,i,n){const s=Dl(e,i,n);return Jt(s,s,Ll(sn(n))),{x:s[0],y:s[1],z:s[2]}}locationPoint(e,i){const n=aa(i.lat,i.lng),s=Fi([],n),c=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(i),e._centerAltitude):e._centerAltitude;Cl(n,n,s,$r(1,0)*Ze*c);const u=jr(new Float64Array(16));return ls(u,e.pixelMatrix,e.globeMatrix),Jt(n,n,u),new Le(n[0],n[1])}pixelsPerMeter(e,i){return $r(1,0)*i}pixelSpaceConversion(e,i,n){const s=$r(1,e)*i,c=gt($r(1,45)*i,s,n);return this.pixelsPerMeter(e,i)/c}createTileMatrix(e,i,n){const s=mu(sn(n.canonical));return ls(new Float64Array(16),e.globeMatrix,s)}createInversionMatrix(e,i){const{center:n}=e,s=Ll(sn(i));return Kc(s,s,ft(n.lng)),ou(s,s,ft(n.lat)),cs(s,s,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(s)}pointCoordinate(e,i,n,s){return Bd(e,i,n,!0)||new ca(0,0)}pointCoordinate3D(e,i,n){const s=this.pointCoordinate(e,i,n,0);return[s.x,s.y,s.z]}isPointAboveHorizon(e,i){return!Bd(e,i.x,i.y,!1)}farthestPixelDistance(e){const i=function(s,c){const u=s.cameraToCenterDistance,p=s._centerAltitude*c,m=s._camera,_=s._camera.forward(),x=Dn([],ur([],_,-u),[0,0,p]),b=s.worldSize/(2*Math.PI),w=[0,0,-b],S=s.width/s.height,M=Math.tan(s.fovAboveCenter),C=ur([],m.up(),M),D=ur([],m.right(),M*S),U=Fi([],Dn([],Dn([],_,C),D)),q=[];let V;if(new cu(x,U).closestPointOnSphere(w,b,q)){const $=Dn([],q,w),X=Gr([],$,x);V=Math.cos(s.fovAboveCenter)*Ml(X)}else{const $=Gr([],x,w),X=Gr([],w,x);Fi(X,X);const W=Ml($)-b;V=Math.sqrt(W*(W+2*b));const ce=Math.acos(V/(b+W))-Math.acos(br(_,X));V*=Math.cos(ce)}return 1.01*V}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=la(e.zoom);if(n>0){const s=sf(e,$r(1,e.center.lat)*e.worldSize),c=e.worldSize/(2*Math.PI),u=Math.max(e.width,e.height)/e.worldSize*Math.PI;return gt(i,s+c*(1-Math.cos(u)),Math.pow(n,10))}return i}upVector(e,i,n){return Dl(i,n,e,1)}upVectorScale(e){return{metersToTile:Yc(Qc(sn(e)))}}}function uf(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new af(t);case"equirectangular":return new eg(t);case"naturalEarth":return new ig(t);case"equalEarth":return new Q_(t);case"winkelTripel":return new rg(t);case"albers":return i?new hf(t):new J_(t);case"lambertConformalConic":return i?new hf(t):new tg(t);case"globe":return new ng(t)}throw new Error(`Invalid projection name: ${t.name}`)}const og=ch.types,sg=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Th(t,e,i,n,s,c,u,p,m,_,x,b,w){const S=p?Math.min(xo,Math.round(p[0])):0,M=p?Math.min(xo,Math.round(p[1])):0;t.emplaceBack(e,i,Math.round(32*n),Math.round(32*s),c,u,(S<<1)+(m?1:0),M,16*_,16*x,256*b,256*w)}function Eh(t,e,i,n,s,c,u){t.emplaceBack(e,i,n,s,c,u)}function Sh(t,e,i,n,s){t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s),t.emplaceBack(e,i,n,s)}function ag(t){for(const e of t.sections)if(eu(e.text))return!0;return!1}class qu{constructor(e){this.layoutVertexArray=new be,this.indexArray=new je,this.programConfigurations=e,this.segments=new ri,this.dynamicLayoutVertexArray=new Te,this.opacityVertexArray=new Ge,this.placedSymbolArray=new ii,this.globeExtVertexArray=new Ae}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(e,i,n,s){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,m_.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,i),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,g_.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,sg,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,__.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||s)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Ue(qu,"SymbolBuffers");class Wu{constructor(e,i,n){this.layoutVertexArray=new e,this.layoutAttributes=i,this.indexArray=new n,this.segments=new ri,this.collisionVertexArray=new ht,this.collisionVertexArrayExt=new at}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,y_.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,x_.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ue(Wu,"CollisionBuffers");class bo{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(u=>u.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=jr([]),this.placementViewportMatrix=jr([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ru(this.zoom,i["text-size"]),this.iconSizeData=Ru(this.zoom,i["icon-size"]);const n=this.layers[0].layout,s=n.get("symbol-sort-key"),c=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey=c!=="viewport-y"&&s.constantOr(1)!==void 0,this.sortFeaturesByY=(c==="viewport-y"||c==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(u=>pr[u]),this.stateDependentLayerIds=this.layers.filter(u=>u.isStateDependent()).map(u=>u.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new qu(new as(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new qu(new as(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Oi,this.lineVertexArray=new ia,this.symbolInstances=new Ut}calculateGlyphDependencies(e,i,n,s,c){for(let u=0;u<e.length;u++)if(i[e.charCodeAt(u)]=!0,s&&c){const p=Zl[e.charAt(u)];p&&(i[p.charCodeAt(0)]=!0)}}populate(e,i,n,s){const c=this.layers[0],u=c.layout,p=this.projection.name==="globe",m=u.get("text-font"),_=u.get("text-field"),x=u.get("icon-image"),b=(_.value.kind!=="constant"||_.value.value instanceof Bi&&!_.value.value.isEmpty()||_.value.value.toString().length>0)&&(m.value.kind!=="constant"||m.value.value.length>0),w=x.value.kind!=="constant"||!!x.value.value||Object.keys(x.parameters).length>0,S=u.get("symbol-sort-key");if(this.features=[],!b&&!w)return;const M=i.iconDependencies,C=i.glyphDependencies,D=i.availableImages,U=new v(this.zoom);for(const{feature:q,id:V,index:$,sourceLayerIndex:X}of e){const W=c._featureFilter.needGeometry,ce=ps(q,W);if(!c._featureFilter.filter(U,ce,n))continue;if(W||(ce.geometry=Ln(q,n,s)),p&&q.type!==1&&n.z<=5){const ue=ce.geometry,ye=.98078528056,xe=(we,Ce)=>br(Dl(we.x,we.y,n,1),Dl(Ce.x,Ce.y,n,1))<ye;for(let we=0;we<ue.length;we++)ue[we]=gm(ue[we],xe)}let se,me;if(b){const ue=c.getValueAndResolveTokens("text-field",ce,n,D),ye=Bi.factory(ue);ag(ye)&&(this.hasRTLText=!0),(!this.hasRTLText||f()==="unavailable"||this.hasRTLText&&y.isParsed())&&(se=w_(ye,c,ce))}if(w){const ue=c.getValueAndResolveTokens("icon-image",ce,n,D);me=ue instanceof Yi?ue:Yi.fromString(ue)}if(!se&&!me)continue;const Se=this.sortFeaturesByKey?S.evaluate(ce,{},n):void 0;if(this.features.push({id:V,text:se,icon:me,index:$,sourceLayerIndex:X,geometry:ce.geometry,properties:q.properties,type:og[q.type],sortKey:Se}),me&&(M[me.name]=!0),se){const ue=m.evaluate(ce,{},n).join(","),ye=u.get("text-rotation-alignment")==="map"&&u.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(pr.vertical)>=0;for(const xe of se.sections)if(xe.image)M[xe.image.name]=!0;else{const we=yl(se.toString()),Ce=xe.fontStack||ue,pe=C[Ce]=C[Ce]||{};this.calculateGlyphDependencies(xe.text,pe,ye,this.allowVerticalPlacement,we)}}}u.get("symbol-placement")==="line"&&(this.features=function(q){const V={},$={},X=[];let W=0;function ce(ue){X.push(q[ue]),W++}function se(ue,ye,xe){const we=$[ue];return delete $[ue],$[ye]=we,X[we].geometry[0].pop(),X[we].geometry[0]=X[we].geometry[0].concat(xe[0]),we}function me(ue,ye,xe){const we=V[ye];return delete V[ye],V[ue]=we,X[we].geometry[0].shift(),X[we].geometry[0]=xe[0].concat(X[we].geometry[0]),we}function Se(ue,ye,xe){const we=xe?ye[0][ye[0].length-1]:ye[0][0];return`${ue}:${we.x}:${we.y}`}for(let ue=0;ue<q.length;ue++){const ye=q[ue],xe=ye.geometry,we=ye.text?ye.text.toString():null;if(!we){ce(ue);continue}const Ce=Se(we,xe),pe=Se(we,xe,!0);if(Ce in $&&pe in V&&$[Ce]!==V[pe]){const De=me(Ce,pe,xe),Ne=se(Ce,pe,X[De].geometry);delete V[Ce],delete $[pe],$[Se(we,X[Ne].geometry,!0)]=Ne,X[De].geometry=null}else Ce in $?se(Ce,pe,xe):pe in V?me(Ce,pe,xe):(ce(ue),V[Ce]=W-1,$[pe]=W-1)}return X.filter(ue=>ue.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((q,V)=>q.sortKey-V.sortKey)}update(e,i,n,s){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,i,this.layers,n,s),this.icon.programConfigurations.updatePaintArrays(e,i,this.layers,n,s))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=uf(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,i){const n=this.lineVertexArray.length;if(e.segment!==void 0)for(const{x:s,y:c}of i)this.lineVertexArray.emplaceBack(s,c);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,i,n,s,c,u,p,m,_,x,b,w,S,M){const C=e.indexArray,D=e.layoutVertexArray,U=e.globeExtVertexArray,q=e.segments.prepareSegment(4*i.length,D,C,this.canOverlap?u.sortKey:void 0),V=this.glyphOffsetArray.length,$=q.vertexLength,X=this.allowVerticalPlacement&&p===pr.vertical?Math.PI/2:0,W=u.text&&u.text.sections;for(let se=0;se<i.length;se++){const{tl:me,tr:Se,bl:ue,br:ye,tex:xe,pixelOffsetTL:we,pixelOffsetBR:Ce,minFontScaleX:pe,minFontScaleY:De,glyphOffset:Ne,isSDF:Re,sectionIndex:Ke}=i[se],ze=q.vertexLength,$e=Ne[1];if(Th(D,_.x,_.y,me.x,$e+me.y,xe.x,xe.y,n,Re,we.x,we.y,pe,De),Th(D,_.x,_.y,Se.x,$e+Se.y,xe.x+xe.w,xe.y,n,Re,Ce.x,we.y,pe,De),Th(D,_.x,_.y,ue.x,$e+ue.y,xe.x,xe.y+xe.h,n,Re,we.x,Ce.y,pe,De),Th(D,_.x,_.y,ye.x,$e+ye.y,xe.x+xe.w,xe.y+xe.h,n,Re,Ce.x,Ce.y,pe,De),m){const{x:Ye,y:xt,z:Je}=m.anchor,[We,Ft,tt]=m.up;Eh(U,Ye,xt,Je,We,Ft,tt),Eh(U,Ye,xt,Je,We,Ft,tt),Eh(U,Ye,xt,Je,We,Ft,tt),Eh(U,Ye,xt,Je,We,Ft,tt),Sh(e.dynamicLayoutVertexArray,Ye,xt,Je,X)}else Sh(e.dynamicLayoutVertexArray,_.x,_.y,_.z,X);C.emplaceBack(ze,ze+1,ze+2),C.emplaceBack(ze+1,ze+2,ze+3),q.vertexLength+=4,q.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Ne[0]),se!==i.length-1&&Ke===i[se+1].sectionIndex||e.programConfigurations.populatePaintArrays(D.length,u,u.index,{},S,M,W&&W[Ke])}const ce=m?m.anchor:_;e.placedSymbolArray.emplaceBack(ce.x,ce.y,ce.z,_.x,_.y,V,this.glyphOffsetArray.length-V,$,x,b,_.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],p,0,!1,0,w,0)}_commitLayoutVertex(e,i,n,s,c,u,p){e.emplaceBack(i,n,s,c,u,Math.round(p.x),Math.round(p.y))}_addCollisionDebugVertices(e,i,n,s,c,u,p){const m=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),_=m.vertexLength,x=p.tileAnchorX,b=p.tileAnchorY;for(let S=0;S<4;S++)n.collisionVertexArray.emplaceBack(0,0,0,0);n.collisionVertexArrayExt.emplaceBack(i,-e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(i,e.padding,-e.padding),n.collisionVertexArrayExt.emplaceBack(i,e.padding,e.padding),n.collisionVertexArrayExt.emplaceBack(i,-e.padding,e.padding),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,b,new Le(e.x1,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,b,new Le(e.x2,e.y1)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,b,new Le(e.x2,e.y2)),this._commitLayoutVertex(n.layoutVertexArray,s,c,u,x,b,new Le(e.x1,e.y2)),m.vertexLength+=4;const w=n.indexArray;w.emplaceBack(_,_+1),w.emplaceBack(_+1,_+2),w.emplaceBack(_+2,_+3),w.emplaceBack(_+3,_),m.primitiveLength+=4}_addTextDebugCollisionBoxes(e,i,n,s,c,u){for(let p=s;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,u,i,p);this._addCollisionDebugVertices(m,_,this.textCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}_addIconDebugCollisionBoxes(e,i,n,s,c,u){for(let p=s;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,u.placedIconSymbolIndex);this._addCollisionDebugVertices(m,_,this.iconCollisionBox,m.projectedAnchorX,m.projectedAnchorY,m.projectedAnchorZ,u)}}generateCollisionDebugBuffers(e,i){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Wu(Ve,Cp.members,xi),this.iconCollisionBox=new Wu(Ve,Cp.members,xi);const n=fa(this.iconSizeData,e),s=fa(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){const u=this.symbolInstances.get(c);this._addTextDebugCollisionBoxes(s,e,i,u.textBoxStartIndex,u.textBoxEndIndex,u),this._addTextDebugCollisionBoxes(s,e,i,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,i,u.iconBoxStartIndex,u.iconBoxEndIndex,u),this._addIconDebugCollisionBoxes(n,e,i,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u)}}getSymbolInstanceTextSize(e,i,n,s){const c=this.text.placedSymbolArray.get(i.rightJustifiedTextSymbolIndex>=0?i.rightJustifiedTextSymbolIndex:i.centerJustifiedTextSymbolIndex>=0?i.centerJustifiedTextSymbolIndex:i.leftJustifiedTextSymbolIndex>=0?i.leftJustifiedTextSymbolIndex:i.verticalPlacedTextSymbolIndex>=0?i.verticalPlacedTextSymbolIndex:s),u=ph(this.textSizeData,e,c)/Ti;return this.tilePixelRatio*u}getSymbolInstanceIconSize(e,i,n){const s=this.icon.placedSymbolArray.get(n),c=ph(this.iconSizeData,e,s);return this.tilePixelRatio*c}_commitDebugCollisionVertexUpdate(e,i,n){e.emplaceBack(i,-n,-n),e.emplaceBack(i,n,-n),e.emplaceBack(i,n,n),e.emplaceBack(i,-n,n)}_updateTextDebugCollisionBoxes(e,i,n,s,c,u){for(let p=s;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceTextSize(e,u,i,p);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,_,m.padding)}}_updateIconDebugCollisionBoxes(e,i,n,s,c,u){for(let p=s;p<c;p++){const m=n.get(p),_=this.getSymbolInstanceIconSize(e,i,u);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,_,m.padding)}}updateCollisionDebugBuffers(e,i){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const n=fa(this.iconSizeData,e),s=fa(this.textSizeData,e);for(let c=0;c<this.symbolInstances.length;c++){const u=this.symbolInstances.get(c);this._updateTextDebugCollisionBoxes(s,e,i,u.textBoxStartIndex,u.textBoxEndIndex,u),this._updateTextDebugCollisionBoxes(s,e,i,u.verticalTextBoxStartIndex,u.verticalTextBoxEndIndex,u),this._updateIconDebugCollisionBoxes(n,e,i,u.iconBoxStartIndex,u.iconBoxEndIndex,u.placedIconSymbolIndex),this._updateIconDebugCollisionBoxes(n,e,i,u.verticalIconBoxStartIndex,u.verticalIconBoxEndIndex,u.placedIconSymbolIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,i,n,s,c,u,p,m,_){const x={};if(i<n){const{x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$,featureIndex:X}=e.get(i);x.textBox={x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$},x.textFeatureIndex=X}if(s<c){const{x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$,featureIndex:X}=e.get(s);x.verticalTextBox={x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$},x.verticalTextFeatureIndex=X}if(u<p){const{x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$,featureIndex:X}=e.get(u);x.iconBox={x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$},x.iconFeatureIndex=X}if(m<_){const{x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$,featureIndex:X}=e.get(m);x.verticalIconBox={x1:b,y1:w,x2:S,y2:M,padding:C,projectedAnchorX:D,projectedAnchorY:U,projectedAnchorZ:q,tileAnchorX:V,tileAnchorY:$},x.verticalIconFeatureIndex=X}return x}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let i=0;i<this.symbolInstances.length;i++){const n=this.symbolInstances.get(i);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,n.textBoxStartIndex,n.textBoxEndIndex,n.verticalTextBoxStartIndex,n.verticalTextBoxEndIndex,n.iconBoxStartIndex,n.iconBoxEndIndex,n.verticalIconBoxStartIndex,n.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,i){const n=e.placedSymbolArray.get(i),s=n.vertexStartIndex+4*n.numGlyphs;for(let c=n.vertexStartIndex;c<s;c+=4)e.indexArray.emplaceBack(c,c+1,c+2),e.indexArray.emplaceBack(c+1,c+2,c+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const i=Math.sin(e),n=Math.cos(e),s=[],c=[],u=[];for(let p=0;p<this.symbolInstances.length;++p){u.push(p);const m=this.symbolInstances.get(p);s.push(0|Math.round(i*m.tileAnchorX+n*m.tileAnchorY)),c.push(m.featureIndex)}return u.sort((p,m)=>s[p]-s[m]||c[m]-c[p]),u}addToSortKeyRanges(e,i){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===i?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:i,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const i of this.symbolInstanceIndexes){const n=this.symbolInstances.get(i);this.featureSortOrder.push(n.featureIndex);const{rightJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:c,leftJustifiedTextSymbolIndex:u,verticalPlacedTextSymbolIndex:p,placedIconSymbolIndex:m,verticalPlacedIconSymbolIndex:_}=n;s>=0&&this.addIndicesForPlacedSymbol(this.text,s),c>=0&&c!==s&&this.addIndicesForPlacedSymbol(this.text,c),u>=0&&u!==c&&u!==s&&this.addIndicesForPlacedSymbol(this.text,u),p>=0&&this.addIndicesForPlacedSymbol(this.text,p),m>=0&&this.addIndicesForPlacedSymbol(this.icon,m),_>=0&&this.addIndicesForPlacedSymbol(this.icon,_)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ue(bo,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),bo.MAX_GLYPHS=65535,bo.addDynamicAttributes=Sh;const lg=new j({"symbol-placement":new I(fe.layout_symbol["symbol-placement"]),"symbol-spacing":new I(fe.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new I(fe.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new L(fe.layout_symbol["symbol-sort-key"]),"symbol-z-order":new I(fe.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new I(fe.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new I(fe.layout_symbol["icon-ignore-placement"]),"icon-optional":new I(fe.layout_symbol["icon-optional"]),"icon-rotation-alignment":new I(fe.layout_symbol["icon-rotation-alignment"]),"icon-size":new L(fe.layout_symbol["icon-size"]),"icon-text-fit":new I(fe.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new I(fe.layout_symbol["icon-text-fit-padding"]),"icon-image":new L(fe.layout_symbol["icon-image"]),"icon-rotate":new L(fe.layout_symbol["icon-rotate"]),"icon-padding":new I(fe.layout_symbol["icon-padding"]),"icon-keep-upright":new I(fe.layout_symbol["icon-keep-upright"]),"icon-offset":new L(fe.layout_symbol["icon-offset"]),"icon-anchor":new L(fe.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new I(fe.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new I(fe.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new I(fe.layout_symbol["text-rotation-alignment"]),"text-field":new L(fe.layout_symbol["text-field"]),"text-font":new L(fe.layout_symbol["text-font"]),"text-size":new L(fe.layout_symbol["text-size"]),"text-max-width":new L(fe.layout_symbol["text-max-width"]),"text-line-height":new L(fe.layout_symbol["text-line-height"]),"text-letter-spacing":new L(fe.layout_symbol["text-letter-spacing"]),"text-justify":new L(fe.layout_symbol["text-justify"]),"text-radial-offset":new L(fe.layout_symbol["text-radial-offset"]),"text-variable-anchor":new I(fe.layout_symbol["text-variable-anchor"]),"text-anchor":new L(fe.layout_symbol["text-anchor"]),"text-max-angle":new I(fe.layout_symbol["text-max-angle"]),"text-writing-mode":new I(fe.layout_symbol["text-writing-mode"]),"text-rotate":new L(fe.layout_symbol["text-rotate"]),"text-padding":new I(fe.layout_symbol["text-padding"]),"text-keep-upright":new I(fe.layout_symbol["text-keep-upright"]),"text-transform":new L(fe.layout_symbol["text-transform"]),"text-offset":new L(fe.layout_symbol["text-offset"]),"text-allow-overlap":new I(fe.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new I(fe.layout_symbol["text-ignore-placement"]),"text-optional":new I(fe.layout_symbol["text-optional"])});var Xu={paint:new j({"icon-opacity":new L(fe.paint_symbol["icon-opacity"]),"icon-color":new L(fe.paint_symbol["icon-color"]),"icon-halo-color":new L(fe.paint_symbol["icon-halo-color"]),"icon-halo-width":new L(fe.paint_symbol["icon-halo-width"]),"icon-halo-blur":new L(fe.paint_symbol["icon-halo-blur"]),"icon-translate":new I(fe.paint_symbol["icon-translate"]),"icon-translate-anchor":new I(fe.paint_symbol["icon-translate-anchor"]),"text-opacity":new L(fe.paint_symbol["text-opacity"]),"text-color":new L(fe.paint_symbol["text-color"],{runtimeType:Zi,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new L(fe.paint_symbol["text-halo-color"]),"text-halo-width":new L(fe.paint_symbol["text-halo-width"]),"text-halo-blur":new L(fe.paint_symbol["text-halo-blur"]),"text-translate":new I(fe.paint_symbol["text-translate"]),"text-translate-anchor":new I(fe.paint_symbol["text-translate-anchor"])}),layout:lg};class df{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:Kn,this.defaultValue=e}evaluate(e){if(e.formattedSection){const i=this.defaultValue.property.overrides;if(i&&i.hasOverride(e.formattedSection))return i.getOverride(e.formattedSection)}return e.feature&&e.featureState?this.defaultValue.evaluate(e.feature,e.featureState):this.defaultValue.property.specification.default}eachChild(e){this.defaultValue.isConstant()||e(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Ue(df,"FormatSectionOverride",{omit:["defaultValue"]});class Mh extends Nr{constructor(e){super(e,Xu)}recalculate(e,i){super.recalculate(e,i),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const s=[];for(const c of n)s.indexOf(c)<0&&s.push(c);this.layout._values["text-writing-mode"]=s}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,i,n,s){const c=this.layout.get(e).evaluate(i,{},n,s),u=this._unevaluatedLayout._values[e];return u.isDataDriven()||lo(u.value)||!c?c:function(p,m){return m.replace(/{([^{}]+)}/g,(_,x)=>x in p?String(p[x]):"")}(i.properties,c)}createBucket(e){return new bo(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Xu.paint.overridableProperties){if(!Mh.hasPaintOverride(this.layout,e))continue;const i=this.paint.get(e),n=new df(i),s=new Xs(n,i.property.specification);let c=null;c=i.value.kind==="constant"||i.value.kind==="source"?new al("source",s):new Jo("composite",s,i.value.zoomStops,i.value._interpolationType),this.paint._values[e]=new B(i.property,c,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,n){return!(!this.layout||i.isDataDriven()||n.isDataDriven())&&Mh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,i){const n=e.get("text-field"),s=Xu.paint.properties[i];let c=!1;const u=p=>{for(const m of p)if(s.overrides&&s.overrides.hasOverride(m))return void(c=!0)};if(n.value.kind==="constant"&&n.value.value instanceof Bi)u(n.value.value.sections);else if(n.value.kind==="source"){const p=_=>{c||(_ instanceof wn&&Xt(_.value)===Ro?u(_.value.sections):_ instanceof tn?u(_.sections):_.eachChild(p))},m=n.value;m._styleExpression&&p(m._styleExpression.expression)}return c}getProgramConfiguration(e){return new _o(this,e)}}var cg={paint:new j({"background-color":new I(fe.paint_background["background-color"]),"background-pattern":new I(fe.paint_background["background-pattern"]),"background-opacity":new I(fe.paint_background["background-opacity"])})},hg={paint:new j({"raster-opacity":new I(fe.paint_raster["raster-opacity"]),"raster-hue-rotate":new I(fe.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new I(fe.paint_raster["raster-brightness-min"]),"raster-brightness-max":new I(fe.paint_raster["raster-brightness-max"]),"raster-saturation":new I(fe.paint_raster["raster-saturation"]),"raster-contrast":new I(fe.paint_raster["raster-contrast"]),"raster-resampling":new I(fe.paint_raster["raster-resampling"]),"raster-fade-duration":new I(fe.paint_raster["raster-fade-duration"])})};class ug extends Nr{constructor(e){super(e,{}),this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var dg={paint:new j({"sky-type":new I(fe.paint_sky["sky-type"]),"sky-atmosphere-sun":new I(fe.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new I(fe.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new I(fe.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new I(fe.paint_sky["sky-gradient-radius"]),"sky-gradient":new N(fe.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new I(fe.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new I(fe.paint_sky["sky-atmosphere-color"]),"sky-opacity":new I(fe.paint_sky["sky-opacity"])})};function Hu(t,e,i){const n=[0,0,1],s=zd([]);return kd(s,s,i?-ft(t)+Math.PI:ft(t)),Pd(s,s,-ft(e)),Md(n,n,s),Fi(n,n)}const pg={circle:class extends Nr{constructor(t){super(t,Em)}createBucket(t){return new bu(t)}queryRadius(t){const e=t;return ha("circle-radius",this,e)+ha("circle-stroke-width",this,e)+ih(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,n,s,c,u,p){const m=ep(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),_=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return tp(t,n,c,u,p,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",m,_)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new _o(this,t)}},heatmap:class extends Nr{createBucket(t){return new rp(t)}constructor(t){super(t,Im),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Su({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return ha("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,n,s,c,u,p){const m=this.paint.get("heatmap-radius").evaluate(e,i);return tp(t,n,c,u,p,!0,!0,new Le(0,0),m)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new _o(this,t)}},hillshade:class extends Nr{constructor(t){super(t,Cm)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Nr{constructor(t){super(t,Zm)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new _o(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];i.value.kind==="constant"&&i.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new ah(t)}queryRadius(){return ih(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,n,s,c){return!t.queryGeometry.isAboveHorizon&&Hd(Qd(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends Nr{constructor(t){super(t,a_)}createBucket(t){return new jl(t)}queryRadius(){return ih(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new _o(this,t)}queryIntersectsFeature(t,e,i,n,s,c,u,p,m){const _=ep(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),x=this.paint.get("fill-extrusion-height").evaluate(e,i),b=this.paint.get("fill-extrusion-base").evaluate(e,i),w=[0,0],S=p&&c.elevation,M=c.elevation?c.elevation.exaggeration():1,C=t.tile.getBucket(this);if(S&&C instanceof jl){const $=C.centroidVertexArray,X=m+1;X<$.length&&(w[0]=$.geta_centroid_pos0(X),w[1]=$.geta_centroid_pos1(X))}if(w[0]===0&&w[1]===1)return!1;c.projection.name==="globe"&&(n=bp([n],[new Le(0,0),new Le(Ze,Ze)],t.tileID.canonical).map($=>$.polygon).flat());const D=S?p:null,[U,q]=function($,X,W,ce,se,me,Se,ue,ye,xe,we){return $.projection.name==="globe"?function(Ce,pe,De,Ne,Re,Ke,ze,$e,Ye,xt,Je){const We=[],Ft=[],tt=Ce.projection.upVectorScale(Je,Ce.center.lat,Ce.worldSize).metersToTile,it=[0,0,0,1],Pt=[0,0,0,1],Rt=(kt,Zt,Ht,oi)=>{kt[0]=Zt,kt[1]=Ht,kt[2]=oi,kt[3]=1},Bt=vp();De>0&&(De+=Bt),Ne+=Bt;for(const kt of pe){const Zt=[],Ht=[];for(const oi of kt){const Dt=oi.x+Re.x,hi=oi.y+Re.y,si=Ce.projection.projectTilePoint(Dt,hi,Je),Wt=Ce.projection.upVector(Je,oi.x,oi.y);let bt=De,ai=Ne;if(ze){const Ot=Sp(Dt,hi,De,Ne,ze,$e,Ye,xt);bt+=Ot.base,ai+=Ot.top}De!==0?Rt(it,si.x+Wt[0]*tt*bt,si.y+Wt[1]*tt*bt,si.z+Wt[2]*tt*bt):Rt(it,si.x,si.y,si.z),Rt(Pt,si.x+Wt[0]*tt*ai,si.y+Wt[1]*tt*ai,si.z+Wt[2]*tt*ai),Jt(it,it,Ke),Jt(Pt,Pt,Ke),Zt.push(new pa(it[0],it[1],it[2])),Ht.push(new pa(Pt[0],Pt[1],Pt[2]))}We.push(Zt),Ft.push(Ht)}return[We,Ft]}($,X,W,ce,se,me,Se,ue,ye,xe,we):Se?function(Ce,pe,De,Ne,Re,Ke,ze,$e,Ye){const xt=[],Je=[],We=[0,0,0,1];for(const Ft of Ce){const tt=[],it=[];for(const Pt of Ft){const Rt=Pt.x+Ne.x,Bt=Pt.y+Ne.y,kt=Sp(Rt,Bt,pe,De,Ke,ze,$e,Ye);We[0]=Rt,We[1]=Bt,We[2]=kt.base,We[3]=1,hs(We,We,Re),We[3]=Math.max(We[3],1e-5);const Zt=new pa(We[0]/We[3],We[1]/We[3],We[2]/We[3]);We[0]=Rt,We[1]=Bt,We[2]=kt.top,We[3]=1,hs(We,We,Re),We[3]=Math.max(We[3],1e-5);const Ht=new pa(We[0]/We[3],We[1]/We[3],We[2]/We[3]);tt.push(Zt),it.push(Ht)}xt.push(tt),Je.push(it)}return[xt,Je]}(X,W,ce,se,me,Se,ue,ye,xe):function(Ce,pe,De,Ne,Re){const Ke=[],ze=[],$e=Re[8]*pe,Ye=Re[9]*pe,xt=Re[10]*pe,Je=Re[11]*pe,We=Re[8]*De,Ft=Re[9]*De,tt=Re[10]*De,it=Re[11]*De;for(const Pt of Ce){const Rt=[],Bt=[];for(const kt of Pt){const Zt=kt.x+Ne.x,Ht=kt.y+Ne.y,oi=Re[0]*Zt+Re[4]*Ht+Re[12],Dt=Re[1]*Zt+Re[5]*Ht+Re[13],hi=Re[2]*Zt+Re[6]*Ht+Re[14],si=Re[3]*Zt+Re[7]*Ht+Re[15],Wt=oi+$e,bt=Dt+Ye,ai=hi+xt,Ot=Math.max(si+Je,1e-5),Ni=oi+We,li=Dt+Ft,Ei=hi+tt,vi=Math.max(si+it,1e-5);Rt.push(new pa(Wt/Ot,bt/Ot,ai/Ot)),Bt.push(new pa(Ni/vi,li/vi,Ei/vi))}Ke.push(Rt),ze.push(Bt)}return[Ke,ze]}(X,W,ce,se,me)}(c,n,b,x,_,u,D,w,M,c.center.lat,t.tileID.canonical),V=t.queryGeometry;return function($,X,W){let ce=1/0;Hd(W,X)&&(ce=Ep(W,X[0]));for(let se=0;se<X.length;se++){const me=X[se],Se=$[se];for(let ue=0;ue<me.length-1;ue++){const ye=me[ue],xe=[ye,me[ue+1],Se[ue+1],Se[ue],ye];Xd(W,xe)&&(ce=Math.min(ce,Ep(W,xe)))}}return ce!==1/0&&ce}(U,q,V.isPointQuery()?V.screenBounds:V.screenGeometry)}},line:class extends Nr{constructor(t){super(t,Mp),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(t){if(t==="line-gradient"){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Xa,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=Ap.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new dh(t)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(t){return new _o(this,t)}queryRadius(t){const e=t,i=Ip(ha("line-width",this,e),ha("line-gap-width",this,e)),n=ha("line-offset",this,e);return i/2+Math.abs(n)+ih(this.paint.get("line-translate"))}queryIntersectsFeature(t,e,i,n,s,c){if(t.queryGeometry.isAboveHorizon)return!1;const u=Qd(t.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),c.angle,t.pixelToTileUnitsFactor),p=t.pixelToTileUnitsFactor/2*Ip(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),m=this.paint.get("line-offset").evaluate(e,i);return m&&(n=function(_,x){const b=[],w=new Le(0,0);for(let S=0;S<_.length;S++){const M=_[S],C=[];for(let D=0;D<M.length;D++){const U=M[D],q=M[D+1],V=D===0?w:U.sub(M[D-1])._unit()._perp(),$=D===M.length-1?w:q.sub(U)._unit()._perp(),X=V._add($)._unit();X._mult(1/(X.x*$.x+X.y*$.y)),C.push(X._mult(x)._add(U))}b.push(C)}return b}(n,m*t.pixelToTileUnitsFactor)),function(_,x,b){for(let w=0;w<x.length;w++){const S=x[w];if(_.length>=3){for(let M=0;M<S.length;M++)if(fs(_,S[M]))return!0}if(vm(_,S,b))return!0}return!1}(u,n,p)}isTileClipped(){return!0}},symbol:Mh,background:class extends Nr{constructor(t){super(t,cg)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Nr{constructor(t){super(t,hg)}getProgramIds(){return["raster"]}},sky:class extends Nr{constructor(t){super(t,dg),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){t==="sky-gradient"?this._updateColorRamp():t!=="sky-atmosphere-sun"&&t!=="sky-atmosphere-halo-color"&&t!=="sky-atmosphere-color"&&t!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=Su({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(t){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const e=t.style.light.properties.get("position");return this._lightPosition.azimuthal!==e.azimuthal||this._lightPosition.polar!==e.polar}return!1}getCenter(t,e){if(this.paint.get("sky-type")==="atmosphere"){const n=this.paint.get("sky-atmosphere-sun"),s=!n,c=t.style.light,u=c.properties.get("position");return s&&c.properties.get("anchor")==="viewport"&&Gt("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),s?Hu(u.azimuthal,90-u.polar,e):Hu(n[0],90-n[1],e)}const i=this.paint.get("sky-gradient-center");return Hu(i[0],90-i[1],e)}is3D(){return!1}isSky(){return!0}markSkyboxValid(t){this._skyboxInvalidated=!1,this._lightPosition=t.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const t=this.paint.get("sky-type");return t==="atmosphere"?["skyboxCapture","skybox"]:t==="gradient"?["skyboxGradient"]:null}}};class Ql{constructor(e,i,n,s){this.context=e,this.format=n,this.texture=e.gl.createTexture(),this.update(i,s)}update(e,i,n){const{width:s,height:c}=e,{context:u}=this,{gl:p}=u,{HTMLImageElement:m,HTMLCanvasElement:_,HTMLVideoElement:x,ImageData:b,ImageBitmap:w}=ve;if(p.bindTexture(p.TEXTURE_2D,this.texture),u.pixelStoreUnpackFlipY.set(!1),u.pixelStoreUnpack.set(1),u.pixelStoreUnpackPremultiplyAlpha.set(this.format===p.RGBA&&(!i||i.premultiply!==!1)),n||this.size&&this.size[0]===s&&this.size[1]===c){const{x:S,y:M}=n||{x:0,y:0};e instanceof m||e instanceof _||e instanceof x||e instanceof b||w&&e instanceof w?p.texSubImage2D(p.TEXTURE_2D,0,S,M,p.RGBA,p.UNSIGNED_BYTE,e):p.texSubImage2D(p.TEXTURE_2D,0,S,M,s,c,p.RGBA,p.UNSIGNED_BYTE,e.data)}else this.size=[s,c],e instanceof m||e instanceof _||e instanceof x||e instanceof b||w&&e instanceof w?p.texImage2D(p.TEXTURE_2D,0,this.format,this.format,p.UNSIGNED_BYTE,e):p.texImage2D(p.TEXTURE_2D,0,this.format,s,c,0,this.format,p.UNSIGNED_BYTE,e.data);this.useMipmap=!!(i&&i.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&p.generateMipmap(p.TEXTURE_2D)}bind(e,i){const{context:n}=this,{gl:s}=n;s.bindTexture(s.TEXTURE_2D,this.texture),e!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_NEAREST:e),this.filter=e),i!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,i),this.wrap=i)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class fg{constructor(e){this._callback=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class mg{constructor(){this.tasks={},this.taskQueue=[],mn(["process"],this),this.invoker=new fg(this.process),this.nextId=0}add(e,i){const n=this.nextId++,s=function({type:c,isSymbolTile:u,zoom:p}){return p=p||0,c==="message"?0:c!=="maybePrepare"||u?c!=="parseTile"||u?c==="parseTile"&&u?300-p:c==="maybePrepare"&&u?400-p:500:200-p:100-p}(i);if(s===0){Ir();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:i,priority:s,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){Ir();try{if(this.taskQueue=this.taskQueue.filter(n=>!!this.tasks[n]),!this.taskQueue.length)return;const e=this.pick();if(e===null)return;const i=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!i)return;i.fn()}finally{}}pick(){let e=null,i=1/0;for(let s=0;s<this.taskQueue.length;s++){const c=this.tasks[this.taskQueue[s]];c.priority<i&&(i=c.priority,e=s)}if(e===null)return null;const n=this.taskQueue[e];return this.taskQueue.splice(e,1),n}remove(){this.invoker.remove()}}class pf{constructor(e){this._stringToNumber={},this._numberToString=[];for(let i=0;i<e.length;i++){const n=e[i];this._stringToNumber[n]=i,this._numberToString[i]=n}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}const _g=["tile","layer","source","sourceLayer","state"];class ff{constructor(e,i,n,s,c){this.type="Feature",this._vectorTileFeature=e,this._z=i,this._x=n,this._y=s,this.properties=e.properties,this.id=c}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};this.id!==void 0&&(e.id=this.id);for(const i of _g)this[i]!==void 0&&(e[i]=this[i]);return e}}const Er=32,cn=33,wo=new Uint16Array(8184);for(let t=0;t<2046;t++){let e=t+2,i=0,n=0,s=0,c=0,u=0,p=0;for(1&e?s=c=u=Er:i=n=p=Er;(e>>=1)>1;){const _=i+s>>1,x=n+c>>1;1&e?(s=i,c=n,i=u,n=p):(i=s,n=c,s=u,c=p),u=_,p=x}const m=4*t;wo[m+0]=i,wo[m+1]=n,wo[m+2]=s,wo[m+3]=c}const hn=new Uint16Array(2178),To=new Uint8Array(1089),Ah=new Uint16Array(1089);function mf(t){return t===0?-.03125:t===32?.03125:0}var _f=te([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const gf={type:2,extent:Ze,loadGeometry:()=>[[new Le(0,0),new Le(Ze+1,0),new Le(Ze+1,Ze+1),new Le(0,Ze+1),new Le(0,0)]]};class Ku{constructor(e,i,n,s,c){this.tileID=e,this.uid=jn(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=c,this.expiredRequestCount=0,this.state="loading",s&&s.transform&&(this.projection=s.transform.projection)}registerFadeDuration(e){const i=e+this.timeAdded;i<Cr.now()||this.fadeEndTime&&i<this.fadeEndTime||(this.fadeEndTime=i)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=_s(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,i,n){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(s,c){const u={};if(!c)return u;for(const p of s){const m=p.layerIds.map(_=>c.getLayer(_)).filter(Boolean);if(m.length!==0){p.layers=m,p.stateDependentLayerIds&&(p.stateDependentLayers=p.stateDependentLayerIds.map(_=>m.filter(x=>x.id===_)[0]));for(const _ of m)u[_.id]=p}}return u}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const s in this.buckets){const c=this.buckets[s];if(c instanceof bo){if(this.hasSymbolBuckets=!0,!n)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const s in this.buckets){const c=this.buckets[s];if(c instanceof bo&&c.hasRTLText){this.hasRTLText=!0,y.isLoading()||y.isLoaded()||f()!=="deferred"||g();break}}this.queryPadding=0;for(const s in this.buckets){const c=this.buckets[s];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(s).queryRadius(c))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new Ct}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const n in this.buckets){const s=this.buckets[n];s.uploadPending()&&s.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new Ql(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new Ql(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new Ql(e,this.lineAtlas.image,i.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,i,n,s,c,u,p,m){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:s,pixelPosMatrix:p,transform:u,params:c,tileTransform:this.tileTransform},e,i,n):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const s=n.loadVTLayers(),c=i?i.sourceLayer:"",u=s._geojsonTileLayer||s[c];if(!u)return;const p=Js(i&&i.filter),{z:m,x:_,y:x}=this.tileID.canonical,b={z:m,x:_,y:x};for(let w=0;w<u.length;w++){const S=u.feature(w);if(p.needGeometry){const D=ps(S,!0);if(!p.filter(new v(this.tileID.overscaledZ),D,this.tileID.canonical))continue}else if(!p.filter(new v(this.tileID.overscaledZ),S))continue;const M=n.getId(S,c),C=new ff(S,m,_,x,M);C.tile=b,e.push(C)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const i=this.expirationTime;if(e.cacheControl){const n=$i(e.cacheControl);n["max-age"]&&(this.expirationTime=Date.now()+1e3*n["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const n=Date.now();let s=!1;if(this.expirationTime>n)s=!1;else if(i)if(this.expirationTime<i)s=!0;else{const c=this.expirationTime-i;c?this.expirationTime=n+Math.max(c,3e4):s=!0}else s=!0;s?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(e,i){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(e).length===0||!i)return;const n=this.latestFeatureIndex.loadVTLayers(),s=i.style.listImages();for(const c in this.buckets){if(!i.style.hasLayer(c))continue;const u=this.buckets[c],p=u.layers[0].sourceLayer||"_geojsonTileLayer",m=n[p],_=e[p];if(!m||!_||Object.keys(_).length===0)continue;if(u.update(_,m,s,this.imageAtlas&&this.imageAtlas.patternPositions||{}),u instanceof dh||u instanceof ah){const b=i.style._getSourceCache(u.layers[0].source);i._terrain&&i._terrain.enabled&&b&&u.programConfigurations.needsUpload&&i._terrain._clearRenderCacheForTile(b.id,this.tileID)}const x=i&&i.style&&i.style.getLayer(c);x&&(this.queryPadding=Math.max(this.queryPadding,x.queryRadius(u)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Cr.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Cr.now()+e}setTexture(e,i){const n=i.context,s=n.gl;this.texture=this.texture||i.getTileTexture(e.width),this.texture?this.texture.update(e,{useMipmap:!0}):(this.texture=new Ql(n,e,s.RGBA,{useMipmap:!0}),this.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE))}setDependencies(e,i){const n={};for(const s of i)n[s]=!0;this.dependencies[e]=n}hasDependency(e,i){for(const n of e){const s=this.dependencies[n];if(s){for(const c of i)if(s[c])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,i){if(!i||i.name==="mercator"||this._tileDebugBuffer)return;const n=Ln(gf,this.tileID.canonical,this.tileTransform)[0],s=new Ee,c=new er;for(let u=0;u<n.length;u++){const{x:p,y:m}=n[u];s.emplaceBack(p,m),c.emplaceBack(u)}c.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(c),this._tileDebugBuffer=e.createVertexBuffer(s,Pl.members),this._tileDebugSegments=ri.simpleSegment(0,0,s.length,c.length)}_makeTileBoundsBuffers(e,i){if(this._tileBoundsBuffer||!i||i.name==="mercator")return;const n=Ln(gf,this.tileID.canonical,this.tileTransform)[0];let s,c;if(this.isRaster){const u=function(p,m){const _=_s(p,m),x=Math.pow(2,p.z);for(let D=0;D<cn;D++)for(let U=0;U<cn;U++){const q=dr((p.x+(U+mf(U))/Er)/x),V=Ci((p.y+(D+mf(D))/Er)/x),$=m.project(q,V),X=D*cn+U;hn[2*X+0]=Math.round(($.x*_.scale-_.x)*Ze),hn[2*X+1]=Math.round(($.y*_.scale-_.y)*Ze)}To.fill(0),Ah.fill(0);for(let D=2045;D>=0;D--){const U=4*D,q=wo[U+0],V=wo[U+1],$=wo[U+2],X=wo[U+3],W=q+$>>1,ce=V+X>>1,se=W+ce-V,me=ce+q-W,Se=V*cn+q,ue=X*cn+$,ye=ce*cn+W,xe=Math.hypot((hn[2*Se+0]+hn[2*ue+0])/2-hn[2*ye+0],(hn[2*Se+1]+hn[2*ue+1])/2-hn[2*ye+1])>=16;To[ye]=To[ye]||(xe?1:0),D<1022&&(To[ye]=To[ye]||To[(V+me>>1)*cn+(q+se>>1)]||To[(X+me>>1)*cn+($+se>>1)])}const b=new ge,w=new je;let S=0;function M(D,U){const q=U*cn+D;return Ah[q]===0&&(b.emplaceBack(hn[2*q+0],hn[2*q+1],D*Ze/Er,U*Ze/Er),Ah[q]=++S),Ah[q]-1}function C(D,U,q,V,$,X){const W=D+q>>1,ce=U+V>>1;if(Math.abs(D-$)+Math.abs(U-X)>1&&To[ce*cn+W])C($,X,D,U,W,ce),C(q,V,$,X,W,ce);else{const se=M(D,U),me=M(q,V),Se=M($,X);w.emplaceBack(se,me,Se)}}return C(0,0,Er,Er,Er,0),C(Er,Er,0,0,0,Er),{vertices:b,indices:w}}(this.tileID.canonical,i);s=u.vertices,c=u.indices}else{s=new ge,c=new je;for(const{x:p,y:m}of n)s.emplaceBack(p,m,0,0);const u=zu(s.int16,void 0,4);for(let p=0;p<u.length;p+=3)c.emplaceBack(u[p],u[p+1],u[p+2])}this._tileBoundsBuffer=e.createVertexBuffer(s,_f.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(c),this._tileBoundsSegments=ri.simpleSegment(0,0,s.length,c.length)}_makeGlobeTileDebugBuffers(e,i){const n=i.projection;if(!n||n.name!=="globe"||i.freezeTileCoverage)return;const s=this.tileID.canonical,c=Ll(Od(s,i)),u=la(i.zoom);let p;u>0&&(p=nu(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,s,i,c,p,u),this._makeGlobeTileDebugTextBuffer(e,s,i,c,p,u)}_globePoint(e,i,n,s,c,u,p){let m=Dl(e,i,n);if(u){const _=1<<n.z,x=an(s.center.lng),b=ln(s.center.lat),w=(n.x+.5)/_-x;let S=0;w>.5?S=-1:w<-.5&&(S=1);let M=(e/Ze+n.x)/_+S,C=(i/Ze+n.y)/_;M=(M-x)*s._pixelsPerMercatorPixel+x,C=(C-b)*s._pixelsPerMercatorPixel+b;const D=[M*s.worldSize,C*s.worldSize,0];Jt(D,D,u),m=ds(m,D,p)}return Jt(m,m,c)}_makeGlobeTileDebugBorderBuffer(e,i,n,s,c,u){const p=new Ee,m=new er,_=new oe,x=(w,S,M,C,D)=>{const U=(M-w)/(D-1),q=(C-S)/(D-1),V=p.length;for(let $=0;$<D;$++){const X=w+$*U,W=S+$*q;p.emplaceBack(X,W);const ce=this._globePoint(X,W,i,n,s,c,u);_.emplaceBack(ce[0],ce[1],ce[2]),m.emplaceBack(V+$)}},b=Ze;x(0,0,b,0,16),x(b,0,b,b,16),x(b,b,0,b,16),x(0,b,0,0,16),this._tileDebugIndexBuffer=e.createIndexBuffer(m),this._tileDebugBuffer=e.createVertexBuffer(p,Pl.members),this._globeTileDebugBorderBuffer=e.createVertexBuffer(_,Ld.members),this._tileDebugSegments=ri.simpleSegment(0,0,p.length,m.length)}_makeGlobeTileDebugTextBuffer(e,i,n,s,c,u){const p=Ze/4,m=new Ee,_=new je,x=new oe,b=25;_.reserve(32),m.reserve(b),x.reserve(b);const w=(S,M)=>b*S+M;for(let S=0;S<b;S++){const M=S*p;for(let C=0;C<b;C++){const D=C*p;m.emplaceBack(D,M);const U=this._globePoint(D,M,i,n,s,c,u);x.emplaceBack(U[0],U[1],U[2])}}for(let S=0;S<4;S++)for(let M=0;M<4;M++){const C=w(S,M),D=w(S,M+1),U=w(S+1,M),q=w(S+1,M+1);_.emplaceBack(C,D,U),_.emplaceBack(U,D,q)}this._tileDebugTextIndexBuffer=e.createIndexBuffer(_),this._tileDebugTextBuffer=e.createVertexBuffer(m,Pl.members),this._globeTileDebugTextBuffer=e.createVertexBuffer(x,Ld.members),this._tileDebugTextSegments=ri.simpleSegment(0,0,b,32)}}class gg{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,n){const s=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][s]=this.stateChanges[e][s]||{},Qt(this.stateChanges[e][s],n),this.deletedStates[e]===null){this.deletedStates[e]={};for(const c in this.state[e])c!==s&&(this.deletedStates[e][c]=null)}else if(this.deletedStates[e]&&this.deletedStates[e][s]===null){this.deletedStates[e][s]={};for(const c in this.state[e][s])n[c]||(this.deletedStates[e][s][c]=null)}else for(const c in n)this.deletedStates[e]&&this.deletedStates[e][s]&&this.deletedStates[e][s][c]===null&&delete this.deletedStates[e][s][c]}removeFeatureState(e,i,n){if(this.deletedStates[e]===null)return;const s=String(i);if(this.deletedStates[e]=this.deletedStates[e]||{},n&&i!==void 0)this.deletedStates[e][s]!==null&&(this.deletedStates[e][s]=this.deletedStates[e][s]||{},this.deletedStates[e][s][n]=null);else if(i!==void 0)if(this.stateChanges[e]&&this.stateChanges[e][s])for(n in this.deletedStates[e][s]={},this.stateChanges[e][s])this.deletedStates[e][s][n]=null;else this.deletedStates[e][s]=null;else this.deletedStates[e]=null}getState(e,i){const n=String(i),s=Qt({},(this.state[e]||{})[n],(this.stateChanges[e]||{})[n]);if(this.deletedStates[e]===null)return{};if(this.deletedStates[e]){const c=this.deletedStates[e][i];if(c===null)return{};for(const u in c)delete s[u]}return s}initializeTileState(e,i){e.setFeatureState(this.state,i)}coalesceChanges(e,i){const n={};for(const s in this.stateChanges){this.state[s]=this.state[s]||{};const c={};for(const u in this.stateChanges[s])this.state[s][u]||(this.state[s][u]={}),Qt(this.state[s][u],this.stateChanges[s][u]),c[u]=this.state[s][u];n[s]=c}for(const s in this.deletedStates){this.state[s]=this.state[s]||{};const c={};if(this.deletedStates[s]===null)for(const u in this.state[s])c[u]={},this.state[s][u]={};else for(const u in this.deletedStates[s]){if(this.deletedStates[s][u]===null)this.state[s][u]={};else if(this.state[s][u])for(const p of Object.keys(this.deletedStates[s][u]))delete this.state[s][u][p];c[u]=this.state[s][u]}n[s]=n[s]||{},Qt(n[s],c)}if(this.stateChanges={},this.deletedStates={},Object.keys(n).length!==0)for(const s in e)e[s].setFeatureState(n,i)}}class yf{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,i){const n=this.toIdx(e,i);return{min:this.minimums[n],max:this.maximums[n]}}isLeaf(e,i){return this.leaves[this.toIdx(e,i)]}toIdx(e,i){return i*this.size+e}}function xf(t,e,i,n){let s=0,c=Number.MAX_VALUE;for(let u=0;u<3;u++)if(Math.abs(n[u])<1e-15){if(i[u]<t[u]||i[u]>e[u])return null}else{const p=1/n[u];let m=(t[u]-i[u])*p,_=(e[u]-i[u])*p;if(m>_){const x=m;m=_,_=x}if(m>s&&(s=m),_<c&&(c=_),s>c)return null}return s}function vf(t,e,i,n,s,c,u,p,m,_,x){const b=n-t,w=s-e,S=c-i,M=u-t,C=p-e,D=m-i,U=x[1]*D-x[2]*C,q=x[2]*M-x[0]*D,V=x[0]*C-x[1]*M,$=b*U+w*q+S*V;if(Math.abs($)<1e-15)return null;const X=1/$,W=_[0]-t,ce=_[1]-e,se=_[2]-i,me=(W*U+ce*q+se*V)*X;if(me<0||me>1)return null;const Se=ce*S-se*w,ue=se*b-W*S,ye=W*w-ce*b,xe=(x[0]*Se+x[1]*ue+x[2]*ye)*X;return xe<0||me+xe>1?null:(M*Se+C*ue+D*ye)*X}function bf(t,e,i){return(t-e)/(i-e)}function wf(t,e,i,n,s,c,u,p,m){const _=1<<i,x=c-n,b=u-s,w=(t+1)/_*x+n,S=(e+0)/_*b+s,M=(e+1)/_*b+s;p[0]=(t+0)/_*x+n,p[1]=S,m[0]=w,m[1]=M}class Tf{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const i=function(c){const u=Math.ceil(Math.log2(c.dim/8)),p=[];let m=Math.ceil(Math.pow(2,u));const _=1/m,x=(S,M,C,D,U)=>{const q=D?1:0,V=(S+1)*C-q,$=M*C,X=(M+1)*C-q;U[0]=S*C,U[1]=$,U[2]=V,U[3]=X};let b=new yf(m);const w=[];for(let S=0;S<m*m;S++){x(S%m,Math.floor(S/m),_,!1,w);const M=Eo(w[0],w[1],c),C=Eo(w[2],w[1],c),D=Eo(w[2],w[3],c),U=Eo(w[0],w[3],c);b.minimums.push(Math.min(M,C,D,U)),b.maximums.push(Math.max(M,C,D,U)),b.leaves.push(1)}for(p.push(b),m/=2;m>=1;m/=2){const S=p[p.length-1];b=new yf(m);for(let M=0;M<m*m;M++){x(M%m,Math.floor(M/m),2,!0,w);const C=S.getElevation(w[0],w[1]),D=S.getElevation(w[2],w[1]),U=S.getElevation(w[2],w[3]),q=S.getElevation(w[0],w[3]),V=S.isLeaf(w[0],w[1]),$=S.isLeaf(w[2],w[1]),X=S.isLeaf(w[2],w[3]),W=S.isLeaf(w[0],w[3]),ce=Math.min(C.min,D.min,U.min,q.min),se=Math.max(C.max,D.max,U.max,q.max),me=V&&$&&X&&W;b.maximums.push(se),b.minimums.push(ce),b.leaves.push(se-ce<=5&&me?1:0)}p.push(b)}return p}(this.dem),n=i.length-1,s=i[n];this._addNode(s.minimums[0],s.maximums[0],s.leaves[0]),this._construct(i,0,0,n,0)}raycastRoot(e,i,n,s,c,u,p=1){return xf([e,i,-100],[n,s,this.maximums[0]*p],c,u)}raycast(e,i,n,s,c,u,p=1){if(!this.nodeCount)return null;const m=this.raycastRoot(e,i,n,s,c,u,p);if(m==null)return null;const _=[],x=[],b=[],w=[],S=[{idx:0,t:m,nodex:0,nodey:0,depth:0}];for(;S.length>0;){const{idx:M,t:C,nodex:D,nodey:U,depth:q}=S.pop();if(this.leaves[M]){wf(D,U,q,e,i,n,s,b,w);const $=1<<q,X=(D+0)/$,W=(D+1)/$,ce=(U+0)/$,se=(U+1)/$,me=Eo(X,ce,this.dem)*p,Se=Eo(W,ce,this.dem)*p,ue=Eo(W,se,this.dem)*p,ye=Eo(X,se,this.dem)*p,xe=vf(b[0],b[1],me,w[0],b[1],Se,w[0],w[1],ue,c,u),we=vf(w[0],w[1],ue,b[0],w[1],ye,b[0],b[1],me,c,u),Ce=Math.min(xe!==null?xe:Number.MAX_VALUE,we!==null?we:Number.MAX_VALUE);if(Ce!==Number.MAX_VALUE)return Ce;{const pe=Cl([],c,u,C);if(Ef(me,Se,ye,ue,bf(pe[0],b[0],w[0]),bf(pe[1],b[1],w[1]))>=pe[2])return C}continue}let V=0;for(let $=0;$<this._siblingOffset.length;$++){wf((D<<1)+this._siblingOffset[$][0],(U<<1)+this._siblingOffset[$][1],q+1,e,i,n,s,b,w),b[2]=-100,w[2]=this.maximums[this.childOffsets[M]+$]*p;const X=xf(b,w,c,u);if(X!=null){const W=X;_[$]=W;let ce=!1;for(let se=0;se<V&&!ce;se++)W>=_[x[se]]&&(x.splice(se,0,$),ce=!0);ce||(x[V]=$),V++}}for(let $=0;$<V;$++){const X=x[$];S.push({idx:this.childOffsets[M]+X,t:_[X],nodex:(D<<1)+this._siblingOffset[X][0],nodey:(U<<1)+this._siblingOffset[X][1],depth:q+1})}}return null}_addNode(e,i,n){return this.minimums.push(e),this.maximums.push(i),this.leaves.push(n),this.childOffsets.push(0),this.nodeCount++}_construct(e,i,n,s,c){if(e[s].isLeaf(i,n)===1)return;this.childOffsets[c]||(this.childOffsets[c]=this.nodeCount);const u=s-1,p=e[u];let m=0,_=0;for(let x=0;x<this._siblingOffset.length;x++){const b=2*i+this._siblingOffset[x][0],w=2*n+this._siblingOffset[x][1],S=p.getElevation(b,w),M=p.isLeaf(b,w),C=this._addNode(S.min,S.max,M);M&&(m|=1<<x),_||(_=C)}for(let x=0;x<this._siblingOffset.length;x++)m&1<<x||this._construct(e,2*i+this._siblingOffset[x][0],2*n+this._siblingOffset[x][1],u,_+x)}}function Ef(t,e,i,n,s,c){return gt(gt(t,i,c),gt(e,n,c),s)}function Eo(t,e,i){const n=i.dim,s=ut(t*n-.5,0,n-1),c=ut(e*n-.5,0,n-1),u=Math.floor(s),p=Math.floor(c),m=Math.min(u+1,n-1),_=Math.min(p+1,n-1);return Ef(i.get(u,p),i.get(m,p),i.get(u,_),i.get(m,_),s-u,c-p)}const Sf={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function yg(t,e,i){return(256*t*256+256*e+i)/10-1e4}function xg(t,e,i){return 256*t+e+i/256-32768}class Ih{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,i,n,s=!1,c=!1){if(this.uid=e,i.height!==i.width)throw new RangeError("DEM tiles must be square");if(n&&n!=="mapbox"&&n!=="terrarium")return Gt(`"${n}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=i.height;const u=this.dim=i.height-2,p=new Uint32Array(i.data.buffer);if(this.pixels=new Uint8Array(i.data.buffer),this.encoding=n||"mapbox",this.borderReady=s,!s){for(let m=0;m<u;m++)p[this._idx(-1,m)]=p[this._idx(0,m)],p[this._idx(u,m)]=p[this._idx(u-1,m)],p[this._idx(m,-1)]=p[this._idx(m,0)],p[this._idx(m,u)]=p[this._idx(m,u-1)];p[this._idx(-1,-1)]=p[this._idx(0,0)],p[this._idx(u,-1)]=p[this._idx(u-1,0)],p[this._idx(-1,u)]=p[this._idx(0,u-1)],p[this._idx(u,u)]=p[this._idx(u-1,u-1)],c&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new Tf(this)}get(e,i,n=!1){n&&(e=ut(e,-1,this.dim),i=ut(i,-1,this.dim));const s=4*this._idx(e,i);return(this.encoding==="terrarium"?xg:yg)(this.pixels[s],this.pixels[s+1],this.pixels[s+2])}static getUnpackVector(e){return Sf[e]}get unpackVector(){return Sf[this.encoding]}_idx(e,i){if(e<-1||e>=this.dim+1||i<-1||i>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(i+1)*this.stride+(e+1)}static pack(e,i){const n=[0,0,0,0],s=Ih.getUnpackVector(i);let c=Math.floor((e+s[3])/s[2]);return n[2]=c%256,c=Math.floor(c/256),n[1]=c%256,c=Math.floor(c/256),n[0]=c,n}getPixels(){return new ir({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,i,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let s=i*this.dim,c=i*this.dim+this.dim,u=n*this.dim,p=n*this.dim+this.dim;switch(i){case-1:s=c-1;break;case 1:c=s+1}switch(n){case-1:u=p-1;break;case 1:p=u+1}const m=-i*this.dim,_=-n*this.dim;for(let x=u;x<p;x++)for(let b=s;b<c;b++){const w=4*this._idx(b,x),S=4*this._idx(b+m,x+_);this.pixels[w+0]=e.pixels[S+0],this.pixels[w+1]=e.pixels[S+1],this.pixels[w+2]=e.pixels[S+2],this.pixels[w+3]=e.pixels[S+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}Ue(Ih,"DEMData"),Ue(Tf,"DemMinMaxQuadTree",{omit:["dem"]});class vg{constructor(e,i){this.max=e,this.onRemove=i,this.reset()}reset(){for(const e in this.data)for(const i of this.data[e])i.timeout&&clearTimeout(i.timeout),this.onRemove(i.value);return this.data={},this.order=[],this}add(e,i,n){const s=e.wrapped().key;this.data[s]===void 0&&(this.data[s]=[]);const c={value:i,timeout:void 0};if(n!==void 0&&(c.timeout=setTimeout(()=>{this.remove(e,c)},n)),this.data[s].push(c),this.order.push(s),this.order.length>this.max){const u=this._getAndRemoveByKey(this.order[0]);u&&this.onRemove(u)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const i=this.data[e].shift();return i.timeout&&clearTimeout(i.timeout),this.data[e].length===0&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),i.value}getByKey(e){const i=this.data[e];return i?i[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,i){if(!this.has(e))return this;const n=e.wrapped().key,s=i===void 0?0:this.data[n].indexOf(i),c=this.data[n][s];return this.data[n].splice(s,1),c.timeout&&clearTimeout(c.timeout),this.data[n].length===0&&delete this.data[n],this.onRemove(c.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const i=this._getAndRemoveByKey(this.order[0]);i&&this.onRemove(i)}return this}filter(e){const i=[];for(const n in this.data)for(const s of this.data[n])e(s.value)||i.push(s);for(const n of i)this.remove(n.value.tileID,n)}}class Ta{constructor(e,i,n){this.func=e,this.mask=i,this.range=n}}Ta.ReadOnly=!1,Ta.ReadWrite=!0,Ta.disabled=new Ta(519,Ta.ReadOnly,[0,1]);const Yu=7680;class Ju{constructor(e,i,n,s,c,u){this.test=e,this.ref=i,this.mask=n,this.fail=s,this.depthFail=c,this.pass=u}}Ju.disabled=new Ju({func:519,mask:0},0,0,Yu,Yu,Yu);class un{constructor(e,i,n){this.blendFunction=e,this.blendColor=i,this.mask=n}}un.Replace=[1,0],un.disabled=new un(un.Replace,Yt.transparent,[!1,!1,!1,!1]),un.unblended=new un(un.Replace,Yt.transparent,[!0,!0,!0,!0]),un.alphaBlended=new un([1,771],Yt.transparent,[!0,!0,!0,!0]);const Qu=1029,ed=2305;class Wr{constructor(e,i,n){this.enable=e,this.mode=i,this.frontFace=n}}Wr.disabled=new Wr(!1,Qu,ed),Wr.backCCW=new Wr(!0,Qu,ed),Wr.backCW=new Wr(!0,Qu,2304),Wr.frontCW=new Wr(!0,1028,2304),Wr.frontCCW=new Wr(!0,1028,ed);class gs extends Lo{constructor(e,i,n){super(),this.id=e,this._onlySymbols=n,i.on("data",s=>{s.dataType==="source"&&s.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&s.dataType==="source"&&s.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),i.on("error",()=>{this._sourceErrored=!0}),this._source=i,this._tiles={},this._cache=new vg(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=i.minTileCacheSize,this._maxTileCacheSize=i.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new gg,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(e){this.map=e,this._minTileCacheSize=this._minTileCacheSize===void 0&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const e in this._tiles){const i=this._tiles[e];if(i.state!=="loaded"&&i.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,i){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,i)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const i in this._tiles){const n=this._tiles[i];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return Hr(this._tiles).map(e=>e.tileID).sort(Mf).map(e=>e.key)}getRenderableIds(e){const i=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&i.push(this._tiles[n]);return e?i.sort((n,s)=>{const c=n.tileID,u=s.tileID,p=new Le(c.canonical.x,c.canonical.y)._rotate(this.transform.angle),m=new Le(u.canonical.x,u.canonical.y)._rotate(this.transform.angle);return c.overscaledZ-u.overscaledZ||m.y-p.y||m.x-p.x}).map(n=>n.tileID.key):i.map(n=>n.tileID).sort(Mf).map(n=>n.key)}hasRenderableParent(e){const i=this.findLoadedParent(e,0);return!!i&&this._isIdRenderable(i.tileID.key)}_isIdRenderable(e,i){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(i||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)this._tiles[e].state!=="errored"&&this._reloadTile(+e,"reloading")}}_reloadTile(e,i){const n=this._tiles[e];n&&(n.state!=="loading"&&(n.state=i),this._loadTile(n,this._tileLoaded.bind(this,n,e,i)))}_tileLoaded(e,i,n,s){if(s)if(e.state="errored",s.status!==404)this._source.fire(new zr(s,{tile:e}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=Cr.now(),n==="expired"&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),this._source.type==="raster-dem"&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new vn("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const i=this.getRenderableIds();for(let s=0;s<i.length;s++){const c=i[s];if(e.neighboringTiles&&e.neighboringTiles[c]){const u=this.getTileByID(c);n(e,u),n(u,e)}}function n(s,c){if(!s.dem||s.dem.borderReady)return;s.needsHillshadePrepare=!0,s.needsDEMTextureUpload=!0;let u=c.tileID.canonical.x-s.tileID.canonical.x;const p=c.tileID.canonical.y-s.tileID.canonical.y,m=Math.pow(2,s.tileID.canonical.z),_=c.tileID.key;u===0&&p===0||Math.abs(p)>1||(Math.abs(u)>1&&(Math.abs(u+m)===1?u+=m:Math.abs(u-m)===1&&(u-=m)),c.dem&&s.dem&&(s.dem.backfillBorder(c.dem,u,p),s.neighboringTiles&&s.neighboringTiles[_]&&(s.neighboringTiles[_].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,i,n,s){for(const c in this._tiles){let u=this._tiles[c];if(s[c]||!u.hasData()||u.tileID.overscaledZ<=i||u.tileID.overscaledZ>n)continue;let p=u.tileID;for(;u&&u.tileID.overscaledZ>i+1;){const _=u.tileID.scaledTo(u.tileID.overscaledZ-1);u=this._tiles[_.key],u&&u.hasData()&&(p=_)}let m=p;for(;m.overscaledZ>i;)if(m=m.scaledTo(m.overscaledZ-1),e[m.key]){s[p.key]=p;break}}}findLoadedParent(e,i){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=i?n:null}for(let n=e.overscaledZ-1;n>=i;n--){const s=e.scaledTo(n),c=this._getLoadedTile(s);if(c)return c}}_getLoadedTile(e){const i=this._tiles[e.key];return i&&i.hasData()?i:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,i){i=i||this._source.tileSize;const n=Math.ceil(e.width/i)+1,s=Math.ceil(e.height/i)+1,c=Math.floor(n*s*5),u=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,c):c,p=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,u):u;this._cache.setMaxSize(p)}handleWrapJump(e){const i=Math.round((e-(this._prevLng===void 0?e:this._prevLng))/360);if(this._prevLng=e,i){const n={};for(const s in this._tiles){const c=this._tiles[s];c.tileID=c.tileID.unwrapTo(c.tileID.wrap+i),n[c.tileID.key]=c}this._tiles=n;for(const s in this._timers)clearTimeout(this._timers[s]),delete this._timers[s];for(const s in this._tiles)this._setTileReloadTimer(+s,this._tiles[s])}}update(e,i,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!n)return;let s;this.updateCacheSize(e,i),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(p=>new Vi(p.canonical.z,p.wrap,p.canonical.z,p.canonical.x,p.canonical.y)):(s=e.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(s=s.filter(p=>this._source.hasTile(p)))):s=[];const c=this._updateRetainedTiles(s);if(Af(this._source.type)&&s.length!==0){const p={},m={},_=Object.keys(c);for(const b of _){const w=c[b],S=this._tiles[b];if(!S||S.fadeEndTime&&S.fadeEndTime<=Cr.now())continue;const M=this.findLoadedParent(w,Math.max(w.overscaledZ-gs.maxOverzooming,this._source.minzoom));M&&(this._addTile(M.tileID),p[M.tileID.key]=M.tileID),m[b]=w}const x=s[s.length-1].overscaledZ;for(const b in this._tiles){const w=this._tiles[b];if(c[b]||!w.hasData())continue;let S=w.tileID;for(;S.overscaledZ>x;){S=S.scaledTo(S.overscaledZ-1);const M=this._tiles[S.key];if(M&&M.hasData()&&m[S.key]){c[b]=w.tileID;break}}}for(const b in p)c[b]||(this._coveredTiles[b]=!0,c[b]=p[b])}for(const p in c)this._tiles[p].clearFadeHold();const u=function(p,m){const _=[];for(const x in p)x in m||_.push(x);return _}(this._tiles,c);for(const p of u){const m=this._tiles[p];m.hasSymbolBuckets&&!m.holdingForFade()?m.setHoldDuration(this.map._fadeDuration):m.hasSymbolBuckets&&!m.symbolFadeFinished()||this._removeTile(+p)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const i={};if(e.length===0)return i;const n={},s=e.reduce((_,x)=>Math.min(_,x.overscaledZ),1/0),c=e[0].overscaledZ,u=Math.max(c-gs.maxOverzooming,this._source.minzoom),p=Math.max(c+gs.maxUnderzooming,this._source.minzoom),m={};for(const _ of e){const x=this._addTile(_);i[_.key]=_,x.hasData()||s<this._source.maxzoom&&(m[_.key]=_)}this._retainLoadedChildren(m,s,p,i);for(const _ of e){let x=this._tiles[_.key];if(x.hasData())continue;if(_.canonical.z>=this._source.maxzoom){const w=_.children(this._source.maxzoom)[0],S=this.getTile(w);if(S&&S.hasData()){i[w.key]=w;continue}}else{const w=_.children(this._source.maxzoom);if(i[w[0].key]&&i[w[1].key]&&i[w[2].key]&&i[w[3].key])continue}let b=x.wasRequested();for(let w=_.overscaledZ-1;w>=u;--w){const S=_.scaledTo(w);if(n[S.key]||(n[S.key]=!0,x=this.getTile(S),!x&&b&&(x=this._addTile(S)),x&&(i[S.key]=S,b=x.wasRequested(),x.hasData())))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const i=[];let n,s=this._tiles[e].tileID;for(;s.overscaledZ>0;){if(s.key in this._loadedParentTiles){n=this._loadedParentTiles[s.key];break}i.push(s.key);const c=s.scaledTo(s.overscaledZ-1);if(n=this._getLoadedTile(c),n)break;s=c}for(const c of i)this._loadedParentTiles[c]=n}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const n=!!i;if(!n){const s=this.map?this.map.painter:null;i=new Ku(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,s,this._isRaster),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))}return i?(i.uses++,this._tiles[e.key]=i,n||this._source.fire(new vn("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i):null}_setTileReloadTimer(e,i){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=i.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const i=this._tiles[e];i&&(i.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),i.uses>0||(i.hasData()&&i.state!=="reloading"?this._cache.add(i.tileID,i,i.getExpiryTimeout()):(i.aborted=!0,this._abortTile(i),this._unloadTile(i))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,i,n){const s=[],c=this.transform;if(!c)return s;const u=c.projection.name==="globe",p=an(c.center.lng);for(const m in this._tiles){const _=this._tiles[m];if(n&&_.clearQueryDebugViz(),_.holdingForFade())continue;let x;if(u){const b=_.tileID.canonical;if(b.z===0){const w=[Math.abs(ut(p,...ec(b,-1))-p),Math.abs(ut(p,...ec(b,1))-p)];x=[0,2*w.indexOf(Math.min(...w))-1]}else{const w=[Math.abs(ut(p,...ec(b,-1))-p),Math.abs(ut(p,...ec(b,0))-p),Math.abs(ut(p,...ec(b,1))-p)];x=[w.indexOf(Math.min(...w))-1]}}else x=[0];for(const b of x){const w=e.containsTile(_,c,i,b);w&&s.push(w)}}return s}getVisibleCoordinates(e){const i=this.getRenderableIds(e).map(n=>this._tiles[n].tileID);for(const n of i)n.projMatrix=this.transform.calculateProjMatrix(n.toUnwrapped());return i}hasTransition(){if(this._source.hasTransition())return!0;if(Af(this._source.type))for(const e in this._tiles){const i=this._tiles[e];if(i.fadeEndTime!==void 0&&i.fadeEndTime>=Cr.now())return!0}return!1}setFeatureState(e,i,n){this._state.updateState(e=e||"_geojsonTileLayer",i,n)}removeFeatureState(e,i,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",i,n)}getFeatureState(e,i){return this._state.getState(e=e||"_geojsonTileLayer",i)}setDependencies(e,i,n){const s=this._tiles[e];s&&s.setDependencies(i,n)}reloadTilesForDependencies(e,i){for(const n in this._tiles)this._tiles[n].hasDependency(e,i)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,i))}_preloadTiles(e,i){if(!this._sourceLoaded){const p=()=>{this._sourceLoaded&&(this._source.off("data",p),this._preloadTiles(e,i))};return void this._source.on("data",p)}const n=new Map,s=Array.isArray(e)?e:[e],c=this.map.painter.terrain,u=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const p of s){const m=p.coveringTiles({tileSize:u,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const _ of m)n.set(_.key,_);this.usedForTerrain&&p.updateElevation(!1)}mi(Array.from(n.values()),(p,m)=>{const _=new Ku(p,this._source.tileSize*p.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(_,x=>{this._source.type==="raster-dem"&&_.dem&&this._backfillDEM(_),m(x,_)})},i)}}function Mf(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Af(t){return t==="raster"||t==="image"||t==="video"||t==="custom"}function ec(t,e){const i=1<<t.z;return[t.x/i+e,(t.x+1)/i+e]}gs.maxOverzooming=10,gs.maxUnderzooming=3;class Ch{constructor(e,i,n){this._demTile=e,this._dem=this._demTile.dem,this._scale=i,this._offset=n}static create(e,i,n){const s=n||e.findDEMTileFor(i);if(!s||!s.dem)return;const c=s.dem,u=s.tileID,p=1<<i.canonical.z-u.canonical.z;return new Ch(s,s.tileSize/Ze/p,[(i.canonical.x/p-u.canonical.x)*c.dim,(i.canonical.y/p-u.canonical.y)*c.dim])}tileCoordToPixel(e,i){const n=i*this._scale+this._offset[1],s=Math.floor(e*this._scale+this._offset[0]),c=Math.floor(n);return new Le(s,c)}getElevationAt(e,i,n,s){const c=e*this._scale+this._offset[0],u=i*this._scale+this._offset[1],p=Math.floor(c),m=Math.floor(u),_=this._dem;return s=!!s,n?gt(gt(_.get(p,m,s),_.get(p,m+1,s),u-m),gt(_.get(p+1,m,s),_.get(p+1,m+1,s),u-m),c-p):_.get(p,m,s)}getElevationAtPixel(e,i,n){return this._dem.get(e,i,!!n)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*$r(1,e)*this._dem.stride}}class If{constructor(e,i){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new An(Ze,16,0),this.featureIndexArray=new os,this.promoteId=i}insert(e,i,n,s,c,u=0){const p=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(n,s,c,u);const m=this.grid;for(let _=0;_<i.length;_++){const x=i[_],b=[1/0,1/0,-1/0,-1/0];for(let w=0;w<x.length;w++){const S=x[w];b[0]=Math.min(b[0],S.x),b[1]=Math.min(b[1],S.y),b[2]=Math.max(b[2],S.x),b[3]=Math.max(b[3],S.y)}b[0]<Ze&&b[1]<Ze&&b[2]>=0&&b[3]>=0&&m.insert(p,b[0],b[1],b[2],b[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Lu(new mh(this.rawTileData)).layers,this.sourceLayerCoder=new pf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,i,n,s){this.loadVTLayers();const c=e.params||{},u=Js(c.filter),p=e.tileResult,m=e.transform,_=p.bufferedTilespaceBounds,x=this.grid.query(_.min.x,_.min.y,_.max.x,_.max.y,(M,C,D,U)=>Jd(p.bufferedTilespaceGeometry,M,C,D,U));x.sort(bg);let b=null;m.elevation&&x.length>0&&(b=Ch.create(m.elevation,this.tileID));const w={};let S;for(let M=0;M<x.length;M++){const C=x[M];if(C===S)continue;S=C;const D=this.featureIndexArray.get(C);let U=null;this.loadMatchingFeature(w,D,u,c.layers,c.availableImages,i,n,s,(q,V,$,X=0)=>(U||(U=Ln(q,this.tileID.canonical,e.tileTransform)),V.queryIntersectsFeature(p,q,$,U,this.z,e.transform,e.pixelPosMatrix,b,X)))}return w}loadMatchingFeature(e,i,n,s,c,u,p,m,_){const{featureIndex:x,bucketIndex:b,sourceLayerIndex:w,layoutVertexArrayOffset:S}=i,M=this.bucketLayerIDs[b];if(s&&!function(q,V){for(let $=0;$<q.length;$++)if(V.indexOf(q[$])>=0)return!0;return!1}(s,M))return;const C=this.sourceLayerCoder.decode(w),D=this.vtLayers[C].feature(x);if(n.needGeometry){const q=ps(D,!0);if(!n.filter(new v(this.tileID.overscaledZ),q,this.tileID.canonical))return}else if(!n.filter(new v(this.tileID.overscaledZ),D))return;const U=this.getId(D,C);for(let q=0;q<M.length;q++){const V=M[q];if(s&&s.indexOf(V)<0)continue;const $=u[V];if(!$)continue;let X={};U!==void 0&&m&&(X=m.getState($.sourceLayer||"_geojsonTileLayer",U));const W=Qt({},p[V]);W.paint=Cf(W.paint,$.paint,D,X,c),W.layout=Cf(W.layout,$.layout,D,X,c);const ce=!_||_(D,$,X,S);if(!ce)continue;const se=new ff(D,this.z,this.x,this.y,U);se.layer=W;let me=e[V];me===void 0&&(me=e[V]=[]),me.push({featureIndex:x,feature:se,intersectionZ:ce})}}lookupSymbolFeatures(e,i,n,s,c,u,p,m){const _={};this.loadVTLayers();const x=Js(c);for(const b of e)this.loadMatchingFeature(_,{bucketIndex:n,sourceLayerIndex:s,featureIndex:b,layoutVertexArrayOffset:0},x,u,p,m,i);return _}loadFeature(e){const{featureIndex:i,sourceLayerIndex:n}=e;this.loadVTLayers();const s=this.sourceLayerCoder.decode(n),c=this.vtFeatures[s];if(c[i])return c[i];const u=this.vtLayers[s].feature(i);return c[i]=u,u}hasLayer(e){for(const i of this.bucketLayerIDs)for(const n of i)if(e===n)return!0;return!1}getId(e,i){let n=e.id;if(this.promoteId){const s=typeof this.promoteId=="string"?this.promoteId:this.promoteId[i];s!=null&&(n=e.properties[s]),typeof n=="boolean"&&(n=Number(n))}return n}}function Cf(t,e,i,n,s){return mt(t,(c,u)=>{const p=e instanceof F?e.get(u):null;return p&&p.evaluate?p.evaluate(i,n,s):p})}function bg(t,e){return e-t}Ue(If,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class zf{constructor(e,i){this.width=e,this.height=i,this.nextRow=0,this.image=new Rn({width:e,height:i}),this.positions={},this.uploaded=!1}getDash(e,i){const n=this.getKey(e,i);return this.positions[n]}trim(){const e=this.width,i=this.height=Ar(this.nextRow);this.image.resize({width:e,height:i})}getKey(e,i){return e.join(",")+i}getDashRanges(e,i,n){const s=[];let c=e.length%2==1?-e[e.length-1]*n:0,u=e[0]*n,p=!0;s.push({left:c,right:u,isDash:p,zeroLength:e[0]===0});let m=e[0];for(let _=1;_<e.length;_++){p=!p;const x=e[_];c=m*n,m+=x,u=m*n,s.push({left:c,right:u,isDash:p,zeroLength:x===0})}return s}addRoundDash(e,i,n){const s=i/2;for(let c=-n;c<=n;c++){const u=this.width*(this.nextRow+n+c);let p=0,m=e[p];for(let _=0;_<this.width;_++){_/m.right>1&&(m=e[++p]);const x=Math.abs(_-m.left),b=Math.abs(_-m.right),w=Math.min(x,b);let S;const M=c/n*(s+1);if(m.isDash){const C=s-Math.abs(M);S=Math.sqrt(w*w+C*C)}else S=s-Math.sqrt(w*w+M*M);this.image.data[u+_]=Math.max(0,Math.min(255,S+128))}}}addRegularDash(e,i){for(let m=e.length-1;m>=0;--m){const _=e[m],x=e[m+1];_.zeroLength?e.splice(m,1):x&&x.isDash===_.isDash&&(x.left=_.left,e.splice(m,1))}const n=e[0],s=e[e.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const c=this.width*this.nextRow;let u=0,p=e[u];for(let m=0;m<this.width;m++){m/p.right>1&&(p=e[++u]);const _=Math.abs(m-p.left),x=Math.abs(m-p.right),b=Math.min(_,x);this.image.data[c+m]=Math.max(0,Math.min(255,(p.isDash?b:-b)+i+128))}}addDash(e,i){const n=this.getKey(e,i);if(this.positions[n])return this.positions[n];const s=i==="round",c=s?7:0,u=2*c+1;if(this.nextRow+u>this.height)return Gt("LineAtlas out of space"),null;e.length===0&&e.push(1);let p=0;for(let x=0;x<e.length;x++)e[x]<0&&(Gt("Negative value is found in line dasharray, replacing values with 0"),e[x]=0),p+=e[x];if(p!==0){const x=this.width/p,b=this.getDashRanges(e,this.width,x);s?this.addRoundDash(b,x,c):this.addRegularDash(b,i==="square"?.5*x:0)}const m=this.nextRow+c;this.nextRow+=u;const _={tl:[m,c],br:[p,0]};return this.positions[n]=_,_}}Ue(zf,"LineAtlas");const Pf=1*qr;class kf{constructor(e){const i={},n=[];for(const p in e){const m=e[p],_=i[p]={};for(const x in m.glyphs){const b=m.glyphs[+x];if(!b||b.bitmap.width===0||b.bitmap.height===0)continue;const w=b.metrics.localGlyph?Pf:1,S={x:0,y:0,w:b.bitmap.width+2*w,h:b.bitmap.height+2*w};n.push(S),_[x]=S}}const{w:s,h:c}=Fu(n),u=new Rn({width:s||1,height:c||1});for(const p in e){const m=e[p];for(const _ in m.glyphs){const x=m.glyphs[+_];if(!x||x.bitmap.width===0||x.bitmap.height===0)continue;const b=i[p][_],w=x.metrics.localGlyph?Pf:1;Rn.copy(x.bitmap,u,{x:0,y:0},{x:b.x+w,y:b.y+w},x.bitmap)}}this.image=u,this.positions=i}}Ue(kf,"GlyphAtlas");class wg{constructor(e){this.tileID=new Vi(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=_s(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,i,n,s,c){this.status="parsing",this.data=e,this.collisionBoxArray=new Ct;const u=new pf(Object.keys(e.layers).sort()),p=new If(this.tileID,this.promoteId);p.bucketLayerIDs=[];const m={},_=new zf(256,256),x={featureIndex:p,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:_,availableImages:n},b=i.familiesBySource[this.source];for(const X in b){const W=e.layers[X];if(!W)continue;let ce=!1,se=!1;for(const ue of b[X])ue[0].type==="symbol"?ce=!0:se=!0;if(this.isSymbolTile===!0&&!ce||this.isSymbolTile===!1&&!se)continue;W.version===1&&Gt(`Vector tile source "${this.source}" layer "${X}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const me=u.encode(X),Se=[];for(let ue=0;ue<W.length;ue++){const ye=W.feature(ue),xe=p.getId(ye,X);Se.push({feature:ye,id:xe,index:ue,sourceLayerIndex:me})}for(const ue of b[X]){const ye=ue[0];this.isSymbolTile!==void 0&&ye.type==="symbol"!==this.isSymbolTile||ye.minzoom&&this.zoom<Math.floor(ye.minzoom)||ye.maxzoom&&this.zoom>=ye.maxzoom||ye.visibility!=="none"&&(td(ue,this.zoom,n),(m[ye.id]=ye.createBucket({index:p.bucketLayerIDs.length,layers:ue,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:me,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(Se,x,this.tileID.canonical,this.tileTransform),p.bucketLayerIDs.push(ue.map(xe=>xe.id)))}}let w,S,M,C;_.trim();const D={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},U=()=>{if(w)return c(w);if(S&&M&&C){const X=new kf(S),W=new Fp(M,C);for(const ce in m){const se=m[ce];se instanceof bo?(td(se.layers,this.zoom,n),X_(se,S,X.positions,M,W.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):se.hasPattern&&(se instanceof dh||se instanceof ah||se instanceof jl)&&(td(se.layers,this.zoom,n),se.addFeatures(x,this.tileID.canonical,W.patternPositions,n,this.tileTransform))}this.status="done",c(null,{buckets:Hr(m).filter(ce=>!ce.isEmpty()),featureIndex:p,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:X.image,lineAtlas:_,imageAtlas:W,glyphMap:this.returnDependencies?S:null,iconMap:this.returnDependencies?M:null,glyphPositions:this.returnDependencies?X.positions:null})}},q=mt(x.glyphDependencies,X=>Object.keys(X).map(Number));Object.keys(q).length?s.send("getGlyphs",{uid:this.uid,stacks:q},(X,W)=>{w||(w=X,S=W,U())},void 0,!1,D):S={};const V=Object.keys(x.iconDependencies);V.length?s.send("getImages",{icons:V,source:this.source,tileID:this.tileID,type:"icons"},(X,W)=>{w||(w=X,M=W,U())},void 0,!1,D):M={};const $=Object.keys(x.patternDependencies);$.length?s.send("getImages",{icons:$,source:this.source,tileID:this.tileID,type:"patterns"},(X,W)=>{w||(w=X,C=W,U())},void 0,!1,D):C={},U()}}function td(t,e,i){const n=new v(e);for(const s of t)s.recalculate(n,i)}class Df{constructor(e){this.entries={},this.scheduler=e}request(e,i,n,s){const c=this.entries[e]=this.entries[e]||{callbacks:[]};if(c.result){const[u,p]=c.result;return this.scheduler?this.scheduler.add(()=>{s(u,p)},i):s(u,p),()=>{}}return c.callbacks.push(s),c.cancel||(c.cancel=n((u,p)=>{c.result=[u,p];for(const m of c.callbacks)this.scheduler?this.scheduler.add(()=>{m(u,p)},i):m(u,p);setTimeout(()=>delete this.entries[e],3e3)})),()=>{c.result||(c.callbacks=c.callbacks.filter(u=>u!==s),c.callbacks.length||(c.cancel(),delete this.entries[e]))}}}function Lf(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},s=>{const c=Xn(t.request,(u,p,m,_)=>{u?s(u):p&&s(null,{vectorTile:i?void 0:new Lu(new mh(p)),rawData:p,cacheControl:m,expires:_})});return()=>{c.cancel(),s()}},e)}const Rf=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class id{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[i,n]=new Uint8Array(e,0,2);if(i!==219)throw new Error("Data does not appear to be in a KDBush format.");const s=n>>4;if(s!==1)throw new Error(`Got v${s} data when expected v1.`);const c=Rf[15&n];if(!c)throw new Error("Unrecognized array type.");const[u]=new Uint16Array(e,2,1),[p]=new Uint32Array(e,4,1);return new id(p,u,c,e)}constructor(e,i=64,n=Float64Array,s){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+i,2),65535),this.ArrayType=n,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const c=Rf.indexOf(this.ArrayType),u=2*e*this.ArrayType.BYTES_PER_ELEMENT,p=e*this.IndexArrayType.BYTES_PER_ELEMENT,m=(8-p%8)%8;if(c<0)throw new Error(`Unexpected typed array class: ${n}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+u+p+m),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+p+m,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+c]),new Uint16Array(this.data,2,1)[0]=i,new Uint32Array(this.data,4,1)[0]=e)}add(e,i){const n=this._pos>>1;return this.ids[n]=n,this.coords[this._pos++]=e,this.coords[this._pos++]=i,n}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return rd(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,i,n,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:c,coords:u,nodeSize:p}=this,m=[0,c.length-1,0],_=[];for(;m.length;){const x=m.pop()||0,b=m.pop()||0,w=m.pop()||0;if(b-w<=p){for(let D=w;D<=b;D++){const U=u[2*D],q=u[2*D+1];U>=e&&U<=n&&q>=i&&q<=s&&_.push(c[D])}continue}const S=w+b>>1,M=u[2*S],C=u[2*S+1];M>=e&&M<=n&&C>=i&&C<=s&&_.push(c[S]),(x===0?e<=M:i<=C)&&(m.push(w),m.push(S-1),m.push(1-x)),(x===0?n>=M:s>=C)&&(m.push(S+1),m.push(b),m.push(1-x))}return _}within(e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:c,nodeSize:u}=this,p=[0,s.length-1,0],m=[],_=n*n;for(;p.length;){const x=p.pop()||0,b=p.pop()||0,w=p.pop()||0;if(b-w<=u){for(let D=w;D<=b;D++)Of(c[2*D],c[2*D+1],e,i)<=_&&m.push(s[D]);continue}const S=w+b>>1,M=c[2*S],C=c[2*S+1];Of(M,C,e,i)<=_&&m.push(s[S]),(x===0?e-n<=M:i-n<=C)&&(p.push(w),p.push(S-1),p.push(1-x)),(x===0?e+n>=M:i+n>=C)&&(p.push(S+1),p.push(b),p.push(1-x))}return m}}function rd(t,e,i,n,s,c){if(s-n<=i)return;const u=n+s>>1;Bf(t,e,u,n,s,c),rd(t,e,i,n,u-1,1-c),rd(t,e,i,u+1,s,1-c)}function Bf(t,e,i,n,s,c){for(;s>n;){if(s-n>600){const _=s-n+1,x=i-n+1,b=Math.log(_),w=.5*Math.exp(2*b/3),S=.5*Math.sqrt(b*w*(_-w)/_)*(x-_/2<0?-1:1);Bf(t,e,i,Math.max(n,Math.floor(i-x*w/_+S)),Math.min(s,Math.floor(i+(_-x)*w/_+S)),c)}const u=e[2*i+c];let p=n,m=s;for(tc(t,e,n,i),e[2*s+c]>u&&tc(t,e,n,s);p<m;){for(tc(t,e,p,m),p++,m--;e[2*p+c]<u;)p++;for(;e[2*m+c]>u;)m--}e[2*n+c]===u?tc(t,e,n,m):(m++,tc(t,e,m,s)),m<=i&&(n=m+1),i<=m&&(s=m-1)}}function tc(t,e,i,n){nd(t,i,n),nd(e,2*i,2*n),nd(e,2*i+1,2*n+1)}function nd(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function Of(t,e,i,n){const s=t-i,c=e-n;return s*s+c*c}a.ARRAY_TYPE=tr,a.AUTH_ERR_MSG=H,a.Aabb=Ui,a.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.cancelCallbacks={},mn(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=Ir()?t:ve,this.scheduler=new mg}send(t,e,i,n,s=!1,c){const u=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=c,this.callbacks[u]=i);const p=Zn(this.globalScope)?void 0:[];return this.target.postMessage({id:u,type:t,hasCallback:!!i,targetMapId:n,mustQueue:s,sourceMapId:this.mapId,data:po(e,p)},p),{cancel:()=>{i&&delete this.callbacks[u],this.target.postMessage({id:u,type:"<cancel>",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(e.type==="<cancel>"){const n=this.cancelCallbacks[i];delete this.cancelCallbacks[i],n&&n.cancel()}else if(e.mustQueue||Ir()){const n=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,e),n&&n.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(e.type==="<response>"){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(In(e.error)):i(null,In(e.data)))}else{const i=Zn(this.globalScope)?void 0:[],n=e.hasCallback?(c,u)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"<response>",sourceMapId:this.mapId,error:c?po(c):null,data:po(u,i)},i)}:c=>{},s=In(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,s,n);else if(this.parent.getWorkerSource){const c=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,c[0],s.source)[c[1]](s,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=uh,a.Color=Yt,a.ColorMode=un,a.CullFaceMode=Wr,a.DEMData=Ih,a.DataConstantProperty=I,a.DedupedRequest=Df,a.DepthMode=Ta,a.EXTENT=Ze,a.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,n=1<<i,s=Math.floor(t.x),c=Math.floor((t.x-s)*n),u=Math.floor(t.y*n),p=this.findDEMTileFor(new Vi(i,s,i,c,u));return!(!p||!p.dem)}getAtPointOrZero(t,e=0){return this.getAtPoint(t,e)||0}getAtPoint(t,e,i=!0){if(this.isUsingMockSource())return null;e==null&&(e=null);const n=this._source();if(!n||t.y<0||t.y>1)return e;const s=n.getSource().maxzoom,c=1<<s,u=Math.floor(t.x),p=t.x-u,m=new Vi(s,u,s,Math.floor(p*c),Math.floor(t.y*c)),_=this.findDEMTileFor(m);if(!_||!_.dem)return e;const x=_.dem,b=1<<_.tileID.canonical.z,w=(p*b-_.tileID.canonical.x)*x.dim,S=(t.y*b-_.tileID.canonical.y)*x.dim,M=Math.floor(w),C=Math.floor(S);return(i?this.exaggeration():1)*gt(gt(x.get(M,C),x.get(M,C+1),S-C),gt(x.get(M+1,C),x.get(M+1,C+1),S-C),w-M)}getAtTileOffset(t,e,i){const n=1<<t.canonical.z;return this.getAtPointOrZero(new ca(t.wrap+(t.canonical.x+e/Ze)/n,(t.canonical.y+i/Ze)/n))}getAtTileOffsetFunc(t,e,i,n){return s=>{const c=this.getAtTileOffset(t,s.x,s.y),u=n.upVector(t.canonical,s.x,s.y);return ur(u,u,c*n.upVectorScale(t.canonical,e,i).metersToTile),u}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const s=Ch.create(this,t,n);return!!s&&(e.forEach(c=>{c[2]=this.exaggeration()*s.getElevationAt(c[0],c[1],i)}),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,s=1<<t.canonical.z-n.canonical.z;let c=t.canonical.x/s-n.canonical.x,u=t.canonical.y/s-n.canonical.y,p=0;for(let m=0;m<t.canonical.z-n.canonical.z&&!i.leaves[p];m++){c*=2,u*=2;const _=2*Math.floor(u)+Math.floor(c);p=i.childOffsets[p]+_,c%=1,u%=1}return{min:this.exaggeration()*i.minimums[p],max:this.exaggeration()*i.maximums[p]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(t,e,i){throw new Error("Pure virtual method called.")}pointCoordinate(t){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(t){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},a.ErrorEvent=zr,a.EvaluationParameters=v,a.Event=vn,a.Evented=Lo,a.FillExtrusionBucket=jl,a.Frustum=uu,a.FrustumCorners=hu,a.GLOBE_RADIUS=on,a.GLOBE_SCALE_MATCH_LATITUDE=45,a.GLOBE_ZOOM_THRESHOLD_MAX=Rd,a.GLOBE_ZOOM_THRESHOLD_MIN=du,a.GlobeSharedBuffers=class{constructor(t){this._createGrid(t),this._createPoles(t)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const t of this._poleSegments)t.destroy();for(const t of this._gridSegments)t.withSkirts.destroy(),t.withoutSkirts.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const t of this._wireframeSegments)t.destroy()}}_fillGridMeshWithLods(t,e){const i=new Ee,n=new je,s=[],c=t+1+2,u=e[0]+1,p=e[0]+1+(1+e.length),m=(_,x,b)=>{let w=_===c-1?_-2:_===0?_:_-1;return w+=b?24575:0,[w,x]};for(let _=0;_<c;++_)i.emplaceBack(...m(_,0,!0));for(let _=0;_<u;++_)for(let x=0;x<c;++x)i.emplaceBack(...m(x,_,(x===0||x===c-1)&&!0));for(let _=0;_<e.length;++_){const x=e[_];for(let b=0;b<c;++b)i.emplaceBack(...m(b,x,!0))}for(let _=0;_<e.length;++_){const x=n.length,b=e[_]+1+2,w=new je;for(let C=0;C<b-1;C++){const D=C===b-2,U=D?c*(p-e.length+_-C):c;for(let q=0;q<c-1;q++){const V=C*c+q;C===0||D||q===0||q===c-2?(w.emplaceBack(V+1,V,V+U),w.emplaceBack(V+U,V+U+1,V+1)):(n.emplaceBack(V+1,V,V+U),n.emplaceBack(V+U,V+U+1,V+1))}}const S=ri.simpleSegment(0,x,i.length,n.length-x);for(let C=0;C<w.uint16.length;C+=3)n.emplaceBack(w.uint16[C],w.uint16[C+1],w.uint16[C+2]);const M=ri.simpleSegment(0,x,i.length,n.length-x);s.push({withoutSkirts:S,withSkirts:M})}return{vertices:i,indices:n,segments:s}}_createGrid(t){const e=this._fillGridMeshWithLods(us,kl);this._gridSegments=e.segments,this._gridBuffer=t.createVertexBuffer(e.vertices,Pl.members),this._gridIndexBuffer=t.createIndexBuffer(e.indices,!0)}_createPoles(t){const e=new je;for(let s=0;s<=us;s++)e.emplaceBack(0,s+1,s+2);this._poleIndexBuffer=t.createIndexBuffer(e,!0);const i=new It,n=new It;this._poleSegments=[];for(let s=0,c=0;s<du;s++){const u=360/(1<<s);i.emplaceBack(0,-on,0,.5,0),n.emplaceBack(0,-on,0,.5,1);for(let p=0;p<=us;p++){const m=p/us,_=gt(0,u,m),[x,b,w]=sa(mm,_m,_,on);i.emplaceBack(x,b,w,m,0),n.emplaceBack(x,b,w,m,1)}this._poleSegments.push(ri.simpleSegment(c,0,66,64)),c+=66}this._poleNorthVertexBuffer=t.createVertexBuffer(i,Dd,!1),this._poleSouthVertexBuffer=t.createVertexBuffer(n,Dd,!1)}getGridBuffers(t,e){return[this._gridBuffer,this._gridIndexBuffer,e?this._gridSegments[t].withSkirts:this._gridSegments[t].withoutSkirts]}getPoleBuffers(t){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[t]]}getWirefameBuffers(t,e){if(!this._wireframeSegments){const i=new xi,n=us,s=n+1+2,c=1;this._wireframeSegments=[];for(let u=0,p=0;u<kl.length;u++){const m=kl[u];for(let x=c;x<m+c;x++)for(let b=c;b<n+c;b++){const w=x*s+b;i.emplaceBack(w,w+1),i.emplaceBack(w,w+s),i.emplaceBack(w,w+s+1)}const _=m*n*3;this._wireframeSegments.push(ri.simpleSegment(0,p,(m+1)*s,_)),p+=_}this._wireframeIndexBuffer=t.createIndexBuffer(i)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[e]]}},a.GlyphManager=ya,a.ImagePosition=Uu,a.KDBush=id,a.LivePerformanceUtils=kh,a.LngLat=zt,a.LngLatBounds=go,a.LocalGlyphMode=ju,a.MAX_MERCATOR_LATITUDE=zi,a.MercatorCoordinate=ca,a.ONE_EM=Ti,a.OverscaledTileID=Vi,a.PerformanceMarkers=Hn,a.Point=Le,a.Properties=j,a.RGBAImage=ir,a.Ray=cu,a.RequestManager=class{constructor(t,e,i){this._transformRequestFn=t,this._customAccessToken=e,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const t=function(){let e="";for(let i=0;i<10;i++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Un,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=t.token,this._skuTokenExpiresAt=t.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!ee(t))return t;const i=ke(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!ee(t))return t;const i=ke(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!ee(t))return t;const s=ke(t);return s.path=`/v4/${s.authority}.json`,s.params.push("secure"),i&&s.params.push(`language=${i}`),n&&s.params.push(`worldview=${n}`),this._makeAPIURL(s,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const s=ke(t);return ee(t)?(s.path=`/styles/v1${s.path}/sprite${e}${i}`,this._makeAPIURL(s,this._customAccessToken||n)):(s.path+=`${e}${i}`,Ie(s))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!ee(t))return t;const n=ke(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&n.authority!=="raster"&&i===512?"@2x":""}${nt.supported?".webp":"$1"}`),n.authority==="raster"?n.path=`/${Xe.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${Xe.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(c){for(const u of c){const p=u.match(/^access_token=(.*)$/);if(p)return p[1]}return null}(n.params)||Xe.ACCESS_TOKEN;return Xe.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(t,e){const i=ke(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${Xe.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${Xe.TILE_URL_VERSION}/`,"")}`;let s=i.params;return e&&(s=s.filter(c=>!c.match(/^access_token=/))),s.length&&(n+=`?${s.join("&")}`),n}canonicalizeTileset(t,e){const i=!!e&&ee(e),n=[];for(const s of t.tiles||[])ne(s)?n.push(this.canonicalizeTileURL(s,i)):n.push(s);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=ke(Xe.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,t.protocol==="http"){const s=t.params.indexOf("secure");s>=0&&t.params.splice(s,1)}if(n.path!=="/"&&(t.path=`${n.path}${t.path}`),!Xe.REQUIRE_ACCESS_TOKEN)return Ie(t);if(e=e||Xe.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if(e[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter(s=>s.indexOf("access_token")===-1),t.params.push(`access_token=${e||""}`),Ie(t)}},a.ResourceType=gn,a.SegmentVector=ri,a.SourceCache=gs,a.StencilMode=Ju,a.StructArrayLayout1ui2=er,a.StructArrayLayout2f1f2i16=qe,a.StructArrayLayout2i4=Ee,a.StructArrayLayout2ui4=xi,a.StructArrayLayout3f12=at,a.StructArrayLayout3ui6=je,a.StructArrayLayout4i8=ge,a.StructArrayLayout5f20=It,a.Texture=Ql,a.Tile=Ku,a.Transitionable=A,a.Uniform1f=Xc,a.Uniform1i=class extends Pn{constructor(t){super(t),this.current=0}set(t,e,i){this.fetchUniformLocation(t,e)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},a.Uniform2f=class extends Pn{constructor(t){super(t),this.current=[0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}},a.Uniform3f=class extends Pn{constructor(t){super(t),this.current=[0,0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}},a.Uniform4f=_d,a.UniformColor=gd,a.UniformMatrix2f=class extends Pn{constructor(t){super(t),this.current=Qf}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let n=0;n<4;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}}},a.UniformMatrix3f=class extends Pn{constructor(t){super(t),this.current=Jf}set(t,e,i){if(this.fetchUniformLocation(t,e)){for(let n=0;n<9;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}}},a.UniformMatrix4f=class extends Pn{constructor(t){super(t),this.current=Yf}set(t,e,i){if(this.fetchUniformLocation(t,e)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let n=1;n<16;n++)if(i[n]!==this.current[n]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}},a.UnwrappedTileID=Tp,a.ValidationError=Fe,a.VectorTileFeature=ch,a.VectorTileWorkerSource=class extends Lo{constructor(t,e,i,n,s){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=s||Lf,this.loading={},this.loaded={},this.deduped=new Df(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,n=t&&t.request,s=n&&n.collectResourceTiming,c=this.loading[i]=new wg(t);c.abort=this.loadVectorData(t,(u,p)=>{const m=!this.loading[i];if(delete this.loading[i],m||u||!p)return c.status="done",m||(this.loaded[i]=c),e(u);const _=p.rawData,x={};p.expires&&(x.expires=p.expires),p.cacheControl&&(x.cacheControl=p.cacheControl),c.vectorTile=p.vectorTile||new Lu(new mh(_));const b=()=>{c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,(w,S)=>{if(w||!S)return e(w);const M={};if(s){const C=Ia(n);C.length>0&&(M.resourceTiming=JSON.parse(JSON.stringify(C)))}e(null,Qt({rawTileData:_.slice(0)},S,x,M))})};this.isSpriteLoaded?b():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(b,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):b()}),this.loaded=this.loaded||{},this.loaded[i]=c})}reloadTile(t,e){const i=this.loaded,n=t.uid,s=this;if(i&&i[n]){const c=i[n];c.showCollisionBoxes=t.showCollisionBoxes,c.enableTerrain=!!t.enableTerrain,c.projection=t.projection,c.tileTransform=_s(t.tileID.canonical,t.projection);const u=(p,m)=>{const _=c.reloadCallback;_&&(delete c.reloadCallback,c.parse(c.vectorTile,s.layerIndex,this.availableImages,s.actor,_)),e(p,m)};c.status==="parsing"?c.reloadCallback=u:c.status==="done"&&(c.vectorTile?c.parse(c.vectorTile,this.layerIndex,this.availableImages,this.actor,u):u())}}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}},a.WritingMode=pr,a.ZoomDependentExpression=Jo,a.add=Dn,a.addDynamicAttributes=Sh,a.adjoint=function(t,e){var i=e[0],n=e[1],s=e[2],c=e[3],u=e[4],p=e[5],m=e[6],_=e[7],x=e[8];return t[0]=u*x-p*_,t[1]=s*_-n*x,t[2]=n*p-s*u,t[3]=p*m-c*x,t[4]=i*x-s*m,t[5]=s*c-i*p,t[6]=c*_-u*m,t[7]=n*m-i*_,t[8]=i*u-n*c,t},a.asyncAll=mi,a.bezier=Ao,a.bindAll=mn,a.boundsAttributes=_f,a.bufferConvexPolygon=function(t,e){const i=[];for(let n=0;n<t.length;n++){const s=di(n-1,-1,t.length-1),c=di(n+1,-1,t.length-1),u=t[n],p=t[c],m=t[s].sub(u).unit(),_=p.sub(u).unit(),x=_.angleWithSep(m.x,m.y),b=m.add(_).unit().mult(-1*e/Math.sin(x/2));i.push(u.add(b))}return i},a.cacheEntryPossiblyAdded=function(t){ko++,ko>Ms&&(t.getActor().send("enforceCacheSizeLimit",Ss),ko=0)},a.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:n}=t.point,s=Vd(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return ls(s,s,mu(sn(e)))},a.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:n,lat:s}=t._center;return Vd(e,i,t.worldSize,n,s)},a.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,i=e/$r(1,t.center.lat),n=jr(new Float64Array(16));return Sl(n,n,[t.point.x,t.point.y,0]),cs(n,n,[i,i,e]),Float32Array.from(n)},a.circumferenceAtLatitude=gu,a.clamp=ut,a.clearTileCache=function(t){if(!Po())return;const e=ve.caches.delete(qn);t&&e.catch(t).then(()=>t())},a.clipLine=Yp,a.clone=function(t){var e=new tr(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},a.clone$1=Gi,a.collisionCircleLayout=v_,a.config=Xe,a.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},a.create=function(){var t=new tr(16);return tr!=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},a.create$1=vd,a.createExpression=co,a.createLayout=te,a.createStyleLayer=function(t){return t.type==="custom"?new ug(t):new pg[t.type](t)},a.cross=lu,a.degToRad=ft,a.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},a.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},a.dot=br,a.earthRadius=Rl,a.ease=ws,a.easeCubicInOut=bs,a.ecefToLatLng=function([t,e,i]){const n=Math.hypot(t,e,i),s=Math.atan2(t,i),c=.5*Math.PI-Math.acos(-e/n);return new zt(fi(s),fi(c))},a.emitValidationErrors=jc,a.endsWith=Gn,a.enforceCacheSizeLimit=function(t){_n(),Hi&&Hi.then(e=>{e.keys().then(i=>{for(let n=0;n<i.length-t;n++)e.delete(i[n])})})},a.evaluateSizeForFeature=ph,a.evaluateSizeForZoom=fa,a.evaluateVariableOffset=rf,a.evented=d,a.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},a.exactEquals$1=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},a.exported=Cr,a.exported$1=nt,a.extend=Qt,a.extend$1=Pr,a.fillExtrusionHeightLift=vp,a.filterObject=$n,a.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},a.fromQuat=function(t,e){var i=e[0],n=e[1],s=e[2],c=e[3],u=i+i,p=n+n,m=s+s,_=i*u,x=n*u,b=n*p,w=s*u,S=s*p,M=s*m,C=c*u,D=c*p,U=c*m;return t[0]=1-b-M,t[1]=x+U,t[2]=w-D,t[3]=0,t[4]=x-U,t[5]=1-_-M,t[6]=S+C,t[7]=0,t[8]=w+D,t[9]=S-C,t[10]=1-_-b,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},a.fromRotation=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=0,t[3]=-i,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},a.fromScaling=wd,a.furthestTileCorner=function(t){const e=Math.round((t+45+360)%360/90)%4;return Aa[e]},a.getAABBPointSquareDist=function(t,e,i){let n=0;for(let s=0;s<2;++s){const c=i?i[s]:0;t[s]>c&&(n+=(t[s]-c)*(t[s]-c)),e[s]<c&&(n+=(c-e[s])*(c-e[s]))}return n},a.getAnchorAlignment=Nu,a.getAnchorJustification=$u,a.getBounds=function(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;for(const c of t)e=Math.min(e,c.x),i=Math.min(i,c.y),n=Math.max(n,c.x),s=Math.max(s,c.y);return{min:new Le(e,i),max:new Le(n,s)}},a.getColumn=Jr,a.getDefaultExportFromCjs=or,a.getGridMatrix=function(t,e,i,n){const s=e.getNorth(),c=e.getSouth(),u=e.getWest(),p=e.getEast(),m=1<<t.z,_=p-u,x=s-c,b=_/us,w=-x/kl[i],S=[0,b,0,w,0,0,s,u,0];if(t.z>0){const M=180/n;bd(S,S,[M/_+1,0,0,0,M/x+1,0,-.5*M/b,.5*M/w,1])}return S[2]=m,S[5]=t.x,S[8]=t.y,S},a.getImage=G,a.getJSON=function(t,e){return xn(Qt(t,{type:"json"}),e)},a.getLatitudinalLod=function(t){const e=zi-5;t=ut(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(ft(t))),3);return Math.round(i*(kl.length-1))},a.getMapSessionAPI=_i,a.getPerformanceMeasurement=Ia,a.getProjection=uf,a.getRTLTextPluginStatus=f,a.getReferrer=yn,a.getTilePoint=function(t,{x:e,y:i},n=0){return new Le(((e-n)*t.scale-t.x)*Ze,(i*t.scale-t.y)*Ze)},a.getTileVec3=function(t,e,i=0){return oa(((e.x-i)*t.scale-t.x)*Ze,(e.y*t.scale-t.y)*Ze,$d(e.z,e.y))},a.getVideo=function(t,e){const i=ve.document.createElement("video");i.muted=!0,i.onloadstart=function(){e(null,i)};for(let n=0;n<t.length;n++){const s=ve.document.createElement("source");As(t[n])||(i.crossOrigin="Anonymous"),s.src=t[n],i.appendChild(s)}return{cancel:()=>{}}},a.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=jr(new Float64Array(16));return ls(i,t.pixelMatrix,t.globeMatrix),Jt(e,e,i),new Le(e[0],e[1])},a.globeDenormalizeECEF=mu,a.globeECEFOrigin=function(t,e){const i=[0,0,0];return Jt(i,i,Ll(sn(e.canonical))),Jt(i,i,t),i},a.globeMetersToEcef=Yc,a.globeNormalizeECEF=Ll,a.globePixelsToTileUnits=function(t,e){return Ze/(512*Math.pow(2,t))*Qc(sn(e))},a.globePoleMatrixForTile=function(t,e,i){const n=jr(new Float64Array(16)),s=(e/(1<<t)-.5)*Math.PI*2;return Kc(n,i.globeMatrix,s),Float32Array.from(n)},a.globeTileBounds=sn,a.globeTiltAtLngLat=Nd,a.globeToMercatorTransition=la,a.globeUseCustomAntiAliasing=function(t,e,i){const n=la(i.zoom),s=t.style.map._antialias,c=!!e.extStandardDerivatives,u=e.extStandardDerivativesForceOff||t.terrain&&t.terrain.exaggeration()>0;return n===0&&!s&&!u&&c},a.identity=jr,a.identity$1=zd,a.invert=nu,a.isFullscreen=function(){return!!ve.document.fullscreenElement||!!ve.document.webkitFullscreenElement},a.isLngLatBehindGlobe=_u,a.isMapAuthenticated=function(t){return Pi.has(t)},a.isMapboxURL=ee,a.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!Zn(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},a.latFromMercatorY=Ci,a.latLngToECEF=aa,a.len=lm,a.length=Ml,a.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},a.lngFromMercatorX=dr,a.loadVectorTile=Lf,a.makeRequest=xn,a.mapValue=function(t,e,i,n,s){return ut((t-e)/(i-e)*(s-n)+n,n,s)},a.mercatorScale=Zd,a.mercatorXfromLng=an,a.mercatorYfromLat=ln,a.mercatorZfromAltitude=$r,a.mul=sm,a.mul$1=am,a.multiply=ls,a.multiply$1=bd,a.multiply$2=Sd,a.nextPowerOfTwo=Ar,a.normalize=Fi,a.normalize$1=cm,a.normalize$2=Id,a.number=gt,a.ortho=function(t,e,i,n,s,c,u){var p=1/(e-i),m=1/(n-s),_=1/(c-u);return t[0]=-2*p,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*m,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*_,t[11]=0,t[12]=(e+i)*p,t[13]=(s+n)*m,t[14]=(u+c)*_,t[15]=1,t},a.pbf=zp,a.perspective=function(t,e,i,n,s){var c,u=1/Math.tan(e/2);return t[0]=u/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0?(t[10]=(s+n)*(c=1/(n-s)),t[14]=2*s*n*c):(t[10]=-1,t[14]=-2*n),t},a.pick=function(t,e){const i={};for(let n=0;n<e.length;n++){const s=e[n];s in t&&(i[s]=t[s])}return i},a.plugin=y,a.pointGeometry=fn,a.polesInViewport=function(t){const e=jr(new Float64Array(16));ls(e,t.pixelMatrix,t.globeMatrix);const i=[0,wr,0],n=[0,Tr,0];return Jt(i,i,e),Jt(n,n,e),[i[0]>0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!_u(t,new zt(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!_u(t,new zt(t.center.lat,-90))]},a.polygonContainsPoint=fs,a.polygonIntersectsBox=Jd,a.polygonIntersectsPolygon=Xd,a.polygonizeBounds=function(t,e,i=0,n=!0){const s=new Le(i,i),c=t.sub(s),u=e.add(s),p=[c,new Le(u.x,c.y),u,new Le(c.x,u.y)];return n&&p.push(c.clone()),p},a.posAttributes=Pl,a.postMapLoadEvent=ei,a.postPerformanceEvent=ci,a.postTurnstileEvent=_t,a.potpack=Fu,a.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},a.radToDeg=fi,a.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],a.registerForPluginStateChange=function(t){return t({pluginStatus:l,pluginURL:r}),d.on("pluginStateChange",t),t},a.removeAuthState=function(t){Pi.delete(t)},a.renderColorRamp=Su,a.resample=qd,a.rotateX=ou,a.rotateX$1=Pd,a.rotateY=Kc,a.rotateY$1=kd,a.rotateZ=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),c=e[0],u=e[1],p=e[2],m=e[3],_=e[4],x=e[5],b=e[6],w=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]=c*s+_*n,t[1]=u*s+x*n,t[2]=p*s+b*n,t[3]=m*s+w*n,t[4]=_*s-c*n,t[5]=x*s-u*n,t[6]=b*s-p*n,t[7]=w*s-m*n,t},a.rotateZ$1=function(t,e,i){i*=.5;var n=e[0],s=e[1],c=e[2],u=e[3],p=Math.sin(i),m=Math.cos(i);return t[0]=n*m+s*p,t[1]=s*m-n*p,t[2]=c*m+u*p,t[3]=u*m-c*p,t},a.scale=cs,a.scale$1=Ad,a.scale$2=ur,a.scaleAndAdd=Cl,a.set=function(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t},a.setCacheLimits=function(t,e){Ss=t,Ms=e},a.setColumn=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},a.setRTLTextPlugin=function(t,e,i=!1){if(l===vl||l===bl||l===wl)throw new Error("setRTLTextPlugin cannot be called multiple times.");r=Cr.resolveURL(t),l=vl,fo=e,h(),i||g()},a.smoothstep=Nn,a.spec=fe,a.squaredLength=function(t){var e=t[0],i=t[1],n=t[2];return e*e+i*i+n*n},a.storeAuthState=function(t,e){e?Pi.add(t):Pi.delete(t)},a.sub=Gr,a.subtract=au,a.symbolSize=b_,a.tileAABB=function(t,e,i,n,s,c,u,p,m){if(m.name==="globe")return fm(t,e,new uh(i,n,s));const _=_s({z:i,x:n,y:s},m);return new Ui([(c+_.x/_.scale)*e,e*(_.y/_.scale),u],[(c+_.x2/_.scale)*e,e*(_.y2/_.scale),p])},a.tileCornersToBounds=Jc,a.tileTransform=_s,a.transformMat3=function(t,e,i){var n=e[0],s=e[1],c=e[2];return t[0]=n*i[0]+s*i[3]+c*i[6],t[1]=n*i[1]+s*i[4]+c*i[7],t[2]=n*i[2]+s*i[5]+c*i[8],t},a.transformMat4=Jt,a.transformMat4$1=hs,a.transformQuat=Md,a.transitionTileAABBinECEF=Od,a.translate=Sl,a.transpose=function(t,e){if(t===e){var i=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=n,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},a.triggerPluginCompletionEvent=o,a.uniqueId=jn,a.updateGlobeVertexNormal=function(t,e,i,n,s){const c=5*e+2;t.float32[c+0]=i,t.float32[c+1]=n,t.float32[c+2]=s},a.validateCustomStyleLayer=function(t){const e=[],i=t.id;return i===void 0&&e.push({message:`layers.${i}: missing required property "id"`}),t.render===void 0&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&t.renderingMode!=="2d"&&t.renderingMode!=="3d"&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},a.validateFilter=t=>Qi(rs(t)),a.validateFog=t=>Qi(Uc(t)),a.validateLayer=t=>Qi(Rc(t)),a.validateLight=t=>Qi(Fc(t)),a.validateSource=t=>Qi(Oc(t)),a.validateStyle=Nc,a.validateTerrain=t=>Qi(ml(t)),a.values=Hr,a.vectorTile=lh,a.version=ui,a.warnOnce=Gt,a.window=ve,a.wrap=di}),Kt(["./shared"],function(a){function ve(Z){if(typeof Z=="number"||typeof Z=="boolean"||typeof Z=="string"||Z==null)return JSON.stringify(Z);if(Array.isArray(Z)){let P="[";for(const G of Z)P+=`${ve(G)},`;return`${P}]`}let z="{";for(const P of Object.keys(Z).sort())z+=`${P}:${ve(Z[P])},`;return`${z}}`}function ui(Z){let z="";for(const P of a.refProperties)z+=`/${ve(Z[P])}`;return z}class pi{constructor(z){this.keyCache={},z&&this.replace(z)}replace(z){this._layerConfigs={},this._layers={},this.update(z,[])}update(z,P){for(const H of z)this._layerConfigs[H.id]=H,(this._layers[H.id]=a.createStyleLayer(H)).compileFilter(),this.keyCache[H.id]&&delete this.keyCache[H.id];for(const H of P)delete this.keyCache[H],delete this._layerConfigs[H],delete this._layers[H];this.familiesBySource={};const G=function(H,ee){const ne={};for(let Q=0;Q<H.length;Q++){const de=ee&&ee[H[Q].id]||ui(H[Q]);ee&&(ee[H[Q].id]=de);let Pe=ne[de];Pe||(Pe=ne[de]=[]),Pe.push(H[Q])}const re=[];for(const Q in ne)re.push(ne[Q]);return re}(a.values(this._layerConfigs),this.keyCache);for(const H of G){const ee=H.map(ke=>this._layers[ke.id]),ne=ee[0];if(ne.visibility==="none")continue;const re=ne.source||"";let Q=this.familiesBySource[re];Q||(Q=this.familiesBySource[re]={});const de=ne.sourceLayer||"_geojsonTileLayer";let Pe=Q[de];Pe||(Pe=Q[de]=[]),Pe.push(ee)}}}class Xe{loadTile(z,P){const{uid:G,encoding:H,rawImageData:ee,padding:ne,buildQuadTree:re}=z,Q=a.window.ImageBitmap&&ee instanceof a.window.ImageBitmap?this.getImageData(ee,ne):ee;P(null,new a.DEMData(G,Q,H,ne<1,re))}getImageData(z,P){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(z.width,z.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=z.width,this.offscreenCanvas.height=z.height,this.offscreenCanvasContext.drawImage(z,0,0,z.width,z.height);const G=this.offscreenCanvasContext.getImageData(-P,-P,z.width+2*P,z.height+2*P);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),G}}function nt(Z,z){if(Z.length!==0){Si(Z[0],z);for(var P=1;P<Z.length;P++)Si(Z[P],!z)}}function Si(Z,z){for(var P=0,G=0,H=0,ee=Z.length,ne=ee-1;H<ee;ne=H++){var re=(Z[H][0]-Z[ne][0])*(Z[ne][1]+Z[H][1]),Q=P+re;G+=Math.abs(P)>=Math.abs(re)?P-Q+re:re-Q+P,P=Q}P+G>=0!=!!z&&Z.reverse()}var Li=a.getDefaultExportFromCjs(function Z(z,P){var G,H=z&&z.type;if(H==="FeatureCollection")for(G=0;G<z.features.length;G++)Z(z.features[G],P);else if(H==="GeometryCollection")for(G=0;G<z.geometries.length;G++)Z(z.geometries[G],P);else if(H==="Feature")Z(z.geometry,P);else if(H==="Polygon")nt(z.coordinates,P);else if(H==="MultiPolygon")for(G=0;G<z.coordinates.length;G++)nt(z.coordinates[G],P);return z});const Sr=a.VectorTileFeature.prototype.toGeoJSON;var Mr={exports:{}},Mo=a.pointGeometry,Un=a.vectorTile.VectorTileFeature,or=Vn;function Vn(Z,z){this.options=z||{},this.features=Z,this.length=Z.length}function sr(Z,z){this.id=typeof Z.id=="number"?Z.id:void 0,this.type=Z.type,this.rawGeometry=Z.type===1?[Z.geometry]:Z.geometry,this.properties=Z.tags,this.extent=z||4096}Vn.prototype.feature=function(Z){return new sr(this.features[Z],this.options.extent)},sr.prototype.loadGeometry=function(){var Z=this.rawGeometry;this.geometry=[];for(var z=0;z<Z.length;z++){for(var P=Z[z],G=[],H=0;H<P.length;H++)G.push(new Mo(P[H][0],P[H][1]));this.geometry.push(G)}return this.geometry},sr.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var Z=this.geometry,z=1/0,P=-1/0,G=1/0,H=-1/0,ee=0;ee<Z.length;ee++)for(var ne=Z[ee],re=0;re<ne.length;re++){var Q=ne[re];z=Math.min(z,Q.x),P=Math.max(P,Q.x),G=Math.min(G,Q.y),H=Math.max(H,Q.y)}return[z,G,P,H]},sr.prototype.toGeoJSON=Un.prototype.toGeoJSON;var pn=a.pbf,fn=or;function ar(Z){var z=new pn;return function(P,G){for(var H in P.layers)G.writeMessage(3,Le,P.layers[H])}(Z,z),z.finish()}function Le(Z,z){var P;z.writeVarintField(15,Z.version||1),z.writeStringField(1,Z.name||""),z.writeVarintField(5,Z.extent||4096);var G={keys:[],values:[],keycache:{},valuecache:{}};for(P=0;P<Z.length;P++)G.feature=Z.feature(P),z.writeMessage(2,Sa,G);var H=G.keys;for(P=0;P<H.length;P++)z.writeStringField(3,H[P]);var ee=G.values;for(P=0;P<ee.length;P++)z.writeMessage(4,bs,ee[P])}function Sa(Z,z){var P=Z.feature;P.id!==void 0&&z.writeVarintField(1,P.id),z.writeMessage(2,Ma,Z),z.writeVarintField(3,P.type),z.writeMessage(4,Aa,P)}function Ma(Z,z){var P=Z.feature,G=Z.keys,H=Z.values,ee=Z.keycache,ne=Z.valuecache;for(var re in P.properties){var Q=P.properties[re],de=ee[re];if(Q!==null){de===void 0&&(G.push(re),ee[re]=de=G.length-1),z.writeVarint(de);var Pe=typeof Q;Pe!=="string"&&Pe!=="boolean"&&Pe!=="number"&&(Q=JSON.stringify(Q));var ke=Pe+":"+Q,Ie=ne[ke];Ie===void 0&&(H.push(Q),ne[ke]=Ie=H.length-1),z.writeVarint(Ie)}}}function ft(Z,z){return(z<<3)+(7&Z)}function fi(Z){return Z<<1^Z>>31}function Aa(Z,z){for(var P=Z.loadGeometry(),G=Z.type,H=0,ee=0,ne=P.length,re=0;re<ne;re++){var Q=P[re],de=1;G===1&&(de=Q.length),z.writeVarint(ft(1,de));for(var Pe=G===3?Q.length-1:Q.length,ke=0;ke<Pe;ke++){ke===1&&G!==1&&z.writeVarint(ft(2,Pe-1));var Ie=Q[ke].x-H,Qe=Q[ke].y-ee;z.writeVarint(fi(Ie)),z.writeVarint(fi(Qe)),H+=Ie,ee+=Qe}G===3&&z.writeVarint(ft(7,1))}}function bs(Z,z){var P=typeof Z;P==="string"?z.writeStringField(1,Z):P==="boolean"?z.writeBooleanField(7,Z):P==="number"&&(Z%1!=0?z.writeDoubleField(3,Z):Z<0?z.writeSVarintField(6,Z):z.writeVarintField(5,Z))}Mr.exports=ar,Mr.exports.fromVectorTileJs=ar,Mr.exports.fromGeojsonVt=function(Z,z){z=z||{};var P={};for(var G in Z)P[G]=new fn(Z[G].features,z),P[G].name=G,P[G].version=z.version,P[G].extent=z.extent;return ar({layers:P})},Mr.exports.GeoJSONWrapper=fn;var Ao=a.getDefaultExportFromCjs(Mr.exports);const ws={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:Z=>Z},ut=Math.fround||(Nn=new Float32Array(1),Z=>(Nn[0]=+Z,Nn[0]));var Nn;const di=3,mi=5,Hr=6;class Qt{constructor(z){this.options=Object.assign(Object.create(ws),z),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(z){const{log:P,minZoom:G,maxZoom:H}=this.options;P&&console.time("total time");const ee=`prepare ${z.length} points`;P&&console.time(ee),this.points=z;const ne=[];for(let Q=0;Q<z.length;Q++){const de=z[Q];if(!de.geometry)continue;const[Pe,ke]=de.geometry.coordinates,Ie=ut(Yr(Pe)),Qe=ut(Ar(ke));ne.push(Ie,Qe,1/0,Q,-1,1),this.options.reduce&&ne.push(0)}let re=this.trees[H+1]=this._createTree(ne);P&&console.timeEnd(ee);for(let Q=H;Q>=G;Q--){const de=+Date.now();re=this.trees[Q]=this._createTree(this._cluster(re,Q)),P&&console.log("z%d: %d clusters in %dms",Q,re.numItems,+Date.now()-de)}return P&&console.timeEnd("total time"),this}getClusters(z,P){let G=((z[0]+180)%360+360)%360-180;const H=Math.max(-90,Math.min(90,z[1]));let ee=z[2]===180?180:((z[2]+180)%360+360)%360-180;const ne=Math.max(-90,Math.min(90,z[3]));if(z[2]-z[0]>=360)G=-180,ee=180;else if(G>ee){const ke=this.getClusters([G,H,180,ne],P),Ie=this.getClusters([-180,H,ee,ne],P);return ke.concat(Ie)}const re=this.trees[this._limitZoom(P)],Q=re.range(Yr(G),Ar(ne),Yr(ee),Ar(H)),de=re.data,Pe=[];for(const ke of Q){const Ie=this.stride*ke;Pe.push(de[Ie+mi]>1?Kr(de,Ie,this.clusterProps):this.points[de[Ie+di]])}return Pe}getChildren(z){const P=this._getOriginId(z),G=this._getOriginZoom(z),H="No cluster with the specified id.",ee=this.trees[G];if(!ee)throw new Error(H);const ne=ee.data;if(P*this.stride>=ne.length)throw new Error(H);const re=this.options.radius/(this.options.extent*Math.pow(2,G-1)),Q=ee.within(ne[P*this.stride],ne[P*this.stride+1],re),de=[];for(const Pe of Q){const ke=Pe*this.stride;ne[ke+4]===z&&de.push(ne[ke+mi]>1?Kr(ne,ke,this.clusterProps):this.points[ne[ke+di]])}if(de.length===0)throw new Error(H);return de}getLeaves(z,P,G){const H=[];return this._appendLeaves(H,z,P=P||10,G=G||0,0),H}getTile(z,P,G){const H=this.trees[this._limitZoom(z)],ee=Math.pow(2,z),{extent:ne,radius:re}=this.options,Q=re/ne,de=(G-Q)/ee,Pe=(G+1+Q)/ee,ke={features:[]};return this._addTileFeatures(H.range((P-Q)/ee,de,(P+1+Q)/ee,Pe),H.data,P,G,ee,ke),P===0&&this._addTileFeatures(H.range(1-Q/ee,de,1,Pe),H.data,ee,G,ee,ke),P===ee-1&&this._addTileFeatures(H.range(0,de,Q/ee,Pe),H.data,-1,G,ee,ke),ke.features.length?ke:null}getClusterExpansionZoom(z){let P=this._getOriginZoom(z)-1;for(;P<=this.options.maxZoom;){const G=this.getChildren(z);if(P++,G.length!==1)break;z=G[0].properties.cluster_id}return P}_appendLeaves(z,P,G,H,ee){const ne=this.getChildren(P);for(const re of ne){const Q=re.properties;if(Q&&Q.cluster?ee+Q.point_count<=H?ee+=Q.point_count:ee=this._appendLeaves(z,Q.cluster_id,G,H,ee):ee<H?ee++:z.push(re),z.length===G)break}return ee}_createTree(z){const P=new a.KDBush(z.length/this.stride|0,this.options.nodeSize,Float32Array);for(let G=0;G<z.length;G+=this.stride)P.add(z[G],z[G+1]);return P.finish(),P.data=z,P}_addTileFeatures(z,P,G,H,ee,ne){for(const re of z){const Q=re*this.stride,de=P[Q+mi]>1;let Pe,ke,Ie;if(de)Pe=jn(P,Q,this.clusterProps),ke=P[Q],Ie=P[Q+1];else{const et=this.points[P[Q+di]];Pe=et.properties;const[st,_t]=et.geometry.coordinates;ke=Yr(st),Ie=Ar(_t)}const Qe={type:1,geometry:[[Math.round(this.options.extent*(ke*ee-G)),Math.round(this.options.extent*(Ie*ee-H))]],tags:Pe};let ot;ot=de||this.options.generateId?P[Q+di]:this.points[P[Q+di]].id,ot!==void 0&&(Qe.id=ot),ne.features.push(Qe)}}_limitZoom(z){return Math.max(this.options.minZoom,Math.min(Math.floor(+z),this.options.maxZoom+1))}_cluster(z,P){const{radius:G,extent:H,reduce:ee,minPoints:ne}=this.options,re=G/(H*Math.pow(2,P)),Q=z.data,de=[],Pe=this.stride;for(let ke=0;ke<Q.length;ke+=Pe){if(Q[ke+2]<=P)continue;Q[ke+2]=P;const Ie=Q[ke],Qe=Q[ke+1],ot=z.within(Q[ke],Q[ke+1],re),et=Q[ke+mi];let st=et;for(const _t of ot){const $t=_t*Pe;Q[$t+2]>P&&(st+=Q[$t+mi])}if(st>et&&st>=ne){let _t,$t=Ie*et,ei=Qe*et,Mi=-1;const ci=((ke/Pe|0)<<5)+(P+1)+this.points.length;for(const fr of ot){const _i=fr*Pe;if(Q[_i+2]<=P)continue;Q[_i+2]=P;const Pi=Q[_i+mi];$t+=Q[_i]*Pi,ei+=Q[_i+1]*Pi,Q[_i+4]=ci,ee&&(_t||(_t=this._map(Q,ke,!0),Mi=this.clusterProps.length,this.clusterProps.push(_t)),ee(_t,this._map(Q,_i)))}Q[ke+4]=ci,de.push($t/st,ei/st,1/0,ci,-1,st),ee&&de.push(Mi)}else{for(let _t=0;_t<Pe;_t++)de.push(Q[ke+_t]);if(st>1)for(const _t of ot){const $t=_t*Pe;if(!(Q[$t+2]<=P)){Q[$t+2]=P;for(let ei=0;ei<Pe;ei++)de.push(Q[$t+ei])}}}}return de}_getOriginId(z){return z-this.points.length>>5}_getOriginZoom(z){return(z-this.points.length)%32}_map(z,P,G){if(z[P+mi]>1){const ne=this.clusterProps[z[P+Hr]];return G?Object.assign({},ne):ne}const H=this.points[z[P+di]].properties,ee=this.options.map(H);return G&&ee===H?Object.assign({},ee):ee}}function Kr(Z,z,P){return{type:"Feature",id:Z[z+di],properties:jn(Z,z,P),geometry:{type:"Point",coordinates:[(G=Z[z],360*(G-.5)),Ts(Z[z+1])]}};var G}function jn(Z,z,P){const G=Z[z+mi],H=G>=1e4?`${Math.round(G/1e3)}k`:G>=1e3?Math.round(G/100)/10+"k":G,ee=Z[z+Hr],ne=ee===-1?{}:Object.assign({},P[ee]);return Object.assign(ne,{cluster:!0,cluster_id:Z[z+di],point_count:G,point_count_abbreviated:H})}function Yr(Z){return Z/360+.5}function Ar(Z){const z=Math.sin(Z*Math.PI/180),P=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return P<0?0:P>1?1:P}function Ts(Z){const z=(180-360*Z)*Math.PI/180;return 360*Math.atan(Math.exp(z))/Math.PI-90}function mn(Z,z,P,G){for(var H,ee=G,ne=P-z>>1,re=P-z,Q=Z[z],de=Z[z+1],Pe=Z[P],ke=Z[P+1],Ie=z+3;Ie<P;Ie+=3){var Qe=Gn(Z[Ie],Z[Ie+1],Q,de,Pe,ke);if(Qe>ee)H=Ie,ee=Qe;else if(Qe===ee){var ot=Math.abs(Ie-ne);ot<re&&(H=Ie,re=ot)}}ee>G&&(H-z>3&&mn(Z,z,H,G),Z[H+2]=ee,P-H>3&&mn(Z,H,P,G))}function Gn(Z,z,P,G,H,ee){var ne=H-P,re=ee-G;if(ne!==0||re!==0){var Q=((Z-P)*ne+(z-G)*re)/(ne*ne+re*re);Q>1?(P=H,G=ee):Q>0&&(P+=ne*Q,G+=re*Q)}return(ne=Z-P)*ne+(re=z-G)*re}function mt(Z,z,P,G){var H={id:Z===void 0?null:Z,type:z,geometry:P,tags:G,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(ee){var ne=ee.geometry,re=ee.type;if(re==="Point"||re==="MultiPoint"||re==="LineString")$n(ee,ne);else if(re==="Polygon"||re==="MultiLineString")for(var Q=0;Q<ne.length;Q++)$n(ee,ne[Q]);else if(re==="MultiPolygon")for(Q=0;Q<ne.length;Q++)for(var de=0;de<ne[Q].length;de++)$n(ee,ne[Q][de])}(H),H}function $n(Z,z){for(var P=0;P<z.length;P+=3)Z.minX=Math.min(Z.minX,z[P]),Z.minY=Math.min(Z.minY,z[P+1]),Z.maxX=Math.max(Z.maxX,z[P]),Z.maxY=Math.max(Z.maxY,z[P+1])}function Gi(Z,z,P,G){if(z.geometry){var H=z.geometry.coordinates,ee=z.geometry.type,ne=Math.pow(P.tolerance/((1<<P.maxZoom)*P.extent),2),re=[],Q=z.id;if(P.promoteId?Q=z.properties[P.promoteId]:P.generateId&&(Q=G||0),ee==="Point")Io(H,re);else if(ee==="MultiPoint")for(var de=0;de<H.length;de++)Io(H[de],re);else if(ee==="LineString")Gt(H,re,ne,!1);else if(ee==="MultiLineString"){if(P.lineMetrics){for(de=0;de<H.length;de++)Gt(H[de],re=[],ne,!1),Z.push(mt(Q,"LineString",re,z.properties));return}Xi(H,re,ne,!1)}else if(ee==="Polygon")Xi(H,re,ne,!0);else{if(ee!=="MultiPolygon"){if(ee==="GeometryCollection"){for(de=0;de<z.geometry.geometries.length;de++)Gi(Z,{id:Q,geometry:z.geometry.geometries[de],properties:z.properties},P,G);return}throw new Error("Input data is not a valid GeoJSON object.")}for(de=0;de<H.length;de++){var Pe=[];Xi(H[de],Pe,ne,!0),re.push(Pe)}}Z.push(mt(Q,ee,re,z.properties))}}function Io(Z,z){z.push(Es(Z[0])),z.push(Ir(Z[1])),z.push(0)}function Gt(Z,z,P,G){for(var H,ee,ne=0,re=0;re<Z.length;re++){var Q=Es(Z[re][0]),de=Ir(Z[re][1]);z.push(Q),z.push(de),z.push(0),re>0&&(ne+=G?(H*de-Q*ee)/2:Math.sqrt(Math.pow(Q-H,2)+Math.pow(de-ee,2))),H=Q,ee=de}var Pe=z.length-3;z[2]=1,mn(z,0,Pe,P),z[Pe+2]=1,z.size=Math.abs(ne),z.start=0,z.end=z.size}function Xi(Z,z,P,G){for(var H=0;H<Z.length;H++){var ee=[];Gt(Z[H],ee,P,G),z.push(ee)}}function Es(Z){return Z/360+.5}function Ir(Z){var z=Math.sin(Z*Math.PI/180),P=.5-.25*Math.log((1+z)/(1-z))/Math.PI;return P<0?0:P>1?1:P}function $i(Z,z,P,G,H,ee,ne,re){if(G/=z,ee>=(P/=z)&&ne<G)return Z;if(ne<P||ee>=G)return null;for(var Q=[],de=0;de<Z.length;de++){var Pe=Z[de],ke=Pe.geometry,Ie=Pe.type,Qe=H===0?Pe.minX:Pe.minY,ot=H===0?Pe.maxX:Pe.maxY;if(Qe>=P&&ot<G)Q.push(Pe);else if(!(ot<P||Qe>=G)){var et=[];if(Ie==="Point"||Ie==="MultiPoint")Co(ke,et,P,G,H);else if(Ie==="LineString")Zn(ke,et,P,G,H,!1,re.lineMetrics);else if(Ie==="MultiLineString")Jr(ke,et,P,G,H,!1);else if(Ie==="Polygon")Jr(ke,et,P,G,H,!0);else if(Ie==="MultiPolygon")for(var st=0;st<ke.length;st++){var _t=[];Jr(ke[st],_t,P,G,H,!0),_t.length&&et.push(_t)}if(et.length){if(re.lineMetrics&&Ie==="LineString"){for(st=0;st<et.length;st++)Q.push(mt(Pe.id,Ie,et[st],Pe.tags));continue}Ie!=="LineString"&&Ie!=="MultiLineString"||(et.length===1?(Ie="LineString",et=et[0]):Ie="MultiLineString"),Ie!=="Point"&&Ie!=="MultiPoint"||(Ie=et.length===3?"Point":"MultiPoint"),Q.push(mt(Pe.id,Ie,et,Pe.tags))}}}return Q.length?Q:null}function Co(Z,z,P,G,H){for(var ee=0;ee<Z.length;ee+=3){var ne=Z[ee+H];ne>=P&&ne<=G&&(z.push(Z[ee]),z.push(Z[ee+1]),z.push(Z[ee+2]))}}function Zn(Z,z,P,G,H,ee,ne){for(var re,Q,de=zo(Z),Pe=H===0?Ss:Ms,ke=Z.start,Ie=0;Ie<Z.length-3;Ie+=3){var Qe=Z[Ie],ot=Z[Ie+1],et=Z[Ie+2],st=Z[Ie+3],_t=Z[Ie+4],$t=H===0?Qe:ot,ei=H===0?st:_t,Mi=!1;ne&&(re=Math.sqrt(Math.pow(Qe-st,2)+Math.pow(ot-_t,2))),$t<P?ei>P&&(Q=Pe(de,Qe,ot,st,_t,P),ne&&(de.start=ke+re*Q)):$t>G?ei<G&&(Q=Pe(de,Qe,ot,st,_t,G),ne&&(de.start=ke+re*Q)):qn(de,Qe,ot,et),ei<P&&$t>=P&&(Q=Pe(de,Qe,ot,st,_t,P),Mi=!0),ei>G&&$t<=G&&(Q=Pe(de,Qe,ot,st,_t,G),Mi=!0),!ee&&Mi&&(ne&&(de.end=ke+re*Q),z.push(de),de=zo(Z)),ne&&(ke+=re)}var ci=Z.length-3;Qe=Z[ci],ot=Z[ci+1],et=Z[ci+2],($t=H===0?Qe:ot)>=P&&$t<=G&&qn(de,Qe,ot,et),ci=de.length-3,ee&&ci>=3&&(de[ci]!==de[0]||de[ci+1]!==de[1])&&qn(de,de[0],de[1],de[2]),de.length&&z.push(de)}function zo(Z){var z=[];return z.size=Z.size,z.start=Z.start,z.end=Z.end,z}function Jr(Z,z,P,G,H,ee){for(var ne=0;ne<Z.length;ne++)Zn(Z[ne],z,P,G,H,ee,!1)}function qn(Z,z,P,G){Z.push(z),Z.push(P),Z.push(G)}function Ss(Z,z,P,G,H,ee){var ne=(ee-z)/(G-z);return Z.push(ee),Z.push(P+(H-P)*ne),Z.push(1),ne}function Ms(Z,z,P,G,H,ee){var ne=(ee-P)/(H-P);return Z.push(z+(G-z)*ne),Z.push(ee),Z.push(1),ne}function Hi(Z,z){for(var P=[],G=0;G<Z.length;G++){var H,ee=Z[G],ne=ee.type;if(ne==="Point"||ne==="MultiPoint"||ne==="LineString")H=Qr(ee.geometry,z);else if(ne==="MultiLineString"||ne==="Polygon"){H=[];for(var re=0;re<ee.geometry.length;re++)H.push(Qr(ee.geometry[re],z))}else if(ne==="MultiPolygon")for(H=[],re=0;re<ee.geometry.length;re++){for(var Q=[],de=0;de<ee.geometry[re].length;de++)Q.push(Qr(ee.geometry[re][de],z));H.push(Q)}P.push(mt(ee.id,ne,H,ee.tags))}return P}function Qr(Z,z){var P=[];P.size=Z.size,Z.start!==void 0&&(P.start=Z.start,P.end=Z.end);for(var G=0;G<Z.length;G+=3)P.push(Z[G]+z,Z[G+1],Z[G+2]);return P}function Po(Z,z){if(Z.transformed)return Z;var P,G,H,ee=1<<Z.z,ne=Z.x,re=Z.y;for(P=0;P<Z.features.length;P++){var Q=Z.features[P],de=Q.geometry,Pe=Q.type;if(Q.geometry=[],Pe===1)for(G=0;G<de.length;G+=2)Q.geometry.push(_n(de[G],de[G+1],z,ee,ne,re));else for(G=0;G<de.length;G++){var ke=[];for(H=0;H<de[G].length;H+=2)ke.push(_n(de[G][H],de[G][H+1],z,ee,ne,re));Q.geometry.push(ke)}}return Z.transformed=!0,Z}function _n(Z,z,P,G,H,ee){return[Math.round(P*(Z*G-H)),Math.round(P*(z*G-ee))]}function Wn(Z,z,P,G,H){for(var ee=z===H.maxZoom?0:H.tolerance/((1<<z)*H.extent),ne={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:P,y:G,z,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},re=0;re<Z.length;re++){ne.numFeatures++,ko(ne,Z[re],ee,H);var Q=Z[re].minX,de=Z[re].minY,Pe=Z[re].maxX,ke=Z[re].maxY;Q<ne.minX&&(ne.minX=Q),de<ne.minY&&(ne.minY=de),Pe>ne.maxX&&(ne.maxX=Pe),ke>ne.maxY&&(ne.maxY=ke)}return ne}function ko(Z,z,P,G){var H=z.geometry,ee=z.type,ne=[];if(ee==="Point"||ee==="MultiPoint")for(var re=0;re<H.length;re+=3)ne.push(H[re]),ne.push(H[re+1]),Z.numPoints++,Z.numSimplified++;else if(ee==="LineString")gn(ne,H,Z,P,!1,!1);else if(ee==="MultiLineString"||ee==="Polygon")for(re=0;re<H.length;re++)gn(ne,H[re],Z,P,ee==="Polygon",re===0);else if(ee==="MultiPolygon")for(var Q=0;Q<H.length;Q++){var de=H[Q];for(re=0;re<de.length;re++)gn(ne,de[re],Z,P,!0,re===0)}if(ne.length){var Pe=z.tags||null;if(ee==="LineString"&&G.lineMetrics){for(var ke in Pe={},z.tags)Pe[ke]=z.tags[ke];Pe.mapbox_clip_start=H.start/H.size,Pe.mapbox_clip_end=H.end/H.size}var Ie={geometry:ne,type:ee==="Polygon"||ee==="MultiPolygon"?3:ee==="LineString"||ee==="MultiLineString"?2:1,tags:Pe};z.id!==null&&(Ie.id=z.id),Z.features.push(Ie)}}function gn(Z,z,P,G,H,ee){var ne=G*G;if(G>0&&z.size<(H?ne:G))P.numPoints+=z.length/3;else{for(var re=[],Q=0;Q<z.length;Q+=3)(G===0||z[Q+2]>ne)&&(P.numSimplified++,re.push(z[Q]),re.push(z[Q+1])),P.numPoints++;H&&function(de,Pe){for(var ke=0,Ie=0,Qe=de.length,ot=Qe-2;Ie<Qe;ot=Ie,Ie+=2)ke+=(de[Ie]-de[ot])*(de[Ie+1]+de[ot+1]);if(ke>0===Pe)for(Ie=0,Qe=de.length;Ie<Qe/2;Ie+=2){var et=de[Ie],st=de[Ie+1];de[Ie]=de[Qe-2-Ie],de[Ie+1]=de[Qe-1-Ie],de[Qe-2-Ie]=et,de[Qe-1-Ie]=st}}(re,ee),Z.push(re)}}function en(Z,z){var P=(z=this.options=function(H,ee){for(var ne in ee)H[ne]=ee[ne];return H}(Object.create(this.options),z)).debug;if(P&&console.time("preprocess data"),z.maxZoom<0||z.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(z.promoteId&&z.generateId)throw new Error("promoteId and generateId cannot be used together.");var G=function(H,ee){var ne=[];if(H.type==="FeatureCollection")for(var re=0;re<H.features.length;re++)Gi(ne,H.features[re],ee,re);else Gi(ne,H.type==="Feature"?H:{geometry:H},ee);return ne}(Z,z);this.tiles={},this.tileCoords=[],P&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",z.indexMaxZoom,z.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),G=function(H,ee){var ne=ee.buffer/ee.extent,re=H,Q=$i(H,1,-1-ne,ne,0,-1,2,ee),de=$i(H,1,1-ne,2+ne,0,-1,2,ee);return(Q||de)&&(re=$i(H,1,-ne,1+ne,0,-1,2,ee)||[],Q&&(re=Hi(Q,1).concat(re)),de&&(re=re.concat(Hi(de,-1)))),re}(G,z),G.length&&this.splitTile(G,0,0,0),P&&(G.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function yn(Z,z,P){return 32*((1<<Z)*P+z)+Z}function xn(Z,z){const P=Z.tileID.canonical;if(!this._geoJSONIndex)return z(null,null);const G=this._geoJSONIndex.getTile(P.z,P.x,P.y);if(!G)return z(null,null);const H=new class{constructor(ne){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=ne.length,this._features=ne}feature(ne){return new class{constructor(re){this._feature=re,this.extent=a.EXTENT,this.type=re.type,this.properties=re.tags,"id"in re&&!isNaN(re.id)&&(this.id=parseInt(re.id,10))}loadGeometry(){if(this._feature.type===1){const re=[];for(const Q of this._feature.geometry)re.push([new a.Point(Q[0],Q[1])]);return re}{const re=[];for(const Q of this._feature.geometry){const de=[];for(const Pe of Q)de.push(new a.Point(Pe[0],Pe[1]));re.push(de)}return re}}toGeoJSON(re,Q,de){return Sr.call(this,re,Q,de)}}(this._features[ne])}}(G.features);let ee=Ao(H);ee.byteOffset===0&&ee.byteLength===ee.buffer.byteLength||(ee=new Uint8Array(ee)),z(null,{vectorTile:H,rawData:ee.buffer})}en.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},en.prototype.splitTile=function(Z,z,P,G,H,ee,ne){for(var re=[Z,z,P,G],Q=this.options,de=Q.debug;re.length;){G=re.pop(),P=re.pop(),z=re.pop(),Z=re.pop();var Pe=1<<z,ke=yn(z,P,G),Ie=this.tiles[ke];if(!Ie&&(de>1&&console.time("creation"),Ie=this.tiles[ke]=Wn(Z,z,P,G,Q),this.tileCoords.push({z,x:P,y:G}),de)){de>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",z,P,G,Ie.numFeatures,Ie.numPoints,Ie.numSimplified),console.timeEnd("creation"));var Qe="z"+z;this.stats[Qe]=(this.stats[Qe]||0)+1,this.total++}if(Ie.source=Z,H){if(z===Q.maxZoom||z===H)continue;var ot=1<<H-z;if(P!==Math.floor(ee/ot)||G!==Math.floor(ne/ot))continue}else if(z===Q.indexMaxZoom||Ie.numPoints<=Q.indexMaxPoints)continue;if(Ie.source=null,Z.length!==0){de>1&&console.time("clipping");var et,st,_t,$t,ei,Mi,ci=.5*Q.buffer/Q.extent,fr=.5-ci,_i=.5+ci,Pi=1+ci;et=st=_t=$t=null,ei=$i(Z,Pe,P-ci,P+_i,0,Ie.minX,Ie.maxX,Q),Mi=$i(Z,Pe,P+fr,P+Pi,0,Ie.minX,Ie.maxX,Q),Z=null,ei&&(et=$i(ei,Pe,G-ci,G+_i,1,Ie.minY,Ie.maxY,Q),st=$i(ei,Pe,G+fr,G+Pi,1,Ie.minY,Ie.maxY,Q),ei=null),Mi&&(_t=$i(Mi,Pe,G-ci,G+_i,1,Ie.minY,Ie.maxY,Q),$t=$i(Mi,Pe,G+fr,G+Pi,1,Ie.minY,Ie.maxY,Q),Mi=null),de>1&&console.timeEnd("clipping"),re.push(et||[],z+1,2*P,2*G),re.push(st||[],z+1,2*P,2*G+1),re.push(_t||[],z+1,2*P+1,2*G),re.push($t||[],z+1,2*P+1,2*G+1)}}},en.prototype.getTile=function(Z,z,P){var G=this.options,H=G.extent,ee=G.debug;if(Z<0||Z>24)return null;var ne=1<<Z,re=yn(Z,z=(z%ne+ne)%ne,P);if(this.tiles[re])return Po(this.tiles[re],H);ee>1&&console.log("drilling down to z%d-%d-%d",Z,z,P);for(var Q,de=Z,Pe=z,ke=P;!Q&&de>0;)de--,Pe=Math.floor(Pe/2),ke=Math.floor(ke/2),Q=this.tiles[yn(de,Pe,ke)];return Q&&Q.source?(ee>1&&console.log("found parent tile z%d-%d-%d",de,Pe,ke),ee>1&&console.time("drilling down"),this.splitTile(Q.source,de,Pe,ke,Z,z,P),ee>1&&console.timeEnd("drilling down"),this.tiles[re]?Po(this.tiles[re],H):null):null};class Xn extends a.VectorTileWorkerSource{constructor(z,P,G,H,ee){super(z,P,G,H,xn),ee&&(this.loadGeoJSON=ee)}loadData(z,P){const G=z&&z.request,H=G&&G.collectResourceTiming;this.loadGeoJSON(z,(ee,ne)=>{if(ee||!ne)return P(ee);if(typeof ne!="object")return P(new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`));{Li(ne,!0);try{if(z.filter){const Q=a.createExpression(z.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Q.result==="error")throw new Error(Q.value.map(Pe=>`${Pe.key}: ${Pe.message}`).join(", "));ne={type:"FeatureCollection",features:ne.features.filter(Pe=>Q.value.evaluate({zoom:0},Pe))}}this._geoJSONIndex=z.cluster?new Qt(function({superclusterOptions:Q,clusterProperties:de}){if(!de||!Q)return Q;const Pe={},ke={},Ie={accumulated:null,zoom:0},Qe={properties:null},ot=Object.keys(de);for(const et of ot){const[st,_t]=de[et],$t=a.createExpression(_t),ei=a.createExpression(typeof st=="string"?[st,["accumulated"],["get",et]]:st);Pe[et]=$t.value,ke[et]=ei.value}return Q.map=et=>{Qe.properties=et;const st={};for(const _t of ot)st[_t]=Pe[_t].evaluate(Ie,Qe);return st},Q.reduce=(et,st)=>{Qe.properties=st;for(const _t of ot)Ie.accumulated=et[_t],et[_t]=ke[_t].evaluate(Ie,Qe)},Q}(z)).load(ne.features):function(Q,de){return new en(Q,de)}(ne,z.geojsonVtOptions)}catch(Q){return P(Q)}this.loaded={};const re={};if(H){const Q=a.getPerformanceMeasurement(G);Q&&(re.resourceTiming={},re.resourceTiming[z.source]=JSON.parse(JSON.stringify(Q)))}P(null,re)}})}reloadTile(z,P){const G=this.loaded;return G&&G[z.uid]?super.reloadTile(z,P):this.loadTile(z,P)}loadGeoJSON(z,P){if(z.request)a.getJSON(z.request,P);else{if(typeof z.data!="string")return P(new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`));try{return P(null,JSON.parse(z.data))}catch{return P(new Error(`Input data given to '${z.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(z,P){try{P(null,this._geoJSONIndex.getClusterExpansionZoom(z.clusterId))}catch(G){P(G)}}getClusterChildren(z,P){try{P(null,this._geoJSONIndex.getChildren(z.clusterId))}catch(G){P(G)}}getClusterLeaves(z,P){try{P(null,this._geoJSONIndex.getLeaves(z.clusterId,z.limit,z.offset))}catch(G){P(G)}}}class As{constructor(z){this.self=z,this.actor=new a.Actor(z,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:Xn},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(P,G)=>{if(this.workerSourceTypes[P])throw new Error(`Worker source with name "${P}" already registered.`);this.workerSourceTypes[P]=G},this.self.registerRTLTextPlugin=P=>{if(a.plugin.isParsed())throw new Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=P.applyArabicShaping,a.plugin.processBidirectionalText=P.processBidirectionalText,a.plugin.processStyledBidirectionalText=P.processStyledBidirectionalText}}clearCaches(z,P,G){delete this.layerIndexes[z],delete this.availableImages[z],delete this.workerSources[z],delete this.demWorkerSources[z],G()}checkIfReady(z,P,G){G()}setReferrer(z,P){this.referrer=P}spriteLoaded(z,P){this.isSpriteLoaded[z]=P;for(const G in this.workerSources[z]){const H=this.workerSources[z][G];for(const ee in H)H[ee]instanceof a.VectorTileWorkerSource&&(H[ee].isSpriteLoaded=P,H[ee].fire(new a.Event("isSpriteLoaded")))}}setImages(z,P,G){this.availableImages[z]=P;for(const H in this.workerSources[z]){const ee=this.workerSources[z][H];for(const ne in ee)ee[ne].availableImages=P}G()}enableTerrain(z,P,G){this.terrain=P,G()}setProjection(z,P){this.projections[z]=a.getProjection(P)}setLayers(z,P,G){this.getLayerIndex(z).replace(P),G()}updateLayers(z,P,G){this.getLayerIndex(z).update(P.layers,P.removedIds),G()}loadTile(z,P,G){const H=this.enableTerrain?a.extend({enableTerrain:this.terrain},P):P;H.projection=this.projections[z]||this.defaultProjection,this.getWorkerSource(z,P.type,P.source).loadTile(H,G)}loadDEMTile(z,P,G){const H=this.enableTerrain?a.extend({buildQuadTree:this.terrain},P):P;this.getDEMWorkerSource(z,P.source).loadTile(H,G)}reloadTile(z,P,G){const H=this.enableTerrain?a.extend({enableTerrain:this.terrain},P):P;H.projection=this.projections[z]||this.defaultProjection,this.getWorkerSource(z,P.type,P.source).reloadTile(H,G)}abortTile(z,P,G){this.getWorkerSource(z,P.type,P.source).abortTile(P,G)}removeTile(z,P,G){this.getWorkerSource(z,P.type,P.source).removeTile(P,G)}removeSource(z,P,G){if(!this.workerSources[z]||!this.workerSources[z][P.type]||!this.workerSources[z][P.type][P.source])return;const H=this.workerSources[z][P.type][P.source];delete this.workerSources[z][P.type][P.source],H.removeSource!==void 0?H.removeSource(P,G):G()}loadWorkerSource(z,P,G){try{this.self.importScripts(P.url),G()}catch(H){G(H.toString())}}syncRTLPluginState(z,P,G){try{a.plugin.setState(P);const H=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&H!=null){this.self.importScripts(H);const ee=a.plugin.isParsed();G(ee?void 0:new Error(`RTL Text Plugin failed to import scripts from ${H}`),ee)}}catch(H){G(H.toString())}}getAvailableImages(z){let P=this.availableImages[z];return P||(P=[]),P}getLayerIndex(z){let P=this.layerIndexes[z];return P||(P=this.layerIndexes[z]=new pi),P}getWorkerSource(z,P,G){if(this.workerSources[z]||(this.workerSources[z]={}),this.workerSources[z][P]||(this.workerSources[z][P]={}),!this.workerSources[z][P][G]){const H={send:(ee,ne,re,Q,de,Pe)=>{this.actor.send(ee,ne,re,z,de,Pe)},scheduler:this.actor.scheduler};this.workerSources[z][P][G]=new this.workerSourceTypes[P](H,this.getLayerIndex(z),this.getAvailableImages(z),this.isSpriteLoaded[z])}return this.workerSources[z][P][G]}getDEMWorkerSource(z,P){return this.demWorkerSources[z]||(this.demWorkerSources[z]={}),this.demWorkerSources[z][P]||(this.demWorkerSources[z][P]=new Xe),this.demWorkerSources[z][P]}enforceCacheSizeLimit(z,P){a.enforceCacheSizeLimit(P)}getWorkerPerformanceMetrics(z,P,G){G(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new As(self)),As}),Kt(["./shared"],function(a){function ve(l,r){if(Array.isArray(l)){if(!Array.isArray(r)||l.length!==r.length)return!1;for(let o=0;o<l.length;o++)if(!ve(l[o],r[o]))return!1;return!0}if(typeof l=="object"&&l!==null&&r!==null){if(typeof r!="object"||Object.keys(l).length!==Object.keys(r).length)return!1;for(const o in l)if(!ve(l[o],r[o]))return!1;return!0}return l===r}var ui=pi;function pi(l){return!function(r){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var h,d,f=new Blob([""],{type:"text/javascript"}),g=URL.createObjectURL(f);try{d=new Worker(g),h=!0}catch{h=!1}return d&&d.terminate(),URL.revokeObjectURL(g),h}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var h=document.createElement("canvas");h.width=h.height=1;var d=h.getContext("2d");if(!d)return!1;var f=d.getImageData(0,0,1,1);return f&&f.width===h.width}()?(Xe[o=r&&r.failIfMajorPerformanceCaveat]===void 0&&(Xe[o]=function(h){var d,f=function(g){var y=document.createElement("canvas"),v=Object.create(pi.webGLContextAttributes);return v.failIfMajorPerformanceCaveat=g,y.getContext("webgl",v)||y.getContext("experimental-webgl",v)}(h);if(!f)return!1;try{d=f.createShader(f.VERTEX_SHADER)}catch{return!1}return!(!d||f.isContextLost())&&(f.shaderSource(d,"void main() {}"),f.compileShader(d),f.getShaderParameter(d,f.COMPILE_STATUS)===!0)}(o)),Xe[o]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var o}(l)}var Xe={};function nt(l,r,o){const h=a.window.document.createElement(l);return r!==void 0&&(h.className=r),o&&o.appendChild(h),h}function Si(l,r,o){const h=a.window.document.createElementNS("http://www.w3.org/2000/svg",l);for(const d of Object.keys(r))h.setAttributeNS(null,d,r[d]);return o&&o.appendChild(h),h}pi.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const Li=a.window.document&&a.window.document.documentElement.style,Sr=Li&&Li.userSelect!==void 0?"userSelect":"WebkitUserSelect";let Mr;function Mo(){Li&&Sr&&(Mr=Li[Sr],Li[Sr]="none")}function Un(){Li&&Sr&&(Li[Sr]=Mr)}function or(l){l.preventDefault(),l.stopPropagation(),a.window.removeEventListener("click",or,!0)}function Vn(){a.window.addEventListener("click",or,!0),a.window.setTimeout(()=>{a.window.removeEventListener("click",or,!0)},0)}function sr(l,r){const o=l.getBoundingClientRect();return ar(l,o,r)}function pn(l,r){const o=l.getBoundingClientRect(),h=[];for(let d=0;d<r.length;d++)h.push(ar(l,o,r[d]));return h}function fn(l){return a.window.InstallTrigger!==void 0&&l.button===2&&l.ctrlKey&&a.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:l.button}function ar(l,r,o){const h=l.offsetWidth===r.width?1:l.offsetWidth/r.width;return new a.Point((o.clientX-r.left)*h,(o.clientY-r.top)*h)}function Le(l,r){var o=r[0],h=r[1],d=r[2],f=r[3],g=o*f-d*h;return g?(l[0]=f*(g=1/g),l[1]=-h*g,l[2]=-d*g,l[3]=o*g,l):null}function Sa(l){const{userImage:r}=l;return!!(r&&r.render&&r.render())&&(l.data.replace(new Uint8Array(r.data.buffer)),!0)}class Ma extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(r){if(this.loaded!==r&&(this.loaded=r,r)){for(const{ids:o,callback:h}of this.requestors)this._notify(o,h);this.requestors=[]}}hasImage(r){return!!this.getImage(r)}getImage(r){return this.images[r]}addImage(r,o){this._validate(r,o)&&(this.images[r]=o)}_validate(r,o){let h=!0;return this._validateStretch(o.stretchX,o.data&&o.data.width)||(this.fire(new a.ErrorEvent(new Error(`Image "${r}" has invalid "stretchX" value`))),h=!1),this._validateStretch(o.stretchY,o.data&&o.data.height)||(this.fire(new a.ErrorEvent(new Error(`Image "${r}" has invalid "stretchY" value`))),h=!1),this._validateContent(o.content,o)||(this.fire(new a.ErrorEvent(new Error(`Image "${r}" has invalid "content" value`))),h=!1),h}_validateStretch(r,o){if(!r)return!0;let h=0;for(const d of r){if(d[0]<h||d[1]<d[0]||o<d[1])return!1;h=d[1]}return!0}_validateContent(r,o){return!(r&&(r.length!==4||r[0]<0||o.data.width<r[0]||r[1]<0||o.data.height<r[1]||r[2]<0||o.data.width<r[2]||r[3]<0||o.data.height<r[3]||r[2]<r[0]||r[3]<r[1]))}updateImage(r,o){o.version=this.images[r].version+1,this.images[r]=o,this.updatedImages[r]=!0}removeImage(r){const o=this.images[r];delete this.images[r],delete this.patterns[r],o.userImage&&o.userImage.onRemove&&o.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(r,o){let h=!0;if(!this.isLoaded())for(const d of r)this.images[d]||(h=!1);this.isLoaded()||h?this._notify(r,o):this.requestors.push({ids:r,callback:o})}_notify(r,o){const h={};for(const d of r){this.images[d]||this.fire(new a.Event("styleimagemissing",{id:d}));const f=this.images[d];f?h[d]={data:f.data.clone(),pixelRatio:f.pixelRatio,sdf:f.sdf,version:f.version,stretchX:f.stretchX,stretchY:f.stretchY,content:f.content,hasRenderCallback:!!(f.userImage&&f.userImage.render)}:a.warnOnce(`Image "${d}" 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.`)}o(null,h)}getPixelSize(){const{width:r,height:o}=this.atlasImage;return{width:r,height:o}}getPattern(r){const o=this.patterns[r],h=this.getImage(r);if(!h)return null;if(o&&o.position.version===h.version)return o.position;if(o)o.position.version=h.version;else{const d={w:h.data.width+2,h:h.data.height+2,x:0,y:0},f=new a.ImagePosition(d,h);this.patterns[r]={bin:d,position:f}}return this._updatePatternAtlas(),this.patterns[r].position}bind(r){const o=r.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.Texture(r,this.atlasImage,o.RGBA),this.atlasTexture&&this.atlasTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE)}_updatePatternAtlas(){const r=[];for(const f in this.patterns)r.push(this.patterns[f].bin);const{w:o,h}=a.potpack(r),d=this.atlasImage;d.resize({width:o||1,height:h||1});for(const f in this.patterns){const{bin:g}=this.patterns[f],y=g.x+1,v=g.y+1,E=this.images[f].data,T=E.width,A=E.height;a.RGBAImage.copy(E,d,{x:0,y:0},{x:y,y:v},{width:T,height:A}),a.RGBAImage.copy(E,d,{x:0,y:A-1},{x:y,y:v-1},{width:T,height:1}),a.RGBAImage.copy(E,d,{x:0,y:0},{x:y,y:v+A},{width:T,height:1}),a.RGBAImage.copy(E,d,{x:T-1,y:0},{x:y-1,y:v},{width:1,height:A}),a.RGBAImage.copy(E,d,{x:0,y:0},{x:y+T,y:v},{width:1,height:A})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(r){for(const o of r){if(this.callbackDispatchedThisFrame[o])continue;this.callbackDispatchedThisFrame[o]=!0;const h=this.images[o];Sa(h)&&this.updateImage(o,h)}}}const ft=new a.Properties({anchor:new a.DataConstantProperty(a.spec.light.anchor),position:new class{constructor(){this.specification=a.spec.light.position}possiblyEvaluate(l,r){return function([o,h,d]){const f=a.degToRad(h+90),g=a.degToRad(d);return{x:o*Math.cos(f)*Math.sin(g),y:o*Math.sin(f)*Math.sin(g),z:o*Math.cos(g),azimuthal:h,polar:d}}(l.expression.evaluate(r))}interpolate(l,r,o){return{x:a.number(l.x,r.x,o),y:a.number(l.y,r.y,o),z:a.number(l.z,r.z,o),azimuthal:a.number(l.azimuthal,r.azimuthal,o),polar:a.number(l.polar,r.polar,o)}}},color:new a.DataConstantProperty(a.spec.light.color),intensity:new a.DataConstantProperty(a.spec.light.intensity)});class fi extends a.Evented{constructor(r){super(),this._transitionable=new a.Transitionable(ft),this.setLight(r),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(r,o={}){if(!this._validate(a.validateLight,r,o))for(const h in r){const d=r[h];a.endsWith(h,"-transition")?this._transitionable.setTransition(h.slice(0,-11),d):this._transitionable.setValue(h,d)}}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,r.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}const Aa=new a.Properties({source:new a.DataConstantProperty(a.spec.terrain.source),exaggeration:new a.DataConstantProperty(a.spec.terrain.exaggeration)});let bs=class extends a.Evented{constructor(l,r){super(),this._transitionable=new a.Transitionable(Aa),this.set(l),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=r}get(){return this._transitionable.serialize()}set(l){for(const r in l){const o=l[r];a.endsWith(r,"-transition")?this._transitionable.setTransition(r.slice(0,-11),o):this._transitionable.setValue(r,o)}}updateTransitions(l){this._transitioning=this._transitionable.transitioned(l,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(l){this.properties=this._transitioning.possiblyEvaluate(l)}};function Ao(l,r,o,h){const d=a.smoothstep(45,65,o),[f,g]=ws(l,h),y=a.length(r);let v=1-Math.min(1,Math.exp((y-f)/(g-f)*-6));return v*=v*v,v=Math.min(1,1.00747*v),v*d*l.alpha}function ws(l,r){const o=.5/Math.tan(.5*r);return[l.range[0]+o,l.range[1]+o]}const ut=new a.Properties({range:new a.DataConstantProperty(a.spec.fog.range),color:new a.DataConstantProperty(a.spec.fog.color),"high-color":new a.DataConstantProperty(a.spec.fog["high-color"]),"space-color":new a.DataConstantProperty(a.spec.fog["space-color"]),"horizon-blend":new a.DataConstantProperty(a.spec.fog["horizon-blend"]),"star-intensity":new a.DataConstantProperty(a.spec.fog["star-intensity"])});class Nn extends a.Evented{constructor(r,o){super(),this._transitionable=new a.Transitionable(ut),this.set(r),this._transitioning=this._transitionable.untransitioned(),this._transform=o}get state(){const r=this._transform,o=r.projection.name==="globe",h=a.globeToMercatorTransition(r.zoom),d=this.properties.get("range"),f=[.5,3];return{range:o?[a.number(f[0],d[0],h),a.number(f[1],d[1],h)]:d,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(r,o={}){if(!this._validate(a.validateFog,r,o)){for(const h of Object.keys(a.spec.fog))r&&r[h]===void 0&&(r[h]=a.spec.fog[h].default);for(const h in r){const d=r[h];a.endsWith(h,"-transition")?this._transitionable.setTransition(h.slice(0,-11),d):this._transitionable.setValue(h,d)}}}getOpacity(r){if(!this._transform.projection.supportsFog)return 0;const o=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:a.smoothstep(45,65,r))*o.a}getOpacityAtLatLng(r,o){return this._transform.projection.supportsFog?function(h,d,f){const g=a.MercatorCoordinate.fromLngLat(d),y=f.elevation?f.elevation.getAtPointOrZero(g):0,v=[g.x,g.y,y];return a.transformMat4(v,v,f.mercatorFogMatrix),Ao(h,v,f.pitch,f._fov)}(this.state,r,o):0}getFovAdjustedRange(r){return this._transform.projection.supportsFog?ws(this.state,r):[0,1]}updateTransitions(r){this._transitioning=this._transitionable.transitioned(r,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(r){this.properties=this._transitioning.possiblyEvaluate(r)}_validate(r,o,h){return(!h||h.validate!==!1)&&a.emitValidationErrors(this,r.call(a.validateStyle,a.extend({value:o,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}class di{constructor(r,o){this.workerPool=r,this.actors=[],this.currentActor=0,this.id=a.uniqueId();const h=this.workerPool.acquire(this.id);for(let d=0;d<h.length;d++){const f=new di.Actor(h[d],o,this.id);f.name=`Worker ${d}`,this.actors.push(f)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(r,o,h){a.asyncAll(this.actors,(d,f)=>{d.send(r,o,f)},h=h||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(r=>{r.remove()}),this.actors=[],this.workerPool.release(this.id)}}function mi(l,r,o){return r*(a.EXTENT/(l.tileSize*Math.pow(2,o-l.tileID.overscaledZ)))}di.Actor=a.Actor;class Hr{constructor(r,o,h,d){this.screenBounds=r,this.cameraPoint=o,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=h,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,d)}static createFromScreenPoints(r,o){let h,d;if(r instanceof a.Point||typeof r[0]=="number"){const f=a.Point.convert(r);h=[f],d=o.isPointAboveHorizon(f)}else{const f=a.Point.convert(r[0]),g=a.Point.convert(r[1]);h=[f,g],d=a.polygonizeBounds(f,g).every(y=>o.isPointAboveHorizon(y))}return new Hr(h,o.getCameraPoint(),d,o)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(r){return a.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],r)}bufferedCameraGeometry(r){const o=this.screenBounds[0],h=this.screenBounds.length===1?this.screenBounds[0].add(new a.Point(1,1)):this.screenBounds[1],d=a.polygonizeBounds(o,h,0,!1);return this.cameraPoint.y>h.y&&(this.cameraPoint.x>o.x&&this.cameraPoint.x<h.x?d.splice(3,0,this.cameraPoint):this.cameraPoint.x>=h.x?d[2]=this.cameraPoint:this.cameraPoint.x<=o.x&&(d[3]=this.cameraPoint)),a.bufferConvexPolygon(d,r)}bufferedCameraGeometryGlobe(r){const o=this.screenBounds[0],h=this.screenBounds.length===1?this.screenBounds[0].add(new a.Point(1,1)):this.screenBounds[1],d=a.polygonizeBounds(o,h,r),f=this.cameraPoint.clone();switch(3*((f.y>o.y)+(f.y>h.y))+((f.x>o.x)+(f.x>h.x))){case 0:d[0]=f,d[4]=f.clone();break;case 1:d.splice(1,0,f);break;case 2:d[1]=f;break;case 3:d.splice(4,0,f);break;case 5:d.splice(2,0,f);break;case 6:d[3]=f;break;case 7:d.splice(3,0,f);break;case 8:d[2]=f}return d}containsTile(r,o,h,d=0){const f=r.queryPadding/o._pixelsPerMercatorPixel+1,g=h?this._bufferedCameraMercator(f,o):this._bufferedScreenMercator(f,o);let y=r.tileID.wrap+(g.unwrapped?d:0);const v=g.polygon.map(F=>a.getTilePoint(r.tileTransform,F,y));if(!a.polygonIntersectsBox(v,0,0,a.EXTENT,a.EXTENT))return;y=r.tileID.wrap+(this.screenGeometryMercator.unwrapped?d:0);const E=this.screenGeometryMercator.polygon.map(F=>a.getTileVec3(r.tileTransform,F,y)),T=E.map(F=>new a.Point(F[0],F[1])),A=o.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),k=a.getTileVec3(r.tileTransform,A,y),R=E.map(F=>{const I=a.sub(F,F,k);return a.normalize(I,I),new a.Ray(k,I)}),O=mi(r,1,o.zoom)*o._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:T,tilespaceRays:R,bufferedTilespaceGeometry:v,bufferedTilespaceBounds:(B=a.getBounds(v),B.min.x=a.clamp(B.min.x,0,a.EXTENT),B.min.y=a.clamp(B.min.y,0,a.EXTENT),B.max.x=a.clamp(B.max.x,0,a.EXTENT),B.max.y=a.clamp(B.max.y,0,a.EXTENT),B),tile:r,tileID:r.tileID,pixelToTileUnitsFactor:O};var B}_bufferedScreenMercator(r,o){const h=jn(r);if(this._screenRaycastCache[h])return this._screenRaycastCache[h];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(r),o):{polygon:this.bufferedScreenGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._screenRaycastCache[h]=d,d}}_bufferedCameraMercator(r,o){const h=jn(r);if(this._cameraRaycastCache[h])return this._cameraRaycastCache[h];{let d;return d=o.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(r),o):{polygon:this.bufferedCameraGeometry(r).map(f=>o.pointCoordinate3D(f)),unwrapped:!0},this._cameraRaycastCache[h]=d,d}}_projectAndResample(r,o){const h=function(f,g){const y=a.multiply([],g.pixelMatrix,g.globeMatrix),v=[0,-a.GLOBE_RADIUS,0,1],E=[0,a.GLOBE_RADIUS,0,1],T=[0,0,0,1];a.transformMat4$1(v,v,y),a.transformMat4$1(E,E,y),a.transformMat4$1(T,T,y);const A=new a.Point(v[0]/v[3],v[1]/v[3]),k=new a.Point(E[0]/E[3],E[1]/E[3]),R=a.polygonContainsPoint(f,A)&&v[3]<T[3],O=a.polygonContainsPoint(f,k)&&E[3]<T[3];if(!R&&!O)return null;const B=function(Y,ie,te){for(let le=1;le<Y.length;le++){const Ee=Kr(ie.pointCoordinate3D(Y[le-1]).x),oe=Kr(ie.pointCoordinate3D(Y[le]).x);if(te<0){if(Ee<oe)return{idx:le,t:-Ee/(oe-1-Ee)}}else if(oe<Ee)return{idx:le,t:(1-Ee)/(oe+1-Ee)}}return null}(f,g,R?-1:1);if(!B)return null;const{idx:F,t:I}=B;let L=F>1?Qt(f.slice(0,F),g):[],N=F<f.length?Qt(f.slice(F),g):[];L=L.map(Y=>new a.Point(Kr(Y.x),Y.y)),N=N.map(Y=>new a.Point(Kr(Y.x),Y.y));const j=[...L];j.length===0&&j.push(N[N.length-1]);const K=a.number(j[j.length-1].y,(N.length===0?L[0]:N[0]).y,I);let J;return J=R?[new a.Point(0,K),new a.Point(0,0),new a.Point(1,0),new a.Point(1,K)]:[new a.Point(1,K),new a.Point(1,1),new a.Point(0,1),new a.Point(0,K)],j.push(...J),N.length===0?j.push(L[0]):j.push(...N),{polygon:j.map(Y=>new a.MercatorCoordinate(Y.x,Y.y)),unwrapped:!1}}(r,o);if(h)return h;const d=function(f,g){let y=!1,v=-1/0,E=0;for(let A=0;A<f.length-1;A++)f[A].x>v&&(v=f[A].x,E=A);for(let A=0;A<f.length-1;A++){const k=(E+A)%(f.length-1),R=f[k],O=f[k+1];Math.abs(R.x-O.x)>.5&&(R.x<O.x?(R.x+=1,k===0&&(f[f.length-1].x+=1)):(O.x+=1,k+1===f.length-1&&(f[0].x+=1)),y=!0)}const T=a.mercatorXfromLng(g.center.lng);return y&&T<Math.abs(T-1)&&f.forEach(A=>{A.x-=1}),{polygon:f,unwrapped:y}}(Qt(r,o).map(f=>new a.Point(Kr(f.x),f.y)),o);return{polygon:d.polygon.map(f=>new a.MercatorCoordinate(f.x,f.y)),unwrapped:d.unwrapped}}}function Qt(l,r){return a.resample(l,o=>{const h=r.pointCoordinate3D(o);o.x=h.x,o.y=h.y},1/256)}function Kr(l){return l<0?1+l%1:l%1}function jn(l){return 100*l|0}function Yr(l,r,o,h,d){const f=function(g,y){if(g)return d(g);if(y){l.url&&y.tiles&&l.tiles&&delete l.tiles;const v=a.pick(a.extend(y,l),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);y.vector_layers&&(v.vectorLayers=y.vector_layers,v.vectorLayerIds=v.vectorLayers.map(E=>E.id)),v.tiles=r.canonicalizeTileset(v,l.url),d(null,v)}};return l.url?a.getJSON(r.transformRequest(r.normalizeSourceURL(l.url,null,o,h),a.ResourceType.Source),f):a.exported.frame(()=>f(null,l))}class Ar{constructor(r,o,h){this.bounds=a.LngLatBounds.convert(this.validateBounds(r)),this.minzoom=o||0,this.maxzoom=h||24}validateBounds(r){return Array.isArray(r)&&r.length===4?[Math.max(-180,r[0]),Math.max(-90,r[1]),Math.min(180,r[2]),Math.min(90,r[3])]:[-180,-90,180,90]}contains(r){const o=Math.pow(2,r.z),h=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*o),d=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*o),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*o),g=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*o);return r.x>=h&&r.x<f&&r.y>=d&&r.y<g}}class Ts{constructor(r,o,h){this.context=r;const d=r.gl;this.buffer=d.createBuffer(),this.dynamicDraw=!!h,this.context.unbindVAO(),r.bindElementBuffer.set(this.buffer),d.bufferData(d.ELEMENT_ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?d.DYNAMIC_DRAW:d.STATIC_DRAW),this.dynamicDraw||o.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.context.unbindVAO(),this.bind(),o.bufferSubData(o.ELEMENT_ARRAY_BUFFER,0,r.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const mn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Gn{constructor(r,o,h,d){this.length=o.length,this.attributes=h,this.itemSize=o.bytesPerElement,this.dynamicDraw=d,this.context=r;const f=r.gl;this.buffer=f.createBuffer(),r.bindVertexBuffer.set(this.buffer),f.bufferData(f.ARRAY_BUFFER,o.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||o.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(r){const o=this.context.gl;this.bind(),o.bufferSubData(o.ARRAY_BUFFER,0,r.arrayBuffer)}enableAttributes(r,o){for(let h=0;h<this.attributes.length;h++){const d=o.attributes[this.attributes[h].name];d!==void 0&&r.enableVertexAttribArray(d)}}setVertexAttribPointers(r,o,h){for(let d=0;d<this.attributes.length;d++){const f=this.attributes[d],g=o.attributes[f.name];g!==void 0&&r.vertexAttribPointer(g,f.components,r[mn[f.type]],!1,this.itemSize,f.offset+this.itemSize*(h||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class mt{constructor(r){this.gl=r.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(r){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class $n extends mt{getDefault(){return a.Color.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.clearColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class Gi extends mt{getDefault(){return 1}set(r){(r!==this.current||this.dirty)&&(this.gl.clearDepth(r),this.current=r,this.dirty=!1)}}class Io extends mt{getDefault(){return 0}set(r){(r!==this.current||this.dirty)&&(this.gl.clearStencil(r),this.current=r,this.dirty=!1)}}class Gt extends mt{getDefault(){return[!0,!0,!0,!0]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.colorMask(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class Xi extends mt{getDefault(){return!0}set(r){(r!==this.current||this.dirty)&&(this.gl.depthMask(r),this.current=r,this.dirty=!1)}}class Es extends mt{getDefault(){return 255}set(r){(r!==this.current||this.dirty)&&(this.gl.stencilMask(r),this.current=r,this.dirty=!1)}}class Ir extends mt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(r){const o=this.current;(r.func!==o.func||r.ref!==o.ref||r.mask!==o.mask||this.dirty)&&(this.gl.stencilFunc(r.func,r.ref,r.mask),this.current=r,this.dirty=!1)}}class $i extends mt{getDefault(){const r=this.gl;return[r.KEEP,r.KEEP,r.KEEP]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||this.dirty)&&(this.gl.stencilOp(r[0],r[1],r[2]),this.current=r,this.dirty=!1)}}class Co extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.STENCIL_TEST):o.disable(o.STENCIL_TEST),this.current=r,this.dirty=!1}}class Zn extends mt{getDefault(){return[0,1]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.depthRange(r[0],r[1]),this.current=r,this.dirty=!1)}}class zo extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),this.current=r,this.dirty=!1}}class Jr extends mt{getDefault(){return this.gl.LESS}set(r){(r!==this.current||this.dirty)&&(this.gl.depthFunc(r),this.current=r,this.dirty=!1)}}class qn extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.BLEND):o.disable(o.BLEND),this.current=r,this.dirty=!1}}class Ss extends mt{getDefault(){const r=this.gl;return[r.ONE,r.ZERO]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||this.dirty)&&(this.gl.blendFunc(r[0],r[1]),this.current=r,this.dirty=!1)}}class Ms extends mt{getDefault(){return a.Color.transparent}set(r){const o=this.current;(r.r!==o.r||r.g!==o.g||r.b!==o.b||r.a!==o.a||this.dirty)&&(this.gl.blendColor(r.r,r.g,r.b,r.a),this.current=r,this.dirty=!1)}}class Hi extends mt{getDefault(){return this.gl.FUNC_ADD}set(r){(r!==this.current||this.dirty)&&(this.gl.blendEquation(r),this.current=r,this.dirty=!1)}}class Qr extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;r?o.enable(o.CULL_FACE):o.disable(o.CULL_FACE),this.current=r,this.dirty=!1}}class Po extends mt{getDefault(){return this.gl.BACK}set(r){(r!==this.current||this.dirty)&&(this.gl.cullFace(r),this.current=r,this.dirty=!1)}}class _n extends mt{getDefault(){return this.gl.CCW}set(r){(r!==this.current||this.dirty)&&(this.gl.frontFace(r),this.current=r,this.dirty=!1)}}let Wn,ko=class extends mt{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}};class gn extends mt{getDefault(){return this.gl.TEXTURE0}set(r){(r!==this.current||this.dirty)&&(this.gl.activeTexture(r),this.current=r,this.dirty=!1)}}class en extends mt{getDefault(){const r=this.gl;return[0,0,r.drawingBufferWidth,r.drawingBufferHeight]}set(r){const o=this.current;(r[0]!==o[0]||r[1]!==o[1]||r[2]!==o[2]||r[3]!==o[3]||this.dirty)&&(this.gl.viewport(r[0],r[1],r[2],r[3]),this.current=r,this.dirty=!1)}}class yn extends mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindFramebuffer(o.FRAMEBUFFER,r),this.current=r,this.dirty=!1}}class xn extends mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindRenderbuffer(o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Xn extends mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindTexture(o.TEXTURE_2D,r),this.current=r,this.dirty=!1}}class As extends mt{getDefault(){return null}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.bindBuffer(o.ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class Z extends mt{getDefault(){return null}set(r){const o=this.gl;o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,r),this.current=r,this.dirty=!1}}class z extends mt{constructor(r){super(r),this.vao=r.extVertexArrayObject}getDefault(){return null}set(r){this.vao&&(r!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(r),this.current=r,this.dirty=!1)}}class P extends mt{getDefault(){return 4}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_ALIGNMENT,r),this.current=r,this.dirty=!1}}class G extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r),this.current=r,this.dirty=!1}}class H extends mt{getDefault(){return!1}set(r){if(r===this.current&&!this.dirty)return;const o=this.gl;o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,r),this.current=r,this.dirty=!1}}class ee extends mt{constructor(r,o){super(r),this.context=r,this.parent=o}getDefault(){return null}}class ne extends ee{setDirty(){this.dirty=!0}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,r,0),this.current=r,this.dirty=!1}}class re extends ee{attachment(){return this.gl.DEPTH_ATTACHMENT}set(r){if(r===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const o=this.gl;o.framebufferRenderbuffer(o.FRAMEBUFFER,this.attachment(),o.RENDERBUFFER,r),this.current=r,this.dirty=!1}}class Q extends re{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class de{constructor(r,o,h,d){this.context=r,this.width=o,this.height=h;const f=this.framebuffer=r.gl.createFramebuffer();this.colorAttachment=new ne(r,f),d&&(this.depthAttachment=new re(r,f))}destroy(){const r=this.context.gl,o=this.colorAttachment.get();if(o&&r.deleteTexture(o),this.depthAttachment){const h=this.depthAttachment.get();h&&r.deleteRenderbuffer(h)}r.deleteFramebuffer(this.framebuffer)}}class Pe{constructor(r,o=!1){if(this.gl=r,this.isWebGL2=o,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),o){const h=r;this.extVertexArrayObject={createVertexArrayOES:h.createVertexArray.bind(r),deleteVertexArrayOES:h.deleteVertexArray.bind(r),bindVertexArrayOES:h.bindVertexArray.bind(r)}}this.clearColor=new $n(this),this.clearDepth=new Gi(this),this.clearStencil=new Io(this),this.colorMask=new Gt(this),this.depthMask=new Xi(this),this.stencilMask=new Es(this),this.stencilFunc=new Ir(this),this.stencilOp=new $i(this),this.stencilTest=new Co(this),this.depthRange=new Zn(this),this.depthTest=new zo(this),this.depthFunc=new Jr(this),this.blend=new qn(this),this.blendFunc=new Ss(this),this.blendColor=new Ms(this),this.blendEquation=new Hi(this),this.cullFace=new Qr(this),this.cullFaceSide=new Po(this),this.frontFace=new _n(this),this.program=new ko(this),this.activeTexture=new gn(this),this.viewport=new en(this),this.bindFramebuffer=new yn(this),this.bindRenderbuffer=new xn(this),this.bindTexture=new Xn(this),this.bindVertexBuffer=new As(this),this.bindElementBuffer=new Z(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new z(this),this.pixelStoreUnpack=new P(this),this.pixelStoreUnpackPremultiplyAlpha=new G(this),this.pixelStoreUnpackFlipY=new H(this),this.extTextureFilterAnisotropic=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=r.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=r.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=r.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=r.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),o||(this.extTextureHalfFloat=r.getExtension("OES_texture_half_float")),(o||this.extTextureHalfFloat&&r.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=r.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=o||r.getExtension("OES_standard_derivatives"),this.extTimerQuery=r.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=r.getParameter(r.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(r,o){return new Ts(this,r,o)}createVertexBuffer(r,o,h){return new Gn(this,r,o,h)}createRenderbuffer(r,o,h){const d=this.gl,f=d.createRenderbuffer();return this.bindRenderbuffer.set(f),d.renderbufferStorage(d.RENDERBUFFER,r,o,h),this.bindRenderbuffer.set(null),f}createFramebuffer(r,o,h){return new de(this,r,o,h)}clear({color:r,depth:o,stencil:h}){const d=this.gl;let f=0;r&&(f|=d.COLOR_BUFFER_BIT,this.clearColor.set(r),this.colorMask.set([!0,!0,!0,!0])),o!==void 0&&(f|=d.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(o),this.depthMask.set(!0)),h!==void 0&&(f|=d.STENCIL_BUFFER_BIT,this.clearStencil.set(h),this.stencilMask.set(255)),d.clear(f)}setCullFace(r){r.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(r.mode),this.frontFace.set(r.frontFace))}setDepthMode(r){r.func!==this.gl.ALWAYS||r.mask?(this.depthTest.set(!0),this.depthFunc.set(r.func),this.depthMask.set(r.mask),this.depthRange.set(r.range)):this.depthTest.set(!1)}setStencilMode(r){r.test.func!==this.gl.ALWAYS||r.mask?(this.stencilTest.set(!0),this.stencilMask.set(r.mask),this.stencilOp.set([r.fail,r.depthFail,r.pass]),this.stencilFunc.set({func:r.test.func,ref:r.ref,mask:r.test.mask})):this.stencilTest.set(!1)}setColorMode(r){ve(r.blendFunction,a.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(r.blendFunction),this.blendColor.set(r.blendColor)),this.colorMask.set(r.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class ke extends a.Evented{constructor(r,o,h,d){if(super(),this.id=r,this.dispatcher=h,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(o,["url","scheme","tileSize","promoteId"])),this._options=a.extend({type:"vector"},o),this._collectResourceTiming=o.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(d),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(r){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"}));const o=Array.isArray(this.map._language)?this.map._language.join():this.map._language,h=this.map._worldview;this._tileJSONRequest=Yr(this._options,this.map._requestManager,o,h,(d,f)=>{this._tileJSONRequest=null,this._loaded=!0,d?(o&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${o}`),h&&h.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${h}`),this.fire(new a.ErrorEvent(d))):f&&(a.extend(this,f),f.bounds&&(this.tileBounds=new Ar(f.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(f.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))),r&&r(d)})}loaded(){return this._loaded}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return a.extend({},this._options)}loadTile(r,o){const h=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme)),d={request:this.map._requestManager.transformRequest(h,a.ResourceType.Tile),data:void 0,uid:r.uid,tileID:r.tileID,tileZoom:r.tileZoom,zoom:r.tileID.overscaledZ,tileSize:this.tileSize*r.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:r.isSymbolTile};if(d.request.collectResourceTiming=this._collectResourceTiming,r.actor&&r.state!=="expired")r.state==="loading"?r.reloadCallback=o:r.request=r.actor.send("reloadTile",d,f.bind(this));else if(r.actor=this._tileWorkers[h]=this._tileWorkers[h]||this.dispatcher.getActor(),this.dispatcher.ready)r.request=r.actor.send("loadTile",d,f.bind(this),void 0,!0);else{const g=a.loadVectorTile.call({deduped:this._deduped},d,(y,v)=>{y||!v?f.call(this,y):(d.data={cacheControl:v.cacheControl,expires:v.expires,rawData:v.rawData.slice(0)},r.actor&&r.actor.send("loadTile",d,f.bind(this),void 0,!0))},!0);r.request={cancel:g}}function f(g,y){return delete r.request,r.aborted?o(null):g&&g.status!==404?o(g):(y&&y.resourceTiming&&(r.resourceTiming=y.resourceTiming),this.map._refreshExpiredTiles&&y&&r.setExpiryData(y),r.loadVectorData(y,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),o(null),void(r.reloadCallback&&(this.loadTile(r,r.reloadCallback),r.reloadCallback=null)))}}abortTile(r){r.request&&(r.request.cancel(),delete r.request),r.actor&&r.actor.send("abortTile",{uid:r.uid,type:this.type,source:this.id})}unloadTile(r){r.unloadVectorData(),r.actor&&r.actor.send("removeTile",{uid:r.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Ie extends a.Evented{constructor(r,o,h,d){super(),this.id=r,this.dispatcher=h,this.setEventedParent(d),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.extend({type:"raster"},o),a.extend(this,a.pick(o,["url","scheme","tileSize"]))}load(r){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Yr(this._options,this.map._requestManager,null,null,(o,h)=>{this._tileJSONRequest=null,this._loaded=!0,o?this.fire(new a.ErrorEvent(o)):h&&(a.extend(this,h),h.bounds&&(this.tileBounds=new Ar(h.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(h.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))),r&&r(o)})}loaded(){return this._loaded}onAdd(r){this.map=r,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(r){return this._options.tiles=r,this.reload(),this}setUrl(r){return this.url=r,this._options.url=r,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return a.extend({},this._options)}hasTile(r){return!this.tileBounds||this.tileBounds.contains(r.canonical)}loadTile(r,o){const h=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(r.tileID.canonical.url(this.tiles,this.scheme),h,this.tileSize);r.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(f,g,y,v)=>(delete r.request,r.aborted?(r.state="unloaded",o(null)):f?(r.state="errored",o(f)):g?(this.map._refreshExpiredTiles&&r.setExpiryData({cacheControl:y,expires:v}),r.setTexture(g,this.map.painter),r.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),void o(null)):o(null)))}static loadTileData(r,o,h){r.setTexture(o,h)}static unloadTileData(r,o){r.texture&&o.saveTileTexture(r.texture)}abortTile(r,o){r.request&&(r.request.cancel(),delete r.request),o()}unloadTile(r,o){r.texture&&this.map.painter.saveTileTexture(r.texture),o()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Qe(l,r,o,h,d,f,g,y){const v=[l,o,d,r,h,f,1,1,1],E=[g,y,1],T=a.adjoint([],v),[A,k,R]=a.transformMat3(E,E,a.transpose(T,T));return a.multiply$1(v,[A,0,0,0,k,0,0,0,R],v)}class ot extends a.Evented{constructor(r,o,h,d){super(),this.id=r,this.dispatcher=h,this.coordinates=o.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=o,this._dirty=!1}load(r,o){this._loaded=o||!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(h,d)=>{if(this._imageRequest=null,this._loaded=!0,h)this.fire(new a.ErrorEvent(h));else if(d){const{HTMLImageElement:f}=a.window;this.image=d instanceof f?a.exported.getImageData(d):d,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,r&&(this.coordinates=r),this._finishLoading()}})}loaded(){return this._loaded}updateImage(r){return this.image&&r.url?(this._imageRequest&&r.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=r.url,this.load(r.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(r){this.map=r,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(r){this.coordinates=r,this._boundsArray=void 0;const o=r.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(h){let d=1/0,f=1/0,g=-1/0,y=-1/0;for(const A of h)d=Math.min(d,A.x),f=Math.min(f,A.y),g=Math.max(g,A.x),y=Math.max(y,A.y);const v=Math.max(g-d,y-f),E=Math.max(0,Math.floor(-Math.log(v)/Math.LN2)),T=Math.pow(2,E);return new a.CanonicalTileID(E,Math.floor((d+g)/2*T),Math.floor((f+y)/2*T))}(o),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(r){for(const v in this.tiles){const E=this.tiles[v];E.state!=="loaded"&&(E.state="loaded",E.texture=this.texture)}if(this._boundsArray)return;const o=a.tileTransform(this.tileID,this.map.transform.projection),[h,d,f,g]=this.coordinates.map(v=>{const E=o.projection.project(v[0],v[1]);return a.getTilePoint(o,E)._round()});this.perspectiveTransform=function(v,E,T,A,k,R,O,B,F,I){const L=Qe(0,0,v,0,0,E,v,E),N=Qe(T,A,k,R,O,B,F,I);return a.multiply$1(N,a.adjoint(L,L),N),[N[6]/N[8]*v/a.EXTENT,N[7]/N[8]*E/a.EXTENT]}(this.width,this.height,h.x,h.y,d.x,d.y,g.x,g.y,f.x,f.y);const y=this._boundsArray=new a.StructArrayLayout4i8;y.emplaceBack(h.x,h.y,0,0),y.emplaceBack(d.x,d.y,a.EXTENT,0),y.emplaceBack(g.x,g.y,0,a.EXTENT),y.emplaceBack(f.x,f.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=r.createVertexBuffer(y,a.boundsAttributes.members),this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const r=this.map.painter.context,o=r.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new a.Texture(r,this.image,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(r)}loadTile(r,o){this.tileID&&this.tileID.equals(r.tileID.canonical)?(this.tiles[String(r.tileID.wrap)]=r,r.buckets={},o(null)):(r.state="errored",o(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const et={vector:ke,raster:Ie,"raster-dem":class extends Ie{constructor(l,r,o,h){super(l,r,o,h),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},r),this.encoding=r.encoding||"mapbox"}loadTile(l,r){const o=this.map._requestManager.normalizeTileURL(l.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function h(d,f){d&&(l.state="errored",r(d)),f&&(l.dem=f,l.dem.onDeserialize(),l.needsHillshadePrepare=!0,l.needsDEMTextureUpload=!0,l.state="loaded",r(null))}l.request=a.getImage(this.map._requestManager.transformRequest(o,a.ResourceType.Tile),function(d,f,g,y){if(delete l.request,l.aborted)l.state="unloaded",r(null);else if(d)l.state="errored",r(d);else if(f){this.map._refreshExpiredTiles&&l.setExpiryData({cacheControl:g,expires:y});const v=a.window.ImageBitmap&&f instanceof a.window.ImageBitmap&&(Wn==null&&(Wn=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&typeof a.window.createImageBitmap=="function"),Wn),E=1-(f.width-a.prevPowerOfTwo(f.width))/2;E<1||l.neighboringTiles||(l.neighboringTiles=this._getNeighboringTiles(l.tileID));const T=v?f:a.exported.getImageData(f,E),A={uid:l.uid,coord:l.tileID,source:this.id,rawImageData:T,encoding:this.encoding,padding:E};l.actor&&l.state!=="expired"||(l.actor=this.dispatcher.getActor(),l.actor.send("loadDEMTile",A,h.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(l){const r=l.canonical,o=Math.pow(2,r.z),h=(r.x-1+o)%o,d=r.x===0?l.wrap-1:l.wrap,f=(r.x+1+o)%o,g=r.x+1===o?l.wrap+1:l.wrap,y={};return y[new a.OverscaledTileID(l.overscaledZ,d,r.z,h,r.y).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y).key]={backfilled:!1},r.y>0&&(y[new a.OverscaledTileID(l.overscaledZ,d,r.z,h,r.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,l.wrap,r.z,r.x,r.y-1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y-1).key]={backfilled:!1}),r.y+1<o&&(y[new a.OverscaledTileID(l.overscaledZ,d,r.z,h,r.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,l.wrap,r.z,r.x,r.y+1).key]={backfilled:!1},y[new a.OverscaledTileID(l.overscaledZ,g,r.z,f,r.y+1).key]={backfilled:!1}),y}unloadTile(l){l.demTexture&&this.map.painter.saveTileTexture(l.demTexture),l.fbo&&(l.fbo.destroy(),delete l.fbo),l.dem&&delete l.dem,delete l.neighboringTiles,l.state="unloaded"}},geojson:class extends a.Evented{constructor(l,r,o,h){super(),this.id=l,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=o.getActor(),this.setEventedParent(h),this._data=r.data,this._options=a.extend({},r),this._collectResourceTiming=r.collectResourceTiming,r.maxzoom!==void 0&&(this.maxzoom=r.maxzoom),r.type&&(this.type=r.type),r.attribution&&(this.attribution=r.attribution),this.promoteId=r.promoteId;const d=a.EXTENT/this.tileSize;this.workerOptions=a.extend({source:this.id,cluster:r.cluster||!1,geojsonVtOptions:{buffer:(r.buffer!==void 0?r.buffer:128)*d,tolerance:(r.tolerance!==void 0?r.tolerance:.375)*d,extent:a.EXTENT,maxZoom:this.maxzoom,lineMetrics:r.lineMetrics||!1,generateId:r.generateId||!1},superclusterOptions:{maxZoom:r.clusterMaxZoom!==void 0?r.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,r.clusterMinPoints||2),extent:a.EXTENT,radius:(r.clusterRadius!==void 0?r.clusterRadius:50)*d,log:!1,generateId:r.generateId||!1},clusterProperties:r.clusterProperties,filter:r.filter},r.workerOptions)}onAdd(l){this.map=l,this.setData(this._data)}setData(l){return this._data=l,this._updateWorkerData(),this}getClusterExpansionZoom(l,r){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:l,source:this.id},r),this}getClusterChildren(l,r){return this.actor.send("geojson.getClusterChildren",{clusterId:l,source:this.id},r),this}getClusterLeaves(l,r,o,h){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:l,limit:r,offset:o},h),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.Event("dataloading",{dataType:"source"})),this._loaded=!1;const l=a.extend({},this.workerOptions),r=this._data;typeof r=="string"?(l.request=this.map._requestManager.transformRequest(a.exported.resolveURL(r),a.ResourceType.Source),l.request.collectResourceTiming=this._collectResourceTiming):l.data=JSON.stringify(r),this._pendingLoad=this.actor.send(`${this.type}.loadData`,l,(o,h)=>{if(this._loaded=!0,this._pendingLoad=null,o)this.fire(new a.ErrorEvent(o));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&h&&h.resourceTiming&&h.resourceTiming[this.id]&&(d.resourceTiming=h.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(l,r){const o=l.actor?"reloadTile":"loadTile";l.actor=this.actor,l.request=this.actor.send(o,{type:this.type,uid:l.uid,tileID:l.tileID,tileZoom:l.tileZoom,zoom:l.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(h,d)=>(delete l.request,l.unloadVectorData(),l.aborted?r(null):h?r(h):(l.loadVectorData(d,this.map.painter,o==="reloadTile"),r(null))),void 0,o==="loadTile")}abortTile(l){l.request&&(l.request.cancel(),delete l.request),l.aborted=!0}unloadTile(l){l.unloadVectorData(),this.actor.send("removeTile",{uid:l.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ot{constructor(l,r,o,h){super(l,r,o,h),this.roundZoom=!0,this.type="video",this.options=r}load(){this._loaded=!1;const l=this.options;this.urls=[];for(const r of l.urls)this.urls.push(this.map._requestManager.transformRequest(r,a.ResourceType.Source).url);a.getVideo(this.urls,(r,o)=>{this._loaded=!0,r?this.fire(new a.ErrorEvent(r)):o&&(this.video=o,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(l){if(this.video){const r=this.video.seekable;l<r.start(0)||l>r.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${r.start(0)} and ${r.end(0)}-second mark.`))):this.video.currentTime=l}}getVideo(){return this.video}onAdd(l){this.map||(this.map=l,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const l=this.map.painter.context,r=l.gl;this.texture?this.video.paused||(this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),r.texSubImage2D(r.TEXTURE_2D,0,0,0,r.RGBA,r.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(l,this.video,r.RGBA),this.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(l)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ot,canvas:class extends ot{constructor(l,r,o,h){super(l,r,o,h),r.coordinates?Array.isArray(r.coordinates)&&r.coordinates.length===4&&!r.coordinates.some(d=>!Array.isArray(d)||d.length!==2||d.some(f=>typeof f!="number"))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'missing required property "coordinates"'))),r.animate&&typeof r.animate!="boolean"&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'optional "animate" property must be a boolean value'))),r.canvas?typeof r.canvas=="string"||r.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${l}`,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 a.ErrorEvent(new a.ValidationError(`sources.${l}`,null,'missing required property "canvas"'))),this.options=r,this.animate=r.animate===void 0||r.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(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(l){this.map=l,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let l=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,l=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,l=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const r=this.map.painter.context;this.texture?(l||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(r,this.canvas,r.gl.RGBA,{premultiply:!0}),this._prepareData(r)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const l of[this.canvas.width,this.canvas.height])if(isNaN(l)||l<=0)return!0;return!1}},custom:class extends a.Evented{constructor(l,r,o,h){super(),this.id=l,this.type="custom",this._dataType="raster",this._dispatcher=o,this._implementation=r,this.setEventedParent(h),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new a.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new a.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new Ar(this._implementation.bounds,this.minzoom,this.maxzoom)),r.update=this._update.bind(this),r.clearTiles=this._clearTiles.bind(this),r.coveringTiles=this._coveringTiles.bind(this),a.extend(this,a.pick(r,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return a.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(l){this._map=l,this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(l),this.load()}onRemove(l){this._implementation.onRemove&&this._implementation.onRemove(l)}hasTile(l){if(this._implementation.hasTile){const{x:r,y:o,z:h}=l.canonical;return this._implementation.hasTile({x:r,y:o,z:h})}return!this.tileBounds||this.tileBounds.contains(l.canonical)}loadTile(l,r){const{x:o,y:h,z:d}=l.tileID.canonical,f=new a.window.AbortController;l.request=Promise.resolve(this._implementation.loadTile({x:o,y:h,z:d},{signal:f.signal})).then(function(g){return delete l.request,l.aborted?(l.state="unloaded",r(null)):g===void 0?(l.state="errored",r(null)):g===null?(this.loadTileData(l,{width:this.tileSize,height:this.tileSize,data:null}),l.state="loaded",r(null)):function(y){return y instanceof a.window.ImageData||y instanceof a.window.HTMLCanvasElement||y instanceof a.window.ImageBitmap||y instanceof a.window.HTMLImageElement}(g)?(this.loadTileData(l,g),l.state="loaded",void r(null)):(l.state="errored",r(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(g=>{g.code!==20&&(l.state="errored",r(g))}),l.request.cancel=()=>f.abort()}loadTileData(l,r){Ie.loadTileData(l,r,this._map.painter)}unloadTileData(l){Ie.unloadTileData(l,this._map.painter)}unloadTile(l,r){if(this.unloadTileData(l),this._implementation.unloadTile){const{x:o,y:h,z:d}=l.tileID.canonical;this._implementation.unloadTile({x:o,y:h,z:d})}r()}abortTile(l,r){l.request&&l.request.cancel&&(l.request.cancel(),delete l.request),r()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(l=>({x:l.canonical.x,y:l.canonical.y,z:l.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"}))}}},st=function(l,r,o,h){const d=new et[r.type](l,r,o,h);if(d.id!==l)throw new Error(`Expected Source id to be ${l} instead of ${d.id}`);return a.bindAll(["load","abort","unload","serialize","prepare"],d),d};function _t(l,r){const o=a.identity([]);return a.scale(o,o,[.5*l.width,.5*-l.height,1]),a.translate(o,o,[1,-1,0]),a.multiply(o,o,l.calculateProjMatrix(r.toUnwrapped())),Float32Array.from(o)}function $t(l,r,o,h,d,f,g,y=!1){const v=l.tilesIn(h,g,y);v.sort(Mi);const E=[];for(const A of v)E.push({wrappedTileID:A.tile.tileID.wrapped().key,queryResults:A.tile.queryRenderedFeatures(r,o,l._state,A,d,f,_t(l.transform,A.tile.tileID),y)});const T=function(A){const k={},R={};for(const O of A){const B=O.queryResults,F=O.wrappedTileID,I=R[F]=R[F]||{};for(const L in B){const N=B[L],j=I[L]=I[L]||{},K=k[L]=k[L]||[];for(const J of N)j[J.featureIndex]||(j[J.featureIndex]=!0,K.push(J))}}return k}(E);for(const A in T)T[A].forEach(k=>{const R=k.feature,O=R.layer;O&&O.type!=="background"&&O.type!=="sky"&&(R.source=O.source,O["source-layer"]&&(R.sourceLayer=O["source-layer"]),R.state=R.id!==void 0?l.getFeatureState(O["source-layer"],R.id):{})});return T}function ei(l,r){const o=l.getRenderableIds().map(f=>l.getTileByID(f)),h=[],d={};for(let f=0;f<o.length;f++){const g=o[f],y=g.tileID.canonical.key;d[y]||(d[y]=!0,g.querySourceFeatures(h,r))}return h}function Mi(l,r){const o=l.tileID,h=r.tileID;return o.overscaledZ-h.overscaledZ||o.canonical.y-h.canonical.y||o.wrap-h.wrap||o.canonical.x-h.canonical.x}function ci(){return fo.workerClass!=null?new fo.workerClass:new a.window.Worker(fo.workerUrl)}const fr="mapboxgl_preloaded_worker_pool";class _i{constructor(){this.active={}}acquire(r){if(!this.workers)for(this.workers=[];this.workers.length<_i.workerCount;)this.workers.push(new ci);return this.active[r]=!0,this.workers.slice()}release(r){delete this.active[r],this.numActive()===0&&(this.workers.forEach(o=>{o.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[fr]}numActive(){return Object.keys(this.active).length}}let Pi;function Hn(){return Pi||(Pi=new _i),Pi}function kh(l,r){const o={};for(const h in l)h!=="ref"&&(o[h]=l[h]);return a.refProperties.forEach(h=>{h in r&&(o[h]=r[h])}),o}function oc(l){l=l.slice();const r=Object.create(null);for(let o=0;o<l.length;o++)r[l[o].id]=l[o];for(let o=0;o<l.length;o++)"ref"in l[o]&&(l[o]=kh(l[o],r[l[o].ref]));return l}_i.workerCount=2;const wt={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function Ia(l,r,o){o.push({command:wt.addSource,args:[l,r[l]]})}function Do(l,r,o){r.push({command:wt.removeSource,args:[l]}),o[l]=!0}function Ca(l,r,o,h){Do(l,o,h),Ia(l,r,o)}function Is(l,r,o){let h;for(h in l[o])if(l[o].hasOwnProperty(h)&&h!=="data"&&!ve(l[o][h],r[o][h]))return!1;for(h in r[o])if(r[o].hasOwnProperty(h)&&h!=="data"&&!ve(l[o][h],r[o][h]))return!1;return!0}function mr(l,r,o,h,d,f){let g;for(g in r=r||{},l=l||{})l.hasOwnProperty(g)&&(ve(l[g],r[g])||o.push({command:f,args:[h,g,r[g],d]}));for(g in r)r.hasOwnProperty(g)&&!l.hasOwnProperty(g)&&(ve(l[g],r[g])||o.push({command:f,args:[h,g,r[g],d]}))}function Cr(l){return l.id}function za(l,r){return l[r.id]=r,l}class Pa{constructor(r,o){this.reset(r,o)}reset(r,o){this.points=r||[],this._distances=[0];for(let h=1;h<this.points.length;h++)this._distances[h]=this._distances[h-1]+this.points[h].dist(this.points[h-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(o||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(r){if(this.points.length===1)return this.points[0];r=a.clamp(r,0,1);let o=1,h=this._distances[o];const d=r*this.paddedLength+this.padding;for(;h<d&&o<this._distances.length;)h=this._distances[++o];const f=o-1,g=this._distances[f],y=h-g,v=y>0?(d-g)/y:0;return this.points[f].mult(1-v).add(this.points[o].mult(v))}}class vn{constructor(r,o,h){const d=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(r/h),this.yCellCount=Math.ceil(o/h);for(let g=0;g<this.xCellCount*this.yCellCount;g++)d.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=r,this.height=o,this.xScale=this.xCellCount/r,this.yScale=this.yCellCount/o,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(r,o,h,d,f){this._forEachCell(o,h,d,f,this._insertBoxCell,this.boxUid++),this.boxKeys.push(r),this.bboxes.push(o),this.bboxes.push(h),this.bboxes.push(d),this.bboxes.push(f)}insertCircle(r,o,h,d){this._forEachCell(o-d,h-d,o+d,h+d,this._insertCircleCell,this.circleUid++),this.circleKeys.push(r),this.circles.push(o),this.circles.push(h),this.circles.push(d)}_insertBoxCell(r,o,h,d,f,g){this.boxCells[f].push(g)}_insertCircleCell(r,o,h,d,f,g){this.circleCells[f].push(g)}_query(r,o,h,d,f,g){if(h<0||r>this.width||d<0||o>this.height)return!f&&[];const y=[];if(r<=0&&o<=0&&this.width<=h&&this.height<=d){if(f)return!0;for(let v=0;v<this.boxKeys.length;v++)y.push({key:this.boxKeys[v],x1:this.bboxes[4*v],y1:this.bboxes[4*v+1],x2:this.bboxes[4*v+2],y2:this.bboxes[4*v+3]});for(let v=0;v<this.circleKeys.length;v++){const E=this.circles[3*v],T=this.circles[3*v+1],A=this.circles[3*v+2];y.push({key:this.circleKeys[v],x1:E-A,y1:T-A,x2:E+A,y2:T+A})}return g?y.filter(g):y}return this._forEachCell(r,o,h,d,this._queryCell,y,{hitTest:f,seenUids:{box:{},circle:{}}},g),f?y.length>0:y}_queryCircle(r,o,h,d,f){const g=r-h,y=r+h,v=o-h,E=o+h;if(y<0||g>this.width||E<0||v>this.height)return!d&&[];const T=[];return this._forEachCell(g,v,y,E,this._queryCellCircle,T,{hitTest:d,circle:{x:r,y:o,radius:h},seenUids:{box:{},circle:{}}},f),d?T.length>0:T}query(r,o,h,d,f){return this._query(r,o,h,d,!1,f)}hitTest(r,o,h,d,f){return this._query(r,o,h,d,!0,f)}hitTestCircle(r,o,h,d){return this._queryCircle(r,o,h,!0,d)}_queryCell(r,o,h,d,f,g,y,v){const E=y.seenUids,T=this.boxCells[f];if(T!==null){const k=this.bboxes;for(const R of T)if(!E.box[R]){E.box[R]=!0;const O=4*R;if(r<=k[O+2]&&o<=k[O+3]&&h>=k[O+0]&&d>=k[O+1]&&(!v||v(this.boxKeys[R]))){if(y.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[R],x1:k[O],y1:k[O+1],x2:k[O+2],y2:k[O+3]})}}}const A=this.circleCells[f];if(A!==null){const k=this.circles;for(const R of A)if(!E.circle[R]){E.circle[R]=!0;const O=3*R;if(this._circleAndRectCollide(k[O],k[O+1],k[O+2],r,o,h,d)&&(!v||v(this.circleKeys[R]))){if(y.hitTest)return g.push(!0),!0;{const B=k[O],F=k[O+1],I=k[O+2];g.push({key:this.circleKeys[R],x1:B-I,y1:F-I,x2:B+I,y2:F+I})}}}}}_queryCellCircle(r,o,h,d,f,g,y,v){const E=y.circle,T=y.seenUids,A=this.boxCells[f];if(A!==null){const R=this.bboxes;for(const O of A)if(!T.box[O]){T.box[O]=!0;const B=4*O;if(this._circleAndRectCollide(E.x,E.y,E.radius,R[B+0],R[B+1],R[B+2],R[B+3])&&(!v||v(this.boxKeys[O])))return g.push(!0),!0}}const k=this.circleCells[f];if(k!==null){const R=this.circles;for(const O of k)if(!T.circle[O]){T.circle[O]=!0;const B=3*O;if(this._circlesCollide(R[B],R[B+1],R[B+2],E.x,E.y,E.radius)&&(!v||v(this.circleKeys[O])))return g.push(!0),!0}}}_forEachCell(r,o,h,d,f,g,y,v){const E=this._convertToXCellCoord(r),T=this._convertToYCellCoord(o),A=this._convertToXCellCoord(h),k=this._convertToYCellCoord(d);for(let R=E;R<=A;R++)for(let O=T;O<=k;O++)if(f.call(this,r,o,h,d,this.xCellCount*O+R,g,y,v))return}_convertToXCellCoord(r){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(r*this.xScale)))}_convertToYCellCoord(r){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(r*this.yScale)))}_circlesCollide(r,o,h,d,f,g){const y=d-r,v=f-o,E=h+g;return E*E>y*y+v*v}_circleAndRectCollide(r,o,h,d,f,g,y){const v=(g-d)/2,E=Math.abs(r-(d+v));if(E>v+h)return!1;const T=(y-f)/2,A=Math.abs(o-(f+T));if(A>T+h)return!1;if(E<=v||A<=T)return!0;const k=E-v,R=A-T;return k*k+R*R<=h*h}}const zr={unknown:0,flipRequired:1,flipNotRequired:2},Lo=Math.tan(85*Math.PI/180);function fe(l,r,o,h,d,f,g){const y=a.create();if(o)if(f.name==="globe"){const v=a.calculateGlobeLabelMatrix(d,r);a.multiply(y,y,v)}else{const v=Le([],g);y[0]=v[0],y[1]=v[1],y[4]=v[2],y[5]=v[3],h||a.rotateZ(y,y,d.angle)}else a.multiply(y,d.labelPlaneMatrix,l);return y}function Pr(l,r,o,h,d,f,g){const y=fe(l,r,o,h,d,f,g);return f.name==="globe"&&o||(y[2]=y[6]=y[10]=y[14]=0),y}function ti(l,r,o,h,d,f,g){if(o){if(f.name==="globe"){const y=fe(l,r,o,h,d,f,g);return a.invert(y,y),a.multiply(y,l,y),y}{const y=a.clone(l),v=a.identity([]);return v[0]=g[0],v[1]=g[1],v[4]=g[2],v[5]=g[3],a.multiply(y,y,v),h||a.rotateZ(y,y,-d.angle),y}}return d.glCoordMatrix}function gi(l,r,o,h){const d=[l,r,o,1];o?a.transformMat4$1(d,d,h):ct(d,d,h);const f=d[3];return d[0]/=f,d[1]/=f,d[2]/=f,d}function sc(l,r){return Math.min(.5+l/r*.5,1.5)}function _r(l,r){const o=l[0]/l[3],h=l[1]/l[3];return o>=-r[0]&&o<=r[0]&&h>=-r[1]&&h<=r[1]}function ka(l,r,o,h,d,f,g,y,v,E){const T=o.transform,A=h?l.textSizeData:l.iconSizeData,k=a.evaluateSizeForZoom(A,o.transform.zoom),R=T.projection.name==="globe",O=[256/o.width*2+1,256/o.height*2+1],B=h?l.text.dynamicLayoutVertexArray:l.icon.dynamicLayoutVertexArray;B.clear();let F=null;R&&(F=h?l.text.globeExtVertexArray:l.icon.globeExtVertexArray);const I=l.lineVertexArray,L=h?l.text.placedSymbolArray:l.icon.placedSymbolArray,N=o.transform.width/o.transform.height;let j,K=!1;for(let J=0;J<L.length;J++){const Y=L.get(J),{numGlyphs:ie,writingMode:te}=Y;if(te!==a.WritingMode.vertical||K||j===a.WritingMode.horizontal||(K=!0),j=te,(Y.hidden||te===a.WritingMode.vertical)&&!K){lr(ie,B);continue}K=!1;const le=new a.Point(Y.tileAnchorX,Y.tileAnchorY);let{x:Ee,y:oe,z:ge}=T.projection.projectTilePoint(le.x,le.y,E.canonical);if(v){const[He,Ve,qe]=v(le);Ee+=He,oe+=Ve,ge+=qe}const he=[Ee,oe,ge,1];if(a.transformMat4$1(he,he,r),!_r(he,O)){lr(ie,B);continue}const Te=sc(o.transform.cameraToCenterDistance,he[3]),ae=a.evaluateSizeForFeature(A,k,Y),_e=g?ae/Te:ae*Te,Me=gi(Ee,oe,ge,d);if(Me[3]<=0){lr(ie,B);continue}let be={};const Ae=g?null:v,Ge=Oe(Y,_e,!1,y,r,d,f,l.glyphOffsetArray,I,B,F,Me,le,be,N,Ae,T.projection,E,g);K=Ge.useVertical,Ae&&Ge.needsFlipping&&(be={}),(Ge.notEnoughRoom||K||Ge.needsFlipping&&Oe(Y,_e,!0,y,r,d,f,l.glyphOffsetArray,I,B,F,Me,le,be,N,Ae,T.projection,E,g).notEnoughRoom)&&lr(ie,B)}h?(l.text.dynamicLayoutVertexBuffer.updateData(B),F&&l.text.globeExtVertexBuffer.updateData(F)):(l.icon.dynamicLayoutVertexBuffer.updateData(B),F&&l.icon.globeExtVertexBuffer.updateData(F))}function ac(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B){const{lineStartIndex:F,glyphStartIndex:I,segment:L}=y,N=I+y.numGlyphs,j=F+y.lineLength,K=r.getoffsetX(I),J=r.getoffsetX(N-1),Y=Zi(l*K,o,h,d,f,g,L,F,j,v,E,T,A,k,!0,R,O,B);if(!Y)return null;const ie=Zi(l*J,o,h,d,f,g,L,F,j,v,E,T,A,k,!0,R,O,B);return ie?{first:Y,last:ie}:null}function Kn(l,r,o,h){return l===a.WritingMode.horizontal&&Math.abs(h)>Math.abs(o)?{useVertical:!0}:l===a.WritingMode.vertical?h>0?{needsFlipping:!0}:null:r!==zr.unknown&&function(d,f){return d===0||Math.abs(f/d)>Lo}(o,h)?r===zr.flipRequired?{needsFlipping:!0}:null:o<0?{needsFlipping:!0}:null}function Oe(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B,F,I,L){const N=r/24,j=l.lineOffsetX*N,K=l.lineOffsetY*N,{lineStartIndex:J,glyphStartIndex:Y,numGlyphs:ie,segment:te,writingMode:le,flipState:Ee}=l,oe=J+l.lineLength,ge=he=>{if(T){const[Me,be,Ae]=he.up,Ge=E.length;a.updateGlobeVertexNormal(T,Ge+0,Me,be,Ae),a.updateGlobeVertexNormal(T,Ge+1,Me,be,Ae),a.updateGlobeVertexNormal(T,Ge+2,Me,be,Ae),a.updateGlobeVertexNormal(T,Ge+3,Me,be,Ae)}const[Te,ae,_e]=he.point;a.addDynamicAttributes(E,Te,ae,_e,he.angle)};if(ie>1){const he=ac(N,y,j,K,o,A,k,l,v,f,R,B,!1,F,I,L);if(!he)return{notEnoughRoom:!0};if(h&&!o){let[Te,ae,_e]=he.first.point,[Me,be,Ae]=he.last.point;[Te,ae]=gi(Te,ae,_e,g),[Me,be]=gi(Me,be,Ae,g);const Ge=Kn(le,Ee,(Me-Te)*O,be-ae);if(l.flipState=Ge&&Ge.needsFlipping?zr.flipRequired:zr.flipNotRequired,Ge)return Ge}ge(he.first);for(let Te=Y+1;Te<Y+ie-1;Te++){const ae=Zi(N*y.getoffsetX(Te),j,K,o,A,k,te,J,oe,v,f,R,B,!1,!1,F,I,L);if(!ae)return E.length-=4*(Te-Y),{notEnoughRoom:!0};ge(ae)}ge(he.last)}else{if(h&&!o){const Te=gi(k.x,k.y,0,d),ae=J+te+1,_e=new a.Point(v.getx(ae),v.gety(ae)),Me=gi(_e.x,_e.y,0,d),be=Me[3]>0?Me:lt(k,_e,Te,1,d,void 0,F,I.canonical),Ae=Kn(le,Ee,(be[0]-Te[0])*O,be[1]-Te[1]);if(l.flipState=Ae&&Ae.needsFlipping?zr.flipRequired:zr.flipNotRequired,Ae)return Ae}const he=Zi(N*y.getoffsetX(Y),j,K,o,A,k,te,J,oe,v,f,R,B,!1,!1,F,I,L);if(!he)return{notEnoughRoom:!0};ge(he)}return{}}function pt(l,r,o,h,d){const{x:f,y:g,z:y}=h.projectTilePoint(l.x,l.y,r);if(!d)return gi(f,g,y,o);const[v,E,T]=d(l);return gi(f+v,g+E,y+T,o)}function lt(l,r,o,h,d,f,g,y){const v=pt(l.sub(r)._unit()._add(l),y,d,g,f);return a.sub(v,o,v),a.normalize(v,v),a.scaleAndAdd(v,o,v,h)}function Zi(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B,F,I){const L=h?l-r:l+r;let N=L>0?1:-1,j=0;h&&(N*=-1,j=Math.PI),N<0&&(j+=Math.PI);let K=y+g+(N>0?0:1)|0,J=d,Y=d,ie=0,te=0;const le=Math.abs(L),Ee=[],oe=[];let ge=f,he=ge;const Te=()=>lt(he,ge,Y,le-ie+1,T,k,B,F.canonical);for(;ie+te<=le;){if(K+=N,K<y||K>=v)return null;if(Y=J,he=ge,Ee.push(Y),R&&oe.push(he),ge=new a.Point(E.getx(K),E.gety(K)),J=A[K],!J){const qe=pt(ge,F.canonical,T,B,k);J=qe[3]>0?A[K]=qe:Te()}ie+=te,te=a.distance(Y,J)}O&&k&&(A[K]&&(J=Te(),te=a.distance(Y,J)),A[K]=J);const ae=(le-ie)/te,_e=ge.sub(he)._mult(ae)._add(he),Me=a.sub([],J,Y),be=a.scaleAndAdd([],Y,Me,ae);let Ae=[0,0,1],Ge=Me[0],He=Me[1];if(I&&(Ae=B.upVector(F.canonical,_e.x,_e.y),Ae[0]!==0||Ae[1]!==0||Ae[2]!==1)){const qe=[Ae[2],0,-Ae[0]],ht=a.cross([],Ae,qe);a.normalize(qe,qe),a.normalize(ht,ht),Ge=a.dot(Me,qe),He=a.dot(Me,ht)}if(o){const qe=a.cross([],Ae,Me);a.normalize(qe,qe),a.scaleAndAdd(be,be,qe,o*N)}const Ve=j+Math.atan2(He,Ge);return Ee.push(be),R&&oe.push(_e),{point:be,angle:Ve,path:Ee,tilePath:oe,up:Ae}}function lr(l,r){const o=r.length,h=o+4*l;r.resize(h),r.float32.fill(-1/0,4*o,4*h)}function ct(l,r,o){const h=r[0],d=r[1];return l[0]=o[0]*h+o[4]*d+o[12],l[1]=o[1]*h+o[5]*d+o[13],l[3]=o[3]*h+o[7]*d+o[15],l}const qi=100;class Ro{constructor(r,o,h=new vn(r.width+200,r.height+200,25),d=new vn(r.width+200,r.height+200,25)){this.transform=r,this.grid=h,this.ignoredGrid=d,this.pitchfactor=Math.cos(r._pitch)*r.cameraToCenterDistance,this.screenRightBoundary=r.width+qi,this.screenBottomBoundary=r.height+qi,this.gridRightBoundary=r.width+200,this.gridBottomBoundary=r.height+200,this.fogState=o}placeCollisionBox(r,o,h,d,f,g,y,v){let E=h.projectedAnchorX,T=h.projectedAnchorY,A=h.projectedAnchorZ;const k=h.elevation,R=h.tileID,O=r.getProjection();if(k&&R){const[J,Y,ie]=O.upVector(R.canonical,h.tileAnchorX,h.tileAnchorY),te=O.upVectorScale(R.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;E+=J*k*te,T+=Y*k*te,A+=ie*k*te}const B=this.projectAndGetPerspectiveRatio(y,E,T,A,h.tileID,O.name==="globe"||!!k||this.transform.pitch>0,O),F=g*B.perspectiveRatio,I=(h.x1*o+d.x-h.padding)*F+B.point.x,L=(h.y1*o+d.y-h.padding)*F+B.point.y,N=(h.x2*o+d.x+h.padding)*F+B.point.x,j=(h.y2*o+d.y+h.padding)*F+B.point.y,K=B.perspectiveRatio<=.55||B.occluded;return!this.isInsideGrid(I,L,N,j)||!f&&this.grid.hitTest(I,L,N,j,v)||K?{box:[],offscreen:!1,occluded:B.occluded}:{box:[I,L,N,j],offscreen:this.isOffscreen(I,L,N,j),occluded:!1}}placeCollisionCircles(r,o,h,d,f,g,y,v,E,T,A,k,R,O,B){const F=[],I=this.transform.elevation,L=r.getProjection(),N=I?I.getAtTileOffsetFunc(B,this.transform.center.lat,this.transform.worldSize,L):null,j=new a.Point(h.tileAnchorX,h.tileAnchorY);let{x:K,y:J,z:Y}=L.projectTilePoint(j.x,j.y,B.canonical);if(N){const[_e,Me,be]=N(j);K+=_e,J+=Me,Y+=be}const ie=L.name==="globe",te=this.projectAndGetPerspectiveRatio(y,K,J,Y,B,ie||!!I||this.transform.pitch>0,L),{perspectiveRatio:le}=te,Ee=(A?g/le:g*le)/a.ONE_EM,oe=gi(K,J,Y,v),ge=te.signedDistanceFromCamera>0?ac(Ee,f,h.lineOffsetX*Ee,h.lineOffsetY*Ee,!1,oe,j,h,d,v,{},I&&!A?N:null,A&&!!I,L,B,A):null;let he=!1,Te=!1,ae=!0;if(ge&&!te.occluded){const _e=.5*R*le+O,Me=new a.Point(-100,-100),be=new a.Point(this.screenRightBoundary,this.screenBottomBoundary),Ae=new Pa,{first:Ge,last:He}=ge,Ve=Ge.path.length;let qe=[];for(let je=Ve-1;je>=1;je--)qe.push(Ge.path[je]);for(let je=1;je<He.path.length;je++)qe.push(He.path[je]);const ht=2.5*_e;E&&(qe=qe.map(([je,Et,Mt],At)=>(N&&!ie&&(Mt=N(At<Ve-1?Ge.tilePath[Ve-1-At]:He.tilePath[At-Ve+2])[2]),gi(je,Et,Mt,E))),qe.some(je=>je[3]<=0)&&(qe=[]));let at=[];if(qe.length>0){let je=1/0,Et=-1/0,Mt=1/0,At=-1/0;for(const It of qe)je=Math.min(je,It[0]),Mt=Math.min(Mt,It[1]),Et=Math.max(Et,It[0]),At=Math.max(At,It[1]);Et>=Me.x&&je<=be.x&&At>=Me.y&&Mt<=be.y&&(at=[qe.map(It=>new a.Point(It[0],It[1]))],(je<Me.x||Et>be.x||Mt<Me.y||At>be.y)&&(at=a.clipLine(at,Me.x,Me.y,be.x,be.y)))}for(const je of at){Ae.reset(je,.25*_e);let Et=0;Et=Ae.length<=.5*_e?1:Math.ceil(Ae.paddedLength/ht)+1;for(let Mt=0;Mt<Et;Mt++){const At=Mt/Math.max(Et-1,1),It=Ae.lerp(At),Ii=It.x+qi,xi=It.y+qi;F.push(Ii,xi,_e,0);const er=Ii-_e,vr=xi-_e,Nt=Ii+_e,Ct=xi+_e;if(ae=ae&&this.isOffscreen(er,vr,Nt,Ct),Te=Te||this.isInsideGrid(er,vr,Nt,Ct),!o&&this.grid.hitTestCircle(Ii,xi,_e,k)&&(he=!0,!T))return{circles:[],offscreen:!1,collisionDetected:he,occluded:!1}}}}return{circles:!T&&he||!Te?[]:F,offscreen:ae,collisionDetected:he,occluded:te.occluded}}queryRenderedSymbols(r){if(r.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const o=[];let h=1/0,d=1/0,f=-1/0,g=-1/0;for(const T of r){const A=new a.Point(T.x+qi,T.y+qi);h=Math.min(h,A.x),d=Math.min(d,A.y),f=Math.max(f,A.x),g=Math.max(g,A.y),o.push(A)}const y=this.grid.query(h,d,f,g).concat(this.ignoredGrid.query(h,d,f,g)),v={},E={};for(const T of y){const A=T.key;if(v[A.bucketInstanceId]===void 0&&(v[A.bucketInstanceId]={}),v[A.bucketInstanceId][A.featureIndex])continue;const k=[new a.Point(T.x1,T.y1),new a.Point(T.x2,T.y1),new a.Point(T.x2,T.y2),new a.Point(T.x1,T.y2)];a.polygonIntersectsPolygon(o,k)&&(v[A.bucketInstanceId][A.featureIndex]=!0,E[A.bucketInstanceId]===void 0&&(E[A.bucketInstanceId]=[]),E[A.bucketInstanceId].push(A.featureIndex))}return E}insertCollisionBox(r,o,h,d,f){(o?this.ignoredGrid:this.grid).insert({bucketInstanceId:h,featureIndex:d,collisionGroupID:f},r[0],r[1],r[2],r[3])}insertCollisionCircles(r,o,h,d,f){const g=o?this.ignoredGrid:this.grid,y={bucketInstanceId:h,featureIndex:d,collisionGroupID:f};for(let v=0;v<r.length;v+=4)g.insertCircle(y,r[v],r[v+1],r[v+2])}projectAndGetPerspectiveRatio(r,o,h,d,f,g,y){const v=[o,h,d,1];let E=!1;d||this.transform.pitch>0?(a.transformMat4$1(v,v,r),this.fogState&&f&&y.name!=="globe"&&(E=function(k,R,O,B,F,I){const L=I.calculateFogTileMatrix(F),N=[R,O,B];return a.transformMat4(N,N,L),Ao(k,N,I.pitch,I._fov)}(this.fogState,o,h,d,f.toUnwrapped(),this.transform)>.9)):ct(v,v,r);const T=v[3];return{point:new a.Point((v[0]/T+1)/2*this.transform.width+qi,(-v[1]/T+1)/2*this.transform.height+qi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(y)/T*.5,1.5),signedDistanceFromCamera:T,occluded:g&&v[2]>T||E}}isOffscreen(r,o,h,d){return h<qi||r>=this.screenRightBoundary||d<qi||o>this.screenBottomBoundary}isInsideGrid(r,o,h,d){return h>=0&&r<this.gridRightBoundary&&d>=0&&o<this.gridBottomBoundary}getViewportMatrix(){const r=a.identity([]);return a.translate(r,r,[-100,-100,0]),r}}function bn(l,r,o){const h=r.createTileMatrix(l,l.worldSize,o.toUnwrapped());return a.multiply(new Float32Array(16),l.projMatrix,h)}function Ki(l,r,o){if(r.projection.name===o.projection.name)return l.projMatrix;const h=o.clone();return h.setProjection(r.projection),bn(h,r.getProjection(),l)}function Vt(l,r,o){return r.name===o.projection.name?l.projMatrix:bn(o,r,l)}class lc{constructor(r,o,h,d){this.opacity=r?Math.max(0,Math.min(1,r.opacity+(r.placed?o:-o))):d&&h?1:0,this.placed=h}isHidden(){return this.opacity===0&&!this.placed}}class kr{constructor(r,o,h,d,f,g=!1){this.text=new lc(r?r.text:null,o,h,f),this.icon=new lc(r?r.icon:null,o,d,f),this.clipped=g}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class Bo{constructor(r,o,h,d=!1){this.text=r,this.icon=o,this.skipFade=h,this.clipped=d}}class Oo{constructor(){this.invProjMatrix=a.create(),this.viewportMatrix=a.create(),this.circles=[]}}class Da{constructor(r,o,h,d,f){this.bucketInstanceId=r,this.featureIndex=o,this.sourceLayerIndex=h,this.bucketIndex=d,this.tileID=f}}class cc{constructor(r){this.crossSourceCollisions=r,this.maxGroupID=0,this.collisionGroups={}}get(r){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[r]){const o=++this.maxGroupID;this.collisionGroups[r]={ID:o,predicate:h=>h.collisionGroupID===o}}return this.collisionGroups[r]}}function Fo(l,r,o,h,d){const{horizontalAlign:f,verticalAlign:g}=a.getAnchorAlignment(l),y=-(f-.5)*r,v=-(g-.5)*o,E=a.evaluateVariableOffset(l,h);return new a.Point(y+E[0]*d,v+E[1]*d)}function Uo(l,r,o,h,d){const f=new a.Point(l,r);return o&&f._rotate(h?d:-d),f}class Cs{constructor(r,o,h,d,f){this.transform=r.clone(),this.projection=r.projection.name,this.collisionIndex=new Ro(this.transform,f),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=o,this.retainedQueryData={},this.collisionGroups=new cc(h),this.collisionCircleArrays={},this.prevPlacement=d,d&&(d.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(r,o,h,d){const f=h.getBucket(o),g=h.latestFeatureIndex;if(!f||!g||o.id!==f.layerIds[0])return;const y=f.layers[0].layout,v=h.collisionBoxArray,E=Math.pow(2,this.transform.zoom-h.tileID.overscaledZ),T=h.tileSize/a.EXTENT,A=h.tileID.toUnwrapped();this.transform.setProjection(f.projection);const k=(R=h.tileID,O=f.getProjection(),B=this.transform,O.name===this.projection?B.calculateProjMatrix(R.toUnwrapped()):bn(B,O,R));var R,O,B;const F=y.get("text-pitch-alignment")==="map",I=y.get("text-rotation-alignment")==="map";o.compileFilter();const L=o.dynamicFilter(),N=o.dynamicFilterNeedsFeature(),j=this.transform.calculatePixelsToTileUnitsMatrix(h),K=Pr(k,h.tileID.canonical,F,I,this.transform,f.getProjection(),j);let J=null;if(F){const te=ti(k,h.tileID.canonical,F,I,this.transform,f.getProjection(),j);J=a.multiply([],this.transform.labelPlaneMatrix,te)}let Y=null;L&&h.latestFeatureIndex&&(Y={unwrappedTileID:A,dynamicFilter:L,dynamicFilterNeedsFeature:N,featureIndex:h.latestFeatureIndex}),this.retainedQueryData[f.bucketInstanceId]=new Da(f.bucketInstanceId,g,f.sourceLayerIndex,f.index,h.tileID);const ie={bucket:f,layout:y,posMatrix:k,textLabelPlaneMatrix:K,labelToScreenMatrix:J,clippingData:Y,scale:E,textPixelRatio:T,holdingForFade:h.holdingForFade(),collisionBoxArray:v,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(f.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(f.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(f.sourceID)};if(d)for(const te of f.sortKeyRanges){const{sortKey:le,symbolInstanceStart:Ee,symbolInstanceEnd:oe}=te;r.push({sortKey:le,symbolInstanceStart:Ee,symbolInstanceEnd:oe,parameters:ie})}else r.push({symbolInstanceStart:0,symbolInstanceEnd:f.symbolInstances.length,parameters:ie})}attemptAnchorPlacement(r,o,h,d,f,g,y,v,E,T,A,k,R,O,B,F,I,L){const{textOffset0:N,textOffset1:j,crossTileID:K}=k,J=[N,j],Y=Fo(r,h,d,J,f),ie=this.collisionIndex.placeCollisionBox(O,f,o,Uo(Y.x,Y.y,g,y,this.transform.angle),A,v,E,T.predicate);if(F){const te=O.getSymbolInstanceIconSize(L,this.transform.zoom,k.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(O,te,F,Uo(Y.x,Y.y,g,y,this.transform.angle),A,v,E,T.predicate).box.length===0)return}if(ie.box.length>0){let te;return this.prevPlacement&&this.prevPlacement.variableOffsets[K]&&this.prevPlacement.placements[K]&&this.prevPlacement.placements[K].text&&(te=this.prevPlacement.variableOffsets[K].anchor),this.variableOffsets[K]={textOffset:J,width:h,height:d,anchor:r,textScale:f,prevAnchor:te},this.markUsedJustification(O,r,k,B),O.allowVerticalPlacement&&(this.markUsedOrientation(O,B,k),this.placedOrientations[K]=B),{shift:Y,placedGlyphBoxes:ie}}}placeLayerBucketPart(r,o,h,d){const{bucket:f,layout:g,posMatrix:y,textLabelPlaneMatrix:v,labelToScreenMatrix:E,clippingData:T,textPixelRatio:A,holdingForFade:k,collisionBoxArray:R,partiallyEvaluatedTextSize:O,partiallyEvaluatedIconSize:B,collisionGroup:F}=r.parameters,I=g.get("text-optional"),L=g.get("icon-optional"),N=g.get("text-allow-overlap"),j=g.get("icon-allow-overlap"),K=g.get("text-rotation-alignment")==="map",J=g.get("text-pitch-alignment")==="map",Y=g.get("icon-text-fit")!=="none",ie=g.get("symbol-z-order")==="viewport-y";this.transform.setProjection(f.projection);let te=N&&(j||!f.hasIconData()||L),le=j&&(N||!f.hasTextData()||I);!f.collisionArrays&&R&&f.deserializeCollisionBoxes(R),h&&d&&f.updateCollisionDebugBuffers(this.transform.zoom,R);const Ee=(oe,ge,he)=>{const{crossTileID:Te,numVerticalGlyphVertices:ae}=oe;if(T){const Nt={zoom:this.transform.zoom,pitch:this.transform.pitch};let Ct=null;if(T.dynamicFilterNeedsFeature){const vt=this.retainedQueryData[f.bucketInstanceId];Ct=T.featureIndex.loadFeature({featureIndex:oe.featureIndex,bucketIndex:vt.bucketIndex,sourceLayerIndex:vt.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,T.dynamicFilter)(Nt,Ct,this.retainedQueryData[f.bucketInstanceId].tileID.canonical,new a.Point(oe.tileAnchorX,oe.tileAnchorY),this.transform.calculateDistanceTileData(T.unwrappedTileID)))return this.placements[Te]=new Bo(!1,!1,!1,!0),void o.add(Te)}if(o.has(Te))return;if(k)return void(this.placements[Te]=new Bo(!1,!1,!1));let _e=!1,Me=!1,be=!0,Ae=!1,Ge=!1,He=null,Ve={box:null,offscreen:null,occluded:null},qe={box:null,offscreen:null,occluded:null},ht=null,at=null,je=null,Et=0,Mt=0,At=0;he.textFeatureIndex?Et=he.textFeatureIndex:oe.useRuntimeCollisionCircles&&(Et=oe.featureIndex),he.verticalTextFeatureIndex&&(Mt=he.verticalTextFeatureIndex);const It=Nt=>{Nt.tileID=this.retainedQueryData[f.bucketInstanceId].tileID;const Ct=this.transform.elevation;(Ct||Nt.elevation)&&(Nt.elevation=Ct?Ct.getAtTileOffset(Nt.tileID,Nt.tileAnchorX,Nt.tileAnchorY):0)},Ii=he.textBox;if(Ii){It(Ii);const Nt=vt=>{let ii=a.WritingMode.horizontal;if(f.allowVerticalPlacement&&!vt&&this.prevPlacement){const ki=this.prevPlacement.placedOrientations[Te];ki&&(this.placedOrientations[Te]=ki,ii=ki,this.markUsedOrientation(f,ii,oe))}return ii},Ct=(vt,ii)=>{if(f.allowVerticalPlacement&&ae>0&&he.verticalTextBox){for(const ki of f.writingModes)if(ki===a.WritingMode.vertical?(Ve=ii(),qe=Ve):Ve=vt(),Ve&&Ve.box&&Ve.box.length)break}else Ve=vt()};if(g.get("text-variable-anchor")){let vt=g.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Te]){const Ut=this.prevPlacement.variableOffsets[Te];vt.indexOf(Ut.anchor)>0&&(vt=vt.filter(Oi=>Oi!==Ut.anchor),vt.unshift(Ut.anchor))}const ii=(Ut,Oi,ia)=>{const Cn=f.getSymbolInstanceTextSize(O,oe,this.transform.zoom,ge),os=(Ut.x2-Ut.x1)*Cn+2*Ut.padding,Ur=(Ut.y2-Ut.y1)*Cn+2*Ut.padding,nn=Y&&!j?Oi:null;nn&&It(nn);let zn={box:[],offscreen:!1,occluded:!1};const ra=N?2*vt.length:vt.length;for(let ss=0;ss<ra;++ss){const Tl=this.attemptAnchorPlacement(vt[ss%vt.length],Ut,os,Ur,Cn,K,J,A,y,F,ss>=vt.length,oe,ge,f,ia,nn,O,B);if(Tl&&(zn=Tl.placedGlyphBoxes,zn&&zn.box&&zn.box.length)){_e=!0,He=Tl.shift;break}}return zn};Ct(()=>ii(Ii,he.iconBox,a.WritingMode.horizontal),()=>{const Ut=he.verticalTextBox;return Ut&&It(Ut),f.allowVerticalPlacement&&!(Ve&&Ve.box&&Ve.box.length)&&ae>0&&Ut?ii(Ut,he.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),Ve&&(_e=Ve.box,be=Ve.offscreen,Ae=Ve.occluded);const ki=Nt(!(!Ve||!Ve.box));if(!_e&&this.prevPlacement){const Ut=this.prevPlacement.variableOffsets[Te];Ut&&(this.variableOffsets[Te]=Ut,this.markUsedJustification(f,Ut.anchor,oe,ki))}}else{const vt=(ii,ki)=>{const Ut=f.getSymbolInstanceTextSize(O,oe,this.transform.zoom,ge),Oi=this.collisionIndex.placeCollisionBox(f,Ut,ii,new a.Point(0,0),N,A,y,F.predicate);return Oi&&Oi.box&&Oi.box.length&&(this.markUsedOrientation(f,ki,oe),this.placedOrientations[Te]=ki),Oi};Ct(()=>vt(Ii,a.WritingMode.horizontal),()=>{const ii=he.verticalTextBox;return f.allowVerticalPlacement&&ae>0&&ii?(It(ii),vt(ii,a.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),Nt(!!(Ve&&Ve.box&&Ve.box.length))}}if(ht=Ve,_e=ht&&ht.box&&ht.box.length>0,be=ht&&ht.offscreen,Ae=ht&&ht.occluded,oe.useRuntimeCollisionCircles){const Nt=f.text.placedSymbolArray.get(oe.centerJustifiedTextSymbolIndex>=0?oe.centerJustifiedTextSymbolIndex:oe.verticalPlacedTextSymbolIndex),Ct=a.evaluateSizeForFeature(f.textSizeData,O,Nt),vt=g.get("text-padding");at=this.collisionIndex.placeCollisionCircles(f,N,Nt,f.lineVertexArray,f.glyphOffsetArray,Ct,y,v,E,h,J,F.predicate,oe.collisionCircleDiameter*Ct/a.ONE_EM,vt,this.retainedQueryData[f.bucketInstanceId].tileID),_e=N||at.circles.length>0&&!at.collisionDetected,be=be&&at.offscreen,Ae=at.occluded}if(he.iconFeatureIndex&&(At=he.iconFeatureIndex),he.iconBox){const Nt=Ct=>{It(Ct);const vt=Y&&He?Uo(He.x,He.y,K,J,this.transform.angle):new a.Point(0,0),ii=f.getSymbolInstanceIconSize(B,this.transform.zoom,oe.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(f,ii,Ct,vt,j,A,y,F.predicate)};qe&&qe.box&&qe.box.length&&he.verticalIconBox?(je=Nt(he.verticalIconBox),Me=je.box.length>0):(je=Nt(he.iconBox),Me=je.box.length>0),be=be&&je.offscreen,Ge=je.occluded}const xi=I||oe.numHorizontalGlyphVertices===0&&ae===0,er=L||oe.numIconVertices===0;if(xi||er?er?xi||(Me=Me&&_e):_e=Me&&_e:Me=_e=Me&&_e,_e&&ht&&ht.box&&this.collisionIndex.insertCollisionBox(ht.box,g.get("text-ignore-placement"),f.bucketInstanceId,qe&&qe.box&&Mt?Mt:Et,F.ID),Me&&je&&this.collisionIndex.insertCollisionBox(je.box,g.get("icon-ignore-placement"),f.bucketInstanceId,At,F.ID),at&&(_e&&this.collisionIndex.insertCollisionCircles(at.circles,g.get("text-ignore-placement"),f.bucketInstanceId,Et,F.ID),h)){const Nt=f.bucketInstanceId;let Ct=this.collisionCircleArrays[Nt];Ct===void 0&&(Ct=this.collisionCircleArrays[Nt]=new Oo);for(let vt=0;vt<at.circles.length;vt+=4)Ct.circles.push(at.circles[vt+0]),Ct.circles.push(at.circles[vt+1]),Ct.circles.push(at.circles[vt+2]),Ct.circles.push(at.collisionDetected?1:0)}const vr=f.projection.name!=="globe";te=te&&(vr||!Ae),le=le&&(vr||!Ge),this.placements[Te]=new Bo(_e||te,Me||le,be||f.justReloaded),o.add(Te)};if(ie){const oe=f.getSortedSymbolIndexes(this.transform.angle);for(let ge=oe.length-1;ge>=0;--ge){const he=oe[ge];Ee(f.symbolInstances.get(he),he,f.collisionArrays[he])}}else for(let oe=r.symbolInstanceStart;oe<r.symbolInstanceEnd;oe++)Ee(f.symbolInstances.get(oe),oe,f.collisionArrays[oe]);if(h&&f.bucketInstanceId in this.collisionCircleArrays){const oe=this.collisionCircleArrays[f.bucketInstanceId];a.invert(oe.invProjMatrix,y),oe.viewportMatrix=this.collisionIndex.getViewportMatrix()}f.justReloaded=!1}markUsedJustification(r,o,h,d){const{leftJustifiedTextSymbolIndex:f,centerJustifiedTextSymbolIndex:g,rightJustifiedTextSymbolIndex:y,verticalPlacedTextSymbolIndex:v,crossTileID:E}=h,T=a.getAnchorJustification(o),A=d===a.WritingMode.vertical?v:T==="left"?f:T==="center"?g:T==="right"?y:-1;f>=0&&(r.text.placedSymbolArray.get(f).crossTileID=A>=0&&f!==A?0:E),g>=0&&(r.text.placedSymbolArray.get(g).crossTileID=A>=0&&g!==A?0:E),y>=0&&(r.text.placedSymbolArray.get(y).crossTileID=A>=0&&y!==A?0:E),v>=0&&(r.text.placedSymbolArray.get(v).crossTileID=A>=0&&v!==A?0:E)}markUsedOrientation(r,o,h){const d=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly?o:0,f=o===a.WritingMode.vertical?o:0,{leftJustifiedTextSymbolIndex:g,centerJustifiedTextSymbolIndex:y,rightJustifiedTextSymbolIndex:v,verticalPlacedTextSymbolIndex:E}=h,T=r.text.placedSymbolArray;g>=0&&(T.get(g).placedOrientation=d),y>=0&&(T.get(y).placedOrientation=d),v>=0&&(T.get(v).placedOrientation=d),E>=0&&(T.get(E).placedOrientation=f)}commit(r){this.commitTime=r,this.zoomAtLastRecencyCheck=this.transform.zoom;const o=this.prevPlacement;let h=!1;this.prevZoomAdjustment=o?o.zoomAdjustment(this.transform.zoom):0;const d=o?o.symbolFadeChange(r):1,f=o?o.opacities:{},g=o?o.variableOffsets:{},y=o?o.placedOrientations:{};for(const v in this.placements){const E=this.placements[v],T=f[v];T?(this.opacities[v]=new kr(T,d,E.text,E.icon,null,E.clipped),h=h||E.text!==T.text.placed||E.icon!==T.icon.placed):(this.opacities[v]=new kr(null,d,E.text,E.icon,E.skipFade,E.clipped),h=h||E.text||E.icon)}for(const v in f){const E=f[v];if(!this.opacities[v]){const T=new kr(E,d,!1,!1);T.isHidden()||(this.opacities[v]=T,h=h||E.text.placed||E.icon.placed)}}for(const v in g)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=g[v]);for(const v in y)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=y[v]);h?this.lastPlacementChangeTime=r:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=o?o.lastPlacementChangeTime:r)}updateLayerOpacities(r,o){const h=new Set;for(const d of o){const f=d.getBucket(r);f&&d.latestFeatureIndex&&r.id===f.layerIds[0]&&this.updateBucketOpacities(f,h,d.collisionBoxArray)}}updateBucketOpacities(r,o,h){r.hasTextData()&&r.text.opacityVertexArray.clear(),r.hasIconData()&&r.icon.opacityVertexArray.clear(),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexArray.clear(),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexArray.clear();const d=r.layers[0].layout,f=!!r.layers[0].dynamicFilter(),g=new kr(null,0,!1,!1,!0),y=d.get("text-allow-overlap"),v=d.get("icon-allow-overlap"),E=d.get("text-variable-anchor"),T=d.get("text-rotation-alignment")==="map",A=d.get("text-pitch-alignment")==="map",k=d.get("icon-text-fit")!=="none",R=new kr(null,0,y&&(v||!r.hasIconData()||d.get("icon-optional")),v&&(y||!r.hasTextData()||d.get("text-optional")),!0);!r.collisionArrays&&h&&(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData())&&r.deserializeCollisionBoxes(h);const O=(F,I,L)=>{for(let N=0;N<I/4;N++)F.opacityVertexArray.emplaceBack(L)};let B=0;for(let F=0;F<r.symbolInstances.length;F++){const I=r.symbolInstances.get(F),{numHorizontalGlyphVertices:L,numVerticalGlyphVertices:N,crossTileID:j,numIconVertices:K}=I,J=o.has(j);let Y=this.opacities[j];J?Y=g:Y||(Y=R,this.opacities[j]=Y),o.add(j);const ie=L>0||N>0,te=K>0,le=this.placedOrientations[j],Ee=le===a.WritingMode.vertical,oe=le===a.WritingMode.horizontal||le===a.WritingMode.horizontalOnly;if(!ie&&!te||Y.isHidden()||B++,ie){const ge=Vo(Y.text);O(r.text,L,Ee?Xt:ge),O(r.text,N,oe?Xt:ge);const he=Y.text.isHidden(),{leftJustifiedTextSymbolIndex:Te,centerJustifiedTextSymbolIndex:ae,rightJustifiedTextSymbolIndex:_e,verticalPlacedTextSymbolIndex:Me}=I,be=r.text.placedSymbolArray,Ae=he||Ee?1:0;Te>=0&&(be.get(Te).hidden=Ae),ae>=0&&(be.get(ae).hidden=Ae),_e>=0&&(be.get(_e).hidden=Ae),Me>=0&&(be.get(Me).hidden=he||oe?1:0);const Ge=this.variableOffsets[j];Ge&&this.markUsedJustification(r,Ge.anchor,I,le);const He=this.placedOrientations[j];He&&(this.markUsedJustification(r,"left",I,He),this.markUsedOrientation(r,He,I))}if(te){const ge=Vo(Y.icon),{placedIconSymbolIndex:he,verticalPlacedIconSymbolIndex:Te}=I,ae=r.icon.placedSymbolArray,_e=Y.icon.isHidden()?1:0;he>=0&&(O(r.icon,K,Ee?Xt:ge),ae.get(he).hidden=_e),Te>=0&&(O(r.icon,I.numVerticalIconVertices,oe?Xt:ge),ae.get(Te).hidden=_e)}if(r.hasIconCollisionBoxData()||r.hasTextCollisionBoxData()){const ge=r.collisionArrays[F];if(ge){let he=new a.Point(0,0),Te=!0;if(ge.textBox||ge.verticalTextBox){if(E){const _e=this.variableOffsets[j];_e?(he=Fo(_e.anchor,_e.width,_e.height,_e.textOffset,_e.textScale),T&&he._rotate(A?this.transform.angle:-this.transform.angle)):Te=!1}f&&(Te=!Y.clipped),ge.textBox&&Yn(r.textCollisionBox.collisionVertexArray,Y.text.placed,!Te||Ee,he.x,he.y),ge.verticalTextBox&&Yn(r.textCollisionBox.collisionVertexArray,Y.text.placed,!Te||oe,he.x,he.y)}const ae=Te&&!!(!oe&&ge.verticalIconBox);ge.iconBox&&Yn(r.iconCollisionBox.collisionVertexArray,Y.icon.placed,ae,k?he.x:0,k?he.y:0),ge.verticalIconBox&&Yn(r.iconCollisionBox.collisionVertexArray,Y.icon.placed,!ae,k?he.x:0,k?he.y:0)}}}if(r.fullyClipped=B===0,r.sortFeatures(this.transform.angle),this.retainedQueryData[r.bucketInstanceId]&&(this.retainedQueryData[r.bucketInstanceId].featureSortOrder=r.featureSortOrder),r.hasTextData()&&r.text.opacityVertexBuffer&&r.text.opacityVertexBuffer.updateData(r.text.opacityVertexArray),r.hasIconData()&&r.icon.opacityVertexBuffer&&r.icon.opacityVertexBuffer.updateData(r.icon.opacityVertexArray),r.hasIconCollisionBoxData()&&r.iconCollisionBox.collisionVertexBuffer&&r.iconCollisionBox.collisionVertexBuffer.updateData(r.iconCollisionBox.collisionVertexArray),r.hasTextCollisionBoxData()&&r.textCollisionBox.collisionVertexBuffer&&r.textCollisionBox.collisionVertexBuffer.updateData(r.textCollisionBox.collisionVertexArray),r.bucketInstanceId in this.collisionCircleArrays){const F=this.collisionCircleArrays[r.bucketInstanceId];r.placementInvProjMatrix=F.invProjMatrix,r.placementViewportMatrix=F.viewportMatrix,r.collisionCircleArray=F.circles,delete this.collisionCircleArrays[r.bucketInstanceId]}}symbolFadeChange(r){return this.fadeDuration===0?1:(r-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(r){return Math.max(0,(this.transform.zoom-r)/1.5)}hasTransitions(r){return this.stale||r-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(r,o){const h=this.zoomAtLastRecencyCheck===o?1-this.zoomAdjustment(o):1;return this.zoomAtLastRecencyCheck=o,this.commitTime+this.fadeDuration*h>r}setStale(){this.stale=!0}}function Yn(l,r,o,h,d){l.emplaceBack(r?1:0,o?1:0,h||0,d||0),l.emplaceBack(r?1:0,o?1:0,h||0,d||0),l.emplaceBack(r?1:0,o?1:0,h||0,d||0),l.emplaceBack(r?1:0,o?1:0,h||0,d||0)}const Ri=Math.pow(2,25),Yt=Math.pow(2,24),La=Math.pow(2,17),Ra=Math.pow(2,16),Bi=Math.pow(2,9),Yi=Math.pow(2,8),hc=Math.pow(2,1);function Vo(l){if(l.opacity===0&&!l.placed)return 0;if(l.opacity===1&&l.placed)return 4294967295;const r=l.placed?1:0,o=Math.floor(127*l.opacity);return o*Ri+r*Yt+o*La+r*Ra+o*Bi+r*Yi+o*hc+r}const Xt=0;class No{constructor(r){this._sortAcrossTiles=r.layout.get("symbol-z-order")!=="viewport-y"&&r.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(r,o,h,d,f){const g=this._bucketParts;for(;this._currentTileIndex<r.length;)if(o.getBucketParts(g,d,r[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,f())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,g.sort((y,v)=>y.sortKey-v.sortKey));this._currentPartIndex<g.length;){const y=g[this._currentPartIndex];if(o.placeLayerBucketPart(y,this._seenCrossTileIDs,h,y.symbolInstanceStart===0),this._currentPartIndex++,f())return!0}return!1}}class Ba{constructor(r,o,h,d,f,g,y,v){this.placement=new Cs(r,f,g,y,v),this._currentPlacementIndex=o.length-1,this._forceFullPlacement=h,this._showCollisionBoxes=d,this._done=!1}isDone(){return this._done}continuePlacement(r,o,h){const d=a.exported.now(),f=()=>{const g=a.exported.now()-d;return!this._forceFullPlacement&&g>2};for(;this._currentPlacementIndex>=0;){const g=o[r[this._currentPlacementIndex]],y=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=y)&&(!g.maxzoom||g.maxzoom>y)){if(this._inProgressLayer||(this._inProgressLayer=new No(g)),this._inProgressLayer.continuePlacement(h[g.source],this.placement,this._showCollisionBoxes,g,f))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(r){return this.placement.commit(r),this.placement}}const wn=512/a.EXTENT/2;class wi{constructor(r,o,h){this.tileID=r,this.bucketInstanceId=h,this.index=new a.KDBush(o.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const d=r.canonical.x*a.EXTENT,f=r.canonical.y*a.EXTENT;for(let g=0;g<o.length;g++){const{key:y,crossTileID:v,tileAnchorX:E,tileAnchorY:T}=o.get(g),A=Math.floor((d+E)*wn),k=Math.floor((f+T)*wn);this.index.add(A,k),this.keys.push(y),this.crossTileIDs.push(v)}this.index.finish()}findMatches(r,o,h){const d=this.tileID.canonical.z<o.canonical.z?1:Math.pow(2,this.tileID.canonical.z-o.canonical.z),f=wn/Math.pow(2,o.canonical.z-this.tileID.canonical.z),g=o.canonical.x*a.EXTENT,y=o.canonical.y*a.EXTENT;for(let v=0;v<r.length;v++){const E=r.get(v);if(E.crossTileID)continue;const{key:T,tileAnchorX:A,tileAnchorY:k}=E,R=Math.floor((g+A)*f),O=Math.floor((y+k)*f),B=this.index.range(R-d,O-d,R+d,O+d);for(const F of B){const I=this.crossTileIDs[F];if(this.keys[F]===T&&!h.has(I)){h.add(I),E.crossTileID=I;break}}}}}class Oa{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Fa{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(r){const o=Math.round((r-this.lng)/360);if(o!==0)for(const h in this.indexes){const d=this.indexes[h],f={};for(const g in d){const y=d[g];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+o),f[y.tileID.key]=y}this.indexes[h]=f}this.lng=r}addBucket(r,o,h){if(this.indexes[r.overscaledZ]&&this.indexes[r.overscaledZ][r.key]){if(this.indexes[r.overscaledZ][r.key].bucketInstanceId===o.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(r.overscaledZ,this.indexes[r.overscaledZ][r.key])}for(let f=0;f<o.symbolInstances.length;f++)o.symbolInstances.get(f).crossTileID=0;this.usedCrossTileIDs[r.overscaledZ]||(this.usedCrossTileIDs[r.overscaledZ]=new Set);const d=this.usedCrossTileIDs[r.overscaledZ];for(const f in this.indexes){const g=this.indexes[f];if(Number(f)>r.overscaledZ)for(const y in g){const v=g[y];v.tileID.isChildOf(r)&&v.findMatches(o.symbolInstances,r,d)}else{const y=g[r.scaledTo(Number(f)).key];y&&y.findMatches(o.symbolInstances,r,d)}}for(let f=0;f<o.symbolInstances.length;f++){const g=o.symbolInstances.get(f);g.crossTileID||(g.crossTileID=h.generate(),d.add(g.crossTileID))}return this.indexes[r.overscaledZ]===void 0&&(this.indexes[r.overscaledZ]={}),this.indexes[r.overscaledZ][r.key]=new wi(r,o.symbolInstances,o.bucketInstanceId),!0}removeBucketCrossTileIDs(r,o){for(const h of o.crossTileIDs)this.usedCrossTileIDs[r].delete(h)}removeStaleBuckets(r){let o=!1;for(const h in this.indexes){const d=this.indexes[h];for(const f in d)r[d[f].bucketInstanceId]||(this.removeBucketCrossTileIDs(h,d[f]),delete d[f],o=!0)}return o}}class Dr{constructor(){this.layerIndexes={},this.crossTileIDs=new Oa,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(r,o,h,d){let f=this.layerIndexes[r.id];f===void 0&&(f=this.layerIndexes[r.id]=new Fa);let g=!1;const y={};d.name!=="globe"&&f.handleWrapJump(h);for(const v of o){const E=v.getBucket(r);E&&r.id===E.layerIds[0]&&(E.bucketInstanceId||(E.bucketInstanceId=++this.maxBucketInstanceId),f.addBucket(v.tileID,E,this.crossTileIDs)&&(g=!0),y[E.bucketInstanceId]=!0)}return f.removeStaleBuckets(y)&&(g=!0),g}pruneUnusedLayers(r){const o={};r.forEach(h=>{o[h]=!0});for(const h in this.layerIndexes)o[h]||delete this.layerIndexes[h]}}const tn=(l,r)=>a.emitValidationErrors(l,r&&r.filter(o=>o.identifier!=="source.canvas")),zs=a.pick(wt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Dh=a.pick(wt,["setCenter","setZoom","setBearing","setPitch"]),Ua={version:8,layers:[],sources:{}},Jn={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class gr extends a.Evented{constructor(r,o={}){super(),this.map=r,this.dispatcher=new di(Hn(),this),this.imageManager=new Ma,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(r._requestManager,o.localFontFamily?a.LocalGlyphMode.all:o.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,o.localFontFamily||o.localIdeographFontFamily),this.crossTileSymbolIndex=new Dr,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const h=this;this._rtlTextPluginCallback=gr.registerForPluginStateChange(d=>{h.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:d.pluginStatus,pluginURL:d.pluginURL},(f,g)=>{if(a.triggerPluginCompletionEvent(f),g&&g.every(y=>y))for(const y in h._sourceCaches){const v=h._sourceCaches[y],E=v.getSource().type;E!=="vector"&&E!=="geojson"||v.reload()}})}),this.on("data",d=>{if(d.dataType!=="source"||d.sourceDataType!=="metadata")return;const f=this.getSource(d.sourceId);if(f&&f.vectorLayerIds)for(const g in this._layers){const y=this._layers[g];y.source===f.id&&this._validateLayer(y)}})}loadURL(r,o={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const h=typeof o.validate=="boolean"?o.validate:!a.isMapboxURL(r);r=this.map._requestManager.normalizeStyleURL(r,o.accessToken);const d=this.map._requestManager.transformRequest(r,a.ResourceType.Style);this._request=a.getJSON(d,(f,g)=>{this._request=null,f?this.fire(new a.ErrorEvent(f)):g&&this._load(g,h)})}loadJSON(r,o={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(r,o.validate!==!1)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(Ua,!1)}_updateLayerCount(r,o){const h=o?1:-1;r.is3D()&&(this._num3DLayers+=h),r.type==="circle"&&(this._numCircleLayers+=h),r.type==="symbol"&&(this._numSymbolLayers+=h)}_load(r,o){if(o&&tn(this,a.validateStyle(r)))return;this._loaded=!0,this.stylesheet=a.clone$1(r),this._updateMapProjection();for(const d in r.sources)this.addSource(d,r.sources[d],{validate:!1});this._changed=!1,r.sprite?this._loadSprite(r.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(r.glyphs);const h=oc(this.stylesheet.layers);this._order=h.map(d=>d.id),this._layers={},this._serializedLayers={};for(const d of h){const f=a.createStyleLayer(d);f.setEventedParent(this,{layer:{id:f.id}}),this._layers[f.id]=f,this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new fi(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(r){r?this.stylesheet.projection=r:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(r){this._spriteRequest=function(o,h,d){let f,g,y;const v=a.exported.devicePixelRatio>1?"@2x":"";let E=a.getJSON(h.transformRequest(h.normalizeSpriteURL(o,v,".json"),a.ResourceType.SpriteJSON),(k,R)=>{E=null,y||(y=k,f=R,A())}),T=a.getImage(h.transformRequest(h.normalizeSpriteURL(o,v,".png"),a.ResourceType.SpriteImage),(k,R)=>{T=null,y||(y=k,g=R,A())});function A(){if(y)d(y);else if(f&&g){const k=a.exported.getImageData(g),R={};for(const O in f){const{width:B,height:F,x:I,y:L,sdf:N,pixelRatio:j,stretchX:K,stretchY:J,content:Y}=f[O],ie=new a.RGBAImage({width:B,height:F});a.RGBAImage.copy(k,ie,{x:I,y:L},{x:0,y:0},{width:B,height:F}),R[O]={data:ie,pixelRatio:j,sdf:N,stretchX:K,stretchY:J,content:Y}}d(null,R)}}return{cancel(){E&&(E.cancel(),E=null),T&&(T.cancel(),T=null)}}}(r,this.map._requestManager,(o,h)=>{if(this._spriteRequest=null,o)this.fire(new a.ErrorEvent(o));else if(h)for(const d in h)this.imageManager.addImage(d,h[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(r){const o=this.getSource(r.source);if(!o)return;const h=r.sourceLayer;h&&(o.type==="geojson"||o.vectorLayerIds&&o.vectorLayerIds.indexOf(h)===-1)&&this.fire(new a.ErrorEvent(new Error(`Source layer "${h}" does not exist on source "${o.id}" as specified by style layer "${r.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const r in this._sourceCaches)if(!this._sourceCaches[r].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(r){const o=[];for(const h of r){const d=this._layers[h];d.type!=="custom"&&o.push(d.serialize())}return o}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const r in this._sourceCaches)if(this._sourceCaches[r].hasTransition())return!0;for(const r in this._layers)if(this._layers[r].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(r){return!!this.terrain&&(typeof r.isLayerDraped=="function"?r.isLayerDraped():Jn[r.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(r){if(!this._loaded)return;const o=this._changed;if(this._changed){const d=Object.keys(this._updatedLayers),f=Object.keys(this._removedLayers);(d.length||f.length)&&this._updateWorkerLayers(d,f);for(const g in this._updatedSources){const y=this._updatedSources[g];y==="reload"?this._reloadSource(g):y==="clear"&&this._clearSource(g)}this._updateTilesForChangedImages();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(r);this.light.updateTransitions(r),this.fog&&this.fog.updateTransitions(r),this._resetUpdates()}const h={};for(const d in this._sourceCaches){const f=this._sourceCaches[d];h[d]=f.used,f.used=!1}for(const d of this._order){const f=this._layers[d];if(f.recalculate(r,this._availableImages),!f.isHidden(r.zoom)){const y=this._getLayerSourceCache(f);y&&(y.used=!0)}const g=this.map.painter;if(g){const y=f.getProgramIds();if(!y)continue;const v=f.getProgramConfiguration(r.zoom);for(const E of y)g.useProgram(E,v)}}for(const d in h){const f=this._sourceCaches[d];h[d]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(r),this.terrain&&this.terrain.recalculate(r),this.fog&&this.fog.recalculate(r),this.z=r.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),o&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const r=Object.keys(this._changedImages);if(r.length){for(const o in this._sourceCaches)this._sourceCaches[o].reloadTilesForDependencies(["icons","patterns"],r);this._changedImages={}}}_updateWorkerLayers(r,o){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(r),removedIds:o})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(r){if(this._checkLoaded(),tn(this,a.validateStyle(r)))return!1;(r=a.clone$1(r)).layers=oc(r.layers);const o=function(d,f){if(!d)return[{command:wt.setStyle,args:[f]}];let g=[];try{if(!ve(d.version,f.version))return[{command:wt.setStyle,args:[f]}];ve(d.center,f.center)||g.push({command:wt.setCenter,args:[f.center]}),ve(d.zoom,f.zoom)||g.push({command:wt.setZoom,args:[f.zoom]}),ve(d.bearing,f.bearing)||g.push({command:wt.setBearing,args:[f.bearing]}),ve(d.pitch,f.pitch)||g.push({command:wt.setPitch,args:[f.pitch]}),ve(d.sprite,f.sprite)||g.push({command:wt.setSprite,args:[f.sprite]}),ve(d.glyphs,f.glyphs)||g.push({command:wt.setGlyphs,args:[f.glyphs]}),ve(d.transition,f.transition)||g.push({command:wt.setTransition,args:[f.transition]}),ve(d.light,f.light)||g.push({command:wt.setLight,args:[f.light]}),ve(d.fog,f.fog)||g.push({command:wt.setFog,args:[f.fog]}),ve(d.projection,f.projection)||g.push({command:wt.setProjection,args:[f.projection]});const y={},v=[];(function(A,k,R,O){let B;for(B in k=k||{},A=A||{})A.hasOwnProperty(B)&&(k.hasOwnProperty(B)||Do(B,R,O));for(B in k){if(!k.hasOwnProperty(B))continue;const F=k[B];A.hasOwnProperty(B)?ve(A[B],F)||(A[B].type==="geojson"&&F.type==="geojson"&&Is(A,k,B)?R.push({command:wt.setGeoJSONSourceData,args:[B,F.data]}):Ca(B,k,R,O)):Ia(B,k,R)}})(d.sources,f.sources,v,y);const E=[];d.layers&&d.layers.forEach(A=>{A.source&&y[A.source]?g.push({command:wt.removeLayer,args:[A.id]}):E.push(A)});let T=d.terrain;T&&y[T.source]&&(g.push({command:wt.setTerrain,args:[void 0]}),T=void 0),g=g.concat(v),ve(T,f.terrain)||g.push({command:wt.setTerrain,args:[f.terrain]}),function(A,k,R){k=k||[];const O=(A=A||[]).map(Cr),B=k.map(Cr),F=A.reduce(za,{}),I=k.reduce(za,{}),L=O.slice(),N=Object.create(null);let j,K,J,Y,ie,te,le;for(j=0,K=0;j<O.length;j++)J=O[j],I.hasOwnProperty(J)?K++:(R.push({command:wt.removeLayer,args:[J]}),L.splice(L.indexOf(J,K),1));for(j=0,K=0;j<B.length;j++)J=B[B.length-1-j],L[L.length-1-j]!==J&&(F.hasOwnProperty(J)?(R.push({command:wt.removeLayer,args:[J]}),L.splice(L.lastIndexOf(J,L.length-K),1)):K++,te=L[L.length-j],R.push({command:wt.addLayer,args:[I[J],te]}),L.splice(L.length-j,0,J),N[J]=!0);for(j=0;j<B.length;j++)if(J=B[j],Y=F[J],ie=I[J],!N[J]&&!ve(Y,ie))if(ve(Y.source,ie.source)&&ve(Y["source-layer"],ie["source-layer"])&&ve(Y.type,ie.type)){for(le in mr(Y.layout,ie.layout,R,J,null,wt.setLayoutProperty),mr(Y.paint,ie.paint,R,J,null,wt.setPaintProperty),ve(Y.filter,ie.filter)||R.push({command:wt.setFilter,args:[J,ie.filter]}),ve(Y.minzoom,ie.minzoom)&&ve(Y.maxzoom,ie.maxzoom)||R.push({command:wt.setLayerZoomRange,args:[J,ie.minzoom,ie.maxzoom]}),Y)Y.hasOwnProperty(le)&&le!=="layout"&&le!=="paint"&&le!=="filter"&&le!=="metadata"&&le!=="minzoom"&&le!=="maxzoom"&&(le.indexOf("paint.")===0?mr(Y[le],ie[le],R,J,le.slice(6),wt.setPaintProperty):ve(Y[le],ie[le])||R.push({command:wt.setLayerProperty,args:[J,le,ie[le]]}));for(le in ie)ie.hasOwnProperty(le)&&!Y.hasOwnProperty(le)&&le!=="layout"&&le!=="paint"&&le!=="filter"&&le!=="metadata"&&le!=="minzoom"&&le!=="maxzoom"&&(le.indexOf("paint.")===0?mr(Y[le],ie[le],R,J,le.slice(6),wt.setPaintProperty):ve(Y[le],ie[le])||R.push({command:wt.setLayerProperty,args:[J,le,ie[le]]}))}else R.push({command:wt.removeLayer,args:[J]}),te=L[L.lastIndexOf(J)+1],R.push({command:wt.addLayer,args:[ie,te]})}(E,f.layers,g)}catch(y){console.warn("Unable to compute style diff:",y),g=[{command:wt.setStyle,args:[f]}]}return g}(this.serialize(),r).filter(d=>!(d.command in Dh));if(o.length===0)return!1;const h=o.filter(d=>!(d.command in zs));if(h.length>0)throw new Error(`Unimplemented: ${h.map(d=>d.command).join(", ")}.`);return o.forEach(d=>{d.command!=="setTransition"&&d.command!=="setProjection"&&this[d.command].apply(this,d.args)}),this.stylesheet=r,this._updateMapProjection(),!0}addImage(r,o){return this.getImage(r)?this.fire(new a.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(r,o),this._afterImageUpdated(r),this)}updateImage(r,o){this.imageManager.updateImage(r,o)}getImage(r){return this.imageManager.getImage(r)}removeImage(r){return this.getImage(r)?(this.imageManager.removeImage(r),this._afterImageUpdated(r),this):this.fire(new a.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(r){this._availableImages=this.imageManager.listImages(),this._changedImages[r]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(r,o,h={}){if(this._checkLoaded(),this.getSource(r)!==void 0)throw new Error("There is already a source with this ID");if(!o.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(o).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(o.type)>=0&&this._validate(a.validateSource,`sources.${r}`,o,null,h))return;this.map&&this.map._collectResourceTiming&&(o.collectResourceTiming=!0);const d=st(r,o,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r),source:d.serialize(),sourceId:r}));const f=g=>{const y=(g?"symbol:":"other:")+r,v=this._sourceCaches[y]=new a.SourceCache(y,d,g);(g?this._symbolSourceCaches:this._otherSourceCaches)[r]=v,v.style=this,v.onAdd(this.map)};f(!1),o.type!=="vector"&&o.type!=="geojson"||f(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(r){this._checkLoaded();const o=this.getSource(r);if(!o)throw new Error("There is no source with this ID");for(const d in this._layers)if(this._layers[d].source===r)return this.fire(new a.ErrorEvent(new Error(`Source "${r}" cannot be removed while layer "${d}" is using it.`)));if(this.terrain&&this.terrain.get().source===r)return this.fire(new a.ErrorEvent(new Error(`Source "${r}" cannot be removed while terrain is using it.`)));const h=this._getSourceCaches(r);for(const d of h)delete this._sourceCaches[d.id],delete this._updatedSources[d.id],d.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:d.getSource().id})),d.setEventedParent(null),d.clearTiles();return delete this._otherSourceCaches[r],delete this._symbolSourceCaches[r],o.setEventedParent(null),o.onRemove&&o.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(r,o){this._checkLoaded(),this.getSource(r).setData(o),this._changed=!0}getSource(r){const o=this._getSourceCache(r);return o&&o.getSource()}_getSources(){const r=[];for(const o in this._otherSourceCaches){const h=this._getSourceCache(o);h&&r.push(h.getSource())}return r}addLayer(r,o,h={}){this._checkLoaded();const d=r.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${d}" already exists on this map`)));let f;if(r.type==="custom"){if(tn(this,a.validateCustomStyleLayer(r)))return;f=a.createStyleLayer(r)}else{if(typeof r.source=="object"&&(this.addSource(d,r.source),r=a.clone$1(r),r=a.extend(r,{source:d})),this._validate(a.validateLayer,`layers.${d}`,r,{arrayIndex:-1},h))return;f=a.createStyleLayer(r),this._validateLayer(f),f.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[f.id]=f.serialize(),this._updateLayerCount(f,!0)}const g=o?this._order.indexOf(o):this._order.length;if(o&&g===-1)return void this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`)));this._order.splice(g,0,d),this._layerOrderChanged=!0,this._layers[d]=f;const y=this._getLayerSourceCache(f);if(this._removedLayers[d]&&f.source&&y&&f.type!=="custom"){const v=this._removedLayers[d];delete this._removedLayers[d],v.type!==f.type?this._updatedSources[f.source]="clear":(this._updatedSources[f.source]="reload",y.pause())}this._updateLayer(f),f.onAdd&&f.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(r,o){if(this._checkLoaded(),this._changed=!0,!this._layers[r])return void this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be moved.`)));if(r===o)return;const h=this._order.indexOf(r);this._order.splice(h,1);const d=o?this._order.indexOf(o):this._order.length;o&&d===-1?this.fire(new a.ErrorEvent(new Error(`Layer with id "${o}" does not exist on this map.`))):(this._order.splice(d,0,r),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(r){this._checkLoaded();const o=this._layers[r];if(!o)return void this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be removed.`)));o.setEventedParent(null),this._updateLayerCount(o,!1);const h=this._order.indexOf(r);this._order.splice(h,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[r]=o,delete this._layers[r],delete this._serializedLayers[r],delete this._updatedLayers[r],delete this._updatedPaintProps[r],o.onRemove&&o.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(r){return this._layers[r]}hasLayer(r){return r in this._layers}hasLayerType(r){for(const o in this._layers)if(this._layers[o].type===r)return!0;return!1}setLayerZoomRange(r,o,h){this._checkLoaded();const d=this.getLayer(r);d?d.minzoom===o&&d.maxzoom===h||(o!=null&&(d.minzoom=o),h!=null&&(d.maxzoom=h),this._updateLayer(d)):this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(r,o,h={}){this._checkLoaded();const d=this.getLayer(r);if(d){if(!ve(d.filter,o))return o==null?(d.filter=void 0,void this._updateLayer(d)):void(this._validate(a.validateFilter,`layers.${d.id}.filter`,o,{layerType:d.type},h)||(d.filter=a.clone$1(o),this._updateLayer(d)))}else this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be filtered.`)))}getFilter(r){const o=this.getLayer(r);return o&&a.clone$1(o.filter)}setLayoutProperty(r,o,h,d={}){this._checkLoaded();const f=this.getLayer(r);f?ve(f.getLayoutProperty(o),h)||(f.setLayoutProperty(o,h,d),this._updateLayer(f)):this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(r,o){const h=this.getLayer(r);if(h)return h.getLayoutProperty(o);this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style.`)))}setPaintProperty(r,o,h,d={}){this._checkLoaded();const f=this.getLayer(r);f?ve(f.getPaintProperty(o),h)||(f.setPaintProperty(o,h,d)&&this._updateLayer(f),this._changed=!0,this._updatedPaintProps[r]=!0):this.fire(new a.ErrorEvent(new Error(`The layer '${r}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(r,o){const h=this.getLayer(r);return h&&h.getPaintProperty(o)}setFeatureState(r,o){this._checkLoaded();const h=r.source,d=r.sourceLayer,f=this.getSource(h);if(!f)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));const g=f.type;if(g==="geojson"&&d)return void this.fire(new a.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(g==="vector"&&!d)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));r.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided.")));const y=this._getSourceCaches(h);for(const v of y)v.setFeatureState(d,r.id,o)}removeFeatureState(r,o){this._checkLoaded();const h=r.source,d=this.getSource(h);if(!d)return void this.fire(new a.ErrorEvent(new Error(`The source '${h}' does not exist in the map's style.`)));const f=d.type,g=f==="vector"?r.sourceLayer:void 0;if(f==="vector"&&!g)return void this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(o&&typeof r.id!="string"&&typeof r.id!="number")return void this.fire(new a.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const y=this._getSourceCaches(h);for(const v of y)v.removeFeatureState(g,r.id,o)}getFeatureState(r){this._checkLoaded();const o=r.source,h=r.sourceLayer,d=this.getSource(o);if(d){if(d.type!=="vector"||h)return r.id===void 0&&this.fire(new a.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(o)[0].getFeatureState(h,r.id);this.fire(new a.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(new Error(`The source '${o}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const r={};for(const o in this._sourceCaches){const h=this._sourceCaches[o].getSource();r[h.id]||(r[h.id]=h.serialize())}return a.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:r,layers:this._serializeLayers(this._order)},o=>o!==void 0)}_updateLayer(r){this._updatedLayers[r.id]=!0;const o=this._getLayerSourceCache(r);r.source&&!this._updatedSources[r.source]&&o&&o.getSource().type!=="raster"&&(this._updatedSources[r.source]="reload",o.pause()),this._changed=!0,r.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(r){const o=g=>this._layers[g].type==="fill-extrusion",h={},d=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(o(y)){h[y]=g;for(const v of r){const E=v[y];if(E)for(const T of E)d.push(T)}}}d.sort((g,y)=>y.intersectionZ-g.intersectionZ);const f=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(o(y))for(let v=d.length-1;v>=0;v--){const E=d[v].feature;if(h[E.layer.id]<g)break;f.push(E),d.pop()}else for(const v of r){const E=v[y];if(E)for(const T of E)f.push(T.feature)}}return f}queryRenderedFeatures(r,o,h){o&&o.filter&&this._validate(a.validateFilter,"queryRenderedFeatures.filter",o.filter,null,o);const d={};if(o&&o.layers){if(!Array.isArray(o.layers))return this.fire(new a.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const v of o.layers){const E=this._layers[v];if(!E)return this.fire(new a.ErrorEvent(new Error(`The layer '${v}' does not exist in the map's style and cannot be queried for features.`))),[];d[E.source]=!0}}const f=[];o.availableImages=this._availableImages;const g=o&&o.layers?o.layers.some(v=>{const E=this.getLayer(v);return E&&E.is3D()}):this.has3DLayers(),y=Hr.createFromScreenPoints(r,h);for(const v in this._sourceCaches){const E=this._sourceCaches[v].getSource().id;o.layers&&!d[E]||f.push($t(this._sourceCaches[v],this._layers,this._serializedLayers,y,o,h,g,!!this.map._showQueryGeometry))}return this.placement&&f.push(function(v,E,T,A,k,R,O){const B={},F=R.queryRenderedSymbols(A),I=[];for(const L of Object.keys(F).map(Number))I.push(O[L]);I.sort(Mi);for(const L of I){const N=L.featureIndex.lookupSymbolFeatures(F[L.bucketInstanceId],E,L.bucketIndex,L.sourceLayerIndex,k.filter,k.layers,k.availableImages,v);for(const j in N){const K=B[j]=B[j]||[],J=N[j];J.sort((Y,ie)=>{const te=L.featureSortOrder;if(te){const le=te.indexOf(Y.featureIndex);return te.indexOf(ie.featureIndex)-le}return ie.featureIndex-Y.featureIndex});for(const Y of J)K.push(Y)}}for(const L in B)B[L].forEach(N=>{const j=N.feature,K=T(v[L]);if(!K)return;const J=K.getFeatureState(j.layer["source-layer"],j.id);j.source=j.layer.source,j.layer["source-layer"]&&(j.sourceLayer=j.layer["source-layer"]),j.state=J});return B}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),y.screenGeometry,o,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(f)}querySourceFeatures(r,o){o&&o.filter&&this._validate(a.validateFilter,"querySourceFeatures.filter",o.filter,null,o);const h=this._getSourceCaches(r);let d=[];for(const f of h)d=d.concat(ei(f,o));return d}addSourceType(r,o,h){return gr.getSourceType(r)?h(new Error(`A source type called "${r}" already exists.`)):(gr.setSourceType(r,o),o.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:r,url:o.workerSourceURL},h):h(null,null))}getLight(){return this.light.getLight()}setLight(r,o={}){this._checkLoaded();const h=this.light.getLight();let d=!1;for(const g in r)if(!ve(r[g],h[g])){d=!0;break}if(!d)return;const f=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(r,o),this.light.updateTransitions(f)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(r,o=1){if(this._checkLoaded(),!r)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let h=r;if(o===1){if(typeof h.source=="object"){const d="terrain-dem-src";this.addSource(d,h.source),h=a.clone$1(h),h=a.extend(h,{source:d})}if(this._validate(a.validateTerrain,"terrain",h))return}if(!this.terrain||this.terrain&&o!==this.terrain.drapeRenderMode){if(!h)return;this._createTerrain(h,o)}else{const d=this.terrain,f=d.get();for(const g of Object.keys(a.spec.terrain))!h.hasOwnProperty(g)&&a.spec.terrain[g].default&&(h[g]=a.spec.terrain[g].default);for(const g in h)if(!ve(h[g],f[g])){d.set(h),this.stylesheet.terrain=h;const y=this._setTransitionParameters({duration:0});d.updateTransitions(y);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(r){const o=this.fog=new Nn(r,this.map.transform);this.stylesheet.fog=r;const h=this._setTransitionParameters({duration:0});o.updateTransitions(h)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const r of this.map._markers)r._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(r){if(this._checkLoaded(),!r)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const o=this.fog,h=o.get();Object.keys(r).length===0&&o.set(r);for(const d in r)if(!ve(r[d],h[d])){o.set(r),this.stylesheet.fog=r;const f=this._setTransitionParameters({duration:0});o.updateTransitions(f);break}}else this._createFog(r);this._markersNeedUpdate=!0}_setTransitionParameters(r){return{now:a.exported.now(),transition:a.extend(r,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const r=this._order.filter(h=>this.isLayerDraped(this._layers[h])),o=this._order.filter(h=>!this.isLayerDraped(this._layers[h]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...r),this._drapedFirstOrder.push(...o)}_createTerrain(r,o){const h=this.terrain=new bs(r,o);this.stylesheet.terrain=r,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const d=this._setTransitionParameters({duration:0});h.updateTransitions(d)}_force3DLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="fill-extrusion"&&this._updateLayer(o)}}_forceSymbolLayerUpdate(){for(const r in this._layers){const o=this._layers[r];o.type==="symbol"&&this._updateLayer(o)}}_validate(r,o,h,d,f={}){return(!f||f.validate!==!1)&&tn(this,r.call(a.validateStyle,a.extend({key:o,style:this.serialize(),value:h,styleSpec:a.spec},d)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const r in this._layers)this._layers[r].setEventedParent(null);for(const r in this._sourceCaches)this._sourceCaches[r].clearTiles(),this._sourceCaches[r].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(r){const o=this._getSourceCaches(r);for(const h of o)h.clearTiles()}_reloadSource(r){const o=this._getSourceCaches(r);for(const h of o)h.resume(),h.reload()}_reloadSources(){for(const r of this._getSources())r.reload&&r.reload()}_updateSources(r){for(const o in this._sourceCaches)this._sourceCaches[o].update(r)}_generateCollisionBoxes(){for(const r in this._sourceCaches){const o=this._sourceCaches[r];o.resume(),o.reload()}}_updatePlacement(r,o,h,d,f=!1){let g=!1,y=!1;const v={};for(const E of this._order){const T=this._layers[E];if(T.type!=="symbol")continue;if(!v[T.source]){const k=this._getLayerSourceCache(T);if(!k)continue;v[T.source]=k.getRenderableIds(!0).map(R=>k.getTileByID(R)).sort((R,O)=>O.tileID.overscaledZ-R.tileID.overscaledZ||(R.tileID.isLessThan(O.tileID)?-1:1))}const A=this.crossTileSymbolIndex.addLayer(T,v[T.source],r.center.lng,r.projection);g=g||A}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),f=f||this._layerOrderChanged||h===0,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(f||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),r.zoom))&&(this.pauseablePlacement=new Ba(r,this._order,f,o,h,d,this.placement,this.fog&&r.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,v),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),y=!0),g&&this.pauseablePlacement.placement.setStale()),y||g)for(const E of this._order){const T=this._layers[E];T.type==="symbol"&&this.placement.updateLayerOpacities(T,v[T.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const r in this._sourceCaches)this._sourceCaches[r].releaseSymbolFadeTiles()}getImages(r,o,h){this.imageManager.getImages(o.icons,h),this._updateTilesForChangedImages();const d=f=>{f&&f.setDependencies(o.tileID.key,o.type,o.icons)};d(this._otherSourceCaches[o.source]),d(this._symbolSourceCaches[o.source])}getGlyphs(r,o,h){this.glyphManager.getGlyphs(o.stacks,h)}getResource(r,o,h){return a.makeRequest(o,h)}_getSourceCache(r){return this._otherSourceCaches[r]}_getLayerSourceCache(r){return r.type==="symbol"?this._symbolSourceCaches[r.source]:this._otherSourceCaches[r.source]}_getSourceCaches(r){const o=[];return this._otherSourceCaches[r]&&o.push(this._otherSourceCaches[r]),this._symbolSourceCaches[r]&&o.push(this._symbolSourceCaches[r]),o}_isSourceCacheLoaded(r){const o=this._getSourceCaches(r);return o.length===0?(this.fire(new a.ErrorEvent(new Error(`There is no source with ID '${r}'`))),!1):o.every(h=>h.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}gr.getSourceType=function(l){return et[l]},gr.setSourceType=function(l,r){et[l]=r},gr.registerForPluginStateChange=a.registerForPluginStateChange;var Va=`
9
+ #define EPSILON 0.0000001
10
+ #define PI 3.141592653589793
11
+ #define EXTENT 8192.0
12
+ #define HALF_PI PI/2.0
13
+ #define QUARTER_PI PI/4.0
14
+ #define RAD_TO_DEG 180.0/PI
15
+ #define DEG_TO_RAD PI/180.0
16
+ #define GLOBE_RADIUS EXTENT/PI/2.0`,Tn="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Lr=`
17
+ #define ELEVATION_SCALE 7.0
18
+ #define ELEVATION_OFFSET 450.0
19
+ #ifdef PROJECTION_GLOBE_VIEW
20
+ uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
21
+ mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
22
+ #else
23
+ vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
24
+ #endif
25
+ const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)
26
+ {float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
27
+ #ifdef TERRAIN
28
+ #ifdef TERRAIN_DEM_FLOAT_FORMAT
29
+ uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
30
+ #else
31
+ uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
32
+ #endif
33
+ uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
34
+ #ifdef TERRAIN_DEM_FLOAT_FORMAT
35
+ vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
36
+ #else
37
+ float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
38
+ #ifdef TERRAIN_DEM_NEAREST_FILTER
39
+ return u_exaggeration*tl;
40
+ #endif
41
+ float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
42
+ #endif
43
+ }float prevElevation(vec2 apos) {
44
+ #ifdef TERRAIN_DEM_FLOAT_FORMAT
45
+ vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
46
+ #else
47
+ float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
48
+ #endif
49
+ }
50
+ #ifdef TERRAIN_VERTEX_MORPHING
51
+ float elevation(vec2 apos) {
52
+ #ifdef ZERO_EXAGGERATION
53
+ return 0.0;
54
+ #endif
55
+ float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
56
+ #else
57
+ float elevation(vec2 apos) {
58
+ #ifdef ZERO_EXAGGERATION
59
+ return 0.0;
60
+ #endif
61
+ return currentElevation(apos);}
62
+ #endif
63
+ highp float unpack_depth(highp vec4 rgba_depth)
64
+ {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
65
+ unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
66
+ );return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
67
+ #ifdef TERRAIN_DEM_FLOAT_FORMAT
68
+ float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
69
+ #else
70
+ vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
71
+ #endif
72
+ return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
73
+ #else
74
+ float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
75
+ #endif`,jo=`#ifdef FOG
76
+ uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
77
+ #endif`,Rr=`#ifdef FOG
78
+ uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
79
+ mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
80
+ #endif`;let Ps={},Qn={};const Go=[];eo(Va,Go),eo(Lr,Go),eo(jo,Go),eo(Rr,Go),Ps=Tt("",Lr),Qn=Tt(Rr,jo);const uc=Tt(`
81
+ #if __VERSION__ >=300
82
+ #define varying in
83
+ #define gl_FragColor glFragColor
84
+ #define texture2D texture
85
+ #define textureCube texture
86
+ out vec4 glFragColor;
87
+ #endif
88
+ highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)
89
+ {const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,`
90
+ #if __VERSION__ >=300
91
+ #define attribute in
92
+ #define varying out
93
+ #define texture2D texture
94
+ #endif
95
+ float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
96
+ #ifdef PROJECTION_GLOBE_VIEW
97
+ vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
98
+ #ifndef PROJECTED_POS_ON_VIEWPORT
99
+ float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
100
+ #else
101
+ return vec3(0.0);
102
+ #endif
103
+ }vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
104
+ #endif
105
+ vec2 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(
106
+ unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
107
+ );}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;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),ks=Va,Na=`
108
+ #ifdef GL_ES
109
+ precision mediump float;
110
+ #else
111
+
112
+ #if !defined(lowp)
113
+ #define lowp
114
+ #endif
115
+
116
+ #if !defined(mediump)
117
+ #define mediump
118
+ #endif
119
+
120
+ #if !defined(highp)
121
+ #define highp
122
+ #endif
123
+
124
+ #endif`;var ja={background:Tt(`uniform vec4 u_color;uniform float u_opacity;
125
+ #ifdef LIGHTING_3D_MODE
126
+ varying vec4 v_color;
127
+ #endif
128
+ void main() {vec4 out_color;
129
+ #ifdef LIGHTING_3D_MODE
130
+ out_color=v_color;
131
+ #else
132
+ out_color=u_color;
133
+ #endif
134
+ #ifdef FOG
135
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
136
+ #endif
137
+ gl_FragColor=out_color*u_opacity;
138
+ #ifdef OVERDRAW_INSPECTOR
139
+ gl_FragColor=vec4(1.0);
140
+ #endif
141
+ }`,`attribute vec2 a_pos;uniform mat4 u_matrix;
142
+ #ifdef LIGHTING_3D_MODE
143
+ uniform vec4 u_color;varying vec4 v_color;
144
+ #endif
145
+ void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
146
+ #ifdef LIGHTING_3D_MODE
147
+ v_color=apply_lighting(u_color);
148
+ #endif
149
+ #ifdef FOG
150
+ v_fog_pos=fog_position(a_pos);
151
+ #endif
152
+ }`),backgroundPattern:Tt(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
153
+ #ifdef LIGHTING_3D_MODE
154
+ out_color=apply_lighting(out_color);
155
+ #endif
156
+ #ifdef FOG
157
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
158
+ #endif
159
+ gl_FragColor=out_color*u_opacity;
160
+ #ifdef OVERDRAW_INSPECTOR
161
+ gl_FragColor=vec4(1.0);
162
+ #endif
163
+ }`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);
164
+ #ifdef FOG
165
+ v_fog_pos=fog_position(a_pos);
166
+ #endif
167
+ }`),circle:Tt(`varying vec3 v_data;varying float v_visibility;
168
+ #pragma mapbox: define highp vec4 color
169
+ #pragma mapbox: define mediump float radius
170
+ #pragma mapbox: define lowp float blur
171
+ #pragma mapbox: define lowp float opacity
172
+ #pragma mapbox: define highp vec4 stroke_color
173
+ #pragma mapbox: define mediump float stroke_width
174
+ #pragma mapbox: define lowp float stroke_opacity
175
+ void main() {
176
+ #pragma mapbox: initialize highp vec4 color
177
+ #pragma mapbox: initialize mediump float radius
178
+ #pragma mapbox: initialize lowp float blur
179
+ #pragma mapbox: initialize lowp float opacity
180
+ #pragma mapbox: initialize highp vec4 stroke_color
181
+ #pragma mapbox: initialize mediump float stroke_width
182
+ #pragma mapbox: initialize lowp float stroke_opacity
183
+ vec2 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(
184
+ antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
185
+ );vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
186
+ #ifdef LIGHTING_3D_MODE
187
+ out_color=apply_lighting(out_color);
188
+ #endif
189
+ #ifdef FOG
190
+ out_color=fog_apply_premultiplied(out_color,v_fog_pos);
191
+ #endif
192
+ gl_FragColor=out_color*(v_visibility*opacity_t);
193
+ #ifdef OVERDRAW_INSPECTOR
194
+ gl_FragColor=vec4(1.0);
195
+ #endif
196
+ }`,`#define NUM_VISIBILITY_RINGS 2
197
+ #define INV_SQRT2 0.70710678
198
+ #define ELEVATION_BIAS 0.0001
199
+ #define NUM_SAMPLES_PER_RING 16
200
+ uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
201
+ #ifdef PROJECTION_GLOBE_VIEW
202
+ attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
203
+ #endif
204
+ varying vec3 v_data;varying float v_visibility;
205
+ #pragma mapbox: define highp vec4 color
206
+ #pragma mapbox: define mediump float radius
207
+ #pragma mapbox: define lowp float blur
208
+ #pragma mapbox: define lowp float opacity
209
+ #pragma mapbox: define highp vec4 stroke_color
210
+ #pragma mapbox: define mediump float stroke_width
211
+ #pragma mapbox: define lowp float stroke_opacity
212
+ vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
213
+ #if defined(TERRAIN)
214
+ return elevation(pos)+ELEVATION_BIAS;
215
+ #else
216
+ return 0.0;
217
+ #endif
218
+ }vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
219
+ #ifdef PITCH_WITH_MAP
220
+ #ifdef PROJECTION_GLOBE_VIEW
221
+ return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
222
+ #else
223
+ return u_matrix*( world_center+vec4(sample_offset,0,0) );
224
+ #endif
225
+ #else
226
+ return projected_center+vec4(sample_offset,0,0);
227
+ #endif
228
+ }float get_sample_step() {
229
+ #ifdef PITCH_WITH_MAP
230
+ return 2.0*PI/float(NUM_SAMPLES_PER_RING);
231
+ #else
232
+ return PI/float(NUM_SAMPLES_PER_RING);
233
+ #endif
234
+ }void main(void) {
235
+ #pragma mapbox: initialize highp vec4 color
236
+ #pragma mapbox: initialize mediump float radius
237
+ #pragma mapbox: initialize lowp float blur
238
+ #pragma mapbox: initialize lowp float opacity
239
+ #pragma mapbox: initialize highp vec4 stroke_color
240
+ #pragma mapbox: initialize mediump float stroke_width
241
+ #pragma mapbox: initialize lowp float stroke_opacity
242
+ vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;
243
+ #ifdef PROJECTION_GLOBE_VIEW
244
+ vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
245
+ #else
246
+ surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);
247
+ #endif
248
+ vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
249
+ #ifdef PITCH_WITH_MAP
250
+ #ifdef SCALE_WITH_MAP
251
+ view_scale=1.0;
252
+ #else
253
+ view_scale=projected_center.w/u_camera_to_center_distance;
254
+ #endif
255
+ #else
256
+ #ifdef SCALE_WITH_MAP
257
+ view_scale=u_camera_to_center_distance;
258
+ #else
259
+ view_scale=projected_center.w;
260
+ #endif
261
+ #endif
262
+ gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
263
+ #ifdef TERRAIN
264
+ float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
265
+ #ifdef PITCH_WITH_MAP
266
+ float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
267
+ #else
268
+ occlusion_world_center=world_center;occlusion_projected_center=projected_center;
269
+ #endif
270
+ for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
271
+ #else
272
+ visibility=1.0;
273
+ #endif
274
+ #ifdef PROJECTION_GLOBE_VIEW
275
+ visibility=1.0;
276
+ #endif
277
+ v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
278
+ #ifdef FOG
279
+ v_fog_pos=fog_position(world_center.xyz);
280
+ #endif
281
+ }`),clippingMask:Tt("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:Tt(`uniform highp float u_intensity;varying vec2 v_extrude;
282
+ #pragma mapbox: define highp float weight
283
+ #define GAUSS_COEF 0.3989422804014327
284
+ void main() {
285
+ #pragma mapbox: initialize highp float weight
286
+ float 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);
287
+ #ifdef FOG
288
+ if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
289
+ #endif
290
+ #ifdef OVERDRAW_INSPECTOR
291
+ gl_FragColor=vec4(1.0);
292
+ #endif
293
+ }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
294
+ #ifdef PROJECTION_GLOBE_VIEW
295
+ attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
296
+ #endif
297
+ varying vec2 v_extrude;
298
+ #pragma mapbox: define highp float weight
299
+ #pragma mapbox: define mediump float radius
300
+ const highp float ZERO=1.0/255.0/16.0;
301
+ #define GAUSS_COEF 0.3989422804014327
302
+ void main(void) {
303
+ #pragma mapbox: initialize highp float weight
304
+ #pragma mapbox: initialize mediump float radius
305
+ vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;
306
+ #ifdef PROJECTION_GLOBE_VIEW
307
+ vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
308
+ #else
309
+ pos=vec3(tilePos+extrude,elevation(tilePos));
310
+ #endif
311
+ gl_Position=u_matrix*vec4(pos,1);
312
+ #ifdef FOG
313
+ v_fog_pos=fog_position(pos);
314
+ #endif
315
+ }`),heatmapTexture:Tt(`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;
316
+ #ifdef OVERDRAW_INSPECTOR
317
+ gl_FragColor=vec4(0.0);
318
+ #endif
319
+ }`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Tt("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
320
+ 0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Tt("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_2f;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_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
321
+ 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(
322
+ 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:Tt("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;
323
+ #ifdef PROJECTION_GLOBE_VIEW
324
+ attribute vec3 a_pos_3;
325
+ #endif
326
+ varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
327
+ #ifdef PROJECTION_GLOBE_VIEW
328
+ gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
329
+ #else
330
+ gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
331
+ #endif
332
+ }`),fill:Tt(`#pragma mapbox: define highp vec4 color
333
+ #pragma mapbox: define lowp float opacity
334
+ void main() {
335
+ #pragma mapbox: initialize highp vec4 color
336
+ #pragma mapbox: initialize lowp float opacity
337
+ vec4 out_color=color;
338
+ #ifdef LIGHTING_3D_MODE
339
+ out_color=apply_lighting(out_color);
340
+ #endif
341
+ #ifdef FOG
342
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
343
+ #endif
344
+ gl_FragColor=out_color*opacity;
345
+ #ifdef OVERDRAW_INSPECTOR
346
+ gl_FragColor=vec4(1.0);
347
+ #endif
348
+ }`,`attribute vec2 a_pos;uniform mat4 u_matrix;
349
+ #pragma mapbox: define highp vec4 color
350
+ #pragma mapbox: define lowp float opacity
351
+ void main() {
352
+ #pragma mapbox: initialize highp vec4 color
353
+ #pragma mapbox: initialize lowp float opacity
354
+ gl_Position=u_matrix*vec4(a_pos,0,1);
355
+ #ifdef FOG
356
+ v_fog_pos=fog_position(a_pos);
357
+ #endif
358
+ }`),fillOutline:Tt(`varying vec2 v_pos;
359
+ #pragma mapbox: define highp vec4 outline_color
360
+ #pragma mapbox: define lowp float opacity
361
+ void main() {
362
+ #pragma mapbox: initialize highp vec4 outline_color
363
+ #pragma mapbox: initialize lowp float opacity
364
+ float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
365
+ #ifdef LIGHTING_3D_MODE
366
+ out_color=apply_lighting(out_color);
367
+ #endif
368
+ #ifdef FOG
369
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
370
+ #endif
371
+ gl_FragColor=out_color*(alpha*opacity);
372
+ #ifdef OVERDRAW_INSPECTOR
373
+ gl_FragColor=vec4(1.0);
374
+ #endif
375
+ }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
376
+ #pragma mapbox: define highp vec4 outline_color
377
+ #pragma mapbox: define lowp float opacity
378
+ void main() {
379
+ #pragma mapbox: initialize highp vec4 outline_color
380
+ #pragma mapbox: initialize lowp float opacity
381
+ gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
382
+ #ifdef FOG
383
+ v_fog_pos=fog_position(a_pos);
384
+ #endif
385
+ }`),fillOutlinePattern:Tt(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;
386
+ #pragma mapbox: define lowp float opacity
387
+ #pragma mapbox: define lowp vec4 pattern
388
+ void main() {
389
+ #pragma mapbox: initialize lowp float opacity
390
+ #pragma mapbox: initialize mediump vec4 pattern
391
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);
392
+ #ifdef LIGHTING_3D_MODE
393
+ out_color=apply_lighting(out_color);
394
+ #endif
395
+ #ifdef FOG
396
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
397
+ #endif
398
+ gl_FragColor=out_color*(alpha*opacity);
399
+ #ifdef OVERDRAW_INSPECTOR
400
+ gl_FragColor=vec4(1.0);
401
+ #endif
402
+ }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;
403
+ #pragma mapbox: define lowp float opacity
404
+ #pragma mapbox: define lowp vec4 pattern
405
+ #pragma mapbox: define lowp float pixel_ratio
406
+ void main() {
407
+ #pragma mapbox: initialize lowp float opacity
408
+ #pragma mapbox: initialize mediump vec4 pattern
409
+ #pragma mapbox: initialize lowp float pixel_ratio
410
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
411
+ #ifdef FOG
412
+ v_fog_pos=fog_position(a_pos);
413
+ #endif
414
+ }`),fillPattern:Tt(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;
415
+ #pragma mapbox: define lowp float opacity
416
+ #pragma mapbox: define lowp vec4 pattern
417
+ void main() {
418
+ #pragma mapbox: initialize lowp float opacity
419
+ #pragma mapbox: initialize mediump vec4 pattern
420
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
421
+ #ifdef LIGHTING_3D_MODE
422
+ out_color=apply_lighting(out_color);
423
+ #endif
424
+ #ifdef FOG
425
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
426
+ #endif
427
+ gl_FragColor=out_color*opacity;
428
+ #ifdef OVERDRAW_INSPECTOR
429
+ gl_FragColor=vec4(1.0);
430
+ #endif
431
+ }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;
432
+ #pragma mapbox: define lowp float opacity
433
+ #pragma mapbox: define lowp vec4 pattern
434
+ #pragma mapbox: define lowp float pixel_ratio
435
+ void main() {
436
+ #pragma mapbox: initialize lowp float opacity
437
+ #pragma mapbox: initialize mediump vec4 pattern
438
+ #pragma mapbox: initialize lowp float pixel_ratio
439
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
440
+ #ifdef FOG
441
+ v_fog_pos=fog_position(a_pos);
442
+ #endif
443
+ }`),fillExtrusion:Tt(`varying vec4 v_color;
444
+ #ifdef RENDER_SHADOWS
445
+ varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
446
+ #endif
447
+ #ifdef FAUX_AO
448
+ uniform lowp vec2 u_ao;varying vec3 v_ao;
449
+ #endif
450
+ #ifdef ZERO_ROOF_RADIUS
451
+ varying vec4 v_roof_color;
452
+ #endif
453
+ #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
454
+ varying highp vec3 v_normal;
455
+ #endif
456
+ void main() {
457
+ #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
458
+ vec3 normal=v_normal;
459
+ #endif
460
+ float z;vec4 color;
461
+ #ifdef ZERO_ROOF_RADIUS
462
+ z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);
463
+ #else
464
+ color=v_color;
465
+ #endif
466
+ #ifdef FAUX_AO
467
+ float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
468
+ #ifdef ZERO_ROOF_RADIUS
469
+ concave*=(1.0-z);
470
+ #endif
471
+ float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;
472
+ #endif
473
+ #ifdef RENDER_SHADOWS
474
+ #ifdef ZERO_ROOF_RADIUS
475
+ normal=mix(normal,vec3(0.0,0.0,1.0),z);
476
+ #endif
477
+ color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);
478
+ #endif
479
+ #ifdef FOG
480
+ color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
481
+ #endif
482
+ gl_FragColor=color;
483
+ #ifdef OVERDRAW_INSPECTOR
484
+ gl_FragColor=vec4(1.0);
485
+ #endif
486
+ }`,`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;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
487
+ #ifdef PROJECTION_GLOBE_VIEW
488
+ attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
489
+ #endif
490
+ varying vec4 v_color;
491
+ #ifdef RENDER_SHADOWS
492
+ uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
493
+ #endif
494
+ #ifdef ZERO_ROOF_RADIUS
495
+ varying vec4 v_roof_color;
496
+ #endif
497
+ #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
498
+ varying highp vec3 v_normal;
499
+ #endif
500
+ #ifdef FAUX_AO
501
+ uniform lowp vec2 u_ao;varying vec3 v_ao;
502
+ #endif
503
+ #pragma mapbox: define highp float base
504
+ #pragma mapbox: define highp float height
505
+ #pragma mapbox: define highp vec4 color
506
+ void main() {
507
+ #pragma mapbox: initialize highp float base
508
+ #pragma mapbox: initialize highp float height
509
+ #pragma mapbox: initialize highp vec4 color
510
+ vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));
511
+ #if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
512
+ v_normal=normal;
513
+ #endif
514
+ base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
515
+ #if defined(HAS_CENTROID) || defined(TERRAIN)
516
+ centroid_pos=a_centroid_pos;
517
+ #endif
518
+ float ele=0.0;float h=0.0;float c_ele;vec3 pos;
519
+ #ifdef TERRAIN
520
+ bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);
521
+ #else
522
+ h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);
523
+ #endif
524
+ #ifdef PROJECTION_GLOBE_VIEW
525
+ float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
526
+ #endif
527
+ float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);
528
+ #ifdef RENDER_SHADOWS
529
+ v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;
530
+ #endif
531
+ float NdotL=0.0;float colorvalue=0.0;
532
+ #ifdef LIGHTING_3D_MODE
533
+ NdotL=calculate_NdotL(normal);
534
+ #else
535
+ colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);
536
+ #endif
537
+ if (normal.y !=0.0) {float r=0.84;
538
+ #ifndef LIGHTING_3D_MODE
539
+ r=mix(0.7,0.98,1.0-u_lightintensity);
540
+ #endif
541
+ NdotL*=(
542
+ (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);
543
+ #ifdef FAUX_AO
544
+ float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
545
+ #ifdef TERRAIN
546
+ top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
547
+ #endif
548
+ v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
549
+ #ifdef PROJECTION_GLOBE_VIEW
550
+ top_height+=u_height_lift;
551
+ #endif
552
+ gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
553
+ #endif
554
+ #ifdef LIGHTING_3D_MODE
555
+ v_color=apply_lighting(color,NdotL);
556
+ #else
557
+ v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
558
+ #endif
559
+ v_color*=u_opacity;
560
+ #ifdef ZERO_ROOF_RADIUS
561
+ v_roof_color=vec4(0.0,0.0,0.0,1.0);
562
+ #ifdef LIGHTING_3D_MODE
563
+ v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));
564
+ #else
565
+ float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
566
+ #endif
567
+ v_roof_color*=u_opacity;
568
+ #endif
569
+ #ifdef FOG
570
+ v_fog_pos=fog_position(pos);
571
+ #endif
572
+ }`),fillExtrusionPattern:Tt(`uniform vec2 u_texsize;uniform sampler2D u_image;
573
+ #ifdef FAUX_AO
574
+ uniform lowp vec2 u_ao;varying vec3 v_ao;
575
+ #endif
576
+ #ifdef LIGHTING_3D_MODE
577
+ varying float v_NdotL;
578
+ #endif
579
+ varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;
580
+ #pragma mapbox: define lowp float base
581
+ #pragma mapbox: define lowp float height
582
+ #pragma mapbox: define lowp vec4 pattern
583
+ #pragma mapbox: define lowp float pixel_ratio
584
+ void main() {
585
+ #pragma mapbox: initialize lowp float base
586
+ #pragma mapbox: initialize lowp float height
587
+ #pragma mapbox: initialize mediump vec4 pattern
588
+ #pragma mapbox: initialize lowp float pixel_ratio
589
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
590
+ #ifdef LIGHTING_3D_MODE
591
+ out_color=apply_lighting(out_color,v_NdotL)*u_opacity;
592
+ #else
593
+ out_color=out_color*v_lighting;
594
+ #endif
595
+ #ifdef FAUX_AO
596
+ float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
597
+ #endif
598
+ #ifdef FOG
599
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
600
+ #endif
601
+ gl_FragColor=out_color;
602
+ #ifdef OVERDRAW_INSPECTOR
603
+ gl_FragColor=vec4(1.0);
604
+ #endif
605
+ }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
606
+ #ifdef PROJECTION_GLOBE_VIEW
607
+ attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
608
+ #endif
609
+ varying vec2 v_pos;varying vec4 v_lighting;
610
+ #ifdef FAUX_AO
611
+ uniform lowp vec2 u_ao;varying vec3 v_ao;
612
+ #endif
613
+ #ifdef LIGHTING_3D_MODE
614
+ varying float v_NdotL;
615
+ #endif
616
+ #pragma mapbox: define lowp float base
617
+ #pragma mapbox: define lowp float height
618
+ #pragma mapbox: define lowp vec4 pattern
619
+ #pragma mapbox: define lowp float pixel_ratio
620
+ void main() {
621
+ #pragma mapbox: initialize lowp float base
622
+ #pragma mapbox: initialize lowp float height
623
+ #pragma mapbox: initialize mediump vec4 pattern
624
+ #pragma mapbox: initialize lowp float pixel_ratio
625
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
626
+ #if defined(HAS_CENTROID) || defined(TERRAIN)
627
+ centroid_pos=a_centroid_pos;
628
+ #endif
629
+ float ele=0.0;float h=z;vec3 p;float c_ele;
630
+ #ifdef TERRAIN
631
+ bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);
632
+ #else
633
+ p=vec3(pos_nx.xy,z);
634
+ #endif
635
+ #ifdef PROJECTION_GLOBE_VIEW
636
+ float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
637
+ #endif
638
+ float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
639
+ ? pos_nx.xy
640
+ : vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
641
+ #ifdef LIGHTING_3D_MODE
642
+ NdotL=calculate_NdotL(normal);
643
+ #else
644
+ NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
645
+ #endif
646
+ if (normal.y !=0.0) {float r=0.84;
647
+ #ifndef LIGHTING_3D_MODE
648
+ r=mix(0.7,0.98,1.0-u_lightintensity);
649
+ #endif
650
+ NdotL*=(
651
+ (1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
652
+ #ifdef FAUX_AO
653
+ float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
654
+ #ifdef TERRAIN
655
+ top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
656
+ #endif
657
+ v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
658
+ #ifdef PROJECTION_GLOBE_VIEW
659
+ top_height+=u_height_lift;
660
+ #endif
661
+ gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
662
+ #endif
663
+ #ifdef LIGHTING_3D_MODE
664
+ v_NdotL=NdotL;
665
+ #else
666
+ v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
667
+ #endif
668
+ #ifdef FOG
669
+ v_fog_pos=fog_position(p);
670
+ #endif
671
+ }`),hillshadePrepare:Tt(`#ifdef GL_ES
672
+ precision highp float;
673
+ #endif
674
+ uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
675
+ #ifdef TERRAIN_DEM_FLOAT_FORMAT
676
+ return texture2D(u_image,coord).a/4.0;
677
+ #else
678
+ vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
679
+ #endif
680
+ }void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
681
+ (c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
682
+ )/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
683
+ deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
684
+ #ifdef OVERDRAW_INSPECTOR
685
+ gl_FragColor=vec4(1.0);
686
+ #endif
687
+ }`,"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:Tt(`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;void 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;
688
+ #ifdef LIGHTING_3D_MODE
689
+ gl_FragColor=apply_lighting(gl_FragColor);
690
+ #endif
691
+ #ifdef FOG
692
+ gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
693
+ #endif
694
+ #ifdef OVERDRAW_INSPECTOR
695
+ gl_FragColor=vec4(1.0);
696
+ #endif
697
+ }`,`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;
698
+ #ifdef FOG
699
+ v_fog_pos=fog_position(a_pos);
700
+ #endif
701
+ }`),line:Tt(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;
702
+ #ifdef RENDER_LINE_DASH
703
+ uniform sampler2D u_dash_image;varying vec2 v_tex;
704
+ #endif
705
+ #ifdef RENDER_LINE_GRADIENT
706
+ uniform sampler2D u_gradient_image;
707
+ #endif
708
+ uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
709
+ #pragma mapbox: define highp vec4 color
710
+ #pragma mapbox: define lowp float floorwidth
711
+ #pragma mapbox: define lowp vec4 dash
712
+ #pragma mapbox: define lowp float blur
713
+ #pragma mapbox: define lowp float opacity
714
+ float linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
715
+ #pragma mapbox: initialize highp vec4 color
716
+ #pragma mapbox: initialize lowp float floorwidth
717
+ #pragma mapbox: initialize lowp vec4 dash
718
+ #pragma mapbox: initialize lowp float blur
719
+ #pragma mapbox: initialize lowp float opacity
720
+ 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);
721
+ #ifdef RENDER_LINE_DASH
722
+ float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
723
+ #endif
724
+ highp vec4 out_color;
725
+ #ifdef RENDER_LINE_GRADIENT
726
+ out_color=texture2D(u_gradient_image,v_uv.xy);
727
+ #else
728
+ out_color=color;
729
+ #endif
730
+ float trimmed=1.0;
731
+ #ifdef RENDER_LINE_TRIM_OFFSET
732
+ highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}
733
+ #endif
734
+ #ifdef LIGHTING_3D_MODE
735
+ out_color=apply_lighting(out_color);
736
+ #endif
737
+ #ifdef FOG
738
+ out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
739
+ #endif
740
+ #ifdef RENDER_LINE_ALPHA_DISCARD
741
+ if (alpha < u_alpha_discard_threshold) {discard;}
742
+ #endif
743
+ #ifdef RENDER_LINE_BORDER
744
+ float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);
745
+ #ifdef RENDER_LINE_BORDER_AUTO
746
+ float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}
747
+ #else
748
+ out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);
749
+ #endif
750
+ }
751
+ #endif
752
+ gl_FragColor=out_color*(alpha*opacity);
753
+ #ifdef OVERDRAW_INSPECTOR
754
+ gl_FragColor=vec4(1.0);
755
+ #endif
756
+ }`,`
757
+ #define EXTRUDE_SCALE 0.015873016
758
+ attribute vec2 a_pos_normal;attribute vec4 a_data;
759
+ #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
760
+ attribute highp vec4 a_packed;
761
+ #endif
762
+ #ifdef RENDER_LINE_DASH
763
+ attribute float a_linesofar;
764
+ #endif
765
+ uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;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 vec4 v_uv;
766
+ #ifdef RENDER_LINE_DASH
767
+ uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;
768
+ #endif
769
+ #ifdef RENDER_LINE_GRADIENT
770
+ uniform float u_image_height;
771
+ #endif
772
+ #pragma mapbox: define highp vec4 color
773
+ #pragma mapbox: define lowp float floorwidth
774
+ #pragma mapbox: define lowp vec4 dash
775
+ #pragma mapbox: define lowp float blur
776
+ #pragma mapbox: define lowp float opacity
777
+ #pragma mapbox: define mediump float gapwidth
778
+ #pragma mapbox: define lowp float offset
779
+ #pragma mapbox: define mediump float width
780
+ void main() {
781
+ #pragma mapbox: initialize highp vec4 color
782
+ #pragma mapbox: initialize lowp float floorwidth
783
+ #pragma mapbox: initialize lowp vec4 dash
784
+ #pragma mapbox: initialize lowp float blur
785
+ #pragma mapbox: initialize lowp float opacity
786
+ #pragma mapbox: initialize mediump float gapwidth
787
+ #pragma mapbox: initialize lowp float offset
788
+ #pragma mapbox: initialize mediump float width
789
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
790
+ #ifndef RENDER_TO_TEXTURE
791
+ float 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;
792
+ #else
793
+ v_gamma_scale=1.0;
794
+ #endif
795
+ #if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
796
+ float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];
797
+ #ifdef RENDER_LINE_GRADIENT
798
+ highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);
799
+ #else
800
+ v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);
801
+ #endif
802
+ #endif
803
+ #ifdef RENDER_LINE_DASH
804
+ float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);
805
+ #endif
806
+ v_width2=vec2(outset,inset);
807
+ #ifdef FOG
808
+ v_fog_pos=fog_position(pos);
809
+ #endif
810
+ }`),linePattern:Tt(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;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;
811
+ #pragma mapbox: define lowp vec4 pattern
812
+ #pragma mapbox: define lowp float pixel_ratio
813
+ #pragma mapbox: define lowp float blur
814
+ #pragma mapbox: define lowp float opacity
815
+ void main() {
816
+ #pragma mapbox: initialize mediump vec4 pattern
817
+ #pragma mapbox: initialize lowp float pixel_ratio
818
+ #pragma mapbox: initialize lowp float blur
819
+ #pragma mapbox: initialize lowp float opacity
820
+ vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);
821
+ #ifdef LIGHTING_3D_MODE
822
+ color=apply_lighting(color);
823
+ #endif
824
+ #ifdef FOG
825
+ color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
826
+ #endif
827
+ gl_FragColor=color*(alpha*opacity);
828
+ #ifdef OVERDRAW_INSPECTOR
829
+ gl_FragColor=vec4(1.0);
830
+ #endif
831
+ }`,`
832
+ #define scale 0.015873016
833
+ attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
834
+ #pragma mapbox: define lowp float blur
835
+ #pragma mapbox: define lowp float opacity
836
+ #pragma mapbox: define lowp float offset
837
+ #pragma mapbox: define mediump float gapwidth
838
+ #pragma mapbox: define mediump float width
839
+ #pragma mapbox: define lowp float floorwidth
840
+ #pragma mapbox: define lowp vec4 pattern
841
+ #pragma mapbox: define lowp float pixel_ratio
842
+ void main() {
843
+ #pragma mapbox: initialize lowp float blur
844
+ #pragma mapbox: initialize lowp float opacity
845
+ #pragma mapbox: initialize lowp float offset
846
+ #pragma mapbox: initialize mediump float gapwidth
847
+ #pragma mapbox: initialize mediump float width
848
+ #pragma mapbox: initialize lowp float floorwidth
849
+ #pragma mapbox: initialize mediump vec4 pattern
850
+ #pragma mapbox: initialize lowp float pixel_ratio
851
+ float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
852
+ #ifndef RENDER_TO_TEXTURE
853
+ float 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;
854
+ #else
855
+ v_gamma_scale=1.0;
856
+ #endif
857
+ v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
858
+ #ifdef FOG
859
+ v_fog_pos=fog_position(pos);
860
+ #endif
861
+ }`),raster:Tt(`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(
862
+ 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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
863
+ #ifdef LIGHTING_3D_MODE
864
+ out_color=apply_lighting(out_color);
865
+ #endif
866
+ #ifdef FOG
867
+ out_color=fog_dither(fog_apply(out_color,v_fog_pos));
868
+ #endif
869
+ gl_FragColor=vec4(out_color*color.a,color.a);
870
+ #ifdef OVERDRAW_INSPECTOR
871
+ gl_FragColor=vec4(1.0);
872
+ #endif
873
+ }`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
874
+ #ifdef FOG
875
+ v_fog_pos=fog_position(a_pos);
876
+ #endif
877
+ }`),symbolIcon:Tt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
878
+ #pragma mapbox: define lowp float opacity
879
+ void main() {
880
+ #pragma mapbox: initialize lowp float opacity
881
+ lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
882
+ #ifdef OVERDRAW_INSPECTOR
883
+ gl_FragColor=vec4(1.0);
884
+ #endif
885
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
886
+ #ifdef PROJECTION_GLOBE_VIEW
887
+ attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
888
+ #endif
889
+ 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 bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;
890
+ #ifdef PROJECTION_GLOBE_VIEW
891
+ uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
892
+ #endif
893
+ varying vec2 v_tex;varying float v_fade_opacity;
894
+ #pragma mapbox: define lowp float opacity
895
+ void main() {
896
+ #pragma mapbox: initialize lowp float opacity
897
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
898
+ #ifdef PROJECTION_GLOBE_VIEW
899
+ mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
900
+ #else
901
+ world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
902
+ #endif
903
+ vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
904
+ camera_to_anchor_distance/u_camera_to_center_distance :
905
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
906
+ 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;
907
+ #ifdef PROJECTION_GLOBE_VIEW
908
+ vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
909
+ #else
910
+ offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
911
+ #endif
912
+ vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
913
+ #ifdef PROJECTION_GLOBE_VIEW
914
+ vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
915
+ #else
916
+ projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
917
+ #endif
918
+ 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
919
+ #ifdef TERRAIN
920
+ #ifdef PITCH_WITH_MAP_TERRAIN
921
+ vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
922
+ #endif
923
+ #endif
924
+ float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
925
+ #ifdef PROJECTION_GLOBE_VIEW
926
+ vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
927
+ #else
928
+ gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
929
+ #endif
930
+ float projection_transition_fade=1.0;
931
+ #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
932
+ projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
933
+ #endif
934
+ 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;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Tt(`#define SDF_PX 8.0
935
+ uniform 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;
936
+ #pragma mapbox: define highp vec4 fill_color
937
+ #pragma mapbox: define highp vec4 halo_color
938
+ #pragma mapbox: define lowp float opacity
939
+ #pragma mapbox: define lowp float halo_width
940
+ #pragma mapbox: define lowp float halo_blur
941
+ void main() {
942
+ #pragma mapbox: initialize highp vec4 fill_color
943
+ #pragma mapbox: initialize highp vec4 halo_color
944
+ #pragma mapbox: initialize lowp float opacity
945
+ #pragma mapbox: initialize lowp float halo_width
946
+ #pragma mapbox: initialize lowp float halo_blur
947
+ float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;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);
948
+ #ifdef OVERDRAW_INSPECTOR
949
+ gl_FragColor=vec4(1.0);
950
+ #endif
951
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
952
+ #ifdef PROJECTION_GLOBE_VIEW
953
+ attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
954
+ #endif
955
+ 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_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;
956
+ #ifdef PROJECTION_GLOBE_VIEW
957
+ uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
958
+ #endif
959
+ varying vec2 v_data0;varying vec3 v_data1;
960
+ #pragma mapbox: define highp vec4 fill_color
961
+ #pragma mapbox: define highp vec4 halo_color
962
+ #pragma mapbox: define lowp float opacity
963
+ #pragma mapbox: define lowp float halo_width
964
+ #pragma mapbox: define lowp float halo_blur
965
+ void main() {
966
+ #pragma mapbox: initialize highp vec4 fill_color
967
+ #pragma mapbox: initialize highp vec4 halo_color
968
+ #pragma mapbox: initialize lowp float opacity
969
+ #pragma mapbox: initialize lowp float halo_width
970
+ #pragma mapbox: initialize lowp float halo_blur
971
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
972
+ #ifdef PROJECTION_GLOBE_VIEW
973
+ mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
974
+ #else
975
+ world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
976
+ #endif
977
+ vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
978
+ camera_to_anchor_distance/u_camera_to_center_distance :
979
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
980
+ 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;
981
+ #ifdef PROJECTION_GLOBE_VIEW
982
+ vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
983
+ #else
984
+ offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
985
+ #endif
986
+ vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
987
+ #ifdef PROJECTION_GLOBE_VIEW
988
+ vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
989
+ #else
990
+ projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
991
+ #endif
992
+ 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
993
+ #ifdef TERRAIN
994
+ #ifdef PITCH_WITH_MAP_TERRAIN
995
+ vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
996
+ #endif
997
+ #endif
998
+ float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
999
+ #ifdef PROJECTION_GLOBE_VIEW
1000
+ vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
1001
+ #else
1002
+ gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
1003
+ #endif
1004
+ float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
1005
+ #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
1006
+ projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
1007
+ #endif
1008
+ vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Tt(`#define SDF_PX 8.0
1009
+ #define SDF 1.0
1010
+ #define ICON 0.0
1011
+ uniform 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;
1012
+ #pragma mapbox: define highp vec4 fill_color
1013
+ #pragma mapbox: define highp vec4 halo_color
1014
+ #pragma mapbox: define lowp float opacity
1015
+ #pragma mapbox: define lowp float halo_width
1016
+ #pragma mapbox: define lowp float halo_blur
1017
+ void main() {
1018
+ #pragma mapbox: initialize highp vec4 fill_color
1019
+ #pragma mapbox: initialize highp vec4 halo_color
1020
+ #pragma mapbox: initialize lowp float opacity
1021
+ #pragma mapbox: initialize lowp float halo_width
1022
+ #pragma mapbox: initialize lowp float halo_blur
1023
+ float 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;
1024
+ #ifdef OVERDRAW_INSPECTOR
1025
+ gl_FragColor=vec4(1.0);
1026
+ #endif
1027
+ return;}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);
1028
+ #ifdef OVERDRAW_INSPECTOR
1029
+ gl_FragColor=vec4(1.0);
1030
+ #endif
1031
+ }`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
1032
+ #ifdef PROJECTION_GLOBE_VIEW
1033
+ attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
1034
+ #endif
1035
+ 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_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;
1036
+ #ifdef PROJECTION_GLOBE_VIEW
1037
+ uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
1038
+ #endif
1039
+ varying vec4 v_data0;varying vec4 v_data1;
1040
+ #pragma mapbox: define highp vec4 fill_color
1041
+ #pragma mapbox: define highp vec4 halo_color
1042
+ #pragma mapbox: define lowp float opacity
1043
+ #pragma mapbox: define lowp float halo_width
1044
+ #pragma mapbox: define lowp float halo_blur
1045
+ void main() {
1046
+ #pragma mapbox: initialize highp vec4 fill_color
1047
+ #pragma mapbox: initialize highp vec4 halo_color
1048
+ #pragma mapbox: initialize lowp float opacity
1049
+ #pragma mapbox: initialize lowp float halo_width
1050
+ #pragma mapbox: initialize lowp float halo_blur
1051
+ vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
1052
+ #ifdef PROJECTION_GLOBE_VIEW
1053
+ mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
1054
+ #else
1055
+ world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
1056
+ #endif
1057
+ vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
1058
+ camera_to_anchor_distance/u_camera_to_center_distance :
1059
+ u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
1060
+ 0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
1061
+ #ifdef PROJECTION_GLOBE_VIEW
1062
+ vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
1063
+ #else
1064
+ projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
1065
+ #endif
1066
+ 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
1067
+ #ifdef TERRAIN
1068
+ #ifdef PITCH_WITH_MAP_TERRAIN
1069
+ vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
1070
+ #endif
1071
+ #endif
1072
+ float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
1073
+ #ifdef PROJECTION_GLOBE_VIEW
1074
+ vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
1075
+ #else
1076
+ gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
1077
+ #endif
1078
+ float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
1079
+ #if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
1080
+ projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
1081
+ #endif
1082
+ v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Tt(`uniform sampler2D u_image0;varying vec2 v_pos0;
1083
+ #ifdef FOG
1084
+ varying float v_fog_opacity;
1085
+ #endif
1086
+ #ifdef RENDER_SHADOWS
1087
+ varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
1088
+ #endif
1089
+ void main() {vec4 color=texture2D(u_image0,v_pos0);
1090
+ #ifdef RENDER_SHADOWS
1091
+ color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);
1092
+ #endif
1093
+ #ifdef FOG
1094
+ #ifdef ZERO_EXAGGERATION
1095
+ color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
1096
+ #else
1097
+ color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
1098
+ #endif
1099
+ #endif
1100
+ gl_FragColor=color;
1101
+ #ifdef TERRAIN_WIREFRAME
1102
+ gl_FragColor=vec4(1.0,0.0,0.0,0.8);
1103
+ #endif
1104
+ #ifdef OVERDRAW_INSPECTOR
1105
+ gl_FragColor=vec4(1.0);
1106
+ #endif
1107
+ }`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;
1108
+ #ifdef FOG
1109
+ varying float v_fog_opacity;
1110
+ #endif
1111
+ #ifdef RENDER_SHADOWS
1112
+ uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
1113
+ #endif
1114
+ const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;
1115
+ #ifdef TERRAIN_WIREFRAME
1116
+ elevation+=wireframeOffset;
1117
+ #endif
1118
+ v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
1119
+ #ifdef FOG
1120
+ #ifdef ZERO_EXAGGERATION
1121
+ v_fog_pos=fog_position(decodedPos);
1122
+ #else
1123
+ v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
1124
+ #endif
1125
+ #endif
1126
+ #ifdef RENDER_SHADOWS
1127
+ vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;
1128
+ #endif
1129
+ }`),terrainDepth:Tt(`#ifdef GL_ES
1130
+ precision highp float;
1131
+ #endif
1132
+ varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Tt(`
1133
+ varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
1134
+ cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
1135
+ #ifdef FOG
1136
+ sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
1137
+ #endif
1138
+ sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
1139
+ #ifdef OVERDRAW_INSPECTOR
1140
+ gl_FragColor=vec4(1.0);
1141
+ #endif
1142
+ }`,Tn),skyboxGradient:Tt(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
1143
+ #ifdef FOG
1144
+ color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
1145
+ #endif
1146
+ color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
1147
+ #ifdef OVERDRAW_INSPECTOR
1148
+ gl_FragColor=vec4(1.0);
1149
+ #endif
1150
+ }`,Tn),skyboxCapture:Tt(`
1151
+ varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
1152
+ #ifdef GL_ES
1153
+ precision highp float;
1154
+ #endif
1155
+ #define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)
1156
+ #define BETA_M vec3(21e-6,21e-6,21e-6)
1157
+ #define MIE_G 0.76
1158
+ #define DENSITY_HEIGHT_SCALE_R 8000.0
1159
+ #define DENSITY_HEIGHT_SCALE_M 1200.0
1160
+ #define PLANET_RADIUS 6360e3
1161
+ #define ATMOSPHERE_RADIUS 6420e3
1162
+ #define SAMPLE_STEPS 10
1163
+ #define DENSITY_STEPS 4
1164
+ float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Tt(`uniform sampler2D u_image0;varying vec2 v_pos0;
1165
+ #ifndef FOG
1166
+ uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
1167
+ #endif
1168
+ void main() {vec4 color;
1169
+ #ifdef CUSTOM_ANTIALIASING
1170
+ vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
1171
+ mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);
1172
+ #else
1173
+ color=texture2D(u_image0,v_pos0);
1174
+ #endif
1175
+ #ifdef FOG
1176
+ color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
1177
+ #endif
1178
+ gl_FragColor=color;
1179
+ #ifdef TERRAIN_WIREFRAME
1180
+ gl_FragColor=vec4(1.0,0.0,0.0,0.8);
1181
+ #endif
1182
+ #ifdef OVERDRAW_INSPECTOR
1183
+ gl_FragColor=vec4(1.0);
1184
+ #endif
1185
+ }`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
1186
+ #ifdef GLOBE_POLES
1187
+ attribute vec3 a_globe_pos;attribute vec2 a_uv;
1188
+ #else
1189
+ attribute vec2 a_pos;
1190
+ #endif
1191
+ varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
1192
+ #ifdef GLOBE_POLES
1193
+ vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
1194
+ #else
1195
+ float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
1196
+ #endif
1197
+ v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
1198
+ #ifdef GLOBE_POLES
1199
+ vec3 up_vector=globe_derived_up_vector;
1200
+ #else
1201
+ vec3 up_vector=elevationVector(tile_pos);
1202
+ #endif
1203
+ float height=elevation(tile_pos);
1204
+ #ifdef TERRAIN_WIREFRAME
1205
+ height+=wireframeOffset;
1206
+ #endif
1207
+ globe_pos+=up_vector*height;
1208
+ #ifndef GLOBE_POLES
1209
+ globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
1210
+ #endif
1211
+ #ifdef GLOBE_POLES
1212
+ vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
1213
+ #else
1214
+ vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
1215
+ #endif
1216
+ gl_Position=u_proj_matrix*interpolated_pos;
1217
+ #ifdef FOG
1218
+ v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
1219
+ #endif
1220
+ }`),globeAtmosphere:Tt(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
1221
+ #ifdef PROJECTION_GLOBE_VIEW
1222
+ globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}
1223
+ #endif
1224
+ highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
1225
+ 0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;
1226
+ #ifdef PROJECTION_GLOBE_VIEW
1227
+ highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
1228
+ PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
1229
+ #else
1230
+ horizon_angle=horizon_angle_mercator;
1231
+ #endif
1232
+ horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:
1233
+ (n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:
1234
+ uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
1235
+ mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
1236
+ mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function eo(l,r){const o=l.replace(/\s*\/\/[^\n]*\n/g,`
1237
+ `).split(`
1238
+ `);for(let h of o)if(h=h.trim(),h[0]==="#"&&h.includes("if")&&!h.includes("endif")){h=h.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const d=h.split(" ");for(const f of d)r.includes(f)||r.push(f)}}function Tt(l,r){const o=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,h=r.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),d={},f=[...Go];return eo(l,f),eo(r,f),{fragmentSource:l=l.replace(o,(g,y,v,E,T)=>(d[T]=!0,y==="define"?`
1239
+ #ifndef HAS_UNIFORM_u_${T}
1240
+ varying ${v} ${E} ${T};
1241
+ #else
1242
+ uniform ${v} ${E} u_${T};
1243
+ #endif
1244
+ `:`
1245
+ #ifdef HAS_UNIFORM_u_${T}
1246
+ ${v} ${E} ${T} = u_${T};
1247
+ #endif
1248
+ `)),vertexSource:r=r.replace(o,(g,y,v,E,T)=>{const A=E==="float"?"vec2":"vec4",k=T.match(/color/)?"color":A;return d[T]?y==="define"?`
1249
+ #ifndef HAS_UNIFORM_u_${T}
1250
+ uniform lowp float u_${T}_t;
1251
+ attribute ${v} ${A} a_${T};
1252
+ varying ${v} ${E} ${T};
1253
+ #else
1254
+ uniform ${v} ${E} u_${T};
1255
+ #endif
1256
+ `:k==="vec4"?`
1257
+ #ifndef HAS_UNIFORM_u_${T}
1258
+ ${T} = a_${T};
1259
+ #else
1260
+ ${v} ${E} ${T} = u_${T};
1261
+ #endif
1262
+ `:`
1263
+ #ifndef HAS_UNIFORM_u_${T}
1264
+ ${T} = unpack_mix_${k}(a_${T}, u_${T}_t);
1265
+ #else
1266
+ ${v} ${E} ${T} = u_${T};
1267
+ #endif
1268
+ `:y==="define"?`
1269
+ #ifndef HAS_UNIFORM_u_${T}
1270
+ uniform lowp float u_${T}_t;
1271
+ attribute ${v} ${A} a_${T};
1272
+ #else
1273
+ uniform ${v} ${E} u_${T};
1274
+ #endif
1275
+ `:k==="vec4"?`
1276
+ #ifndef HAS_UNIFORM_u_${T}
1277
+ ${v} ${E} ${T} = a_${T};
1278
+ #else
1279
+ ${v} ${E} ${T} = u_${T};
1280
+ #endif
1281
+ `:`
1282
+ #ifndef HAS_UNIFORM_u_${T}
1283
+ ${v} ${E} ${T} = unpack_mix_${k}(a_${T}, u_${T}_t);
1284
+ #else
1285
+ ${v} ${E} ${T} = u_${T};
1286
+ #endif
1287
+ `}),staticAttributes:h,usedDefines:f}}class Lh{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(r,o,h,d,f,g,y){this.context=r;let v=this.boundPaintVertexBuffers.length!==d.length;for(let T=0;!v&&T<d.length;T++)this.boundPaintVertexBuffers[T]!==d[T]&&(v=!0);let E=this.boundDynamicVertexBuffers.length!==y.length;for(let T=0;!E&&T<y.length;T++)this.boundDynamicVertexBuffers[T]!==y[T]&&(E=!0);if(!r.extVertexArrayObject||!this.vao||this.boundProgram!==o||this.boundLayoutVertexBuffer!==h||v||E||this.boundIndexBuffer!==f||this.boundVertexOffset!==g)this.freshBind(o,h,d,f,g,y);else{r.bindVertexArrayOES.set(this.vao);for(const T of y)T&&T.bind();f&&f.dynamicDraw&&f.bind()}}freshBind(r,o,h,d,f,g){let y;const v=r.numAttributes,E=this.context,T=E.gl;if(E.extVertexArrayObject)this.vao&&this.destroy(),this.vao=E.extVertexArrayObject.createVertexArrayOES(),E.bindVertexArrayOES.set(this.vao),y=0,this.boundProgram=r,this.boundLayoutVertexBuffer=o,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=d,this.boundVertexOffset=f,this.boundDynamicVertexBuffers=g;else{y=E.currentNumAttributes||0;for(let A=v;A<y;A++)T.disableVertexAttribArray(A)}o.enableAttributes(T,r),o.bind(),o.setVertexAttribPointers(T,r,f);for(const A of h)A.enableAttributes(T,r),A.bind(),A.setVertexAttribPointers(T,r,f);for(const A of g)A&&(A.enableAttributes(T,r),A.bind(),A.setVertexAttribPointers(T,r,f));d&&d.bind(),E.currentNumAttributes=v}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function Ga(l,r){const o=Math.pow(2,r.canonical.z),h=r.canonical.y;return[new a.MercatorCoordinate(0,h/o).toLngLat().lat,new a.MercatorCoordinate(0,(h+1)/o).toLngLat().lat]}function dc(l,r,o,h,d,f,g){const y=l.context,v=y.gl,E=o.fbo;if(!E)return;l.prepareDrawTile();const T=l.useProgram("hillshade");y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,E.colorAttachment.get());const A=((B,F,I,L)=>{const N=I.paint.get("hillshade-shadow-color"),j=I.paint.get("hillshade-highlight-color"),K=I.paint.get("hillshade-accent-color");let J=I.paint.get("hillshade-illumination-direction")*(Math.PI/180);I.paint.get("hillshade-illumination-anchor")==="viewport"&&(J-=B.transform.angle);const Y=!B.options.moving;return{u_matrix:L||B.transform.calculateProjMatrix(F.tileID.toUnwrapped(),Y),u_image:0,u_latrange:Ga(0,F.tileID),u_light:[I.paint.get("hillshade-exaggeration"),J],u_shadow:N,u_highlight:j,u_accent:K}})(l,o,h,l.terrain?r.projMatrix:null);l.prepareDrawProgram(y,T,r.toUnwrapped());const{tileBoundsBuffer:k,tileBoundsIndexBuffer:R,tileBoundsSegments:O}=l.getTileBoundsBuffers(o);T.draw(y,v.TRIANGLES,d,f,g,a.CullFaceMode.disabled,A,h.id,k,R,O)}function $a(l,r,o){if(!r.needsDEMTextureUpload)return;const h=l.context,d=h.gl;h.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||l.getTileTexture(o.stride);const f=o.getPixels();r.demTexture?r.demTexture.update(f,{premultiply:!1}):r.demTexture=new a.Texture(h,f,d.RGBA,{premultiply:!1}),r.needsDEMTextureUpload=!1}function pc(l,r,o,h,d,f){const g=l.context,y=g.gl;if(!r.dem)return;const v=r.dem;if(g.activeTexture.set(y.TEXTURE1),$a(l,r,v),!r.demTexture)return;r.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);const E=v.dim;g.activeTexture.set(y.TEXTURE0);let T=r.fbo;if(!T){const O=new a.Texture(g,{width:E,height:E,data:null},y.RGBA);O.bind(y.LINEAR,y.CLAMP_TO_EDGE),T=r.fbo=g.createFramebuffer(E,E,!0),T.colorAttachment.set(O.texture)}g.bindFramebuffer.set(T.framebuffer),g.viewport.set([0,0,E,E]);const{tileBoundsBuffer:A,tileBoundsIndexBuffer:k,tileBoundsSegments:R}=l.getMercatorTileBoundsBuffers();l.useProgram("hillshadePrepare").draw(g,y.TRIANGLES,h,d,f,a.CullFaceMode.disabled,((O,B)=>{const F=B.stride,I=a.create();return a.ortho(I,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(I,I,[0,-a.EXTENT,0]),{u_matrix:I,u_image:1,u_dimension:[F,F],u_zoom:O.overscaledZ,u_unpack:B.unpackVector}})(r.tileID,v),o.id,A,k,R),r.needsHillshadePrepare=!1}const Za=l=>({u_matrix:new a.UniformMatrix4f(l),u_image0:new a.Uniform1i(l),u_skirt_height:new a.Uniform1f(l)}),to=(l,r)=>({u_matrix:l,u_image0:0,u_skirt_height:r}),Ds=(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O)=>({u_proj_matrix:Float32Array.from(l),u_globe_matrix:r,u_normalize_matrix:Float32Array.from(h),u_merc_matrix:o,u_zoom_transition:d,u_merc_center:f,u_image0:0,u_frustum_tl:g,u_frustum_tr:y,u_frustum_br:v,u_frustum_bl:E,u_globe_pos:T,u_globe_radius:A,u_viewport:k,u_grid_matrix:O?Float32Array.from(O):new Float32Array(9),u_skirt_height:R});function io(l,r){return l!=null&&r!=null&&!(!l.hasData()||!r.hasData())&&l.demTexture!=null&&r.demTexture!=null&&l.tileID.key!==r.tileID.key}const Br=new class{constructor(){this.operations={}}newMorphing(l,r,o,h,d){if(l in this.operations){const f=this.operations[l];f.to.tileID.key!==o.tileID.key&&(f.queued=o)}else this.operations[l]={startTime:h,phase:0,duration:d,from:r,to:o,queued:null}}getMorphValuesForProxy(l){if(!(l in this.operations))return null;const r=this.operations[l];return{from:r.from,to:r.to,phase:r.phase}}update(l){for(const r in this.operations){const o=this.operations[r];for(o.phase=(l-o.startTime)/o.duration;o.phase>=1||!this._validOp(o);)if(!this._nextOp(o,l)){delete this.operations[r];break}}}_nextOp(l,r){return!!l.queued&&(l.from=l.to,l.to=l.queued,l.queued=null,l.phase=0,l.startTime=r,!0)}_validOp(l){return l.from.hasData()&&l.to.hasData()}},En={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Ls(l){return 6*Math.pow(1.5,22-l)}function fc(l,r){const o=1<<l.z;return!r&&(l.x===0||l.x===o-1)||l.y===0||l.y===o-1}const $o=l=>({u_matrix:l});function qa(l,r,o,h,d){if(d>0){const f=a.exported.now(),g=(f-l.timeAdded)/d,y=r?(f-r.timeAdded)/d:-1,v=o.getSource(),E=h.coveringZoomLevel({tileSize:v.tileSize,roundZoom:v.roundZoom}),T=!r||Math.abs(r.tileID.overscaledZ-E)>Math.abs(l.tileID.overscaledZ-E),A=T&&l.refreshedUponExpiration?1:a.clamp(T?g:1-y,0,1);return l.refreshedUponExpiration&&g>=1&&(l.refreshedUponExpiration=!1),r?{opacity:1,mix:1-A}:{opacity:A,mix:0}}return{opacity:1,mix:0}}class Wa extends a.SourceCache{constructor(r){const o={type:"raster-dem",maxzoom:r.transform.maxZoom},h=new di(Hn(),null),d=st("mock-dem",o,h,r.style);super("mock-dem",d,!1),d.setEventedParent(this),this._sourceLoaded=!0}_loadTile(r,o){r.state="loaded",o(null)}}class Rs extends a.SourceCache{constructor(r){const o=st("proxy",{type:"geojson",maxzoom:r.transform.maxZoom},new di(Hn(),null),r.style);super("proxy",o,!1),o.setEventedParent(this),this.map=this.getSource().map=r,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(r,o,h){if(r.freezeTileCoverage)return;this.transform=r;const d=r.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((f,g)=>{if(f[g.key]="",!this._tiles[g.key]){const y=new a.Tile(g,this._source.tileSize*g.overscaleFactor(),r.tileZoom);y.state="loaded",this._tiles[g.key]=y}return f},{});for(const f in this._tiles)f in d||(this.freeFBO(f),this._tiles[f].unloadVectorData(),delete this._tiles[f])}freeFBO(r){const o=this.proxyCachedFBO[r];if(o!==void 0){const h=Object.values(o);this.renderCachePool.push(...h),delete this.proxyCachedFBO[r]}}deallocRenderCache(){this.renderCache.forEach(r=>r.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Bs extends a.OverscaledTileID{constructor(r,o,h){super(r.overscaledZ,r.wrap,r.canonical.z,r.canonical.x,r.canonical.y),this.proxyTileKey=o,this.projMatrix=h}}class Xa extends a.Elevation{constructor(r,o){super(),this.painter=r,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[h,d,f]=function(v){const E=new a.StructArrayLayout2i4,T=new a.StructArrayLayout3ui6,A=131;E.reserve(17161),T.reserve(33800);const k=a.EXTENT/128,R=a.EXTENT+k/2,O=R+k;for(let F=-k;F<O;F+=k)for(let I=-k;I<O;I+=k){const L=I<0||I>R||F<0||F>R?24575:0,N=a.clamp(Math.round(I),0,a.EXTENT),j=a.clamp(Math.round(F),0,a.EXTENT);E.emplaceBack(N+L,j)}const B=(F,I)=>{const L=I*A+F;T.emplaceBack(L+1,L,L+A),T.emplaceBack(L+A,L+A+1,L+1)};for(let F=1;F<129;F++)for(let I=1;I<129;I++)B(I,F);return[0,129].forEach(F=>{for(let I=0;I<130;I++)B(I,F),B(F,I)}),[E,T,32768]}(),g=r.context;this.gridBuffer=g.createVertexBuffer(h,a.posAttributes.members),this.gridIndexBuffer=g.createIndexBuffer(d),this.gridSegments=a.SegmentVector.simpleSegment(0,0,h.length,d.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,h.length,f),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Rs(o.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,a.EXTENT,0,a.EXTENT,0,1);const y=g.gl;this._overlapStencilMode=new a.StencilMode({func:y.GEQUAL,mask:255},0,255,y.KEEP,y.KEEP,y.REPLACE),this._previousZoom=r.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=o,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Wa(o.map)}set style(r){r.on("data",this._onStyleDataEvent.bind(this)),r.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=r,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(r,o,h){if(r&&r.terrain){this._style!==r&&(this.style=r),this.enabled=!0;const d=r.terrain.properties;this.sourceCache=r.terrain.drapeRenderMode===0?this._mockSourceCache:r._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");const f=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
1288
+ This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const g=this.getScaledDemTileSize();this.sourceCache.update(o,g,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,f(),this._initializing=!0),f(),o.updateElevation(!0,h),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(o),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(r){this._findCoveringTileCache[r]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const r=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||r.efficiency!==100&&a.warnOnce(`Terrain render cache efficiency is not optimal (${r.efficiency}%) and performance
1289
+ may be affected negatively, consider placing all background, fill and line layers before layer
1290
+ with id '${r.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(r){r.coord&&r.dataType==="source"?this._clearRenderCacheForTile(r.sourceCacheId,r.coord):r.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const r in this._style._sourceCaches)this._style._sourceCaches[r].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(r=>r.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const r=2*this.proxySourceCache.getSource().tileSize;return[r,r]}set useVertexMorphing(r){this._useVertexMorphing=r}updateTileBinding(r){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const o=this.proxySourceCache,h=this.painter.transform;this._initializing&&(this._initializing=h._centerAltitude===0&&this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(h.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const d=this.proxyCoords=o.getIds().map(v=>{const E=o.getTileByID(v).tileID;return E.projMatrix=h.calculateProjMatrix(E.toUnwrapped()),E});(function(v,E){const T=E.transform.pointCoordinate(E.transform.getCameraPoint()),A=new a.Point(T.x,T.y);v.sort((k,R)=>{if(R.overscaledZ-k.overscaledZ)return R.overscaledZ-k.overscaledZ;const O=new a.Point(k.canonical.x+(1<<k.canonical.z)*k.wrap,k.canonical.y),B=new a.Point(R.canonical.x+(1<<R.canonical.z)*R.wrap,R.canonical.y),F=A.mult(1<<k.canonical.z);return F.x-=.5,F.y-=.5,F.distSqr(O)-F.distSqr(B)})})(d,this.painter),this._previousZoom=h.zoom;const f=this.proxyToSource||{};this.proxyToSource={},d.forEach(v=>{this.proxyToSource[v.key]={}}),this.terrainTileForTile={};const g=this._style._sourceCaches;for(const v in g){const E=g[v];if(!E.used||(E!==this.sourceCache&&this.resetTileLookupCache(E.id),this._setupProxiedCoordsForOrtho(E,r[v],f),E.usedForTerrain))continue;const T=r[v];E.getSource().reparseOverscaled&&this._assignTerrainTiles(T)}this.proxiedCoords[o.id]=d.map(v=>new Bs(v,v.key,this.orthoMatrix)),this._assignTerrainTiles(d),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(f),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const y={};this._visibleDemTiles=[];for(const v of this.proxyCoords){const E=this.terrainTileForTile[v.key];if(!E)continue;const T=E.tileID.key;T in y||(this._visibleDemTiles.push(E),y[T]=T)}}_assignTerrainTiles(r){this._initializing||r.forEach(o=>{if(this.terrainTileForTile[o.key])return;const h=this._findTileCoveringTileID(o,this.sourceCache);h&&(this.terrainTileForTile[o.key]=h)})}_prepareDEMTextures(){const r=this.painter.context,o=r.gl;for(const h in this.terrainTileForTile){const d=this.terrainTileForTile[h],f=d.dem;!f||d.demTexture&&!d.needsDEMTextureUpload||(r.activeTexture.set(o.TEXTURE1),$a(this.painter,d,f))}}_prepareDemTileUniforms(r,o,h,d){if(!o||o.demTexture==null)return!1;const f=r.tileID.canonical,g=Math.pow(2,o.tileID.canonical.z-f.z),y=d||"";return h[`u_dem_tl${y}`]=[f.x*g%1,f.y*g%1],h[`u_dem_scale${y}`]=g,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const r=this.painter.context,o=r.gl;if(!this._emptyDepthBufferTexture){const h=new a.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new a.Texture(r,h,o.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let r=0;const o=this._visibleDemTiles.reduce((h,d)=>{if(!d.dem)return h;const f=d.dem.tree.minimums[0];return f>0&&r++,h+f},0);return r?o/r:0}_updateEmptyDEMTexture(){const r=this.painter.context,o=r.gl;r.activeTexture.set(o.TEXTURE2);const h=this._getLoadedAreaMinimum(),d=new a.RGBAImage({width:1,height:1},new Uint8Array(a.DEMData.pack(h,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let f=this._emptyDEMTexture;return f?f.update(d,{premultiply:!1}):f=this._emptyDEMTexture=new a.Texture(r,d,o.RGBA,{premultiply:!1}),f}setupElevationDraw(r,o,h){const d=this.painter.context,f=d.gl,g=(y=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(y),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var y;g.u_dem_size=this.sourceCache.getSource().tileSize,g.u_exaggeration=this.exaggeration();let v=null,E=null,T=1;if(h&&h.morphing&&this._useVertexMorphing){const A=h.morphing.srcDemTile,k=h.morphing.dstDemTile;T=h.morphing.phase,A&&k&&(this._prepareDemTileUniforms(r,A,g,"_prev")&&(E=A),this._prepareDemTileUniforms(r,k,g)&&(v=k))}if(E&&v?(d.activeTexture.set(f.TEXTURE2),v.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),d.activeTexture.set(f.TEXTURE4),E.demTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE,f.NEAREST),g.u_dem_lerp=T):(v=this.terrainTileForTile[r.tileID.key],d.activeTexture.set(f.TEXTURE2),(this._prepareDemTileUniforms(r,v,g)?v.demTexture:this.emptyDEMTexture).bind(f.NEAREST,f.CLAMP_TO_EDGE)),d.activeTexture.set(f.TEXTURE3),h&&h.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),this._depthFBO&&(g.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.u_depth_size_inv=[1,1]),h&&h.useMeterToDem&&v){const A=(1<<v.tileID.canonical.z)*a.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;g.u_meter_to_dem=A}if(h&&h.labelPlaneMatrixInv&&(g.u_label_plane_matrix_inv=h.labelPlaneMatrixInv),o.setTerrainUniformValues(d,g),this.painter.transform.projection.name==="globe"){const A=this.globeUniformValues(this.painter.transform,r.tileID.canonical,h&&h.useDenormalizedUpVectorScale);o.setGlobeUniformValues(d,A)}}globeUniformValues(r,o,h){const d=r.projection;return{u_tile_tl_up:d.upVector(o,0,0),u_tile_tr_up:d.upVector(o,a.EXTENT,0),u_tile_br_up:d.upVector(o,a.EXTENT,a.EXTENT),u_tile_bl_up:d.upVector(o,0,a.EXTENT),u_tile_up_scale:h?a.globeMetersToEcef(1):d.upVectorScale(o,r.center.lat,r.worldSize).metersToTile}}renderToBackBuffer(r){const o=this.painter,h=this.painter.context;r.length!==0&&(h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),o.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(d,f,g,y,v){if(d.transform.projection.name==="globe")(function(E,T,A,k,R){const O=E.context,B=O.gl;let F,I;const L=E.options.showTerrainWireframe?2:0,N=E.transform,j=a.globeUseCustomAntiAliasing(E,O,N),K=(Te,ae)=>{if(I===Te)return;const _e=[En[Te],"PROJECTION_GLOBE_VIEW"];j&&_e.push("CUSTOM_ANTIALIASING"),ae&&_e.push(En[L]),F=E.useProgram("globeRaster",null,_e),I=Te},J=E.colorModeForRenderPass(),Y=new a.DepthMode(B.LEQUAL,a.DepthMode.ReadWrite,E.depthRangeFor3D);Br.update(R);const ie=a.calculateGlobeMercatorMatrix(N),te=[a.mercatorXfromLng(N.center.lng),a.mercatorYfromLat(N.center.lat)],le=L?[!1,!0]:[!1],Ee=E.globeSharedBuffers,oe=[N.width*a.exported.devicePixelRatio,N.height*a.exported.devicePixelRatio],ge=Float32Array.from(N.globeMatrix),he={useDenormalizedUpVectorScale:!0};if(le.forEach(Te=>{const ae=E.transform,_e=Ls(ae.zoom)*T.exaggeration();I=-1;const Me=Te?B.LINES:B.TRIANGLES;for(const be of k){const Ae=A.getTile(be),Ge=a.StencilMode.disabled,He=T.prevTerrainTileForTile[be.key],Ve=T.terrainTileForTile[be.key];io(He,Ve)&&Br.newMorphing(be.key,He,Ve,R,250),O.activeTexture.set(B.TEXTURE0),Ae.texture.bind(B.LINEAR,B.CLAMP_TO_EDGE);const qe=Br.getMorphValuesForProxy(be.key),ht=qe?1:0;qe&&a.extend$1(he,{morphing:{srcDemTile:qe.from,dstDemTile:qe.to,phase:a.easeCubicInOut(qe.phase)}});const at=a.tileCornersToBounds(be.canonical),je=a.getLatitudinalLod(at.getCenter().lat),Et=a.getGridMatrix(be.canonical,at,je,ae.worldSize/ae._pixelsPerMercatorPixel),Mt=a.globeNormalizeECEF(a.globeTileBounds(be.canonical)),At=Ds(ae.projMatrix,ge,ie,Mt,a.globeToMercatorTransition(ae.zoom),te,ae.frustumCorners.TL,ae.frustumCorners.TR,ae.frustumCorners.BR,ae.frustumCorners.BL,ae.globeCenterInViewSpace,ae.globeRadius,oe,_e,Et);if(K(ht,Te),T.setupElevationDraw(Ae,F,he),E.prepareDrawProgram(O,F,be.toUnwrapped()),Ee){const[It,Ii,xi]=Te?Ee.getWirefameBuffers(E.context,je):Ee.getGridBuffers(je,_e!==0);F.draw(O,Me,Y,Ge,J,a.CullFaceMode.backCCW,At,"globe_raster",It,Ii,xi)}}}),Ee){const Te=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];j&&Te.push("CUSTOM_ANTIALIASING"),F=E.useProgram("globeRaster",null,Te);for(const ae of k){const{x:_e,y:Me,z:be}=ae.canonical,Ae=Me===0,Ge=Me===(1<<be)-1,[He,Ve,qe,ht]=Ee.getPoleBuffers(be);if(ht&&(Ae||Ge)){const at=A.getTile(ae);O.activeTexture.set(B.TEXTURE0),at.texture.bind(B.LINEAR,B.CLAMP_TO_EDGE);let je=a.globePoleMatrixForTile(be,_e,N);const Et=a.globeNormalizeECEF(a.globeTileBounds(ae.canonical)),Mt=(At,It)=>At.draw(O,B.TRIANGLES,Y,a.StencilMode.disabled,J,a.CullFaceMode.disabled,Ds(N.projMatrix,je,je,Et,0,te,N.frustumCorners.TL,N.frustumCorners.TR,N.frustumCorners.BR,N.frustumCorners.BL,N.globeCenterInViewSpace,N.globeRadius,oe,0),"globe_pole_raster",It,qe,ht);T.setupElevationDraw(at,F,he),E.prepareDrawProgram(O,F,ae.toUnwrapped()),Ae&&Mt(F,He),Ge&&(je=a.scale(a.create(),je,[1,-1,1]),Mt(F,Ve))}}}})(d,f,g,y,v);else{const E=d.context,T=E.gl;let A,k;const R=d.options.showTerrainWireframe?2:0,O=(N,j)=>{if(k===N)return;const K=[En[N]];j&&K.push(En[R]),A=d.useProgram("terrainRaster",null,K),k=N},B=d.colorModeForRenderPass(),F=new a.DepthMode(T.LEQUAL,a.DepthMode.ReadWrite,d.depthRangeFor3D);Br.update(v);const I=d.transform,L=Ls(I.zoom)*f.exaggeration();(R?[!1,!0]:[!1]).forEach(N=>{k=-1;const j=N?T.LINES:T.TRIANGLES,[K,J]=N?f.getWirefameBuffer():[f.gridIndexBuffer,f.gridSegments];for(const Y of y){const ie=g.getTile(Y),te=a.StencilMode.disabled,le=f.prevTerrainTileForTile[Y.key],Ee=f.terrainTileForTile[Y.key];io(le,Ee)&&Br.newMorphing(Y.key,le,Ee,v,250),E.activeTexture.set(T.TEXTURE0),ie.texture.bind(T.LINEAR,T.CLAMP_TO_EDGE,T.LINEAR_MIPMAP_NEAREST);const oe=Br.getMorphValuesForProxy(Y.key),ge=oe?1:0;let he;oe&&(he={morphing:{srcDemTile:oe.from,dstDemTile:oe.to,phase:a.easeCubicInOut(oe.phase)}});const Te=to(Y.projMatrix,fc(Y.canonical,I.renderWorldCopies)?L/10:L);O(ge,N),f.setupElevationDraw(ie,A,he),d.prepareDrawProgram(E,A,Y.toUnwrapped()),A.draw(E,j,F,te,B,a.CullFaceMode.backCCW,Te,"terrain_raster",f.gridBuffer,K,J)}})}}(o,this,this.proxySourceCache,r,this._updateTimestamp),this.renderingToTexture=!0,o.gpuTimingDeferredRenderEnd(),r.splice(0,r.length))}renderBatch(r){if(this._drapedRenderBatches.length===0)return r+1;this.renderingToTexture=!0;const o=this.painter,h=this.painter.context,d=this.proxySourceCache,f=this.proxiedCoords[d.id],g=this._drapedRenderBatches.shift(),y=[],v=o.style.order;let E=0;for(const T of f){const A=d.getTileByID(T.proxyTileKey),k=d.proxyCachedFBO[T.key]?d.proxyCachedFBO[T.key][r]:void 0,R=k!==void 0?d.renderCache[k]:this.pool[E++],O=k!==void 0;if(A.texture=R.tex,O&&!R.dirty){y.push(A.tileID);continue}let B;h.bindFramebuffer.set(R.fb.framebuffer),this.renderedToTile=!1,R.dirty&&(h.clear({color:a.Color.transparent,stencil:0}),R.dirty=!1);for(let F=g.start;F<=g.end;++F){const I=o.style._layers[v[F]];if(I.isHidden(o.transform.zoom))continue;const L=o.style._getLayerSourceCache(I),N=L?this.proxyToSource[T.key][L.id]:[T];if(!N)continue;const j=N;h.viewport.set([0,0,R.fb.width,R.fb.height]),B!==(L?L.id:null)&&(this._setupStencil(R,N,I,L),B=L?L.id:null),o.renderLayer(o,L,I,j)}this.renderedToTile?(R.dirty=!0,y.push(A.tileID)):O||--E,E===5&&(E=0,this.renderToBackBuffer(y))}return this.renderToBackBuffer(y),this.renderingToTexture=!1,h.bindFramebuffer.set(null),h.viewport.set([0,0,o.width,o.height]),g.end+1}postRender(){}renderCacheEfficiency(r){const o=r.order.length;if(o===0)return{efficiency:100};let h,d=0,f=0,g=!1;for(let y=0;y<o;++y){const v=r._layers[r.order[y]];this._style.isLayerDraped(v)?(g&&++d,++f):g||(g=!0,h=v.id)}return f===0?{efficiency:100}:{efficiency:100*(1-d/f),firstUndrapedLayer:h}}getMinElevationBelowMSL(){let r=0;return this._visibleDemTiles.filter(o=>o.dem).forEach(o=>{r=Math.min(r,o.dem.tree.minimums[0])}),r===0?r:(r-30)*this._exaggeration}raycast(r,o,h){if(!this._visibleDemTiles)return null;const d=this._visibleDemTiles.filter(f=>f.dem).map(f=>{const g=f.tileID,y=1<<g.overscaledZ,{x:v,y:E}=g.canonical,T=v/y,A=(v+1)/y,k=E/y,R=(E+1)/y;return{minx:T,miny:k,maxx:A,maxy:R,t:f.dem.tree.raycastRoot(T,k,A,R,r,o,h),tile:f}});d.sort((f,g)=>(f.t!==null?f.t:Number.MAX_VALUE)-(g.t!==null?g.t:Number.MAX_VALUE));for(const f of d){if(f.t==null)return null;const g=f.tile.dem.tree.raycast(f.minx,f.miny,f.maxx,f.maxy,r,o,h);if(g!=null)return g}return null}_createFBO(){const r=this.painter.context,o=r.gl,h=this.drapeBufferSize;r.activeTexture.set(o.TEXTURE0);const d=new a.Texture(r,{width:h[0],height:h[1],data:null},o.RGBA);d.bind(o.LINEAR,o.CLAMP_TO_EDGE);const f=r.createFramebuffer(h[0],h[1],!1);return f.colorAttachment.set(d.texture),f.depthAttachment=new Q(r,f.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=r.createRenderbuffer(r.gl.DEPTH_STENCIL,h[0],h[1]),this._stencilRef=0,f.depthAttachment.set(this._sharedDepthStencil),r.clear({stencil:0})):f.depthAttachment.set(this._sharedDepthStencil),r.extTextureFilterAnisotropic&&!r.extTextureFilterAnisotropicForceOff&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax),{fb:f,tex:d,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const r in this._style._sourceCaches)if(this._style._sourceCaches[r].hasTransition())return!0;return this._style.order.some(r=>{const o=this._style._layers[r],h=o.isHidden(this.painter.transform.zoom);return o.type==="custom"?!h&&o.shouldRedrape():!h&&o.hasTransition()})}_clearLineLayersFromRenderCache(){let r=!1;for(const h of this._style._getSources())if(h instanceof ke){r=!0;break}if(!r)return;const o={};for(let h=0;h<this._style.order.length;++h){const d=this._style._layers[this._style.order[h]],f=this._style._getLayerSourceCache(d);if(f&&!o[f.id]&&!d.isHidden(this.painter.transform.zoom)&&d.type==="line"&&d.widthExpression()instanceof a.ZoomDependentExpression){o[f.id]=!0;for(const g of this.proxyCoords){const y=this.proxyToSource[g.key][f.id];if(y)for(const v of y)this._clearRenderCacheForTile(f.id,v)}}}}_clearRasterLayersFromRenderCache(){let r=!1;for(const h in this._style._sourceCaches)if(this._style._sourceCaches[h]._source instanceof Ie){r=!0;break}if(!r)return;const o={};for(let h=0;h<this._style.order.length;++h){const d=this._style._layers[this._style.order[h]],f=this._style._getLayerSourceCache(d);if(!f||o[f.id]||d.isHidden(this.painter.transform.zoom)||d.type!=="raster")continue;const g=d.paint.get("raster-fade-duration");for(const y of this.proxyCoords){const v=this.proxyToSource[y.key][f.id];if(v)for(const E of v){const T=qa(f.getTile(E),f.findLoadedParent(E,0),f,this.painter.transform,g);(T.opacity!==1||T.mix!==0)&&this._clearRenderCacheForTile(f.id,E)}}}}_setupDrapedRenderBatches(){const r=this._style.order,o=r.length;if(o===0)return;const h=[];let d,f=0,g=this._style._layers[r[f]];for(;!this._style.isLayerDraped(g)&&g.isHidden(this.painter.transform.zoom)&&++f<o;)g=this._style._layers[r[f]];for(;f<o;++f){const y=this._style._layers[r[f]];y.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(y)?d===void 0&&(d=f):d!==void 0&&(h.push({start:d,end:f-1}),d=void 0))}d!==void 0&&h.push({start:d,end:f-1}),this._drapedRenderBatches=h}_setupRenderCache(r){const o=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,o.renderCache.length>o.renderCachePool.length){const g=Object.values(o.proxyCachedFBO);o.proxyCachedFBO={};for(let y=0;y<g.length;++y){const v=Object.values(g[y]);o.renderCachePool.push(...v)}}return}this._clearRasterLayersFromRenderCache();const h=this.proxyCoords,d=this._tilesDirty;for(let g=h.length-1;g>=0;g--){const y=h[g];if(o.getTileByID(y.key),o.proxyCachedFBO[y.key]!==void 0){const v=r[y.key],E=this.proxyToSource[y.key];let T=0;for(const A in E){const k=E[A],R=v[A];if(!R||R.length!==k.length||k.some((O,B)=>O!==R[B]||d[A]&&d[A].hasOwnProperty(O.key))){T=-1;break}++T}for(const A in o.proxyCachedFBO[y.key])o.renderCache[o.proxyCachedFBO[y.key][A]].dirty=T<0||T!==Object.values(v).length}}const f=[...this._drapedRenderBatches];f.sort((g,y)=>y.end-y.start-(g.end-g.start));for(const g of f)for(const y of h){if(o.proxyCachedFBO[y.key])continue;let v=o.renderCachePool.pop();v===void 0&&o.renderCache.length<50&&(v=o.renderCache.length,o.renderCache.push(this._createFBO())),v!==void 0&&(o.proxyCachedFBO[y.key]={},o.proxyCachedFBO[y.key][g.start]=v,o.renderCache[v].dirty=!0)}this._tilesDirty={}}_setupStencil(r,o,h,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const f=this.painter.context,g=f.gl;if(o.length<=1)return void(this._overlapStencilType=!1);let y;if(h.isTileClipped())y=o.length,this._overlapStencilMode.test={func:g.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(o[0].overscaledZ>o[o.length-1].overscaledZ))return void(this._overlapStencilType=!1);y=1,this._overlapStencilMode.test={func:g.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+y>255&&(f.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=y,this._overlapStencilMode.ref=this._stencilRef,h.isTileClipped()&&this._renderTileClippingMasks(o,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(r){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[r.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(r,o){const h=this.painter,d=this.painter.context,f=d.gl;h._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const g=h.useProgram("clippingMask");for(const y of r){const v=h._tileClippingMaskIDs[y.key]=--o;g.draw(d,f.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:f.ALWAYS,mask:0},v,255,f.KEEP,f.KEEP,f.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,$o(y.projMatrix),"$clipping",h.tileExtentBuffer,h.quadTriangleIndexBuffer,h.tileExtentSegments)}}pointCoordinate(r){const o=this.painter.transform;if(r.x<0||r.x>o.width||r.y<0||r.y>o.height)return null;const h=[r.x,r.y,1,1];a.transformMat4$1(h,h,o.pixelMatrixInverse),a.scale$1(h,h,1/h[3]),h[0]/=o.worldSize,h[1]/=o.worldSize;const d=o._camera.position,f=a.mercatorZfromAltitude(1,o.center.lat),g=[d[0],d[1],d[2]/f,0],y=a.subtract([],h.slice(0,3),g);a.normalize(y,y);const v=this.raycast(g,y,this._exaggeration);return v!==null&&v?(a.scaleAndAdd(g,g,y,v),g[3]=g[2],g[2]*=f,g):null}drawDepth(){const r=this.painter,o=r.context,h=this.proxySourceCache,d=Math.ceil(r.width),f=Math.ceil(r.height);if(!this._depthFBO||this._depthFBO.width===d&&this._depthFBO.height===f||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const g=o.gl,y=o.createFramebuffer(d,f,!0);o.activeTexture.set(g.TEXTURE0);const v=new a.Texture(o,{width:d,height:f,data:null},g.RGBA);v.bind(g.NEAREST,g.CLAMP_TO_EDGE),y.colorAttachment.set(v.texture);const E=o.createRenderbuffer(o.gl.DEPTH_COMPONENT16,d,f);y.depthAttachment.set(E),this._depthFBO=y,this._depthTexture=v}o.bindFramebuffer.set(this._depthFBO.framebuffer),o.viewport.set([0,0,d,f]),function(g,y,v,E){if(g.transform.projection.name==="globe")return;const T=g.context,A=T.gl;T.clear({depth:1});const k=g.useProgram("terrainDepth"),R=new a.DepthMode(A.LESS,a.DepthMode.ReadWrite,g.depthRangeFor3D);for(const O of E){const B=v.getTile(O),F=to(O.projMatrix,0);y.setupElevationDraw(B,k),k.draw(T,A.TRIANGLES,R,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,F,"terrain_depth",y.gridBuffer,y.gridIndexBuffer,y.gridNoSkirtSegments)}}(r,this,h,this.proxyCoords)}_setupProxiedCoordsForOrtho(r,o,h){if(r.getSource()instanceof ot)return this._setupProxiedCoordsForImageSource(r,o,h);this._findCoveringTileCache[r.id]=this._findCoveringTileCache[r.id]||{};const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords;for(let y=0;y<f.length;y++){const v=f[y],E=this._findTileCoveringTileID(v,r);if(E){const T=this._createProxiedId(v,E,h[v.key]&&h[v.key][r.id]);d.push(T),this.proxyToSource[v.key][r.id]=[T]}}let g=!1;for(let y=0;y<o.length;y++){const v=r.getTile(o[y]);if(!v||!v.hasData())continue;const E=this._findTileCoveringTileID(v.tileID,this.proxySourceCache);if(E&&E.tileID.canonical.z!==v.tileID.canonical.z){const T=this.proxyToSource[E.tileID.key][r.id],A=this._createProxiedId(E.tileID,v,h[E.tileID.key]&&h[E.tileID.key][r.id]);T?T.splice(T.length-1,0,A):this.proxyToSource[E.tileID.key][r.id]=[A],d.push(A),g=!0}}this._sourceTilesOverlap[r.id]=g}_setupProxiedCoordsForImageSource(r,o,h){if(!r.getSource().loaded())return;const d=this.proxiedCoords[r.id]=[],f=this.proxyCoords,g=r.getSource(),y=new a.Point(g.tileID.x,g.tileID.y)._div(1<<g.tileID.z),v=g.coordinates.map(a.MercatorCoordinate.fromLngLat).reduce((T,A)=>(T.min.x=Math.min(T.min.x,A.x-y.x),T.min.y=Math.min(T.min.y,A.y-y.y),T.max.x=Math.max(T.max.x,A.x-y.x),T.max.y=Math.max(T.max.y,A.y-y.y),T),{min:new a.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),E=(T,A)=>{const k=T.wrap+T.canonical.x/(1<<T.canonical.z),R=T.canonical.y/(1<<T.canonical.z),O=a.EXTENT/(1<<T.canonical.z),B=A.wrap+A.canonical.x/(1<<A.canonical.z),F=A.canonical.y/(1<<A.canonical.z);return k+O<B+v.min.x||k>B+v.max.x||R+O<F+v.min.y||R>F+v.max.y};for(let T=0;T<f.length;T++){const A=f[T];for(let k=0;k<o.length;k++){const R=r.getTile(o[k]);if(!R||!R.hasData()||E(A,R.tileID))continue;const O=this._createProxiedId(A,R,h[A.key]&&h[A.key][r.id]),B=this.proxyToSource[A.key][r.id];B?B.push(O):this.proxyToSource[A.key][r.id]=[O],d.push(O)}}}_createProxiedId(r,o,h){let d=this.orthoMatrix;if(h){const f=h.find(g=>g.key===o.tileID.key);if(f)return f}if(o.tileID.key!==r.key){const f=r.canonical.z-o.tileID.canonical.z;let g,y,v;d=a.create();const E=o.tileID.wrap-r.wrap<<r.overscaledZ;f>0?(g=a.EXTENT>>f,y=g*((o.tileID.canonical.x<<f)-r.canonical.x+E),v=g*((o.tileID.canonical.y<<f)-r.canonical.y)):(g=a.EXTENT<<-f,y=a.EXTENT*(o.tileID.canonical.x-(r.canonical.x+E<<-f)),v=a.EXTENT*(o.tileID.canonical.y-(r.canonical.y<<-f))),a.ortho(d,0,g,0,g,0,1),a.translate(d,d,[y,v,0])}return new Bs(o.tileID,r.key,d)}_findTileCoveringTileID(r,o){let h=o.getTile(r);if(h&&h.hasData())return h;const d=this._findCoveringTileCache[o.id],f=d[r.key];if(h=f?o.getTileByID(f):null,h&&h.hasData()||f===null)return h;let g=h?h.tileID:r,y=g.overscaledZ;const v=o.getSource().minzoom,E=[];if(!f){const A=o.getSource().maxzoom;if(r.canonical.z>=A){const k=r.canonical.z-A;o.getSource().reparseOverscaled?(y=Math.max(r.canonical.z+2,o.transform.tileZoom),g=new a.OverscaledTileID(y,r.wrap,A,r.canonical.x>>k,r.canonical.y>>k)):k!==0&&(y=A,g=new a.OverscaledTileID(y,r.wrap,A,r.canonical.x>>k,r.canonical.y>>k))}g.key!==r.key&&(E.push(g.key),h=o.getTile(g))}const T=A=>{E.forEach(k=>{d[k]=A}),E.length=0};for(y-=1;y>=v&&(!h||!h.hasData());y--){h&&T(h.tileID.key);const A=g.calculateScaledKey(y);if(h=o.getTileByID(A),h&&h.hasData())break;const k=d[A];if(k===null)break;k===void 0?E.push(A):h=o.getTileByID(k)}return T(h?h.tileID.key:null),h&&h.hasData()?h:null}findDEMTileFor(r){return this.enabled?this._findTileCoveringTileID(r,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(r,o){let h=this._tilesDirty[r];h||(h=this._tilesDirty[r]={}),h[o.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const r=function(o){let h=0;const d=new a.StructArrayLayout2ui4,f=131;for(let g=1;g<129;g++){for(let y=1;y<129;y++)h=g*f+y,d.emplaceBack(h,h+1),d.emplaceBack(h,h+f),d.emplaceBack(h+1,h+f),g===128&&d.emplaceBack(h+f,h+f+1);d.emplaceBack(h+1,h+1+f)}return d}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(r),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,r.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class gt{static cacheKey(r,o,h,d){let f=`${o}${d?d.cacheKey:""}`;for(const g of h)r.usedDefines.includes(g)&&(f+=`/${g}`);return f}constructor(r,o,h,d,f,g){const y=r.gl;this.program=y.createProgram();const v=function(I){const L=[];for(let N=0;N<I.length;N++){if(I[N]===null)continue;const j=I[N].split(" ");L.push(j.pop())}return L}(h.staticAttributes),E=d?d.getBinderAttributes():[],T=v.concat(E);let A=d?d.defines():[];A=A.concat(g.map(I=>`#define ${I}`));const k=r.isWebGL2?`#version 300 es
1291
+ `:"",R=k+A.concat(r.extStandardDerivatives&&k.length===0?`#extension GL_OES_standard_derivatives : enable
1292
+ `.concat(Na):Na,Na,ks,uc.fragmentSource,Qn.fragmentSource,h.fragmentSource).join(`
1293
+ `),O=k+A.concat(`
1294
+ #ifdef GL_ES
1295
+ precision highp float;
1296
+ #else
1297
+
1298
+ #if !defined(lowp)
1299
+ #define lowp
1300
+ #endif
1301
+
1302
+ #if !defined(mediump)
1303
+ #define mediump
1304
+ #endif
1305
+
1306
+ #if !defined(highp)
1307
+ #define highp
1308
+ #endif
1309
+
1310
+ #endif`,ks,uc.vertexSource,Qn.vertexSource,Ps.vertexSource,h.vertexSource).join(`
1311
+ `),B=y.createShader(y.FRAGMENT_SHADER);if(y.isContextLost())return void(this.failedToCreate=!0);y.shaderSource(B,R),y.compileShader(B),y.attachShader(this.program,B);const F=y.createShader(y.VERTEX_SHADER);if(y.isContextLost())this.failedToCreate=!0;else{y.shaderSource(F,O),y.compileShader(F),y.attachShader(this.program,F),this.attributes={},this.numAttributes=T.length;for(let I=0;I<this.numAttributes;I++)T[I]&&(y.bindAttribLocation(this.program,I,T[I]),this.attributes[T[I]]=I);y.linkProgram(this.program),y.deleteShader(F),y.deleteShader(B),this.fixedUniforms=f(r),this.binderUniforms=d?d.getUniforms(r):[],g.includes("TERRAIN")&&(this.terrainUniforms=(I=>({u_dem:new a.Uniform1i(I),u_dem_prev:new a.Uniform1i(I),u_dem_unpack:new a.Uniform4f(I),u_dem_tl:new a.Uniform2f(I),u_dem_scale:new a.Uniform1f(I),u_dem_tl_prev:new a.Uniform2f(I),u_dem_scale_prev:new a.Uniform1f(I),u_dem_size:new a.Uniform1f(I),u_dem_lerp:new a.Uniform1f(I),u_exaggeration:new a.Uniform1f(I),u_depth:new a.Uniform1i(I),u_depth_size_inv:new a.Uniform2f(I),u_meter_to_dem:new a.Uniform1f(I),u_label_plane_matrix_inv:new a.UniformMatrix4f(I)}))(r)),g.includes("GLOBE")&&(this.globeUniforms=(I=>({u_tile_tl_up:new a.Uniform3f(I),u_tile_tr_up:new a.Uniform3f(I),u_tile_br_up:new a.Uniform3f(I),u_tile_bl_up:new a.Uniform3f(I),u_tile_up_scale:new a.Uniform1f(I)}))(r)),g.includes("FOG")&&(this.fogUniforms=(I=>({u_fog_matrix:new a.UniformMatrix4f(I),u_fog_range:new a.Uniform2f(I),u_fog_color:new a.Uniform4f(I),u_fog_horizon_blend:new a.Uniform1f(I),u_fog_temporal_offset:new a.Uniform1f(I),u_frustum_tl:new a.Uniform3f(I),u_frustum_tr:new a.Uniform3f(I),u_frustum_br:new a.Uniform3f(I),u_frustum_bl:new a.Uniform3f(I),u_globe_pos:new a.Uniform3f(I),u_globe_radius:new a.Uniform1f(I),u_globe_transition:new a.Uniform1f(I),u_is_globe:new a.Uniform1i(I),u_viewport:new a.Uniform2f(I)}))(r))}}setTerrainUniformValues(r,o){if(!this.terrainUniforms)return;const h=this.terrainUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d]&&h[d].set(this.program,d,o[d])}}setGlobeUniformValues(r,o){if(!this.globeUniforms)return;const h=this.globeUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d]&&h[d].set(this.program,d,o[d])}}setFogUniformValues(r,o){if(!this.fogUniforms)return;const h=this.fogUniforms;if(!this.failedToCreate){r.program.set(this.program);for(const d in o)h[d].set(this.program,d,o[d])}}draw(r,o,h,d,f,g,y,v,E,T,A,k,R,O,B){const F=r.gl;if(this.failedToCreate)return;r.program.set(this.program),r.setDepthMode(h),r.setStencilMode(d),r.setColorMode(f),r.setCullFace(g);for(const L of Object.keys(this.fixedUniforms))this.fixedUniforms[L].set(this.program,L,y[L]);O&&O.setUniforms(this.program,r,this.binderUniforms,k,{zoom:R});const I={[F.LINES]:2,[F.TRIANGLES]:3,[F.LINE_STRIP]:1}[o];for(const L of A.get()){const N=L.vaos||(L.vaos={});(N[v]||(N[v]=new Lh)).bind(r,this,E,O?O.getPaintVertexBuffers():[],T,L.vertexOffset,B||[]),F.drawElements(o,L.primitiveLength*I,F.UNSIGNED_SHORT,L.primitiveOffset*I*2)}}}function Zo(l,r){const o=Math.pow(2,r.tileID.overscaledZ),h=r.tileSize*Math.pow(2,l.transform.tileZoom)/o,d=h*(r.tileID.canonical.x+r.tileID.wrap*o),f=h*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_tile_units_to_pixels:1/mi(r,1,l.transform.tileZoom),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}const mc=a.create(),Ha=(l,r,o,h,d,f,g,y,v,E,T)=>{const A=r.style.light,k=A.properties.get("position"),R=[k.x,k.y,k.z],O=a.create$1();A.properties.get("anchor")==="viewport"&&(a.fromRotation(O,-r.transform.angle),a.transformMat3(R,R,O));const B=A.properties.get("color"),F=r.transform,I={u_matrix:l,u_lightpos:R,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[B.r,B.g,B.b],u_vertical_gradient:+o,u_opacity:h,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:mc,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:d,u_edge_radius:f};return F.projection.name==="globe"&&(I.u_tile_id=[g.canonical.x,g.canonical.y,1<<g.canonical.z],I.u_zoom_transition=v,I.u_inv_rot_matrix=T,I.u_merc_center=E,I.u_up_dir=F.projection.upVector(new a.CanonicalTileID(0,0,0),E[0]*a.EXTENT,E[1]*a.EXTENT),I.u_height_lift=y),I},_c=(l,r,o,h,d,f,g,y,v,E,T,A)=>{const k=Ha(l,r,o,h,d,f,g,v,E,T,A),R={u_height_factor:-Math.pow(2,g.overscaledZ)/y.tileSize/8};return a.extend(k,Zo(r,y),R)},Sn=l=>({u_matrix:l}),Ka=(l,r,o)=>a.extend(Sn(l),Zo(r,o)),Rh=(l,r)=>({u_matrix:l,u_world:r}),Bh=(l,r,o,h)=>a.extend(Ka(l,r,o),{u_world:h}),Oh=a.create(),Ya=(l,r,o,h,d,f)=>{const g=l.transform,y=g.projection.name==="globe";let v;if(f.paint.get("circle-pitch-alignment")==="map")if(y){const T=a.globePixelsToTileUnits(g.zoom,r.canonical)*g._pixelsPerMercatorPixel;v=Float32Array.from([T,0,0,T])}else v=g.calculatePixelsToTileUnitsMatrix(o);else v=new Float32Array([g.pixelsToGLUnits[0],0,0,g.pixelsToGLUnits[1]]);const E={u_camera_to_center_distance:g.cameraToCenterDistance,u_matrix:l.translatePosMatrix(r.projMatrix,o,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:v,u_inv_rot_matrix:Oh,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(y){E.u_inv_rot_matrix=h,E.u_merc_center=d,E.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],E.u_zoom_transition=a.globeToMercatorTransition(g.zoom);const T=d[0]*a.EXTENT,A=d[1]*a.EXTENT;E.u_up_dir=g.projection.upVector(new a.CanonicalTileID(0,0,0),T,A)}return E},Ja=l=>{const r=[];return l.paint.get("circle-pitch-alignment")==="map"&&r.push("PITCH_WITH_MAP"),l.paint.get("circle-pitch-scale")==="map"&&r.push("SCALE_WITH_MAP"),r},Qa=(l,r,o,h)=>{const d=a.EXTENT/o.tileSize;return{u_matrix:l,u_camera_to_center_distance:r.getCameraToCenterDistance(h),u_extrude_scale:[r.pixelsToGLUnits[0]/d,r.pixelsToGLUnits[1]/d]}},Os=(l,r,o=1)=>({u_matrix:l,u_color:r,u_overlay:0,u_overlay_scale:o}),gc=a.create(),yc=(l,r,o,h,d,f,g)=>{const y=l.transform,v=y.projection.name==="globe",E=v?a.globePixelsToTileUnits(y.zoom,r.canonical)*y._pixelsPerMercatorPixel:mi(o,1,f),T={u_matrix:r.projMatrix,u_extrude_scale:E,u_intensity:g,u_inv_rot_matrix:gc,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(v){T.u_inv_rot_matrix=h,T.u_merc_center=d,T.u_tile_id=[r.canonical.x,r.canonical.y,1<<r.canonical.z],T.u_zoom_transition=a.globeToMercatorTransition(y.zoom);const A=d[0]*a.EXTENT,k=d[1]*a.EXTENT;T.u_up_dir=y.projection.upVector(new a.CanonicalTileID(0,0,0),A,k)}return T},Fh=(l,r,o,h,d,f,g)=>{const y=l.transform,v=y.calculatePixelsToTileUnitsMatrix(r);return{u_matrix:el(l,r,o,h),u_pixels_to_tile_units:v,u_device_pixel_ratio:f,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:d,u_texsize:Wo(o)?r.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:ro(r,l.transform),u_alpha_discard_threshold:0,u_trim_offset:g}},qo=(l,r,o,h,d)=>{const f=l.transform;return{u_matrix:el(l,r,o,h),u_texsize:r.imageAtlasTexture.size,u_pixels_to_tile_units:f.calculatePixelsToTileUnitsMatrix(r),u_device_pixel_ratio:d,u_image:0,u_tile_units_to_pixels:ro(r,f),u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function ro(l,r){return 1/mi(l,1,r.tileZoom)}function el(l,r,o,h){return l.translatePosMatrix(h||r.tileID.projMatrix,r,o.paint.get("line-translate"),o.paint.get("line-translate-anchor"))}function Wo(l){const r=l.paint.get("line-dasharray").value;return r.value||r.kind!=="constant"}const tl=(l,r,o,h,d,f)=>{return{u_matrix:l,u_tl_parent:r,u_scale_parent:o,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:(y=d.paint.get("raster-saturation"),y>0?1-1/(1.001-y):-y),u_contrast_factor:(g=d.paint.get("raster-contrast"),g>0?1/(1-g):1+g),u_spin_weights:yr(d.paint.get("raster-hue-rotate")),u_perspective_transform:f};var g,y};function yr(l){l*=Math.PI/180;const r=Math.sin(l),o=Math.cos(l);return[(2*o+1)/3,(-Math.sqrt(3)*r-o+1)/3,(Math.sqrt(3)*r-o+1)/3]}const Fs=a.create(),il=(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B)=>{const F=d.transform,I={u_is_size_zoom_constant:+(l==="constant"||l==="source"),u_is_size_feature_constant:+(l==="constant"||l==="camera"),u_size_t:r?r.uSizeT:0,u_size:r?r.uSize:0,u_camera_to_center_distance:F.cameraToCenterDistance,u_rotate_symbol:+o,u_aspect_ratio:F.width/F.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:f,u_label_plane_matrix:g,u_coord_matrix:y,u_is_text:+v,u_pitch_with_map:+h,u_texsize:E,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Fs,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Fs,u_up_vector:[0,-1,0]};return B.name==="globe"&&(I.u_tile_id=[T.canonical.x,T.canonical.y,1<<T.canonical.z],I.u_zoom_transition=A,I.u_inv_rot_matrix=R,I.u_merc_center=k,I.u_camera_forward=F._camera.forward(),I.u_ecef_origin=a.globeECEFOrigin(F.globeMatrix,T.toUnwrapped()),I.u_tile_matrix=Float32Array.from(F.globeMatrix),I.u_up_vector=O),I},Us=(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B,F)=>a.extend(il(l,r,o,h,d,f,g,y,v,E,A,k,R,O,B,F),{u_gamma_scale:h?d.transform.cameraToCenterDistance*Math.cos(d.terrain?0:d.transform._pitch):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+T}),xc=(l,r,o,h,d,f,g,y,v,E,T,A,k,R,O,B)=>a.extend(Us(l,r,o,h,d,f,g,y,!0,v,!0,T,A,k,R,O,B),{u_texsize_icon:E,u_texture_icon:1}),rl=(l,r,o)=>({u_matrix:l,u_opacity:r,u_color:o}),Uh=(l,r,o,h,d)=>a.extend(function(f,g,y){const v=g.imageManager.getPattern(f.toString()),{width:E,height:T}=g.imageManager.getPixelSize(),A=Math.pow(2,y.tileID.overscaledZ),k=y.tileSize*Math.pow(2,g.transform.tileZoom)/A,R=k*(y.tileID.canonical.x+y.tileID.wrap*A),O=k*y.tileID.canonical.y;return{u_image:0,u_pattern_tl:v.tl,u_pattern_br:v.br,u_texsize:[E,T],u_pattern_size:v.displaySize,u_tile_units_to_pixels:1/mi(y,1,g.transform.tileZoom),u_pixel_coord_upper:[R>>16,O>>16],u_pixel_coord_lower:[65535&R,65535&O]}}(h,o,d),{u_matrix:l,u_opacity:r}),nl={fillExtrusion:l=>({u_matrix:new a.UniformMatrix4f(l),u_lightpos:new a.Uniform3f(l),u_lightintensity:new a.Uniform1f(l),u_lightcolor:new a.Uniform3f(l),u_vertical_gradient:new a.Uniform1f(l),u_opacity:new a.Uniform1f(l),u_edge_radius:new a.Uniform1f(l),u_ao:new a.Uniform2f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_up_dir:new a.Uniform3f(l),u_height_lift:new a.Uniform1f(l)}),fillExtrusionPattern:l=>({u_matrix:new a.UniformMatrix4f(l),u_lightpos:new a.Uniform3f(l),u_lightintensity:new a.Uniform1f(l),u_lightcolor:new a.Uniform3f(l),u_vertical_gradient:new a.Uniform1f(l),u_height_factor:new a.Uniform1f(l),u_edge_radius:new a.Uniform1f(l),u_ao:new a.Uniform2f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_up_dir:new a.Uniform3f(l),u_height_lift:new a.Uniform1f(l),u_image:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_pixel_coord_upper:new a.Uniform2f(l),u_pixel_coord_lower:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l),u_opacity:new a.Uniform1f(l)}),fill:l=>({u_matrix:new a.UniformMatrix4f(l)}),fillPattern:l=>({u_matrix:new a.UniformMatrix4f(l),u_image:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_pixel_coord_upper:new a.Uniform2f(l),u_pixel_coord_lower:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l)}),fillOutline:l=>({u_matrix:new a.UniformMatrix4f(l),u_world:new a.Uniform2f(l)}),fillOutlinePattern:l=>({u_matrix:new a.UniformMatrix4f(l),u_world:new a.Uniform2f(l),u_image:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_pixel_coord_upper:new a.Uniform2f(l),u_pixel_coord_lower:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l)}),circle:l=>({u_camera_to_center_distance:new a.Uniform1f(l),u_extrude_scale:new a.UniformMatrix2f(l),u_device_pixel_ratio:new a.Uniform1f(l),u_matrix:new a.UniformMatrix4f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_up_dir:new a.Uniform3f(l)}),collisionBox:l=>({u_matrix:new a.UniformMatrix4f(l),u_camera_to_center_distance:new a.Uniform1f(l),u_extrude_scale:new a.Uniform2f(l)}),collisionCircle:l=>({u_matrix:new a.UniformMatrix4f(l),u_inv_matrix:new a.UniformMatrix4f(l),u_camera_to_center_distance:new a.Uniform1f(l),u_viewport_size:new a.Uniform2f(l)}),debug:l=>({u_color:new a.UniformColor(l),u_matrix:new a.UniformMatrix4f(l),u_overlay:new a.Uniform1i(l),u_overlay_scale:new a.Uniform1f(l)}),clippingMask:l=>({u_matrix:new a.UniformMatrix4f(l)}),heatmap:l=>({u_extrude_scale:new a.Uniform1f(l),u_intensity:new a.Uniform1f(l),u_matrix:new a.UniformMatrix4f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_up_dir:new a.Uniform3f(l)}),heatmapTexture:l=>({u_image:new a.Uniform1i(l),u_color_ramp:new a.Uniform1i(l),u_opacity:new a.Uniform1f(l)}),hillshade:l=>({u_matrix:new a.UniformMatrix4f(l),u_image:new a.Uniform1i(l),u_latrange:new a.Uniform2f(l),u_light:new a.Uniform2f(l),u_shadow:new a.UniformColor(l),u_highlight:new a.UniformColor(l),u_accent:new a.UniformColor(l)}),hillshadePrepare:l=>({u_matrix:new a.UniformMatrix4f(l),u_image:new a.Uniform1i(l),u_dimension:new a.Uniform2f(l),u_zoom:new a.Uniform1f(l),u_unpack:new a.Uniform4f(l)}),line:l=>({u_matrix:new a.UniformMatrix4f(l),u_pixels_to_tile_units:new a.UniformMatrix2f(l),u_device_pixel_ratio:new a.Uniform1f(l),u_units_to_pixels:new a.Uniform2f(l),u_dash_image:new a.Uniform1i(l),u_gradient_image:new a.Uniform1i(l),u_image_height:new a.Uniform1f(l),u_texsize:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l),u_alpha_discard_threshold:new a.Uniform1f(l),u_trim_offset:new a.Uniform2f(l)}),linePattern:l=>({u_matrix:new a.UniformMatrix4f(l),u_texsize:new a.Uniform2f(l),u_pixels_to_tile_units:new a.UniformMatrix2f(l),u_device_pixel_ratio:new a.Uniform1f(l),u_image:new a.Uniform1i(l),u_units_to_pixels:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l),u_alpha_discard_threshold:new a.Uniform1f(l)}),raster:l=>({u_matrix:new a.UniformMatrix4f(l),u_tl_parent:new a.Uniform2f(l),u_scale_parent:new a.Uniform1f(l),u_fade_t:new a.Uniform1f(l),u_opacity:new a.Uniform1f(l),u_image0:new a.Uniform1i(l),u_image1:new a.Uniform1i(l),u_brightness_low:new a.Uniform1f(l),u_brightness_high:new a.Uniform1f(l),u_saturation_factor:new a.Uniform1f(l),u_contrast_factor:new a.Uniform1f(l),u_spin_weights:new a.Uniform3f(l),u_perspective_transform:new a.Uniform2f(l)}),symbolIcon:l=>({u_is_size_zoom_constant:new a.Uniform1i(l),u_is_size_feature_constant:new a.Uniform1i(l),u_size_t:new a.Uniform1f(l),u_size:new a.Uniform1f(l),u_camera_to_center_distance:new a.Uniform1f(l),u_rotate_symbol:new a.Uniform1i(l),u_aspect_ratio:new a.Uniform1f(l),u_fade_change:new a.Uniform1f(l),u_matrix:new a.UniformMatrix4f(l),u_label_plane_matrix:new a.UniformMatrix4f(l),u_coord_matrix:new a.UniformMatrix4f(l),u_is_text:new a.Uniform1i(l),u_pitch_with_map:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_camera_forward:new a.Uniform3f(l),u_tile_matrix:new a.UniformMatrix4f(l),u_up_vector:new a.Uniform3f(l),u_ecef_origin:new a.Uniform3f(l),u_texture:new a.Uniform1i(l)}),symbolSDF:l=>({u_is_size_zoom_constant:new a.Uniform1i(l),u_is_size_feature_constant:new a.Uniform1i(l),u_size_t:new a.Uniform1f(l),u_size:new a.Uniform1f(l),u_camera_to_center_distance:new a.Uniform1f(l),u_rotate_symbol:new a.Uniform1i(l),u_aspect_ratio:new a.Uniform1f(l),u_fade_change:new a.Uniform1f(l),u_matrix:new a.UniformMatrix4f(l),u_label_plane_matrix:new a.UniformMatrix4f(l),u_coord_matrix:new a.UniformMatrix4f(l),u_is_text:new a.Uniform1i(l),u_pitch_with_map:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_texture:new a.Uniform1i(l),u_gamma_scale:new a.Uniform1f(l),u_device_pixel_ratio:new a.Uniform1f(l),u_tile_id:new a.Uniform3f(l),u_zoom_transition:new a.Uniform1f(l),u_inv_rot_matrix:new a.UniformMatrix4f(l),u_merc_center:new a.Uniform2f(l),u_camera_forward:new a.Uniform3f(l),u_tile_matrix:new a.UniformMatrix4f(l),u_up_vector:new a.Uniform3f(l),u_ecef_origin:new a.Uniform3f(l),u_is_halo:new a.Uniform1i(l)}),symbolTextAndIcon:l=>({u_is_size_zoom_constant:new a.Uniform1i(l),u_is_size_feature_constant:new a.Uniform1i(l),u_size_t:new a.Uniform1f(l),u_size:new a.Uniform1f(l),u_camera_to_center_distance:new a.Uniform1f(l),u_rotate_symbol:new a.Uniform1i(l),u_aspect_ratio:new a.Uniform1f(l),u_fade_change:new a.Uniform1f(l),u_matrix:new a.UniformMatrix4f(l),u_label_plane_matrix:new a.UniformMatrix4f(l),u_coord_matrix:new a.UniformMatrix4f(l),u_is_text:new a.Uniform1i(l),u_pitch_with_map:new a.Uniform1i(l),u_texsize:new a.Uniform2f(l),u_texsize_icon:new a.Uniform2f(l),u_texture:new a.Uniform1i(l),u_texture_icon:new a.Uniform1i(l),u_gamma_scale:new a.Uniform1f(l),u_device_pixel_ratio:new a.Uniform1f(l),u_is_halo:new a.Uniform1i(l)}),background:l=>({u_matrix:new a.UniformMatrix4f(l),u_opacity:new a.Uniform1f(l),u_color:new a.UniformColor(l)}),backgroundPattern:l=>({u_matrix:new a.UniformMatrix4f(l),u_opacity:new a.Uniform1f(l),u_image:new a.Uniform1i(l),u_pattern_tl:new a.Uniform2f(l),u_pattern_br:new a.Uniform2f(l),u_texsize:new a.Uniform2f(l),u_pattern_size:new a.Uniform2f(l),u_pixel_coord_upper:new a.Uniform2f(l),u_pixel_coord_lower:new a.Uniform2f(l),u_tile_units_to_pixels:new a.Uniform1f(l)}),terrainRaster:Za,terrainDepth:Za,skybox:l=>({u_matrix:new a.UniformMatrix4f(l),u_sun_direction:new a.Uniform3f(l),u_cubemap:new a.Uniform1i(l),u_opacity:new a.Uniform1f(l),u_temporal_offset:new a.Uniform1f(l)}),skyboxGradient:l=>({u_matrix:new a.UniformMatrix4f(l),u_color_ramp:new a.Uniform1i(l),u_center_direction:new a.Uniform3f(l),u_radius:new a.Uniform1f(l),u_opacity:new a.Uniform1f(l),u_temporal_offset:new a.Uniform1f(l)}),skyboxCapture:l=>({u_matrix_3f:new a.UniformMatrix3f(l),u_sun_direction:new a.Uniform3f(l),u_sun_intensity:new a.Uniform1f(l),u_color_tint_r:new a.Uniform4f(l),u_color_tint_m:new a.Uniform4f(l),u_luminance:new a.Uniform1f(l)}),globeRaster:l=>({u_proj_matrix:new a.UniformMatrix4f(l),u_globe_matrix:new a.UniformMatrix4f(l),u_normalize_matrix:new a.UniformMatrix4f(l),u_merc_matrix:new a.UniformMatrix4f(l),u_zoom_transition:new a.Uniform1f(l),u_merc_center:new a.Uniform2f(l),u_image0:new a.Uniform1i(l),u_grid_matrix:new a.UniformMatrix3f(l),u_skirt_height:new a.Uniform1f(l),u_frustum_tl:new a.Uniform3f(l),u_frustum_tr:new a.Uniform3f(l),u_frustum_br:new a.Uniform3f(l),u_frustum_bl:new a.Uniform3f(l),u_globe_pos:new a.Uniform3f(l),u_globe_radius:new a.Uniform1f(l),u_viewport:new a.Uniform2f(l)}),globeAtmosphere:l=>({u_frustum_tl:new a.Uniform3f(l),u_frustum_tr:new a.Uniform3f(l),u_frustum_br:new a.Uniform3f(l),u_frustum_bl:new a.Uniform3f(l),u_horizon:new a.Uniform1f(l),u_transition:new a.Uniform1f(l),u_fadeout_range:new a.Uniform1f(l),u_color:new a.Uniform4f(l),u_high_color:new a.Uniform4f(l),u_space_color:new a.Uniform4f(l),u_star_intensity:new a.Uniform1f(l),u_star_density:new a.Uniform1f(l),u_star_size:new a.Uniform1f(l),u_temporal_offset:new a.Uniform1f(l),u_horizon_angle:new a.Uniform1f(l),u_rotation_matrix:new a.UniformMatrix4f(l)})};let Vs;function Xo(l,r,o,h,d,f,g){const y=l.context,v=y.gl,E=l.transform,T=l.useProgram("collisionBox"),A=[];let k=0,R=0;for(let j=0;j<h.length;j++){const K=h[j],J=r.getTile(K),Y=J.getBucket(o);if(!Y)continue;const ie=Ki(K,Y,E);let te=ie;d[0]===0&&d[1]===0||(te=l.translatePosMatrix(ie,J,d,f));const le=g?Y.textCollisionBox:Y.iconCollisionBox,Ee=Y.collisionCircleArray;if(Ee.length>0){const oe=a.create(),ge=te;a.mul(oe,Y.placementInvProjMatrix,E.glCoordMatrix),a.mul(oe,oe,Y.placementViewportMatrix),A.push({circleArray:Ee,circleOffset:R,transform:ge,invTransform:oe,projection:Y.getProjection()}),k+=Ee.length/4,R=k}le&&(l.terrain&&l.terrain.setupElevationDraw(J,T),T.draw(y,v.LINES,a.DepthMode.disabled,a.StencilMode.disabled,l.colorModeForRenderPass(),a.CullFaceMode.disabled,Qa(te,E,J,Y.getProjection()),o.id,le.layoutVertexBuffer,le.indexBuffer,le.segments,null,E.zoom,null,[le.collisionVertexBuffer,le.collisionVertexBufferExt]))}if(!g||!A.length)return;const O=l.useProgram("collisionCircle"),B=new a.StructArrayLayout2f1f2i16;B.resize(4*k),B._trim();let F=0;for(const j of A)for(let K=0;K<j.circleArray.length/4;K++){const J=4*K,Y=j.circleArray[J+0],ie=j.circleArray[J+1],te=j.circleArray[J+2],le=j.circleArray[J+3];B.emplace(F++,Y,ie,te,le,0),B.emplace(F++,Y,ie,te,le,1),B.emplace(F++,Y,ie,te,le,2),B.emplace(F++,Y,ie,te,le,3)}(!Vs||Vs.length<2*k)&&(Vs=function(j){const K=2*j,J=new a.StructArrayLayout3ui6;J.resize(K),J._trim();for(let Y=0;Y<K;Y++){const ie=6*Y;J.uint16[ie+0]=4*Y+0,J.uint16[ie+1]=4*Y+1,J.uint16[ie+2]=4*Y+2,J.uint16[ie+3]=4*Y+2,J.uint16[ie+4]=4*Y+3,J.uint16[ie+5]=4*Y+0}return J}(k));const I=y.createIndexBuffer(Vs,!0),L=y.createVertexBuffer(B,a.collisionCircleLayout.members,!0);for(const j of A){const K={u_matrix:j.transform,u_inv_matrix:j.invTransform,u_camera_to_center_distance:(N=E).getCameraToCenterDistance(j.projection),u_viewport_size:[N.width,N.height]};O.draw(y,v.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,l.colorModeForRenderPass(),a.CullFaceMode.disabled,K,o.id,L,I,a.SegmentVector.simpleSegment(0,2*j.circleOffset,j.circleArray.length,j.circleArray.length/2),null,E.zoom)}var N;L.destroy(),I.destroy()}const vc=a.create();function ol({width:l,height:r,anchor:o,textOffset:h,textScale:d},f){const{horizontalAlign:g,verticalAlign:y}=a.getAnchorAlignment(o),v=-(g-.5)*l,E=-(y-.5)*r,T=a.evaluateVariableOffset(o,h);return new a.Point((v/d+T[0])*f,(E/d+T[1])*f)}function Vh(l,r,o,h,d,f,g,y,v,E,T){const A=l.text.placedSymbolArray,k=l.text.dynamicLayoutVertexArray,R=l.icon.dynamicLayoutVertexArray,O={},B=l.getProjection(),F=Vt(y,B,f),I=f.elevation,L=B.upVectorScale(y.canonical,f.center.lat,f.worldSize).metersToTile;k.clear();for(let N=0;N<A.length;N++){const j=A.get(N),{tileAnchorX:K,tileAnchorY:J,numGlyphs:Y}=j,ie=j.hidden||!j.crossTileID||l.allowVerticalPlacement&&!j.placedOrientation?null:h[j.crossTileID];if(ie){let te=0,le=0,Ee=0;if(I){const Ae=I?I.getAtTileOffset(y,K,J):0,[Ge,He,Ve]=B.upVector(y.canonical,K,J);te=Ae*Ge*L,le=Ae*He*L,Ee=Ae*Ve*L}let[oe,ge,he,Te]=gi(j.projectedAnchorX+te,j.projectedAnchorY+le,j.projectedAnchorZ+Ee,o?F:g);const ae=sc(f.getCameraToCenterDistance(B),Te);let _e=d.evaluateSizeForFeature(l.textSizeData,E,j)*ae/a.ONE_EM;o&&(_e*=l.tilePixelRatio/v);const Me=ol(ie,_e);o?({x:oe,y:ge,z:he}=B.projectTilePoint(K+Me.x,J+Me.y,y.canonical),[oe,ge,he]=gi(oe+te,ge+le,he+Ee,g)):(r&&Me._rotate(-f.angle),oe+=Me.x,ge+=Me.y,he=0);const be=l.allowVerticalPlacement&&j.placedOrientation===a.WritingMode.vertical?Math.PI/2:0;for(let Ae=0;Ae<Y;Ae++)a.addDynamicAttributes(k,oe,ge,he,be);T&&j.associatedIconIndex>=0&&(O[j.associatedIconIndex]={x:oe,y:ge,z:he,angle:be})}else lr(Y,k)}if(T){R.clear();const N=l.icon.placedSymbolArray;for(let j=0;j<N.length;j++){const K=N.get(j),{numGlyphs:J}=K,Y=O[j];if(K.hidden||!Y)lr(J,R);else{const{x:ie,y:te,z:le,angle:Ee}=Y;for(let oe=0;oe<J;oe++)a.addDynamicAttributes(R,ie,te,le,Ee)}}l.icon.dynamicLayoutVertexBuffer.updateData(R)}l.text.dynamicLayoutVertexBuffer.updateData(k)}function sl(l,r,o){return o.iconsInText&&r?"symbolTextAndIcon":l?"symbolSDF":"symbolIcon"}function bc(l,r,o,h,d,f,g,y,v,E,T,A){const k=l.context,R=k.gl,O=l.transform,B=y==="map",F=v==="map",I=B&&o.layout.get("symbol-placement")!=="point",L=B&&!F&&!I,N=o.layout.get("symbol-sort-key").constantOr(1)!==void 0;let j=!1;const K=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),J=[a.mercatorXfromLng(O.center.lng),a.mercatorYfromLat(O.center.lat)],Y=o.layout.get("text-variable-anchor"),ie=O.projection.name==="globe",te=[],le=[0,-1,0];let Ee=le;!ie&&!O.mercatorFromTransition||B||(Ee=function(oe){const ge=oe._camera.getWorldToCamera(oe.worldSize,1),he=a.multiply([],ge,oe.globeMatrix);a.invert(he,he);const Te=[0,0,0],ae=[0,1,0,0];return a.transformMat4$1(ae,ae,he),Te[0]=ae[0],Te[1]=ae[1],Te[2]=ae[2],a.normalize(Te,Te),Te}(O));for(const oe of h){const ge=r.getTile(oe),he=ge.getBucket(o);if(!he||he.projection.name==="mercator"&&ie)continue;const Te=d?he.text:he.icon;if(!Te||he.fullyClipped||!Te.segments.get().length)continue;const ae=Te.programConfigurations.get(o.id),_e=d||he.sdfIcons,Me=d?he.textSizeData:he.iconSizeData,be=F||O.pitch!==0,Ae=a.evaluateSizeForZoom(Me,O.zoom);let Ge,He,Ve,qe,ht=[0,0],at=null;if(d)He=ge.glyphAtlasTexture,Ve=R.LINEAR,Ge=ge.glyphAtlasTexture.size,he.iconsInText&&(ht=ge.imageAtlasTexture.size,at=ge.imageAtlasTexture,qe=be||l.options.rotating||l.options.zooming||Me.kind==="composite"||Me.kind==="camera"?R.LINEAR:R.NEAREST);else{const Ur=o.layout.get("icon-size").constantOr(0)!==1||he.iconsNeedLinear;He=ge.imageAtlasTexture,Ve=_e||l.options.rotating||l.options.zooming||Ur||be?R.LINEAR:R.NEAREST,Ge=ge.imageAtlasTexture.size}const je=he.projection.name==="globe",Et=je?Ee:le,Mt=je?a.globeToMercatorTransition(O.zoom):0,At=Vt(oe,he.getProjection(),O),It=O.calculatePixelsToTileUnitsMatrix(ge),Ii=fe(At,ge.tileID.canonical,F,B,O,he.getProjection(),It),xi=l.terrain&&F&&I?a.invert(a.create(),Ii):vc,er=ti(At,ge.tileID.canonical,F,B,O,he.getProjection(),It),vr=Y&&he.hasTextData(),Nt=o.layout.get("icon-text-fit")!=="none"&&vr&&he.hasIconData();if(I){const Ur=O.elevation,nn=Ur?Ur.getAtTileOffsetFunc(oe,O.center.lat,O.worldSize,he.getProjection()):null,zn=Pr(At,ge.tileID.canonical,F,B,O,he.getProjection(),It);ka(he,At,l,d,zn,er,F,E,nn,oe)}const Ct=I||d&&Y||Nt,vt=l.translatePosMatrix(At,ge,f,g),ii=Ct?vc:Ii,ki=l.translatePosMatrix(er,ge,f,g,!0),Ut=he.getProjection().createInversionMatrix(O,oe.canonical),Oi=[];l.terrainRenderModeElevated()&&F&&Oi.push("PITCH_WITH_MAP_TERRAIN"),je&&Oi.push("PROJECTION_GLOBE_VIEW"),Ct&&Oi.push("PROJECTED_POS_ON_VIEWPORT");const ia=_e&&o.paint.get(d?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Cn;Cn=_e?he.iconsInText?xc(Me.kind,Ae,L,F,l,vt,ii,ki,Ge,ht,oe,Mt,J,Ut,Et,he.getProjection()):Us(Me.kind,Ae,L,F,l,vt,ii,ki,d,Ge,!0,oe,Mt,J,Ut,Et,he.getProjection()):il(Me.kind,Ae,L,F,l,vt,ii,ki,d,Ge,oe,Mt,J,Ut,Et,he.getProjection());const os={program:l.useProgram(sl(_e,d,he),ae,Oi),buffers:Te,uniformValues:Cn,atlasTexture:He,atlasTextureIcon:at,atlasInterpolation:Ve,atlasInterpolationIcon:qe,isSDF:_e,hasHalo:ia,tile:ge,labelPlaneMatrixInv:xi};if(N&&he.canOverlap){j=!0;const Ur=Te.segments.get();for(const nn of Ur)te.push({segments:new a.SegmentVector([nn]),sortKey:nn.sortKey,state:os})}else te.push({segments:Te.segments,sortKey:0,state:os})}j&&te.sort((oe,ge)=>oe.sortKey-ge.sortKey);for(const oe of te){const ge=oe.state;if(l.terrain&&l.terrain.setupElevationDraw(ge.tile,ge.program,{useDepthForOcclusion:!ie,labelPlaneMatrixInv:ge.labelPlaneMatrixInv}),k.activeTexture.set(R.TEXTURE0),ge.atlasTexture.bind(ge.atlasInterpolation,R.CLAMP_TO_EDGE),ge.atlasTextureIcon&&(k.activeTexture.set(R.TEXTURE1),ge.atlasTextureIcon&&ge.atlasTextureIcon.bind(ge.atlasInterpolationIcon,R.CLAMP_TO_EDGE)),ge.isSDF){const he=ge.uniformValues;ge.hasHalo&&(he.u_is_halo=1,Ho(ge.buffers,oe.segments,o,l,ge.program,K,T,A,he)),he.u_is_halo=0}Ho(ge.buffers,oe.segments,o,l,ge.program,K,T,A,ge.uniformValues)}}function Ho(l,r,o,h,d,f,g,y,v){const E=h.context,T=[l.dynamicLayoutVertexBuffer,l.opacityVertexBuffer,l.globeExtVertexBuffer];d.draw(E,E.gl.TRIANGLES,f,g,y,a.CullFaceMode.disabled,v,o.id,l.layoutVertexBuffer,l.indexBuffer,r,o.paint,h.transform.zoom,l.programConfigurations.get(o.id),T)}function wc(l,r,o,h,d,f,g){const y=l.context.gl,v=o.paint.get("fill-pattern"),E=v&&v.constantOr(1);let T,A,k,R,O;g?(A=E&&!o.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",T=y.LINES):(A=E?"fillPattern":"fill",T=y.TRIANGLES);for(const B of h){const F=r.getTile(B);if(E&&!F.patternsLoaded())continue;const I=F.getBucket(o);if(!I)continue;l.prepareDrawTile();const L=I.programConfigurations.get(o.id),N=l.useProgram(A,L);E&&(l.context.activeTexture.set(y.TEXTURE0),F.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),L.updatePaintBuffers());const j=v.constantOr(null);if(j&&F.imageAtlas){const J=F.imageAtlas.patternPositions[j.toString()];J&&L.setConstantPatternPositions(J)}const K=l.translatePosMatrix(B.projMatrix,F,o.paint.get("fill-translate"),o.paint.get("fill-translate-anchor"));if(g){R=I.indexBuffer2,O=I.segments2;const J=l.terrain&&l.terrain.renderingToTexture?l.terrain.drapeBufferSize:[y.drawingBufferWidth,y.drawingBufferHeight];k=A==="fillOutlinePattern"&&E?Bh(K,l,F,J):Rh(K,J)}else R=I.indexBuffer,O=I.segments,k=E?Ka(K,l,F):Sn(K);l.prepareDrawProgram(l.context,N,B.toUnwrapped()),N.draw(l.context,T,d,l.stencilModeForClipping(B),f,a.CullFaceMode.disabled,k,o.id,I.layoutVertexBuffer,R,O,o.paint,l.transform.zoom,L)}}function Ns(l,r,o,h,d,f,g){const y=l.context,v=y.gl,E=l.transform,T=o.paint.get("fill-extrusion-pattern"),A=T.constantOr(1),k=o.paint.get("fill-extrusion-opacity"),R=[o.paint.get("fill-extrusion-ambient-occlusion-intensity"),o.paint.get("fill-extrusion-ambient-occlusion-radius")],O=o.layout.get("fill-extrusion-edge-radius"),B=O>0&&!o.paint.get("fill-extrusion-rounded-roof"),F=B?0:O,I=E.projection.name==="globe"?a.fillExtrusionHeightLift():0,L=E.projection.name==="globe",N=L?a.globeToMercatorTransition(E.zoom):0,j=[a.mercatorXfromLng(E.center.lng),a.mercatorYfromLat(E.center.lat)],K=[];L&&K.push("PROJECTION_GLOBE_VIEW"),R[0]>0&&K.push("FAUX_AO"),B&&K.push("ZERO_ROOF_RADIUS");for(const J of h){const Y=r.getTile(J),ie=Y.getBucket(o);if(!ie||ie.projection.name!==E.projection.name)continue;const te=ie.programConfigurations.get(o.id),le=l.useProgram(A?"fillExtrusionPattern":"fillExtrusion",te,K);if(l.terrain){const _e=l.terrain;if(l.style.terrainSetForDrapingOnly())_e.setupElevationDraw(Y,le,{useMeterToDem:!0});else{if(!ie.enableTerrain)continue;if(_e.setupElevationDraw(Y,le,{useMeterToDem:!0}),Tc(y,r,J,ie,o,_e),!ie.centroidVertexBuffer){const Me=le.attributes.a_centroid_pos;Me!==void 0&&v.vertexAttrib2f(Me,0,0)}}}A&&(l.context.activeTexture.set(v.TEXTURE0),Y.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),te.updatePaintBuffers());const Ee=T.constantOr(null);if(Ee&&Y.imageAtlas){const _e=Y.imageAtlas.patternPositions[Ee.toString()];_e&&te.setConstantPatternPositions(_e)}const oe=l.translatePosMatrix(J.projMatrix,Y,o.paint.get("fill-extrusion-translate"),o.paint.get("fill-extrusion-translate-anchor")),ge=E.projection.createInversionMatrix(E,J.canonical),he=o.paint.get("fill-extrusion-vertical-gradient"),Te=A?_c(oe,l,he,k,R,F,J,Y,I,N,j,ge):Ha(oe,l,he,k,R,F,J,I,N,j,ge);l.prepareDrawProgram(y,le,J.toUnwrapped());const ae=[];l.terrain&&ae.push(ie.centroidVertexBuffer),L&&ae.push(ie.layoutVertexExtBuffer),le.draw(y,y.gl.TRIANGLES,d,f,g,a.CullFaceMode.backCCW,Te,o.id,ie.layoutVertexBuffer,ie.indexBuffer,ie.segments,o.paint,l.transform.zoom,te,ae)}}function Tc(l,r,o,h,d,f){const g=[I=>{let L=I.canonical.x-1,N=I.wrap;return L<0&&(L=(1<<I.canonical.z)-1,N--),new a.OverscaledTileID(I.overscaledZ,N,I.canonical.z,L,I.canonical.y)},I=>{let L=I.canonical.x+1,N=I.wrap;return L===1<<I.canonical.z&&(L=0,N++),new a.OverscaledTileID(I.overscaledZ,N,I.canonical.z,L,I.canonical.y)},I=>new a.OverscaledTileID(I.overscaledZ,I.wrap,I.canonical.z,I.canonical.x,(I.canonical.y===0?1<<I.canonical.z:I.canonical.y)-1),I=>new a.OverscaledTileID(I.overscaledZ,I.wrap,I.canonical.z,I.canonical.x,I.canonical.y===(1<<I.canonical.z)-1?0:I.canonical.y+1)],y=I=>{const L=r.getSource().minzoom,N=K=>{const J=r.getTileByID(K);if(J&&J.hasData())return J.getBucket(d)},j=[0,-1,1];for(const K of j){if(I.overscaledZ+K<L)continue;const J=N(I.calculateScaledKey(I.overscaledZ+K));if(J)return J}},v=[0,0,0],E=(I,L)=>(v[0]=Math.min(I.min.y,L.min.y),v[1]=Math.max(I.max.y,L.max.y),v[2]=a.EXTENT-L.min.x>I.max.x?L.min.x-a.EXTENT:I.max.x,v),T=(I,L)=>(v[0]=Math.min(I.min.x,L.min.x),v[1]=Math.max(I.max.x,L.max.x),v[2]=a.EXTENT-L.min.y>I.max.y?L.min.y-a.EXTENT:I.max.y,v),A=[(I,L)=>E(I,L),(I,L)=>E(L,I),(I,L)=>T(I,L),(I,L)=>T(L,I)],k=new a.Point(0,0);let R,O,B;const F=(I,L,N,j,K)=>{const J=[[j?N:I,j?I:N,0],[j?N:L,j?L:N,0]],Y=K<0?a.EXTENT+K:K,ie=[j?Y:(I+L)/2,j?(I+L)/2:Y,0];return N===0&&K<0||N!==0&&K>0?f.getForTilePoints(B,[ie],!0,O):J.push(ie),f.getForTilePoints(o,J,!0,R),Math.max(J[0][2],J[1][2],ie[2])/f.exaggeration()};for(let I=0;I<4;I++){const L=(I<2?1:5)-I,N=h.borders[I];if(N.length===0)continue;const j=B=g[I](o),K=y(j);if(!(K&&K instanceof a.FillExtrusionBucket&&K.enableTerrain)||h.borderDoneWithNeighborZ[I]===K.canonical.z&&K.borderDoneWithNeighborZ[L]===h.canonical.z||(O=f.findDEMTileFor(j),!O||!O.dem))continue;if(!R){const te=f.findDEMTileFor(o);if(!te||!te.dem)return;R=te}const J=K.borders[L];let Y=0;const ie=K.borderDoneWithNeighborZ[L]!==h.canonical.z;if(h.canonical.z===K.canonical.z){for(let te=0;te<N.length;te++){const le=h.featuresOnBorder[N[te]],Ee=le.borders[I];let oe;for(;Y<J.length&&(oe=K.featuresOnBorder[J[Y]],!(oe.borders[L][1]>Ee[0]+3));)ie&&K.encodeCentroid(void 0,oe,!1),Y++;if(oe&&Y<J.length){const ge=Y;let he=0;for(;!(oe.borders[L][0]>Ee[1]-3)&&(he++,++Y!==J.length);)oe=K.featuresOnBorder[J[Y]];if(oe=K.featuresOnBorder[J[ge]],le.intersectsCount()>1||oe.intersectsCount()>1||he!==1){he!==1&&(Y=ge),h.encodeCentroid(void 0,le,!1),ie&&K.encodeCentroid(void 0,oe,!1);continue}const Te=A[I](le,oe),ae=I%2?a.EXTENT-1:0;k.x=F(Te[0],Math.min(a.EXTENT-1,Te[1]),ae,I<2,Te[2]),k.y=0,h.encodeCentroid(k,le,!1),ie&&K.encodeCentroid(k,oe,!1)}else h.encodeCentroid(void 0,le,!1)}h.borderDoneWithNeighborZ[I]=K.canonical.z,h.needsCentroidUpdate=!0,ie&&(K.borderDoneWithNeighborZ[L]=h.canonical.z,K.needsCentroidUpdate=!0)}else{for(const te of N)h.encodeCentroid(void 0,h.featuresOnBorder[te],!1);if(ie){for(const te of J)K.encodeCentroid(void 0,K.featuresOnBorder[te],!1);K.borderDoneWithNeighborZ[L]=h.canonical.z,K.needsCentroidUpdate=!0}h.borderDoneWithNeighborZ[I]=K.canonical.z,h.needsCentroidUpdate=!0}}(h.needsCentroidUpdate||!h.centroidVertexBuffer&&h.centroidVertexArray.length!==0)&&h.uploadCentroid(l)}const no=new a.Color(1,0,0,1),Nh=new a.Color(0,1,0,1),jh=new a.Color(0,0,1,1),Gh=new a.Color(1,0,1,1),$h=new a.Color(0,1,1,1);function Zh(l,r,o){const h=l.context,d=l.transform,f=h.gl,g=d.projection.name==="globe",y=g?["PROJECTION_GLOBE_VIEW"]:null;let v=o.projMatrix;if(g&&a.globeToMercatorTransition(d.zoom)>0){const le=a.transitionTileAABBinECEF(o.canonical,d),Ee=a.globeDenormalizeECEF(le);v=a.multiply(new Float32Array(16),d.globeMatrix,Ee),a.multiply(v,d.projMatrix,v)}const E=l.useProgram("debug",null,y),T=r.getTileByID(o.key);l.terrain&&l.terrain.setupElevationDraw(T,E);const A=a.DepthMode.disabled,k=a.StencilMode.disabled,R=l.colorModeForRenderPass(),O="$debug";h.activeTexture.set(f.TEXTURE0),l.emptyTexture.bind(f.LINEAR,f.CLAMP_TO_EDGE),g?T._makeGlobeTileDebugBuffers(l.context,d):T._makeDebugTileBoundsBuffers(l.context,d.projection);const B=T._tileDebugBuffer||l.debugBuffer,F=T._tileDebugIndexBuffer||l.debugIndexBuffer,I=T._tileDebugSegments||l.debugSegments;E.draw(h,f.LINE_STRIP,A,k,R,a.CullFaceMode.disabled,Os(v,a.Color.red),O,B,F,I,null,null,null,[T._globeTileDebugBorderBuffer]);const L=T.latestRawTileData,N=Math.floor((L&&L.byteLength||0)/1024),j=r.getTile(o).tileSize,K=512/Math.min(j,512)*(o.overscaledZ/d.zoom)*.5;let J=o.canonical.toString();o.overscaledZ!==o.canonical.z&&(J+=` => ${o.overscaledZ}`),J+=` ${N}kb`,function(le,Ee){le.initDebugOverlayCanvas();const oe=le.debugOverlayCanvas,ge=le.context.gl,he=le.debugOverlayCanvas.getContext("2d");he.clearRect(0,0,oe.width,oe.height),he.shadowColor="white",he.shadowBlur=2,he.lineWidth=1.5,he.strokeStyle="white",he.textBaseline="top",he.font="bold 36px Open Sans, sans-serif",he.fillText(Ee,5,5),he.strokeText(Ee,5,5),le.debugOverlayTexture.update(oe),le.debugOverlayTexture.bind(ge.LINEAR,ge.CLAMP_TO_EDGE)}(l,J);const Y=T._tileDebugTextBuffer||l.debugBuffer,ie=T._tileDebugTextIndexBuffer||l.quadTriangleIndexBuffer,te=T._tileDebugTextSegments||l.debugSegments;E.draw(h,f.TRIANGLES,A,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,Os(v,a.Color.transparent,K),O,Y,ie,te,null,null,null,[T._globeTileDebugTextBuffer])}function Ec(l,r,o,h){oo(l,0,r+o/2,l.transform.width,o,h)}function js(l,r,o,h){oo(l,r-o/2,0,o,l.transform.height,h)}function oo(l,r,o,h,d,f){const g=l.context,y=g.gl;y.enable(y.SCISSOR_TEST),y.scissor(r*a.exported.devicePixelRatio,o*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio,d*a.exported.devicePixelRatio),g.clear({color:f}),y.disable(y.SCISSOR_TEST)}const Sc=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Mc}=Sc;function Or(l,r,o,h){l.emplaceBack(r,o,h)}class Gs{constructor(r){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,Or(this.vertexArray,-1,-1,1),Or(this.vertexArray,1,-1,1),Or(this.vertexArray,-1,1,1),Or(this.vertexArray,1,1,1),Or(this.vertexArray,-1,-1,-1),Or(this.vertexArray,1,-1,-1),Or(this.vertexArray,-1,1,-1),Or(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=r.createVertexBuffer(this.vertexArray,Mc),this.indexBuffer=r.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function Ji(l,r,o,h,d,f){const g=l.gl,y=r.paint.get("sky-atmosphere-color"),v=r.paint.get("sky-atmosphere-halo-color"),E=r.paint.get("sky-atmosphere-sun-intensity"),T=((A,k,R,O,B)=>({u_matrix_3f:A,u_sun_direction:k,u_sun_intensity:R,u_color_tint_r:[O.r,O.g,O.b,O.a],u_color_tint_m:[B.r,B.g,B.b,B.a],u_luminance:5e-5}))(a.fromMat4(a.create$1(),h),d,E,y,v);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_CUBE_MAP_POSITIVE_X+f,r.skyboxTexture,0),o.draw(l,g.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,T,"skyboxCapture",r.skyboxGeometry.vertexBuffer,r.skyboxGeometry.indexBuffer,r.skyboxGeometry.segment)}const Ko=a.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Ac{constructor(r){const o=new a.StructArrayLayout5f20;o.emplaceBack(-1,1,1,0,0),o.emplaceBack(1,1,1,1,0),o.emplaceBack(1,-1,1,1,1),o.emplaceBack(-1,-1,1,0,1);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,3,0),this.vertexBuffer=r.createVertexBuffer(o,Ko.members),this.indexBuffer=r.createIndexBuffer(h),this.segments=a.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Mn={symbol:function(l,r,o,h,d){if(l.renderPass!=="translucent")return;const f=a.StencilMode.disabled,g=l.colorModeForRenderPass();o.layout.get("text-variable-anchor")&&function(y,v,E,T,A,k,R){const O=v.transform,B=A==="map",F=k==="map";for(const I of y){const L=T.getTile(I),N=L.getBucket(E);if(!N||!N.text||!N.text.segments.get().length)continue;const j=a.evaluateSizeForZoom(N.textSizeData,O.zoom),K=Vt(I,N.getProjection(),O),J=O.calculatePixelsToTileUnitsMatrix(L),Y=fe(K,L.tileID.canonical,F,B,O,N.getProjection(),J),ie=E.layout.get("icon-text-fit")!=="none"&&N.hasIconData();if(j){const te=Math.pow(2,O.zoom-L.tileID.overscaledZ);Vh(N,B,F,R,a.symbolSize,O,Y,I,te,j,ie)}}}(h,l,o,r,o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),d),o.paint.get("icon-opacity").constantOr(1)!==0&&bc(l,r,o,h,!1,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),o.layout.get("icon-rotation-alignment"),o.layout.get("icon-pitch-alignment"),o.layout.get("icon-keep-upright"),f,g),o.paint.get("text-opacity").constantOr(1)!==0&&bc(l,r,o,h,!0,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),o.layout.get("text-rotation-alignment"),o.layout.get("text-pitch-alignment"),o.layout.get("text-keep-upright"),f,g),r.map.showCollisionBoxes&&(Xo(l,r,o,h,o.paint.get("text-translate"),o.paint.get("text-translate-anchor"),!0),Xo(l,r,o,h,o.paint.get("icon-translate"),o.paint.get("icon-translate-anchor"),!1))},circle:function(l,r,o,h){if(l.renderPass!=="translucent")return;const d=o.paint.get("circle-opacity"),f=o.paint.get("circle-stroke-width"),g=o.paint.get("circle-stroke-opacity"),y=o.layout.get("circle-sort-key").constantOr(1)!==void 0;if(d.constantOr(1)===0&&(f.constantOr(1)===0||g.constantOr(1)===0))return;const v=l.context,E=v.gl,T=l.transform,A=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),k=a.StencilMode.disabled,R=l.colorModeForRenderPass(),O=T.projection.name==="globe",B=[a.mercatorXfromLng(T.center.lng),a.mercatorYfromLat(T.center.lat)],F=[];for(let L=0;L<h.length;L++){const N=h[L],j=r.getTile(N),K=j.getBucket(o);if(!K||K.projection.name!==T.projection.name)continue;const J=K.programConfigurations.get(o.id),Y=Ja(o);O&&Y.push("PROJECTION_GLOBE_VIEW");const ie=l.useProgram("circle",J,Y),te=K.layoutVertexBuffer,le=K.globeExtVertexBuffer,Ee=K.indexBuffer,oe=T.projection.createInversionMatrix(T,N.canonical),ge={programConfiguration:J,program:ie,layoutVertexBuffer:te,globeExtVertexBuffer:le,indexBuffer:Ee,uniformValues:Ya(l,N,j,oe,B,o),tile:j};if(y){const he=K.segments.get();for(const Te of he)F.push({segments:new a.SegmentVector([Te]),sortKey:Te.sortKey,state:ge})}else F.push({segments:K.segments,sortKey:0,state:ge})}y&&F.sort((L,N)=>L.sortKey-N.sortKey);const I={useDepthForOcclusion:!O};for(const L of F){const{programConfiguration:N,program:j,layoutVertexBuffer:K,globeExtVertexBuffer:J,indexBuffer:Y,uniformValues:ie,tile:te}=L.state,le=L.segments;l.terrain&&l.terrain.setupElevationDraw(te,j,I),l.prepareDrawProgram(v,j,te.tileID.toUnwrapped()),j.draw(v,E.TRIANGLES,A,k,R,a.CullFaceMode.disabled,ie,o.id,K,Y,le,o.paint,T.zoom,N,[J])}},heatmap:function(l,r,o,h){if(o.paint.get("heatmap-opacity")!==0)if(l.renderPass==="offscreen"){const d=l.context,f=d.gl,g=a.StencilMode.disabled,y=new a.ColorMode([f.ONE,f.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(R,O,B,F){const I=R.gl,L=O.width*F,N=O.height*F;R.activeTexture.set(I.TEXTURE1),R.viewport.set([0,0,L,N]);let j=B.heatmapFbo;if(!j||j&&(j.width!==L||j.height!==N)){j&&j.destroy();const K=I.createTexture();I.bindTexture(I.TEXTURE_2D,K),I.texParameteri(I.TEXTURE_2D,I.TEXTURE_WRAP_S,I.CLAMP_TO_EDGE),I.texParameteri(I.TEXTURE_2D,I.TEXTURE_WRAP_T,I.CLAMP_TO_EDGE),I.texParameteri(I.TEXTURE_2D,I.TEXTURE_MIN_FILTER,I.LINEAR),I.texParameteri(I.TEXTURE_2D,I.TEXTURE_MAG_FILTER,I.LINEAR),j=B.heatmapFbo=R.createFramebuffer(L,N,!1),function(J,Y,ie,te,le,Ee){const oe=J.gl;oe.texImage2D(oe.TEXTURE_2D,0,J.isWebGL2&&J.extRenderToTextureHalfFloat?oe.RGBA16F:oe.RGBA,le,Ee,0,oe.RGBA,J.extRenderToTextureHalfFloat?J.isWebGL2?oe.HALF_FLOAT:J.extTextureHalfFloat.HALF_FLOAT_OES:oe.UNSIGNED_BYTE,null),te.colorAttachment.set(ie)}(R,0,K,j,L,N)}else I.bindTexture(I.TEXTURE_2D,j.colorAttachment.get()),R.bindFramebuffer.set(j.framebuffer)})(d,l,o,l.transform.projection.name==="globe"?.5:.25),d.clear({color:a.Color.transparent});const v=l.transform,E=v.projection.name==="globe",T=E?["PROJECTION_GLOBE_VIEW"]:null,A=E?a.CullFaceMode.frontCCW:a.CullFaceMode.disabled,k=[a.mercatorXfromLng(v.center.lng),a.mercatorYfromLat(v.center.lat)];for(let R=0;R<h.length;R++){const O=h[R];if(r.hasRenderableParent(O))continue;const B=r.getTile(O),F=B.getBucket(o);if(!F||F.projection.name!==v.projection.name)continue;const I=F.programConfigurations.get(o.id),L=l.useProgram("heatmap",I,T),{zoom:N}=l.transform;l.terrain&&l.terrain.setupElevationDraw(B,L),l.prepareDrawProgram(d,L,O.toUnwrapped());const j=v.projection.createInversionMatrix(v,O.canonical);L.draw(d,f.TRIANGLES,a.DepthMode.disabled,g,y,A,yc(l,O,B,j,k,N,o.paint.get("heatmap-intensity")),o.id,F.layoutVertexBuffer,F.indexBuffer,F.segments,o.paint,l.transform.zoom,I,E?[F.globeExtVertexBuffer]:null)}d.viewport.set([0,0,l.width,l.height])}else l.renderPass==="translucent"&&(l.context.setColorMode(l.colorModeForRenderPass()),function(d,f){const g=d.context,y=g.gl,v=f.heatmapFbo;if(!v)return;g.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,v.colorAttachment.get()),g.activeTexture.set(y.TEXTURE1);let E=f.colorRampTexture;E||(E=f.colorRampTexture=new a.Texture(g,f.colorRamp,y.RGBA)),E.bind(y.LINEAR,y.CLAMP_TO_EDGE),d.useProgram("heatmapTexture").draw(g,y.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,d.colorModeForRenderPass(),a.CullFaceMode.disabled,((T,A,k,R)=>({u_image:0,u_color_ramp:1,u_opacity:A.paint.get("heatmap-opacity")}))(0,f),f.id,d.viewportBuffer,d.quadTriangleIndexBuffer,d.viewportSegments,f.paint,d.transform.zoom)}(l,o))},line:function(l,r,o,h){if(l.renderPass!=="translucent")return;const d=o.paint.get("line-opacity"),f=o.paint.get("line-width");if(d.constantOr(1)===0||f.constantOr(1)===0)return;const g=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),y=l.colorModeForRenderPass(),v=l.terrain&&l.terrain.renderingToTexture?1:a.exported.devicePixelRatio,E=o.paint.get("line-dasharray"),T=E.constantOr(1),A=o.layout.get("line-cap"),k=o.paint.get("line-pattern"),R=k.constantOr(1),O=o.paint.get("line-gradient"),B=R?"linePattern":"line",F=l.context,I=F.gl,L=(j=>{const K=[];Wo(j)&&K.push("RENDER_LINE_DASH"),j.paint.get("line-gradient")&&K.push("RENDER_LINE_GRADIENT");const J=j.paint.get("line-trim-offset");J[0]===0&&J[1]===0||K.push("RENDER_LINE_TRIM_OFFSET");const Y=j.paint.get("line-pattern").constantOr(1),ie=j.paint.get("line-opacity").constantOr(1)!==1;return!Y&&ie&&K.push("RENDER_LINE_ALPHA_DISCARD"),K})(o);let N=L.includes("RENDER_LINE_ALPHA_DISCARD");l.terrain&&l.terrain.clipOrMaskOverlapStencilType()&&(N=!1);for(const j of h){const K=r.getTile(j);if(R&&!K.patternsLoaded())continue;const J=K.getBucket(o);if(!J)continue;l.prepareDrawTile();const Y=J.programConfigurations.get(o.id),ie=l.useProgram(B,Y,L),te=k.constantOr(null);if(te&&K.imageAtlas){const _e=K.imageAtlas.patternPositions[te.toString()];_e&&Y.setConstantPatternPositions(_e)}const le=E.constantOr(null),Ee=A.constantOr(null);if(!R&&le&&Ee&&K.lineAtlas){const _e=K.lineAtlas.getDash(le,Ee);_e&&Y.setConstantPatternPositions(_e)}let[oe,ge]=o.paint.get("line-trim-offset");(Ee==="round"||Ee==="square")&&oe!==ge&&(oe===0&&(oe-=1),ge===1&&(ge+=1));const he=l.terrain?j.projMatrix:null,Te=R?qo(l,K,o,he,v):Fh(l,K,o,he,J.lineClipsArray.length,v,[oe,ge]);if(O){const _e=J.gradients[o.id];let Me=_e.texture;if(o.gradientVersion!==_e.version){let be=256;if(o.stepInterpolant){const Ae=r.getSource().maxzoom,Ge=j.canonical.z===Ae?Math.ceil(1<<l.transform.maxZoom-j.canonical.z):1;be=a.clamp(a.nextPowerOfTwo(J.maxLineLength/a.EXTENT*1024*Ge),256,F.maxTextureSize)}_e.gradient=a.renderColorRamp({expression:o.gradientExpression(),evaluationKey:"lineProgress",resolution:be,image:_e.gradient||void 0,clips:J.lineClipsArray}),_e.texture?_e.texture.update(_e.gradient):_e.texture=new a.Texture(F,_e.gradient,I.RGBA),_e.version=o.gradientVersion,Me=_e.texture}F.activeTexture.set(I.TEXTURE1),Me.bind(o.stepInterpolant?I.NEAREST:I.LINEAR,I.CLAMP_TO_EDGE)}T&&(F.activeTexture.set(I.TEXTURE0),K.lineAtlasTexture.bind(I.LINEAR,I.REPEAT),Y.updatePaintBuffers()),R&&(F.activeTexture.set(I.TEXTURE0),K.imageAtlasTexture.bind(I.LINEAR,I.CLAMP_TO_EDGE),Y.updatePaintBuffers()),l.prepareDrawProgram(F,ie,j.toUnwrapped());const ae=_e=>{ie.draw(F,I.TRIANGLES,g,_e,y,a.CullFaceMode.disabled,Te,o.id,J.layoutVertexBuffer,J.indexBuffer,J.segments,o.paint,l.transform.zoom,Y,[J.layoutVertexBuffer2])};if(N){const _e=l.stencilModeForClipping(j).ref;_e===0&&l.terrain&&F.clear({stencil:0});const Me={func:I.EQUAL,mask:255};Te.u_alpha_discard_threshold=.8,ae(new a.StencilMode(Me,_e,255,I.KEEP,I.KEEP,I.INVERT)),Te.u_alpha_discard_threshold=0,ae(new a.StencilMode(Me,_e,255,I.KEEP,I.KEEP,I.KEEP))}else ae(l.stencilModeForClipping(j))}N&&(l.resetStencilClippingMasks(),l.terrain&&F.clear({stencil:0}))},fill:function(l,r,o,h){const d=o.paint.get("fill-color"),f=o.paint.get("fill-opacity");if(f.constantOr(1)===0)return;const g=l.colorModeForRenderPass(),y=o.paint.get("fill-pattern"),v=l.opaquePassEnabledForLayer()&&!y.constantOr(1)&&d.constantOr(a.Color.transparent).a===1&&f.constantOr(0)===1?"opaque":"translucent";if(l.renderPass===v){const E=l.depthModeForSublayer(1,l.renderPass==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);wc(l,r,o,h,E,g,!1)}if(l.renderPass==="translucent"&&o.paint.get("fill-antialias")){const E=l.depthModeForSublayer(o.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);wc(l,r,o,h,E,g,!0)}},"fill-extrusion":function(l,r,o,h){const d=o.paint.get("fill-extrusion-opacity");if(d!==0&&l.renderPass==="translucent"){const f=new a.DepthMode(l.context.gl.LEQUAL,a.DepthMode.ReadWrite,l.depthRangeFor3D);if(d!==1||o.paint.get("fill-extrusion-pattern").constantOr(1))Ns(l,r,o,h,f,a.StencilMode.disabled,a.ColorMode.disabled),Ns(l,r,o,h,f,l.stencilModeFor3D(),l.colorModeForRenderPass()),l.resetStencilClippingMasks();else{const g=l.colorModeForRenderPass();Ns(l,r,o,h,f,a.StencilMode.disabled,g)}}},hillshade:function(l,r,o,h){if(l.renderPass!=="offscreen"&&l.renderPass!=="translucent")return;const d=l.context,f=l.depthModeForSublayer(0,a.DepthMode.ReadOnly),g=l.colorModeForRenderPass(),y=l.terrain&&l.terrain.renderingToTexture,[v,E]=l.renderPass!=="translucent"||y?[{},h]:l.stencilConfigForOverlap(h);for(const T of E){const A=r.getTile(T);if(A.needsHillshadePrepare&&l.renderPass==="offscreen")pc(l,A,o,f,a.StencilMode.disabled,g);else if(l.renderPass==="translucent"){const k=y&&l.terrain?l.terrain.stencilModeForRTTOverlap(T):v[T.overscaledZ];dc(l,T,A,o,f,k,g)}}d.viewport.set([0,0,l.width,l.height]),l.resetStencilClippingMasks()},raster:function(l,r,o,h,d,f){if(l.renderPass!=="translucent"||o.paint.get("raster-opacity")===0||!h.length)return;const g=l.context,y=g.gl,v=r.getSource(),E=l.useProgram("raster"),T=l.colorModeForRenderPass(),A=l.terrain&&l.terrain.renderingToTexture,[k,R]=v instanceof ot||A?[{},h]:l.stencilConfigForOverlap(h),O=R[R.length-1].overscaledZ,B=!l.options.moving;for(const F of R){const I=A?a.DepthMode.disabled:l.depthModeForSublayer(F.overscaledZ-O,o.paint.get("raster-opacity")===1?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,y.LESS),L=F.toUnwrapped(),N=r.getTile(F);if(A&&(!N||!N.hasData()))continue;const j=A?F.projMatrix:l.transform.calculateProjMatrix(L,B),K=l.terrain&&A?l.terrain.stencilModeForRTTOverlap(F):k[F.overscaledZ],J=f?0:o.paint.get("raster-fade-duration");N.registerFadeDuration(J);const Y=r.findLoadedParent(F,0),ie=qa(N,Y,r,l.transform,J);let te,le;l.terrain&&l.terrain.prepareDrawTile();const Ee=o.paint.get("raster-resampling")==="nearest"?y.NEAREST:y.LINEAR;g.activeTexture.set(y.TEXTURE0),N.texture.bind(Ee,y.CLAMP_TO_EDGE),g.activeTexture.set(y.TEXTURE1),Y?(Y.texture.bind(Ee,y.CLAMP_TO_EDGE),te=Math.pow(2,Y.tileID.overscaledZ-N.tileID.overscaledZ),le=[N.tileID.canonical.x*te%1,N.tileID.canonical.y*te%1]):N.texture.bind(Ee,y.CLAMP_TO_EDGE),N.texture.useMipmap&&g.extTextureFilterAnisotropic&&l.transform.pitch>20&&y.texParameterf(y.TEXTURE_2D,g.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,g.extTextureFilterAnisotropicMax);const oe=tl(j,le||[0,0],te||1,ie,o,v instanceof ot?v.perspectiveTransform:[0,0]);if(l.prepareDrawProgram(g,E,L),v instanceof ot)v.boundsBuffer&&v.boundsSegments&&E.draw(g,y.TRIANGLES,I,a.StencilMode.disabled,T,a.CullFaceMode.disabled,oe,o.id,v.boundsBuffer,l.quadTriangleIndexBuffer,v.boundsSegments);else{const{tileBoundsBuffer:ge,tileBoundsIndexBuffer:he,tileBoundsSegments:Te}=l.getTileBoundsBuffers(N);E.draw(g,y.TRIANGLES,I,K,T,a.CullFaceMode.disabled,oe,o.id,ge,he,Te)}}l.resetStencilClippingMasks()},background:function(l,r,o,h){const d=o.paint.get("background-color"),f=o.paint.get("background-opacity");if(f===0)return;const g=l.context,y=g.gl,v=l.transform,E=v.tileSize,T=o.paint.get("background-pattern");if(l.isPatternMissing(T))return;const A=!T&&d.a===1&&f===1&&l.opaquePassEnabledForLayer()?"opaque":"translucent";if(l.renderPass!==A)return;const k=a.StencilMode.disabled,R=l.depthModeForSublayer(0,A==="opaque"?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),O=l.colorModeForRenderPass(),B=l.useProgram(T?"backgroundPattern":"background");let F,I=h;I||(F=l.getBackgroundTiles(),I=Object.values(F).map(L=>L.tileID)),T&&(g.activeTexture.set(y.TEXTURE0),l.imageManager.bind(l.context));for(const L of I){const N=L.toUnwrapped(),j=h?L.projMatrix:l.transform.calculateProjMatrix(N);l.prepareDrawTile();const K=r?r.getTile(L):F?F[L.key]:new a.Tile(L,E,v.zoom,l),J=T?Uh(j,f,l,T,{tileID:L,tileSize:E}):rl(j,f,d);l.prepareDrawProgram(g,B,N);const{tileBoundsBuffer:Y,tileBoundsIndexBuffer:ie,tileBoundsSegments:te}=l.getTileBoundsBuffers(K);B.draw(g,y.TRIANGLES,R,k,O,a.CullFaceMode.disabled,J,o.id,Y,ie,te)}},sky:function(l,r,o){const h=l.transform,d=h.projection.name==="mercator"||h.projection.name==="globe"?1:a.smoothstep(7,8,h.zoom),f=o.paint.get("sky-opacity")*d;if(f===0)return;const g=l.context,y=o.paint.get("sky-type"),v=new a.DepthMode(g.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),E=l.frameCounter/1e3%1;y==="atmosphere"?l.renderPass==="offscreen"?o.needsSkyboxCapture(l)&&(function(T,A,k,R){const O=T.context,B=O.gl;let F=A.skyboxFbo;if(!F){F=A.skyboxFbo=O.createFramebuffer(32,32,!1),A.skyboxGeometry=new Gs(O),A.skyboxTexture=O.gl.createTexture(),B.bindTexture(B.TEXTURE_CUBE_MAP,A.skyboxTexture),B.texParameteri(B.TEXTURE_CUBE_MAP,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_CUBE_MAP,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_CUBE_MAP,B.TEXTURE_MIN_FILTER,B.LINEAR),B.texParameteri(B.TEXTURE_CUBE_MAP,B.TEXTURE_MAG_FILTER,B.LINEAR);for(let j=0;j<6;++j)B.texImage2D(B.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,B.RGBA,32,32,0,B.RGBA,B.UNSIGNED_BYTE,null)}O.bindFramebuffer.set(F.framebuffer),O.viewport.set([0,0,32,32]);const I=A.getCenter(T,!0),L=T.useProgram("skyboxCapture"),N=new Float64Array(16);a.identity(N),a.rotateY(N,N,.5*-Math.PI),Ji(O,A,L,N,I,0),a.identity(N),a.rotateY(N,N,.5*Math.PI),Ji(O,A,L,N,I,1),a.identity(N),a.rotateX(N,N,.5*-Math.PI),Ji(O,A,L,N,I,2),a.identity(N),a.rotateX(N,N,.5*Math.PI),Ji(O,A,L,N,I,3),a.identity(N),Ji(O,A,L,N,I,4),a.identity(N),a.rotateY(N,N,Math.PI),Ji(O,A,L,N,I,5),O.viewport.set([0,0,T.width,T.height])}(l,o),o.markSkyboxValid(l)):l.renderPass==="sky"&&function(T,A,k,R,O){const B=T.context,F=B.gl,I=T.transform,L=T.useProgram("skybox");B.activeTexture.set(F.TEXTURE0),F.bindTexture(F.TEXTURE_CUBE_MAP,A.skyboxTexture);const N=((j,K,J,Y,ie)=>({u_matrix:j,u_sun_direction:K,u_cubemap:0,u_opacity:Y,u_temporal_offset:ie}))(I.skyboxMatrix,A.getCenter(T,!1),0,R,O);T.prepareDrawProgram(B,L),L.draw(B,F.TRIANGLES,k,a.StencilMode.disabled,T.colorModeForRenderPass(),a.CullFaceMode.backCW,N,"skybox",A.skyboxGeometry.vertexBuffer,A.skyboxGeometry.indexBuffer,A.skyboxGeometry.segment)}(l,o,v,f,E):y==="gradient"&&l.renderPass==="sky"&&function(T,A,k,R,O){const B=T.context,F=B.gl,I=T.transform,L=T.useProgram("skyboxGradient");A.skyboxGeometry||(A.skyboxGeometry=new Gs(B)),B.activeTexture.set(F.TEXTURE0);let N=A.colorRampTexture;N||(N=A.colorRampTexture=new a.Texture(B,A.colorRamp,F.RGBA)),N.bind(F.LINEAR,F.CLAMP_TO_EDGE);const j=((K,J,Y,ie,te)=>({u_matrix:K,u_color_ramp:0,u_center_direction:J,u_radius:a.degToRad(Y),u_opacity:ie,u_temporal_offset:te}))(I.skyboxMatrix,A.getCenter(T,!1),A.paint.get("sky-gradient-radius"),R,O);T.prepareDrawProgram(B,L),L.draw(B,F.TRIANGLES,k,a.StencilMode.disabled,T.colorModeForRenderPass(),a.CullFaceMode.backCW,j,"skyboxGradient",A.skyboxGeometry.vertexBuffer,A.skyboxGeometry.indexBuffer,A.skyboxGeometry.segment)}(l,o,v,f,E)},debug:function(l,r,o){for(let h=0;h<o.length;h++)Zh(l,r,o[h])},custom:function(l,r,o,h){const d=l.context,f=o.implementation;if(!l.transform.projection.unsupportedLayers||!l.transform.projection.unsupportedLayers.includes("custom")||l.terrain&&(l.terrain.renderingToTexture||l.renderPass==="offscreen")&&o.isLayerDraped()){if(l.renderPass==="offscreen"){const g=f.prerender;if(g){if(l.setCustomLayerDefaults(),d.setColorMode(l.colorModeForRenderPass()),l.transform.projection.name==="globe"){const y=l.transform.pointMerc;g.call(f,d.gl,l.transform.customLayerMatrix(),l.transform.getProjection(),l.transform.globeToMercatorMatrix(),a.globeToMercatorTransition(l.transform.zoom),[y.x,y.y],l.transform.pixelsPerMeterRatio)}else g.call(f,d.gl,l.transform.customLayerMatrix());d.setDirty(),l.setBaseState()}}else if(l.renderPass==="translucent"){if(l.terrain&&l.terrain.renderingToTexture){const y=f.renderToTile;if(y){const v=h[0].canonical,E=new a.MercatorCoordinate(v.x+h[0].wrap*(1<<v.z),v.y,v.z);d.setDepthMode(a.DepthMode.disabled),d.setStencilMode(a.StencilMode.disabled),d.setColorMode(l.colorModeForRenderPass()),l.setCustomLayerDefaults(),y.call(f,d.gl,E),d.setDirty(),l.setBaseState()}return}l.setCustomLayerDefaults(),d.setColorMode(l.colorModeForRenderPass()),d.setStencilMode(a.StencilMode.disabled);const g=f.renderingMode==="3d"?new a.DepthMode(l.context.gl.LEQUAL,a.DepthMode.ReadWrite,l.depthRangeFor3D):l.depthModeForSublayer(0,a.DepthMode.ReadOnly);if(d.setDepthMode(g),l.transform.projection.name==="globe"){const y=l.transform.pointMerc;f.render(d.gl,l.transform.customLayerMatrix(),l.transform.getProjection(),l.transform.globeToMercatorMatrix(),a.globeToMercatorTransition(l.transform.zoom),[y.x,y.y],l.transform.pixelsPerMeterRatio)}else f.render(d.gl,l.transform.customLayerMatrix());d.setDirty(),l.setBaseState(),d.bindFramebuffer.set(null)}}else a.warnOnce("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}};class so{constructor(r,o,h=!1){this.context=new Pe(r,h),this.transform=o,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=a.SourceCache.maxUnderzooming+a.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(r,o){const h=!!r&&!!r.terrain&&this.transform.projection.supportsTerrain;if(!(h||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Xa(this,r));const d=this._terrain;this.transform.elevation=h?d:null,d.update(r,this.transform,o)}_updateFog(r){const o=r.fog;if(!o||this.transform.projection.name==="globe"||o.getOpacity(this.transform.pitch)<1||o.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[h,d]=o.getFovAdjustedRange(this.transform._fov);if(h>d)return void(this.transform.fogCullDistSq=null);const f=h+.78*(d-h);this.transform.fogCullDistSq=f*f}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(r,o){if(this.width=r*a.exported.devicePixelRatio,this.height=o*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const h of this.style.order)this.style._layers[h].resize()}setup(){const r=this.context,o=new a.StructArrayLayout2i4;o.emplaceBack(0,0),o.emplaceBack(a.EXTENT,0),o.emplaceBack(0,a.EXTENT),o.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=r.createVertexBuffer(o,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout2i4;h.emplaceBack(0,0),h.emplaceBack(a.EXTENT,0),h.emplaceBack(0,a.EXTENT),h.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=r.createVertexBuffer(h,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const d=new a.StructArrayLayout2i4;d.emplaceBack(-1,-1),d.emplaceBack(1,-1),d.emplaceBack(-1,1),d.emplaceBack(1,1),this.viewportBuffer=r.createVertexBuffer(d,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=r.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const g=new a.StructArrayLayout3ui6;g.emplaceBack(0,1,2),g.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=r.createIndexBuffer(g);const y=new a.StructArrayLayout1ui2;for(const E of[0,1,3,2,0])y.emplaceBack(E);this.debugIndexBuffer=r.createIndexBuffer(y),this.emptyTexture=new a.Texture(r,new a.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),r.gl.RGBA),this.identityMat=a.create();const v=this.context.gl;this.stencilClearMode=new a.StencilMode({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO),this.loadTimeStamps.push(a.window.performance.now()),this.atmosphereBuffer=new Ac(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(r){return r._makeTileBoundsBuffers(this.context,this.transform.projection),r._tileBoundsBuffer?{tileBoundsBuffer:r._tileBoundsBuffer,tileBoundsIndexBuffer:r._tileBoundsIndexBuffer,tileBoundsSegments:r._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const r=this.context,o=r.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(r,o.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,$o(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(r,o,h){if(!o||this.currentStencilSource===o.id||!r.isTileClipped()||!h||h.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let y=!1;for(const v of h)if(this._tileClippingMaskIDs[v.key]===void 0){y=!0;break}if(!y)return}this.currentStencilSource=o.id;const d=this.context,f=d.gl;this.nextStencilID+h.length>256&&this.clearStencil(),d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const g=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const y of h){const v=o.getTile(y),E=this._tileClippingMaskIDs[y.key]=this.nextStencilID++,{tileBoundsBuffer:T,tileBoundsIndexBuffer:A,tileBoundsSegments:k}=this.getTileBoundsBuffers(v);g.draw(d,f.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:f.ALWAYS,mask:0},E,255,f.KEEP,f.KEEP,f.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,$o(y.projMatrix),"$clipping",T,A,k)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const r=this.nextStencilID++,o=this.context.gl;return new a.StencilMode({func:o.NOTEQUAL,mask:255},r,255,o.KEEP,o.KEEP,o.REPLACE)}stencilModeForClipping(r){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(r);const o=this.context.gl;return new a.StencilMode({func:o.EQUAL,mask:255},this._tileClippingMaskIDs[r.key],0,o.KEEP,o.KEEP,o.REPLACE)}stencilConfigForOverlap(r){const o=this.context.gl,h=r.sort((g,y)=>y.overscaledZ-g.overscaledZ),d=h[h.length-1].overscaledZ,f=h[0].overscaledZ-d+1;if(f>1){this.currentStencilSource=void 0,this.nextStencilID+f>256&&this.clearStencil();const g={};for(let y=0;y<f;y++)g[y+d]=new a.StencilMode({func:o.GEQUAL,mask:255},y+this.nextStencilID,255,o.KEEP,o.KEEP,o.REPLACE);return this.nextStencilID+=f,[g,h]}return[{[d]:a.StencilMode.disabled},h]}colorModeForRenderPass(){const r=this.context.gl;return this._showOverdrawInspector?new a.ColorMode([r.CONSTANT_COLOR,r.ONE],new a.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?a.ColorMode.unblended:a.ColorMode.alphaBlended}depthModeForSublayer(r,o,h){if(!this.opaquePassEnabledForLayer())return a.DepthMode.disabled;const d=1-((1+this.currentLayer)*this.numSublayers+r)*this.depthEpsilon;return new a.DepthMode(h||this.context.gl.LEQUAL,o,[d,d])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(r,o){this.style=r,this.options=o,this.imageManager=r.imageManager,this.glyphManager=r.glyphManager,this.symbolFadeChange=r.placement.symbolFadeChange(a.exported.now()),this.imageManager.beginFrame();const h=this.style.order,d=this.style._sourceCaches;for(const E in d){const T=d[E];T.used&&T.prepare(this.context)}const f={},g={},y={};for(const E in d){const T=d[E];f[E]=T.getVisibleCoordinates(),g[E]=f[E].slice().reverse(),y[E]=T.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let E=0;E<h.length;E++)if(this.style._layers[h[E]].is3D()){this.opaquePassCutoff=E;break}if(this.terrain&&(this.terrain.updateTileBinding(y),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new a.GlobeSharedBuffers(this.context)),!a.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const E of h){const T=this.style._layers[E],A=r._getLayerSourceCache(T);if(!T.hasOffscreenPass()||T.isHidden(this.transform.zoom))continue;const k=A?g[A.id]:void 0;(T.type==="custom"||T.isSky()||k&&k.length)&&this.renderLayer(this,A,T,k)}this.depthRangeFor3D=[0,1-(r.order.length+2)*this.numSublayers*this.depthEpsilon];const v=this.terrain;if(v&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&v.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:o.showOverdrawInspector?a.Color.black:a.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=o.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=h.length-1;this.currentLayer>=0;this.currentLayer--){const E=this.style._layers[h[this.currentLayer]],T=r._getLayerSourceCache(E);if(E.isSky())continue;const A=T?g[T.id]:void 0;this._renderTileClippingMasks(E,T,A),this.renderLayer(this,T,E,A)}if(this.style.fog&&this.transform.projection.supportsFog&&function(E,T){const A=E.context,k=A.gl,R=E.transform,O=new a.DepthMode(k.LEQUAL,a.DepthMode.ReadOnly,[0,1]),B=E.useProgram("globeAtmosphere",null,R.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),F=a.globeToMercatorTransition(R.zoom),I=T.properties.get("color").toArray01(),L=T.properties.get("high-color").toArray01(),N=T.properties.get("space-color").toArray01PremultipliedAlpha(),j=a.identity$1([]);a.rotateY$1(j,j,-a.degToRad(R._center.lng)),a.rotateX$1(j,j,a.degToRad(R._center.lat)),a.rotateZ$1(j,j,R.angle),a.rotateX$1(j,j,-R._pitch);const K=a.fromQuat(new Float32Array(16),j),J=a.mapValue(T.properties.get("star-intensity"),0,1,0,.25),Y=5e-4,ie=a.mapValue(T.properties.get("horizon-blend"),0,1,Y,.25),te=a.globeUseCustomAntiAliasing(E,A,R)&&ie===Y?R.worldSize/(2*Math.PI*1.025)-1:R.globeRadius,le=E.frameCounter/1e3%1,Ee=a.length(R.globeCenterInViewSpace),oe=Math.sqrt(Math.pow(Ee,2)-Math.pow(te,2)),ge=Math.acos(oe/Ee),he=((ae,_e,Me,be,Ae,Ge,He,Ve,qe,ht,at,je,Et,Mt)=>({u_frustum_tl:ae,u_frustum_tr:_e,u_frustum_br:Me,u_frustum_bl:be,u_horizon:Ae,u_transition:Ge,u_fadeout_range:He,u_color:Ve,u_high_color:qe,u_space_color:ht,u_star_intensity:at,u_star_size:5*a.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:je,u_horizon_angle:Et,u_rotation_matrix:Mt}))(R.frustumCorners.TL,R.frustumCorners.TR,R.frustumCorners.BR,R.frustumCorners.BL,R.frustumCorners.horizon,F,ie,I,L,N,J,le,ge,K);E.prepareDrawProgram(A,B);const Te=E.atmosphereBuffer;Te&&B.draw(A,k.TRIANGLES,O,a.StencilMode.disabled,a.ColorMode.alphaBlended,a.CullFaceMode.backCW,he,"skybox",Te.vertexBuffer,Te.indexBuffer,Te.segments)}(this,this.style.fog),this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<h.length;this.currentLayer++){const E=this.style._layers[h[this.currentLayer]],T=r._getLayerSourceCache(E);E.isSky()&&this.renderLayer(this,T,E,T?g[T.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<h.length;){const E=this.style._layers[h[this.currentLayer]],T=r._getLayerSourceCache(E);if(E.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(E)){if(E.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const A=T?(E.type==="symbol"?y:g)[T.id]:void 0;this._renderTileClippingMasks(E,T,T?f[T.id]:void 0),this.renderLayer(this,T,E,A),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let E=null;a.values(this.style._layers).forEach(T=>{const A=r._getLayerSourceCache(T);A&&!T.isHidden(this.transform.zoom)&&(!E||E.getSource().maxzoom<A.getSource().maxzoom)&&(E=A)}),E&&this.options.showTileBoundaries&&Mn.debug(this,E,E.getVisibleCoordinates())}this.options.showPadding&&function(E){const T=E.transform.padding;Ec(E,E.transform.height-(T.top||0),3,no),Ec(E,T.bottom||0,3,Nh),js(E,T.left||0,3,jh),js(E,E.transform.width-(T.right||0),3,Gh);const A=E.transform.centerPoint;(function(k,R,O,B){oo(k,R-1,O-10,2,20,B),oo(k,R-10,O-1,20,2,B)})(E,A.x,E.transform.height-A.y,$h)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(a.window.performance.now()),this.saveCanvasCopy())}renderLayer(r,o,h,d){h.isHidden(this.transform.zoom)||(h.type==="background"||h.type==="sky"||h.type==="custom"||d&&d.length)&&(this.id=h.id,this.gpuTimingStart(h),(!r.transform.projection.unsupportedLayers||!r.transform.projection.unsupportedLayers.includes(h.type)||r.terrain&&h.type==="custom")&&Mn[h.type](r,o,h,d,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(r){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery;let h=this.gpuTimers[r.id];h||(h=this.gpuTimers[r.id]={calls:0,cpuTime:0,query:o.createQueryEXT()}),h.calls++,o.beginQueryEXT(o.TIME_ELAPSED_EXT,h.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const r=this.context.extTimerQuery,o=r.createQueryEXT();this.deferredRenderGpuTimeQueries.push(o),r.beginQueryEXT(r.TIME_ELAPSED_EXT,o)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const r=this.context.extTimerQuery;r.endQueryEXT(r.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const r=this.context.extTimerQuery;r.endQueryEXT(r.TIME_ELAPSED_EXT)}collectGpuTimers(){const r=this.gpuTimers;return this.gpuTimers={},r}collectDeferredRenderGpuQueries(){const r=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],r}queryGpuTimers(r){const o={};for(const h in r){const d=r[h],f=this.context.extTimerQuery,g=f.getQueryObjectEXT(d.query,f.QUERY_RESULT_EXT)/1e6;f.deleteQueryEXT(d.query),o[h]=g}return o}queryGpuTimeDeferredRender(r){if(!this.options.gpuTimingDeferredRender)return 0;const o=this.context.extTimerQuery;let h=0;for(const d of r)h+=o.getQueryObjectEXT(d,o.QUERY_RESULT_EXT)/1e6,o.deleteQueryEXT(d);return h}translatePosMatrix(r,o,h,d,f){if(!h[0]&&!h[1])return r;const g=f?d==="map"?this.transform.angle:0:d==="viewport"?-this.transform.angle:0;if(g){const E=Math.sin(g),T=Math.cos(g);h=[h[0]*T-h[1]*E,h[0]*E+h[1]*T]}const y=[f?h[0]:mi(o,h[0],this.transform.zoom),f?h[1]:mi(o,h[1],this.transform.zoom),0],v=new Float32Array(16);return a.translate(v,r,y),v}saveTileTexture(r){const o=this._tileTextures[r.size[0]];o?o.push(r):this._tileTextures[r.size[0]]=[r]}getTileTexture(r){const o=this._tileTextures[r];return o&&o.length>0?o.pop():null}isPatternMissing(r){return r===null||r!==void 0&&!this.imageManager.getPattern(r.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const r=this.terrain&&this.terrain.renderingToTexture,o=this.terrain&&this.terrain.exaggeration()===0,h=this.style&&this.style.fog,d=[];return this.terrainRenderModeElevated()&&d.push("TERRAIN"),this.transform.projection.name==="globe"&&d.push("GLOBE"),o&&d.push("ZERO_EXAGGERATION"),h&&!r&&h.getOpacity(this.transform.pitch)!==0&&d.push("FOG"),r&&d.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&d.push("OVERDRAW_INSPECTOR"),d}useProgram(r,o,h){this.cache=this.cache||{};const d=h||[],f=this.currentGlobalDefines().concat(d),g=gt.cacheKey(ja[r],r,f,o);return this.cache[g]||(this.cache[g]=new gt(this.context,r,ja[r],o,nl[r],f)),this.cache[g]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const r=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(r.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(r,o,h){if(this.terrain&&this.terrain.renderingToTexture)return;const d=this.style.fog;if(d){const f=d.getOpacity(this.transform.pitch),g=((y,v,E,T,A,k,R,O,B,F,I)=>{const L=y.transform,N=v.properties.get("color").toArray01();N[3]=T;const j=y.frameCounter/1e3%1;return{u_fog_matrix:E?L.calculateFogTileMatrix(E):y.identityMat,u_fog_range:v.getFovAdjustedRange(L._fov),u_fog_color:N,u_fog_horizon_blend:v.properties.get("horizon-blend"),u_fog_temporal_offset:j,u_frustum_tl:A,u_frustum_tr:k,u_frustum_br:R,u_frustum_bl:O,u_globe_pos:B,u_globe_radius:F,u_viewport:I,u_globe_transition:a.globeToMercatorTransition(L.zoom),u_is_globe:+(L.projection.name==="globe")}})(this,d,h,f,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*a.exported.devicePixelRatio,this.transform.height*a.exported.devicePixelRatio]);o.setFogUniformValues(r,g)}}setTileLoadedFlag(r){this.tileLoaded=r}saveCanvasCopy(){const r=this.canvasCopy();r&&(this.frameCopies.push(r),this.tileLoaded=!1)}canvasCopy(){const r=this.context.gl,o=r.createTexture();return r.bindTexture(r.TEXTURE_2D,o),r.copyTexImage2D(r.TEXTURE_2D,0,r.RGBA,0,0,r.drawingBufferWidth,r.drawingBufferHeight,0),o}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const r=this.style&&this.style.fog;return!!r&&r.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const r=this._backgroundTiles,o=this._backgroundTiles={},h=this.transform.coveringTiles({tileSize:512});for(const d of h)o[d.key]=r[d.key]||new a.Tile(d,512,this.transform.tileZoom,this);return o}clearBackgroundTiles(){this._backgroundTiles={}}}class $s{constructor(r=0,o=0,h=0,d=0){if(isNaN(r)||r<0||isNaN(o)||o<0||isNaN(h)||h<0||isNaN(d)||d<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=r,this.bottom=o,this.left=h,this.right=d}interpolate(r,o,h){return o.top!=null&&r.top!=null&&(this.top=a.number(r.top,o.top,h)),o.bottom!=null&&r.bottom!=null&&(this.bottom=a.number(r.bottom,o.bottom,h)),o.left!=null&&r.left!=null&&(this.left=a.number(r.left,o.left,h)),o.right!=null&&r.right!=null&&(this.right=a.number(r.right,o.right,h)),this}getCenter(r,o){const h=a.clamp((this.left+r-this.right)/2,0,r),d=a.clamp((this.top+o-this.bottom)/2,0,o);return new a.Point(h,d)}equals(r){return this.top===r.top&&this.bottom===r.bottom&&this.left===r.left&&this.right===r.right}clone(){return new $s(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Zs(l,r){const o=a.getColumn(l,3);a.fromQuat(l,r),a.setColumn(l,3,o)}function yt(l,r){const o=a.identity$1([]);return a.rotateZ$1(o,o,-r),a.rotateX$1(o,o,-l),o}function Yo(l,r){const o=[l[0],l[1],0],h=[r[0],r[1],0];if(a.length(o)>=1e-15){const g=a.normalize([],o);a.scale$2(h,g,a.dot(h,g)),r[0]=h[0],r[1]=h[1]}const d=a.cross([],r,l);if(a.len(d)<1e-15)return null;const f=Math.atan2(-d[1],d[0]);return yt(Math.atan2(Math.sqrt(l[0]*l[0]+l[1]*l[1]),-l[2]),f)}class Ic{constructor(r,o){this.position=r,this.orientation=o}get position(){return this._position}set position(r){if(r){const o=r instanceof a.MercatorCoordinate?r:new a.MercatorCoordinate(r[0],r[1],r[2]);this._renderWorldCopies&&(o.x=a.wrap(o.x,0,1)),this._position=o}else this._position=null}lookAtPoint(r,o){if(this.orientation=null,!this.position)return;const h=this.position,d=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(r)):0,f=a.MercatorCoordinate.fromLngLat(r,d),g=[f.x-h.x,f.y-h.y,f.z-h.z];o||(o=[0,0,1]),o[2]=Math.abs(o[2]),this.orientation=Yo(g,o)}setPitchBearing(r,o){this.orientation=yt(a.degToRad(r),a.degToRad(-o))}}class qs{constructor(r,o){this._transform=a.identity([]),this.orientation=o,this.position=r}get mercatorPosition(){const r=this.position;return new a.MercatorCoordinate(r[0],r[1],r[2])}get position(){const r=a.getColumn(this._transform,3);return[r[0],r[1],r[2]]}set position(r){var o;r&&a.setColumn(this._transform,3,[(o=r)[0],o[1],o[2],1])}get orientation(){return this._orientation}set orientation(r){this._orientation=r||a.identity$1([]),r&&Zs(this._transform,this._orientation)}getPitchBearing(){const r=this.forward(),o=this.right();return{bearing:Math.atan2(-o[1],o[0]),pitch:Math.atan2(Math.sqrt(r[0]*r[0]+r[1]*r[1]),-r[2])}}setPitchBearing(r,o){this._orientation=yt(r,o),Zs(this._transform,this._orientation)}forward(){const r=a.getColumn(this._transform,2);return[-r[0],-r[1],-r[2]]}up(){const r=a.getColumn(this._transform,1);return[-r[0],-r[1],-r[2]]}right(){const r=a.getColumn(this._transform,0);return[r[0],r[1],r[2]]}getCameraToWorld(r,o){const h=new Float64Array(16);return a.invert(h,this.getWorldToCamera(r,o)),h}getWorldToCameraPosition(r,o,h){const d=this.position;a.scale$2(d,d,-r);const f=new Float64Array(16);return a.fromScaling(f,[h,h,h]),a.translate(f,f,d),f[10]*=o,f}getWorldToCamera(r,o){const h=new Float64Array(16),d=new Float64Array(4),f=this.position;return a.conjugate(d,this._orientation),a.scale$2(f,f,-r),a.fromQuat(h,d),a.translate(h,h,f),h[1]*=-1,h[5]*=-1,h[9]*=-1,h[13]*=-1,h[8]*=o,h[9]*=o,h[10]*=o,h[11]*=o,h}getCameraToClipPerspective(r,o,h,d){const f=new Float64Array(16);return a.perspective(f,r,o,h,d),f}getDistanceToElevation(r,o=!1){const h=r===0?0:a.mercatorZfromAltitude(r,o?a.latFromMercatorY(this.position[1]):this.position[1]),d=this.forward();return(h-this.position[2])/d[2]}clone(){return new qs([...this.position],[...this.orientation])}}function ao(l,r){const o=Ws(l.projection,l.zoom,l.width,l.height),h=function(f,g,y,v,E){const T=new a.LngLat(y.lng-180*Fr,y.lat),A=new a.LngLat(y.lng+180*Fr,y.lat),k=f.project(T.lng,T.lat),R=f.project(A.lng,A.lat),O=-Math.atan2(R.y-k.y,R.x-k.x),B=a.MercatorCoordinate.fromLngLat(y);B.y=a.clamp(B.y,-1+Fr,1-Fr);const F=B.toLngLat(),I=f.project(F.lng,F.lat),L=a.MercatorCoordinate.fromLngLat(F);L.x+=Fr;const N=L.toLngLat(),j=f.project(N.lng,N.lat),K=Xs(j.x-I.x,j.y-I.y,O),J=a.MercatorCoordinate.fromLngLat(F);J.y+=Fr;const Y=J.toLngLat(),ie=f.project(Y.lng,Y.lat),te=Xs(ie.x-I.x,ie.y-I.y,O),le=Math.abs(K.x)/Math.abs(te.y),Ee=a.identity([]);a.rotateZ(Ee,Ee,-O*(1-(E?0:v)));const oe=a.identity([]);return a.scale(oe,oe,[1,1-(1-le)*v,1]),oe[4]=-te.x/te.y*v,a.rotateZ(oe,oe,O),a.multiply(oe,Ee,oe),oe}(l.projection,0,l.center,o,r),d=Cc(l);return a.scale(h,h,[d,d,1]),h}function Cc(l){const r=l.projection,o=Ws(l.projection,l.zoom,l.width,l.height),h=zc(r,l.center),d=zc(r,a.LngLat.convert(r.center));return Math.pow(2,h*o+(1-o)*d)}function Ws(l,r,o,h,d=1/0){const f=l.range;if(!f)return 0;const g=Math.min(d,Math.max(o,h)),y=Math.log(g/1024)/Math.LN2;return a.smoothstep(f[0]+y,f[1]+y,r)}const Fr=1/4e4;function zc(l,r){const o=a.clamp(r.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=new a.LngLat(r.lng-180*Fr,o),d=new a.LngLat(r.lng+180*Fr,o),f=l.project(h.lng,o),g=l.project(d.lng,o),y=a.MercatorCoordinate.fromLngLat(h),v=a.MercatorCoordinate.fromLngLat(d),E=g.x-f.x,T=g.y-f.y,A=v.x-y.x,k=v.y-y.y,R=Math.sqrt((A*A+k*k)/(E*E+T*T));return Math.log(R)/Math.LN2}function Xs(l,r,o){const h=Math.cos(o),d=Math.sin(o);return{x:l*h-r*d,y:l*d+r*h}}class lo{constructor(r,o,h,d,f,g,y){this.tileSize=512,this._renderWorldCopies=f===void 0||f,this._minZoom=r||0,this._maxZoom=o||22,this._minPitch=h??0,this._maxPitch=d??60,this.setProjection(g),this.setMaxBounds(y),this.width=0,this.height=0,this._center=new a.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new $s,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new qs,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const r=new lo(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return r._elevation=this._elevation,r._centerAltitude=this._centerAltitude,r._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,r.tileSize=this.tileSize,r.mercatorFromTransition=this.mercatorFromTransition,r.width=this.width,r.height=this.height,r.cameraElevationReference=this.cameraElevationReference,r._center=this._center,r._setZoom(this.zoom),r._seaLevelZoom=this._seaLevelZoom,r.angle=this.angle,r._fov=this._fov,r._pitch=this._pitch,r._nearZ=this._nearZ,r._farZ=this._farZ,r._averageElevation=this._averageElevation,r._unmodified=this._unmodified,r._edgeInsets=this._edgeInsets.clone(),r._camera=this._camera.clone(),r._calcMatrices(),r.freezeTileCoverage=this.freezeTileCoverage,r.frustumCorners=this.frustumCorners,r}get elevation(){return this._elevation}set elevation(r){this._elevation!==r&&(this._elevation=r,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(r,o=!1){const h=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||h)&&this._updateCameraOnTerrain(),(r||h)&&this._constrainCamera(o),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels"])}setProjection(r){this.projectionOptions=r||{name:"mercator"};const o=this.projection?this.getProjection():void 0;this.projection=a.getProjection(this.projectionOptions);const h=!ve(o,this.getProjection());return h&&this._calcMatrices(),this.mercatorFromTransition=!1,h}setMercatorFromTransition(){const r=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=a.getProjection({name:"mercator"});const o=r!==this.projection.name;return o&&this._calcMatrices(),o}get minZoom(){return this._minZoom}set minZoom(r){this._minZoom!==r&&(this._minZoom=r,this.zoom=Math.max(this.zoom,r))}get maxZoom(){return this._maxZoom}set maxZoom(r){this._maxZoom!==r&&(this._maxZoom=r,this.zoom=Math.min(this.zoom,r))}get minPitch(){return this._minPitch}set minPitch(r){this._minPitch!==r&&(this._minPitch=r,this.pitch=Math.max(this.pitch,r))}get maxPitch(){return this._maxPitch}set maxPitch(r){this._maxPitch!==r&&(this._maxPitch=r,this.pitch=Math.min(this.pitch,r))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(r){r===void 0?r=!0:r===null&&(r=!1),this._renderWorldCopies=r}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get cameraWorldSize(){const r=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(r))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return a.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new a.Point(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(r){this.rotation=r}get rotation(){return-this.angle/Math.PI*180}set rotation(r){const o=-r*Math.PI/180;var h;this.angle!==o&&(this._unmodified=!1,this.angle=o,this._calcMatrices(),this.rotationMatrix=(h=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(h[1]=0,h[2]=0),h[0]=1,h[3]=1,h),function(d,f,g){var y=f[0],v=f[1],E=f[2],T=f[3],A=Math.sin(g),k=Math.cos(g);d[0]=y*k+E*A,d[1]=v*k+T*A,d[2]=y*-A+E*k,d[3]=v*-A+T*k}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(r){const o=a.clamp(r,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==o&&(this._unmodified=!1,this._pitch=o,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const r=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/r)}set fov(r){r=Math.max(.01,Math.min(60,r)),this._fov!==r&&(this._unmodified=!1,this._fov=a.degToRad(r),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(r){this._averageElevation=r,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(r){const o=Math.min(Math.max(r,this.minZoom),this.maxZoom);this._zoom!==o&&(this._unmodified=!1,this._setZoom(o),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(r){this._zoom=r,this.scale=this.zoomScale(r),this.tileZoom=Math.floor(r),this.zoomFraction=r-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const r=this._elevation;this._centerAltitude=r.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=r.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const r=this._elevation,o=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],h=this.horizonLineFromTop();let d=0,f=0;for(let g=0;g<o.length;g++){const y=new a.Point(o[g][0]*this.width,h+o[g][1]*(this.height-h)),v=r.pointCoordinate(y);if(!v)continue;const E=1/Math.hypot(v[0]-this._camera.position[0],v[1]-this._camera.position[1]);d+=v[3]*E,f+=E}return f===0?NaN:d/f}get center(){return this._center}set center(r){r.lat===this._center.lat&&r.lng===this._center.lng||(this._unmodified=!1,this._center=r,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const r=this._seaLevelZoom,o=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),h=this.pixelsPerMeter/this.worldSize*o,d=this._mercatorZfromZoom(r),f=this._mercatorZfromZoom(this._maxZoom),g=Math.max(d-h,f);this._setZoom(this._zoomFromMercatorZ(g))}get padding(){return this._edgeInsets.toJSON()}set padding(r){this._edgeInsets.equals(r)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,r,1),this._calcMatrices())}computeZoomRelativeTo(r){const o=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,r.toAltitude()));let h;h=r.z<this._camera.position[2]?[o.x,o.y,o.z]:[r.x,r.y,r.z];const d=a.length(a.sub([],this._camera.position,h));return a.clamp(this._zoomFromMercatorZ(d),this._minZoom,this._maxZoom)}setFreeCameraOptions(r){if(!this.height||!r.position&&!r.orientation)return;this._updateCameraState();let o=!1;if(r.orientation&&!a.exactEquals(r.orientation,this._camera.orientation)&&(o=this._setCameraOrientation(r.orientation)),r.position){const h=[r.position.x,r.position.y,r.position.z];a.exactEquals$1(h,this._camera.position)||(this._setCameraPosition(h),o=!0)}o&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const r=this._camera.position,o=new Ic;return o.position=new a.MercatorCoordinate(r[0],r[1],r[2]),o.orientation=this._camera.orientation,o._elevation=this.elevation,o._renderWorldCopies=this.renderWorldCopies,o}_setCameraOrientation(r){if(!a.length$1(r))return!1;a.normalize$1(r,r);const o=a.transformQuat([],[0,0,-1],r),h=a.transformQuat([],[0,-1,0],r);if(h[2]<0)return!1;const d=Yo(o,h);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(r){const o=this.zoomScale(this.minZoom)*this.tileSize,h=this.zoomScale(this.maxZoom)*this.tileSize,d=this.cameraToCenterDistance;r[2]=a.clamp(r[2],d/h,d/o),this._camera.position=r}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(r){return this._edgeInsets.equals(r)}interpolatePadding(r,o,h){this._unmodified=!1,this._edgeInsets.interpolate(r,o,h),this._constrain(),this._calcMatrices()}coveringZoomLevel(r){const o=(r.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/r.tileSize));return Math.max(0,o)}getVisibleUnwrappedCoordinates(r){const o=[new a.UnwrappedTileID(0,r)];if(this.renderWorldCopies){const h=this.pointCoordinate(new a.Point(0,0)),d=this.pointCoordinate(new a.Point(this.width,0)),f=this.pointCoordinate(new a.Point(this.width,this.height)),g=this.pointCoordinate(new a.Point(0,this.height)),y=Math.floor(Math.min(h.x,d.x,f.x,g.x)),v=Math.floor(Math.max(h.x,d.x,f.x,g.x)),E=1;for(let T=y-E;T<=v+E;T++)T!==0&&o.push(new a.UnwrappedTileID(T,r))}return o}coveringTiles(r){let o=this.coveringZoomLevel(r);const h=o,d=this.elevation&&!r.isTerrainDEM,f=this.projection.name==="mercator";if(r.minzoom!==void 0&&o<r.minzoom)return[];r.maxzoom!==void 0&&o>r.maxzoom&&(o=r.maxzoom);const g=this.locationCoordinate(this.center),y=this.center.lat,v=1<<o,E=[v*g.x,v*g.y,0],T=this.projection.name==="globe",A=!T,k=a.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,o,A),R=T?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),O=v*a.mercatorZfromAltitude(1,this.center.lat),B=this._camera.position[2]/a.mercatorZfromAltitude(1,this.center.lat),F=[v*R.x,v*R.y,B*(A?1:O)],I=this.cameraToCenterDistance/r.tileSize*(r.roundZoom?1:.502),L=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?o:0,N=r.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,j=r.isTerrainDEM?-N:this._elevation?this._elevation.getMinElevationBelowMSL():0,K=this.projection.isReprojectedInTileSpace?Cc(this):1,J=ae=>{const Me=new a.MercatorCoordinate(ae.x+25e-6,ae.y,ae.z),be=new a.MercatorCoordinate(ae.x,ae.y+25e-6,ae.z),Ae=ae.toLngLat(),Ge=Me.toLngLat(),He=be.toLngLat(),Ve=this.locationCoordinate(Ae),qe=this.locationCoordinate(Ge),ht=this.locationCoordinate(He),at=Math.hypot(qe.x-Ve.x,qe.y-Ve.y),je=Math.hypot(ht.x-Ve.x,ht.y-Ve.y);return Math.sqrt(at*je)*K/25e-6},Y=ae=>{const _e=N,Me=j;return{aabb:a.tileAABB(this,v,0,0,0,ae,Me,_e,this.projection),zoom:0,x:0,y:0,minZ:Me,maxZ:_e,wrap:ae,fullyVisible:!1}},ie=[];let te=[];const le=o,Ee=r.reparseOverscaled?h:o,oe=ae=>ae*ae,ge=oe((B-this._centerAltitude)*O),he=ae=>{if(!this._elevation||!ae.tileID||!f)return;const _e=this._elevation.getMinMaxForTile(ae.tileID),Me=ae.aabb;_e?(Me.min[2]=_e.min,Me.max[2]=_e.max,Me.center[2]=(Me.min[2]+Me.max[2])/2):(ae.shouldSplit=Te(ae),ae.shouldSplit||(Me.min[2]=Me.max[2]=Me.center[2]=this._centerAltitude))},Te=ae=>{if(ae.zoom<L)return!0;if(ae.zoom===le)return!1;if(ae.shouldSplit!=null)return ae.shouldSplit;const _e=ae.aabb.distanceX(F),Me=ae.aabb.distanceY(F);let be=ge,Ae=1;if(T){be=oe(ae.aabb.distanceZ(F));const Ve=Math.pow(2,ae.zoom),qe=a.latFromMercatorY((ae.y+1)/Ve),ht=a.latFromMercatorY(ae.y/Ve),at=Math.min(Math.max(y,qe),ht),je=a.circumferenceAtLatitude(at)/a.circumferenceAtLatitude(y);if(Ae=at===y?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,je/this._mercatorScaleRatio),this.zoom<=a.GLOBE_ZOOM_THRESHOLD_MIN&&ae.zoom===le-1&&je>=.9)return!0}else if(d&&(be=oe(ae.aabb.distanceZ(F)*O)),this.projection.isReprojectedInTileSpace&&h<=5){const Ve=Math.pow(2,ae.zoom),qe=J(new a.MercatorCoordinate((ae.x+.5)/Ve,(ae.y+.5)/Ve));Ae=qe>.85?1:qe}const Ge=_e*_e+Me*Me+be,He=oe((1<<le-ae.zoom)*I*Ae*((Ve,qe)=>{if(qe*oe(.707)<Ve)return 1;const ht=Math.sqrt(qe/Ve);return ht/(1.4144271570014144+(Math.pow(1.1,ht-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(be,ge),Ge));return Ge<He};if(this.renderWorldCopies)for(let ae=1;ae<=3;ae++)ie.push(Y(-ae)),ie.push(Y(ae));for(ie.push(Y(0));ie.length>0;){const ae=ie.pop(),_e=ae.x,Me=ae.y;let be=ae.fullyVisible;if(!be){const Ae=ae.aabb.intersects(k);if(Ae===0)continue;be=Ae===2}if(ae.zoom!==le&&Te(ae))for(let Ae=0;Ae<4;Ae++){const Ge=(_e<<1)+Ae%2,He=(Me<<1)+(Ae>>1),Ve={aabb:f?ae.aabb.quadrant(Ae):a.tileAABB(this,v,ae.zoom+1,Ge,He,ae.wrap,ae.minZ,ae.maxZ,this.projection),zoom:ae.zoom+1,x:Ge,y:He,wrap:ae.wrap,fullyVisible:be,tileID:void 0,shouldSplit:void 0,minZ:ae.minZ,maxZ:ae.maxZ};d&&!T&&(Ve.tileID=new a.OverscaledTileID(ae.zoom+1===le?Ee:ae.zoom+1,ae.wrap,ae.zoom+1,Ge,He),he(Ve)),ie.push(Ve)}else{const Ae=ae.zoom===le?Ee:ae.zoom;if(r.minzoom&&r.minzoom>Ae)continue;const Ge=E[0]-(.5+_e+(ae.wrap<<ae.zoom))*(1<<o-ae.zoom),He=E[1]-.5-Me,Ve=ae.tileID?ae.tileID:new a.OverscaledTileID(Ae,ae.wrap,ae.zoom,_e,Me);te.push({tileID:Ve,distanceSq:Ge*Ge+He*He})}}if(this.fogCullDistSq){const ae=this.fogCullDistSq,_e=this.horizonLineFromTop();te=te.filter(Me=>{const be=[0,0,0,1],Ae=[a.EXTENT,a.EXTENT,0,1],Ge=this.calculateFogTileMatrix(Me.tileID.toUnwrapped());a.transformMat4$1(be,be,Ge),a.transformMat4$1(Ae,Ae,Ge);const He=a.getAABBPointSquareDist(be,Ae);if(He===0)return!0;let Ve=!1;const qe=this._elevation;if(qe&&He>ae&&_e!==0){const ht=this.calculateProjMatrix(Me.tileID.toUnwrapped());let at;r.isTerrainDEM||(at=qe.getMinMaxForTile(Me.tileID)),at||(at={min:j,max:N});const je=a.furthestTileCorner(this.rotation),Et=[je[0]*a.EXTENT,je[1]*a.EXTENT,at.max];a.transformMat4(Et,Et,ht),Ve=(1-Et[1])*this.height*.5<_e}return He<ae||Ve})}return te.sort((ae,_e)=>ae.distanceSq-_e.distanceSq).map(ae=>ae.tileID)}resize(r,o){this.width=r,this.height=o,this.pixelsToGLUnits=[2/r,-2/o],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(r){return Math.pow(2,r)}scaleZoom(r){return Math.log(r)/Math.LN2}project(r){const o=a.clamp(r.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),h=this.projection.project(r.lng,o);return new a.Point(h.x*this.worldSize,h.y*this.worldSize)}unproject(r){return this.projection.unproject(r.x/this.worldSize,r.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/a.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(r,o){let h,d;const f=this.centerPoint;if(this.projection.name==="globe"){const y=this.worldSize;h=(o.x-f.x)/y,d=(o.y-f.y)/y}else{const y=this.pointCoordinate(o),v=this.pointCoordinate(f);h=y.x-v.x,d=y.y-v.y}const g=this.locationCoordinate(r);this.setLocation(new a.MercatorCoordinate(g.x-h,g.y-d))}setLocation(r){this.center=this.coordinateLocation(r),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(r){return this.projection.locationPoint(this,r)}locationPoint3D(r){return this.projection.locationPoint(this,r,!0)}pointLocation(r){return this.coordinateLocation(this.pointCoordinate(r))}pointLocation3D(r){return this.coordinateLocation(this.pointCoordinate3D(r))}locationCoordinate(r,o){const h=o?a.mercatorZfromAltitude(o,r.lat):void 0,d=this.projection.project(r.lng,r.lat);return new a.MercatorCoordinate(d.x,d.y,h)}coordinateLocation(r){return this.projection.unproject(r.x,r.y)}pointRayIntersection(r,o){const h=o??this._centerAltitude,d=[r.x,r.y,0,1],f=[r.x,r.y,1,1];a.transformMat4$1(d,d,this.pixelMatrixInverse),a.transformMat4$1(f,f,this.pixelMatrixInverse);const g=f[3];a.scale$1(d,d,1/d[3]),a.scale$1(f,f,1/g);const y=d[2],v=f[2];return{p0:d,p1:f,t:y===v?0:(h-y)/(v-y)}}screenPointToMercatorRay(r){const o=[r.x,r.y,0,1],h=[r.x,r.y,1,1];return a.transformMat4$1(o,o,this.pixelMatrixInverse),a.transformMat4$1(h,h,this.pixelMatrixInverse),a.scale$1(o,o,1/o[3]),a.scale$1(h,h,1/h[3]),o[2]=a.mercatorZfromAltitude(o[2],this._center.lat)*this.worldSize,h[2]=a.mercatorZfromAltitude(h[2],this._center.lat)*this.worldSize,a.scale$1(o,o,1/this.worldSize),a.scale$1(h,h,1/this.worldSize),new a.Ray([o[0],o[1],o[2]],a.normalize([],a.sub([],h,o)))}rayIntersectionCoordinate(r){const{p0:o,p1:h,t:d}=r,f=a.mercatorZfromAltitude(o[2],this._center.lat),g=a.mercatorZfromAltitude(h[2],this._center.lat);return new a.MercatorCoordinate(a.number(o[0],h[0],d)/this.worldSize,a.number(o[1],h[1],d)/this.worldSize,a.number(f,g,d))}pointCoordinate(r,o=this._centerAltitude){return this.projection.pointCoordinate(this,r.x,r.y,o)}pointCoordinate3D(r){if(!this.elevation)return this.pointCoordinate(r);let o=this.projection.pointCoordinate3D(this,r.x,r.y);if(o)return new a.MercatorCoordinate(o[0],o[1],o[2]);let h=0,d=this.horizonLineFromTop();if(r.y>d)return this.pointCoordinate(r);const f=.02*d,g=r.clone();for(let y=0;y<10&&d-h>f;y++){g.y=a.number(h,d,.66);const v=this.projection.pointCoordinate3D(this,g.x,g.y);v?(d=g.y,o=v):h=g.y}return o?new a.MercatorCoordinate(o[0],o[1],o[2]):this.pointCoordinate(r)}isPointAboveHorizon(r){return this.projection.isPointAboveHorizon(this,r)}isPointOnSurface(r){if(r.y<0||r.y>this.height||r.x<0||r.x>this.width)return!1;if(this.elevation||this.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(r);const o=this.pointCoordinate(r);return o.y>=0&&o.y<=1}_coordinatePoint(r,o){const h=o&&this.elevation?this.elevation.getAtPointOrZero(r,this._centerAltitude):this._centerAltitude,d=[r.x*this.worldSize,r.y*this.worldSize,h+r.toAltitude(),1];return a.transformMat4$1(d,d,this.pixelMatrix),d[3]>0?new a.Point(d[0]/d[3],d[1]/d[3]):new a.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:r,left:o}=this._edgeInsets,h=this.height-this._edgeInsets.bottom,d=this.width-this._edgeInsets.right,f=this.pointLocation3D(new a.Point(o,r)),g=this.pointLocation3D(new a.Point(d,r)),y=this.pointLocation3D(new a.Point(d,h)),v=this.pointLocation3D(new a.Point(o,h));let E=Math.min(f.lng,g.lng,y.lng,v.lng),T=Math.max(f.lng,g.lng,y.lng,v.lng),A=Math.min(f.lat,g.lat,y.lat,v.lat),k=Math.max(f.lat,g.lat,y.lat,v.lat);const R=Math.pow(2,-this.zoom)/16*270,O=this.projection.name==="globe"?1:4,B=(F,I,L,N,j)=>{const K=(F+L)/2,J=(I+N)/2,Y=new a.Point(K,J),{lng:ie,lat:te}=this.pointLocation3D(Y),le=Math.max(0,E-ie,A-te,ie-T,te-k);E=Math.min(E,ie),T=Math.max(T,ie),A=Math.min(A,te),k=Math.max(k,te),(j<O||le>R)&&(B(F,I,K,J,j+1),B(K,J,L,N,j+1))};if(B(o,r,d,r,1),B(d,r,d,h,1),B(d,h,o,h,1),B(o,h,o,r,1),this.projection.name==="globe"){const[F,I]=a.polesInViewport(this);F?(k=90,T=180,E=-180):I&&(A=-90,T=180,E=-180)}return new a.LngLatBounds(new a.LngLat(E,A),new a.LngLat(T,k))}_getBoundsRectangular(r,o){const{top:h,left:d}=this._edgeInsets,f=this.height-this._edgeInsets.bottom,g=this.width-this._edgeInsets.right,y=new a.Point(d,h),v=new a.Point(g,h),E=new a.Point(g,f),T=new a.Point(d,f);let A=this.pointCoordinate(y,r),k=this.pointCoordinate(v,r);const R=this.pointCoordinate(E,o),O=this.pointCoordinate(T,o),B=(F,I)=>(I.y-F.y)/(I.x-F.x);return A.y>1&&k.y>=0?A=new a.MercatorCoordinate((1-O.y)/B(O,A)+O.x,1):A.y<0&&k.y<=1&&(A=new a.MercatorCoordinate(-O.y/B(O,A)+O.x,0)),k.y>1&&A.y>=0?k=new a.MercatorCoordinate((1-R.y)/B(R,k)+R.x,1):k.y<0&&A.y<=1&&(k=new a.MercatorCoordinate(-R.y/B(R,k)+R.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(A)).extend(this.coordinateLocation(k)).extend(this.coordinateLocation(O)).extend(this.coordinateLocation(R))}_getBoundsRectangularTerrain(){const r=this.elevation;if(!r.visibleDemTiles.length||r.isUsingMockSource())return this._getBoundsRectangular(0,0);const o=r.visibleDemTiles.reduce((h,d)=>{if(d.dem){const f=d.dem.tree;h.min=Math.min(h.min,f.minimums[0]),h.max=Math.max(h.max,f.maximums[0])}return h},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(o.min*r.exaggeration(),o.max*r.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(r=!0){const o=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,h=this.height/2-o*(1-this._horizonShift);return r?Math.max(0,h):h}getMaxBounds(){return this.maxBounds}setMaxBounds(r){this.maxBounds=r,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,r&&(this.minLat=r.getSouth(),this.maxLat=r.getNorth(),this.minLng=r.getWest(),this.maxLng=r.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=a.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=a.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=a.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(r,o){return this.projection.createTileMatrix(this,o,r)}calculateDistanceTileData(r){const o=r.key,h=this._distanceTileDataCache;if(h[o])return h[o];const d=r.canonical,f=1/this.height,g=this.cameraWorldSize,y=g/this.zoomScale(d.z),v=(d.x+Math.pow(2,d.z)*r.wrap)*y,E=d.y*y,T=this.point;T.x*=g/this.worldSize,T.y*=g/this.worldSize;const A=this.angle,k=Math.sin(-A),R=-Math.cos(-A);return h[o]={bearing:[k,R],center:[(T.x-v)*f,(T.y-E)*f],scale:y/a.EXTENT*f},h[o]}calculateFogTileMatrix(r){const o=r.key,h=this._fogTileMatrixCache;if(h[o])return h[o];const d=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,r);return a.multiply(d,this.worldToFogMatrix,d),h[o]=new Float32Array(d),h[o]}calculateProjMatrix(r,o=!1){const h=r.key,d=o?this._alignedProjMatrixCache:this._projMatrixCache;if(d[h])return d[h];const f=this.calculatePosMatrix(r,this.worldSize);return a.multiply(f,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:o?this.alignedProjMatrix:this.projMatrix,f),d[h]=new Float32Array(f),d[h]}calculatePixelsToTileUnitsMatrix(r){const o=r.tileID.key,h=this._pixelsToTileUnitsCache;if(h[o])return h[o];const d=function(f,g){const{scale:y}=f.tileTransform,v=y*a.EXTENT/(f.tileSize*Math.pow(2,g.zoom-f.tileID.overscaledZ+f.tileID.canonical.z));return E=new Float32Array(4),k=(T=g.inverseAdjustmentMatrix)[1],R=T[2],O=T[3],F=(A=[v,v])[1],E[0]=T[0]*(B=A[0]),E[1]=k*B,E[2]=R*F,E[3]=O*F,E;var E,T,A,k,R,O,B,F}(r,this);return h[o]=d,h[o]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const r=1/this.worldSize,o=a.fromScaling([],[r,r,r]);return a.multiply(o,o,this.globeMatrix),o}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const r=this._elevation;this._updateCameraState();const o=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,h=this._computeCameraPosition(o),d=this._camera.forward(),f=a.mercatorZfromAltitude(1,this._center.lat);h[2]/=f,d[2]/=f,a.normalize(d,d);const g=r.raycast(h,d,r.exaggeration());if(g){const y=a.scaleAndAdd([],h,d,g),v=new a.MercatorCoordinate(y[0],y[1],a.mercatorZfromAltitude(y[2],a.latFromMercatorY(y[1]))),E=(v.z+a.length([v.x-h[0],v.y-h[1],v.z-h[2]*f]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(E),this._centerAltitude=v.toAltitude(),this._center=this.coordinateLocation(v),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(r=!1){if(!this._elevation)return;const o=this._elevation,h=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(h),f=o.getAtPointOrZero(new a.MercatorCoordinate(...d)),g=this.pixelsPerMeter/this.worldSize*f,y=this._minimumHeightOverTerrain(),v=d[2]-g;if(v<=y)if(v<0||r){const E=this.locationCoordinate(this._center,this._centerAltitude),T=[d[0],d[1],E.z-d[2]],A=a.length(T);T[2]-=(y-v)/this._pixelsPerMercatorPixel;const k=a.length(T);if(k===0)return;a.scale$2(T,T,A/k*this._pixelsPerMercatorPixel),this._camera.position=[d[0],d[1],E.z*this._pixelsPerMercatorPixel-T[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const r=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||r){const k=this.center;return k.lat=a.clamp(k.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!r)&&(k.lng=a.clamp(k.lng,this.minLng,this.maxLng)),this.center=k,void(this._constraining=!1)}const o=this._unmodified,{x:h,y:d}=this.point;let f=0,g=h,y=d;const v=this.width/2,E=this.height/2,T=this.worldMinY*this.scale,A=this.worldMaxY*this.scale;if(d-E<T&&(y=T+E),d+E>A&&(y=A-E),A-T<this.height&&(f=Math.max(f,this.height/(A-T)),y=(A+T)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const k=this.worldMinX*this.scale,R=this.worldMaxX*this.scale,O=this.worldSize/2-(k+R)/2;g=(h+O+this.worldSize)%this.worldSize-O,g-v<k&&(g=k+v),g+v>R&&(g=R-v),R-k<this.width&&(f=Math.max(f,this.width/(R-k)),g=(R+k)/2)}g===h&&y===d||(this.center=this.unproject(new a.Point(g,y))),f&&(this.zoom+=this.scaleZoom(f)),this._constrainCamera(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let r=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(r=Math.max(r,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),r}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const r=this.centerOffset,o=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=a.mercatorZfromAltitude(1,this.center.lat)/a.mercatorZfromAltitude(1,a.GLOBE_SCALE_MATCH_LATITUDE));const h=Ws(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,h),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const d=this.projection.zAxisUnit==="meters"?o:1,f=this._camera.getWorldToCamera(this.worldSize,d),g=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);g[8]=2*-r.x/this.width,g[9]=2*r.y/this.height;let y=a.mul([],g,f);if(this.projection.isReprojectedInTileSpace){const J=this.locationCoordinate(this.center),Y=a.identity([]);a.translate(Y,Y,[J.x*this.worldSize,J.y*this.worldSize,0]),a.multiply(Y,Y,ao(this)),a.translate(Y,Y,[-J.x*this.worldSize,-J.y*this.worldSize,0]),a.multiply(y,y,Y),this.inverseAdjustmentMatrix=function(ie){const te=ao(ie,!0);return Le([],[te[0],te[1],te[4],te[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=a.scale([],y,[this.worldSize,this.worldSize,this.worldSize/d,1]),this.projMatrix=y,this.invProjMatrix=a.invert(new Float64Array(16),this.projMatrix);const v=a.invert([],g);this.frustumCorners=a.FrustumCorners.fromInvProjectionMatrix(v,this.horizonLineFromTop(),this.height);const E=new Float32Array(16);a.identity(E),a.scale(E,E,[1,-1,1]),a.rotateX(E,E,this._pitch),a.rotateZ(E,E,this.angle);const T=a.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),A=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;T[8]=2*-r.x/this.width,T[9]=2*(r.y+A)/this.height,this.skyboxMatrix=a.multiply(E,T,E);const k=this.point,R=k.x,O=k.y,B=this.width%2/2,F=this.height%2/2,I=Math.cos(this.angle),L=Math.sin(this.angle),N=R-Math.round(R)+I*B+L*F,j=O-Math.round(O)+I*F+L*B,K=new Float64Array(y);if(a.translate(K,K,[N>.5?N-1:N,j>.5?j-1:j,0]),this.alignedProjMatrix=K,y=a.create(),a.scale(y,y,[this.width/2,-this.height/2,1]),a.translate(y,y,[1,-1,0]),this.labelPlaneMatrix=y,y=a.create(),a.scale(y,y,[1,-1,1]),a.translate(y,y,[-1,-1,0]),a.scale(y,y,[2/this.width,2/this.height,1]),this.glCoordMatrix=y,this.pixelMatrix=a.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},y=a.invert(new Float64Array(16),this.pixelMatrix),!y)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=y,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=a.calculateGlobeMatrix(this);const J=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=a.transformMat4(J,J,f),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=y;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const r=this.cameraWorldSizeForFog,o=this.cameraPixelsPerMeter,h=this._camera.position,d=1/this.height/this._pixelsPerMercatorPixel,f=[r,r,o];a.scale$2(f,f,d),a.scale$2(h,h,-1),a.multiply$2(h,h,f);const g=a.create();a.translate(g,g,h),a.scale(g,g,f),this.mercatorFogMatrix=g,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(r,o,d)}_computeCameraPosition(r){const o=(r=r||this.pixelsPerMeter)/this.pixelsPerMeter,h=this._camera.forward(),d=this.point,f=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*o-r/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-h[0]*f,d.y/this.worldSize-h[1]*f,r/this.worldSize*this._centerAltitude-h[2]*f]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(r){const o=this._maxCameraBoundsDistance()*Math.cos(this._pitch),h=this._camera.position[2],d=r[2];let f=1;this.projection.wrap&&(this.center=this.center.wrap()),d>0&&(f=Math.min((o-h)/d,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,r,f),this._updateStateFromCamera()}_updateStateFromCamera(){const r=this._camera.position,o=this._camera.forward(),{pitch:h,bearing:d}=this._camera.getPitchBearing(),f=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,g=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),y=Math.max((r[2]-f)/Math.cos(h),g),v=this._zoomFromMercatorZ(y);a.scaleAndAdd(r,r,o,y),this._pitch=a.clamp(h,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(d,-Math.PI,Math.PI),this._setZoom(a.clamp(v,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new a.MercatorCoordinate(r[0],r[1],r[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(r){return Math.pow(2,r)*this.tileSize}_mercatorZfromZoom(r){return this.cameraToCenterDistance/this._worldSizeFromZoom(r)}_minimumHeightOverTerrain(){const r=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(r)}_zoomFromMercatorZ(r){return this.scaleZoom(this.cameraToCenterDistance/(r*this.tileSize))}zoomFromMercatorZAdjusted(r){let o=0,h=a.GLOBE_ZOOM_THRESHOLD_MAX,d=0,f=1/0;for(;h-o>1e-6&&h>o;){const g=o+.5*(h-o),y=this.tileSize*Math.pow(2,g),v=this.getCameraToCenterDistance(this.projection,g,y),E=this.scaleZoom(v/(r*this.tileSize)),T=Math.abs(g-E);T<f&&(f=T,d=g),g<E?o=g:h=g}return d}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(r,o){const h=Math.min(r.x,o.x),d=Math.max(r.x,o.x),f=Math.min(r.y,o.y),g=Math.max(r.y,o.y);if(f<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const y=[new a.Point(h,f),new a.Point(d,g),new a.Point(h,g),new a.Point(d,f)],v=this.renderWorldCopies?-3:0,E=this.renderWorldCopies?4:1;for(const T of y){const A=this.pointRayIntersection(T);if(A.t<0)return!0;const k=this.rayIntersectionCoordinate(A);if(k.x<v||k.y<0||k.x>E||k.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.Point(0,0),new a.Point(this.width,this.height))}zoomDeltaToMovement(r,o){const h=a.length(a.sub([],this._camera.position,r)),d=this._zoomFromMercatorZ(h)+o;return h-this._mercatorZfromZoom(d)}getCameraPoint(){if(this.projection.name==="globe"){const r=function([o,h,d],f){const g=[o,h,d,1];a.transformMat4$1(g,g,f);const y=g[3]=Math.max(g[3],1e-6);return g[0]/=y,g[1]/=y,g[2]/=y,g}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new a.Point(r[0],r[1])}{const r=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.Point(0,r))}}getCameraToCenterDistance(r,o=this.zoom,h=this.worldSize){const d=Ws(r,o,this.width,this.height,1024),f=r.pixelSpaceConversion(this.center.lat,h,d);return .5/Math.tan(.5*this._fov)*this.height*f}getWorldToCameraMatrix(){const r=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&a.multiply(r,r,this.globeMatrix),r}}function co(l,r){let o=!1,h=null;const d=()=>{h=null,o&&(l(),h=setTimeout(d,r),o=!1)};return()=>(o=!0,h||d(),h)}class al{constructor(r){this._hashName=r&&encodeURIComponent(r),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=co(this._updateHashUnthrottled.bind(this),300)}addTo(r){return this._map=r,a.window.addEventListener("hashchange",this._onHashChange,!1),r.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),a.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const r=this._map;if(!r)return"";const o=Jo(r);if(this._hashName){const h=this._hashName;let d=!1;const f=a.window.location.hash.slice(1).split("&").map(g=>{const y=g.split("=")[0];return y===h?(d=!0,`${y}=${o}`):g}).filter(g=>g);return d||f.push(`${h}=${o}`),`#${f.join("&")}`}return`#${o}`}_getCurrentHash(){const r=a.window.location.hash.replace("#","");if(this._hashName){let o;return r.split("&").map(h=>h.split("=")).forEach(h=>{h[0]===this._hashName&&(o=h)}),(o&&o[1]||"").split("/")}return r.split("/")}_onHashChange(){const r=this._map;if(!r)return!1;const o=this._getCurrentHash();if(o.length>=3&&!o.some(h=>isNaN(h))){const h=r.dragRotate.isEnabled()&&r.touchZoomRotate.isEnabled()?+(o[3]||0):r.getBearing();return r.jumpTo({center:[+o[2],+o[1]],zoom:+o[0],bearing:h,pitch:+(o[4]||0)}),!0}return!1}_updateHashUnthrottled(){const r=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,r)}}function Jo(l,r){const o=l.getCenter(),h=Math.round(100*l.getZoom())/100,d=Math.ceil((h*Math.LN2+Math.log(512/360/.5))/Math.LN10),f=Math.pow(10,d),g=Math.round(o.lng*f)/f,y=Math.round(o.lat*f)/f,v=l.getBearing(),E=l.getPitch();let T=r?`/${g}/${y}/${h}`:`${h}/${y}/${g}`;return(v||E)&&(T+="/"+Math.round(10*v)/10),E&&(T+=`/${Math.round(E)}`),T}const Qo={linearity:.3,easing:a.bezier(0,0,.3,1)},Hs=a.extend({deceleration:2500,maxSpeed:1400},Qo),Ks=a.extend({deceleration:20,maxSpeed:1400},Qo),Fe=a.extend({deceleration:1e3,maxSpeed:360},Qo),cr=a.extend({deceleration:1e3,maxSpeed:90},Qo);class Pc{constructor(r){this._map=r,this.clear()}clear(){this._inertiaBuffer=[]}record(r){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:r})}_drainInertiaBuffer(){const r=this._inertiaBuffer,o=a.exported.now();for(;r.length>0&&o-r[0].time>160;)r.shift()}_onMoveEnd(r){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const o={zoom:0,bearing:0,pitch:0,pan:new a.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:f}of this._inertiaBuffer)o.zoom+=f.zoomDelta||0,o.bearing+=f.bearingDelta||0,o.pitch+=f.pitchDelta||0,f.panDelta&&o.pan._add(f.panDelta),f.around&&(o.around=f.around),f.pinchAround&&(o.pinchAround=f.pinchAround);const h=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,d={};if(o.pan.mag()){const f=ts(o.pan.mag(),h,a.extend({},Hs,r||{}));d.offset=o.pan.mult(f.amount/o.pan.mag()),d.center=this._map.transform.center,es(d,f)}if(o.zoom){const f=ts(o.zoom,h,Ks);d.zoom=this._map.transform.zoom+f.amount,es(d,f)}if(o.bearing){const f=ts(o.bearing,h,Fe);d.bearing=this._map.transform.bearing+a.clamp(f.amount,-179,179),es(d,f)}if(o.pitch){const f=ts(o.pitch,h,cr);d.pitch=this._map.transform.pitch+f.amount,es(d,f)}if(d.zoom||d.bearing){const f=o.pinchAround===void 0?o.around:o.pinchAround;d.around=f?this._map.unproject(f):this._map.getCenter()}return this.clear(),d.noMoveStart=!0,d}}function es(l,r){(!l.duration||l.duration<r.duration)&&(l.duration=r.duration,l.easing=r.easing)}function ts(l,r,o){const{maxSpeed:h,linearity:d,deceleration:f}=o,g=a.clamp(l*d/(r/1e3),-h,h),y=Math.abs(g)/(f*d);return{easing:o.easing,duration:1e3*y,amount:g*(y/2)}}class yi extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h,d={}){const f=sr(o.getCanvasContainer(),h),g=o.unproject(f);super(r,a.extend({point:f,lngLat:g,originalEvent:h},d)),this._defaultPrevented=!1,this.target=o}}class is extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h){const d=r==="touchend"?h.changedTouches:h.touches,f=pn(o.getCanvasContainer(),d),g=f.map(v=>o.unproject(v)),y=f.reduce((v,E,T,A)=>v.add(E.div(A.length)),new a.Point(0,0));super(r,{points:f,point:y,lngLats:g,lngLat:o.unproject(y),originalEvent:h}),this._defaultPrevented=!1}}class Ys extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(r,o,h){super(r,{originalEvent:h}),this._defaultPrevented=!1}}class ll{constructor(r,o){this._map=r,this._clickTolerance=o.clickTolerance}reset(){this._mousedownPos=void 0}wheel(r){return this._firePreventable(new Ys(r.type,this._map,r))}mousedown(r,o){return this._mousedownPos=o,this._firePreventable(new yi(r.type,this._map,r))}mouseup(r){this._map.fire(new yi(r.type,this._map,r))}preclick(r){const o=a.extend({},r);o.type="preclick",this._map.fire(new yi(o.type,this._map,o))}click(r,o){this._mousedownPos&&this._mousedownPos.dist(o)>=this._clickTolerance||(this.preclick(r),this._map.fire(new yi(r.type,this._map,r)))}dblclick(r){return this._firePreventable(new yi(r.type,this._map,r))}mouseover(r){this._map.fire(new yi(r.type,this._map,r))}mouseout(r){this._map.fire(new yi(r.type,this._map,r))}touchstart(r){return this._firePreventable(new is(r.type,this._map,r))}touchmove(r){this._map.fire(new is(r.type,this._map,r))}touchend(r){this._map.fire(new is(r.type,this._map,r))}touchcancel(r){this._map.fire(new is(r.type,this._map,r))}_firePreventable(r){if(this._map.fire(r),r.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Js{constructor(r){this._map=r}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(r){this._map.fire(new yi(r.type,this._map,r))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new yi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(r){this._delayContextMenu?this._contextMenuEvent=r:this._map.fire(new yi(r.type,this._map,r)),this._map.listens("contextmenu")&&r.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class kc{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._container=r.getContainer(),this._clickTolerance=o.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(r,o){this.isEnabled()&&r.shiftKey&&r.button===0&&(Mo(),this._startPos=this._lastPos=o,this._active=!0)}mousemoveWindow(r,o){if(!this._active)return;const h=o,d=this._startPos,f=this._lastPos;if(!d||!f||f.equals(h)||!this._box&&h.dist(d)<this._clickTolerance)return;this._lastPos=h,this._box||(this._box=nt("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",r));const g=Math.min(d.x,h.x),y=Math.max(d.x,h.x),v=Math.min(d.y,h.y),E=Math.max(d.y,h.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${g}px,${v}px)`,this._box.style.width=y-g+"px",this._box.style.height=E-v+"px")})}mouseupWindow(r,o){if(!this._active)return;const h=this._startPos,d=o;if(h&&r.button===0){if(this.reset(),Vn(),h.x!==d.x||h.y!==d.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:r})),{cameraAnimation:f=>f.fitScreenCoordinates(h,d,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",r)}}keydown(r){this._active&&r.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",r))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Un(),delete this._startPos,delete this._lastPos}_fireEvent(r,o){return this._map.fire(new a.Event(r,{originalEvent:o}))}}function Qs(l,r){const o={};for(let h=0;h<l.length;h++)o[l[h].identifier]=r[h];return o}class ho{constructor(r){this.reset(),this.numTouches=r.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(r,o,h){(this.centroid||h.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=r.timeStamp),h.length===this.numTouches&&(this.centroid=function(d){const f=new a.Point(0,0);for(const g of d)f._add(g);return f.div(d.length)}(o),this.touches=Qs(h,o)))}touchmove(r,o,h){if(this.aborted||!this.centroid)return;const d=Qs(h,o);for(const f in this.touches){const g=d[f];(!g||g.dist(this.touches[f])>30)&&(this.aborted=!0)}}touchend(r,o,h){if((!this.centroid||r.timeStamp-this.startTime>500)&&(this.aborted=!0),h.length===0){const d=!this.aborted&&this.centroid;if(this.reset(),d)return d}}}class cl{constructor(r){this.singleTap=new ho(r),this.numTaps=r.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(r,o,h){this.singleTap.touchstart(r,o,h)}touchmove(r,o,h){this.singleTap.touchmove(r,o,h)}touchend(r,o,h){const d=this.singleTap.touchend(r,o,h);if(d){const f=r.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(d)<30;if(f&&g||this.reset(),this.count++,this.lastTime=r.timeStamp,this.lastTap=d,this.count===this.numTaps)return this.reset(),d}}}class qh{constructor(){this._zoomIn=new cl({numTouches:1,numTaps:2}),this._zoomOut=new cl({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(r,o,h){this._zoomIn.touchstart(r,o,h),this._zoomOut.touchstart(r,o,h)}touchmove(r,o,h){this._zoomIn.touchmove(r,o,h),this._zoomOut.touchmove(r,o,h)}touchend(r,o,h){const d=this._zoomIn.touchend(r,o,h),f=this._zoomOut.touchend(r,o,h);return d?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()+1,around:g.unproject(d)},{originalEvent:r})}):f?(this._active=!0,r.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:g=>g.easeTo({duration:300,zoom:g.getZoom()-1,around:g.unproject(f)},{originalEvent:r})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Dc={0:1,2:2};class uo{constructor(r){this.reset(),this._clickTolerance=r.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(r,o){return!1}_move(r,o){return{}}mousedown(r,o){if(this._lastPoint)return;const h=fn(r);this._correctButton(r,h)&&(this._lastPoint=o,this._eventButton=h)}mousemoveWindow(r,o){const h=this._lastPoint;if(h){if(r.preventDefault(),this._eventButton!=null&&function(d,f){const g=Dc[f];return d.buttons===void 0||(d.buttons&g)!==g}(r,this._eventButton))this.reset();else if(this._moved||!(o.dist(h)<this._clickTolerance))return this._moved=!0,this._lastPoint=o,this._move(h,o)}}mouseupWindow(r){this._lastPoint&&fn(r)===this._eventButton&&(this._moved&&Vn(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class hl extends uo{mousedown(r,o){super.mousedown(r,o),this._lastPoint&&(this._active=!0)}_correctButton(r,o){return o===0&&!r.ctrlKey}_move(r,o){return{around:o,panDelta:o.sub(r)}}}class ul extends uo{_correctButton(r,o){return o===0&&r.ctrlKey||o===2}_move(r,o){const h=.8*(o.x-r.x);if(h)return this._active=!0,{bearingDelta:h}}contextmenu(r){r.preventDefault()}}class dl extends uo{_correctButton(r,o){return o===0&&r.ctrlKey||o===2}_move(r,o){const h=-.5*(o.y-r.y);if(h)return this._active=!0,{pitchDelta:h}}contextmenu(r){r.preventDefault()}}class ea{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._minTouches=1,this._clickTolerance=o.clickTolerance||1,this.reset(),a.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new a.Point(0,0)}touchstart(r,o,h){return this._calculateTransform(r,o,h)}touchmove(r,o,h){if(this._active&&!(h.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(h.length===1&&!a.isFullscreen())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return r.cancelable&&r.preventDefault(),this._calculateTransform(r,o,h)}}touchend(r,o,h){this._calculateTransform(r,o,h),this._active&&h.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(r,o,h){h.length>0&&(this._active=!0);const d=Qs(h,o),f=new a.Point(0,0),g=new a.Point(0,0);let y=0;for(const E in d){const T=d[E],A=this._touches[E];A&&(f._add(T),g._add(T.sub(A)),y++,d[E]=T)}if(this._touches=d,y<this._minTouches||!g.mag())return;const v=g.div(y);return this._sum._add(v),this._sum.mag()<this._clickTolerance?void 0:{around:f.div(y),panDelta:v}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=nt("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class rs{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(r){}_move(r,o,h){return{}}touchstart(r,o,h){this._firstTwoTouches||h.length<2||(this._firstTwoTouches=[h[0].identifier,h[1].identifier],this._start([o[0],o[1]]))}touchmove(r,o,h){const d=this._firstTwoTouches;if(!d)return;r.preventDefault();const[f,g]=d,y=ns(h,o,f),v=ns(h,o,g);if(!y||!v)return;const E=this._aroundCenter?null:y.add(v).div(2);return this._move([y,v],E,r)}touchend(r,o,h){if(!this._firstTwoTouches)return;const[d,f]=this._firstTwoTouches,g=ns(h,o,d),y=ns(h,o,f);g&&y||(this._active&&Vn(),this.reset())}touchcancel(){this.reset()}enable(r){this._enabled=!0,this._aroundCenter=!!r&&r.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function ns(l,r,o){for(let h=0;h<l.length;h++)if(l[h].identifier===o)return r[h]}function pl(l,r){return Math.log(l/r)/Math.LN2}class Lc extends rs{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(r){this._startDistance=this._distance=r[0].dist(r[1])}_move(r,o){const h=this._distance;if(this._distance=r[0].dist(r[1]),this._active||!(Math.abs(pl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:pl(this._distance,h),pinchAround:o}}}function fl(l,r){return 180*l.angleWith(r)/Math.PI}class Rc extends rs{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(r){this._startVector=this._vector=r[0].sub(r[1]),this._minDiameter=r[0].dist(r[1])}_move(r,o){const h=this._vector;if(this._vector=r[0].sub(r[1]),h&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:fl(this._vector,h),pinchAround:o}}_isBelowThreshold(r){this._minDiameter=Math.min(this._minDiameter,r.mag());const o=25/(Math.PI*this._minDiameter)*360,h=this._startVector;if(!h)return!1;const d=fl(r,h);return Math.abs(d)<o}}function rn(l){return Math.abs(l.y)>Math.abs(l.x)}class Bc extends rs{constructor(r){super(),this._map=r}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(r){this._lastPoints=r,rn(r[0].sub(r[1]))&&(this._valid=!1)}_move(r,o,h){const d=this._lastPoints;if(!d)return;const f=r[0].sub(d[0]),g=r[1].sub(d[1]);return this._map._cooperativeGestures&&!a.isFullscreen()&&h.touches.length<3||(this._valid=this.gestureBeginsVertically(f,g,h.timeStamp),!this._valid)?void 0:(this._lastPoints=r,this._active=!0,{pitchDelta:(f.y+g.y)/2*-.5})}gestureBeginsVertically(r,o,h){if(this._valid!==void 0)return this._valid;const d=r.mag()>=2,f=o.mag()>=2;if(!d&&!f)return;if(!d||!f)return this._firstMove==null&&(this._firstMove=h),h-this._firstMove<100&&void 0;const g=r.y>0==o.y>0;return rn(r)&&rn(o)&&g}}const Oc={panStep:100,bearingStep:15,pitchStep:10};class Wh{constructor(){const r=Oc;this._panStep=r.panStep,this._bearingStep=r.bearingStep,this._pitchStep=r.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(r){if(r.altKey||r.ctrlKey||r.metaKey)return;let o=0,h=0,d=0,f=0,g=0;switch(r.keyCode){case 61:case 107:case 171:case 187:o=1;break;case 189:case 109:case 173:o=-1;break;case 37:r.shiftKey?h=-1:(r.preventDefault(),f=-1);break;case 39:r.shiftKey?h=1:(r.preventDefault(),f=1);break;case 38:r.shiftKey?d=1:(r.preventDefault(),g=-1);break;case 40:r.shiftKey?d=-1:(r.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(h=0,d=0),{cameraAnimation:y=>{const v=y.getZoom();y.easeTo({duration:300,easeId:"keyboardHandler",easing:Fc,zoom:o?Math.round(v)+o*(r.shiftKey?2:1):v,bearing:y.getBearing()+h*this._bearingStep,pitch:y.getPitch()+d*this._pitchStep,offset:[-f*this._panStep,-g*this._panStep],center:y.getCenter()},{originalEvent:r})}}}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 Fc(l){return l*(2-l)}const ml=4.000244140625;class Uc{constructor(r,o){this._map=r,this._el=r.getCanvasContainer(),this._handler=o,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(r){this._defaultZoomRate=r}setWheelZoomRate(r){this._wheelZoomRate=r}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(r){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!r&&r.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(r){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(r.ctrlKey||r.metaKey||this.isZooming()||a.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let o=r.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*r.deltaY:r.deltaY;const h=a.exported.now(),d=h-(this._lastWheelEventTime||0);this._lastWheelEventTime=h,o!==0&&o%ml==0?this._type="wheel":o!==0&&Math.abs(o)<4?this._type="trackpad":d>400?(this._type=null,this._lastValue=o,this._timeout=setTimeout(this._onTimeout,40,r)):this._type||(this._type=Math.abs(d*o)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,o+=this._lastValue)),r.shiftKey&&o&&(o/=4),this._type&&(this._lastWheelEvent=r,this._delta-=o,this._active||this._start(r)),r.preventDefault()}_onTimeout(r){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(r)}_start(r){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 o=sr(this._el,r);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:o,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const r=this._map.transform;this._type==="wheel"&&r.projection.wrap&&(r._center.lng>=180||r._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const o=()=>r._terrainEnabled()&&this._aroundCoord?r.computeZoomRelativeTo(this._aroundCoord):r.zoom;if(this._delta!==0){const v=this._type==="wheel"&&Math.abs(this._delta)>ml?this._wheelZoomRate:this._defaultZoomRate;let E=2/(1+Math.exp(-Math.abs(this._delta*v)));this._delta<0&&E!==0&&(E=1/E);const T=o(),A=Math.pow(2,T),k=typeof this._targetZoom=="number"?r.zoomScale(this._targetZoom):A;this._targetZoom=Math.min(r.maxZoom,Math.max(r.minZoom,r.scaleZoom(k*E))),this._type==="wheel"&&(this._startZoom=T,this._easing=this._smoothOutEasing(200)),this._delta=0}const h=typeof this._targetZoom=="number"?this._targetZoom:o(),d=this._startZoom,f=this._easing;let g,y=!1;if(this._type==="wheel"&&d&&f){const v=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),E=f(v);g=a.number(d,h,E),v<1?this._frameId||(this._frameId=!0):y=!0}else g=h,y=!0;return this._active=!0,y&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!y,zoomDelta:g-o(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(r){let o=a.ease;if(this._prevEase){const h=this._prevEase,d=(a.exported.now()-h.start)/h.duration,f=h.easing(d+.01)-h.easing(d),g=.27/Math.sqrt(f*f+1e-4)*.01,y=Math.sqrt(.0729-g*g);o=a.bezier(g,y,.25,1)}return this._prevEase={start:a.exported.now(),duration:r,easing:o},o}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=nt("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Vc{constructor(r,o){this._clickZoom=r,this._tapZoom=o}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 Ai{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(r,o){return r.preventDefault(),{cameraAnimation:h=>{h.easeTo({duration:300,zoom:h.getZoom()+(r.shiftKey?-1:1),around:h.unproject(o)},{originalEvent:r})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Xh{constructor(){this._tap=new cl({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(r,o,h){this._swipePoint||(this._tapTime&&r.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?h.length>0&&(this._swipePoint=o[0],this._swipeTouch=h[0].identifier):this._tap.touchstart(r,o,h))}touchmove(r,o,h){if(this._tapTime){if(this._swipePoint){if(h[0].identifier!==this._swipeTouch)return;const d=o[0],f=d.y-this._swipePoint.y;return this._swipePoint=d,r.preventDefault(),this._active=!0,{zoomDelta:f/128}}}else this._tap.touchmove(r,o,h)}touchend(r,o,h){this._tapTime?this._swipePoint&&h.length===0&&this.reset():this._tap.touchend(r,o,h)&&(this._tapTime=r.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Nc{constructor(r,o,h){this._el=r,this._mousePan=o,this._touchPan=h}enable(r){this._inertiaOptions=r||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Hh{constructor(r,o,h){this._pitchWithRotate=r.pitchWithRotate,this._mouseRotate=o,this._mousePitch=h}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 Kh{constructor(r,o,h,d){this._el=r,this._touchZoom=o,this._touchRotate=h,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(r){this._touchZoom.enable(r),this._rotationDisabled||this._touchRotate.enable(r),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Qi=l=>l.zoom||l.drag||l.pitch||l.rotate;class jc extends a.Event{}class Yh{constructor(){this.constants=[1,1,.01],this.radius=0}setup(r,o){const h=a.sub([],o,r);this.radius=a.length(h[2]<0?a.div([],h,this.constants):[h[0],h[1],0])}projectRay(r){a.div(r,r,this.constants),a.normalize(r,r),a.mul$1(r,r,this.constants);const o=a.scale$2([],r,this.radius);if(o[2]>0){const h=a.scale$2([],[0,0,1],a.dot(o,[0,0,1])),d=a.scale$2([],a.normalize([],[o[0],o[1],0]),this.radius),f=a.add([],o,a.scale$2([],a.sub([],a.add([],d,h),o),2));o[0]=f[0],o[1]=f[1]}return o}}function hr(l){return l.panDelta&&l.panDelta.mag()||l.zoomDelta||l.bearingDelta||l.pitchDelta}class xr{constructor(r,o){this._map=r,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pc(r),this._bearingSnap=o.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Yh,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(o),a.bindAll(["handleEvent","handleWindowEvent"],this);const h=this._el;this._listeners=[[h,"touchstart",{passive:!0}],[h,"touchmove",{passive:!1}],[h,"touchend",void 0],[h,"touchcancel",void 0],[h,"mousedown",void 0],[h,"mousemove",void 0],[h,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0}],[a.window.document,"mouseup",void 0],[h,"mouseover",void 0],[h,"mouseout",void 0],[h,"dblclick",void 0],[h,"click",void 0],[h,"keydown",{capture:!1}],[h,"keyup",void 0],[h,"wheel",{passive:!1}],[h,"contextmenu",void 0],[a.window,"blur",void 0]];for(const[d,f,g]of this._listeners)d.addEventListener(f,d===a.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[r,o,h]of this._listeners)r.removeEventListener(o,r===a.window.document?this.handleWindowEvent:this.handleEvent,h)}_addDefaultHandlers(r){const o=this._map,h=o.getCanvasContainer();this._add("mapEvent",new ll(o,r));const d=o.boxZoom=new kc(o,r);this._add("boxZoom",d);const f=new qh,g=new Ai;o.doubleClickZoom=new Vc(g,f),this._add("tapZoom",f),this._add("clickZoom",g);const y=new Xh;this._add("tapDragZoom",y);const v=o.touchPitch=new Bc(o);this._add("touchPitch",v);const E=new ul(r),T=new dl(r);o.dragRotate=new Hh(r,E,T),this._add("mouseRotate",E,["mousePitch"]),this._add("mousePitch",T,["mouseRotate"]);const A=new hl(r),k=new ea(o,r);o.dragPan=new Nc(h,A,k),this._add("mousePan",A),this._add("touchPan",k,["touchZoom","touchRotate"]);const R=new Rc,O=new Lc;o.touchZoomRotate=new Kh(h,O,R,y),this._add("touchRotate",R,["touchPan","touchZoom"]),this._add("touchZoom",O,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Js(o));const B=o.scrollZoom=new Uc(o,this);this._add("scrollZoom",B,["mousePan"]);const F=o.keyboard=new Wh;this._add("keyboard",F);for(const I of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])r.interactive&&r[I]&&o[I].enable(r[I])}_add(r,o,h){this._handlers.push({handlerName:r,handler:o,allowed:h}),this._handlersById[r]=o}stop(r){if(!this._updatingCamera){for(const{handler:o}of this._handlers)o.reset();this._inertia.clear(),this._fireEvents({},{},r),this._changes=[]}}isActive(){for(const{handler:r}of this._handlers)if(r.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Qi(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(r,o,h){for(const d in r)if(d!==h&&(!o||o.indexOf(d)<0))return!0;return!1}handleWindowEvent(r){this.handleEvent(r,`${r.type}Window`)}_getMapTouches(r){const o=[];for(const h of r)this._el.contains(h.target)&&o.push(h);return o}handleEvent(r,o){this._updatingCamera=!0;const h=r.type==="renderFrame",d=h?void 0:r,f={needsRenderFrame:!1},g={},y={},v=r.touches?this._getMapTouches(r.touches):void 0,E=v?pn(this._el,v):h?void 0:sr(this._el,r);for(const{handlerName:k,handler:R,allowed:O}of this._handlers){if(!R.isEnabled())continue;let B;this._blockedByActive(y,O,k)?R.reset():R[o||r.type]&&(B=R[o||r.type](r,E,v),this.mergeHandlerResult(f,g,B,k,d),B&&B.needsRenderFrame&&this._triggerRenderFrame()),(B||R.isActive())&&(y[k]=R)}const T={};for(const k in this._previousActiveHandlers)y[k]||(T[k]=d);this._previousActiveHandlers=y,(Object.keys(T).length||hr(f))&&(this._changes.push([f,g,T]),this._triggerRenderFrame()),(Object.keys(y).length||hr(f))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:A}=f;A&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],A(this._map))}mergeHandlerResult(r,o,h,d,f){if(!h)return;a.extend(r,h);const g={handlerName:d,originalEvent:h.originalEvent||f};h.zoomDelta!==void 0&&(o.zoom=g),h.panDelta!==void 0&&(o.drag=g),h.pitchDelta!==void 0&&(o.pitch=g),h.bearingDelta!==void 0&&(o.rotate=g)}_applyChanges(){const r={},o={},h={};for(const[d,f,g]of this._changes)d.panDelta&&(r.panDelta=(r.panDelta||new a.Point(0,0))._add(d.panDelta)),d.zoomDelta&&(r.zoomDelta=(r.zoomDelta||0)+d.zoomDelta),d.bearingDelta&&(r.bearingDelta=(r.bearingDelta||0)+d.bearingDelta),d.pitchDelta&&(r.pitchDelta=(r.pitchDelta||0)+d.pitchDelta),d.around!==void 0&&(r.around=d.around),d.aroundCoord!==void 0&&(r.aroundCoord=d.aroundCoord),d.pinchAround!==void 0&&(r.pinchAround=d.pinchAround),d.noInertia&&(r.noInertia=d.noInertia),a.extend(o,f),a.extend(h,g);this._updateMapTransform(r,o,h),this._changes=[]}_updateMapTransform(r,o,h){const d=this._map,f=d.transform,g=L=>[L.x,L.y,L.z];if((L=>{const N=this._eventsInProgress.drag;return N&&!this._handlersById[N.handlerName].isActive()})()&&!hr(r)){const L=f.zoom;f.cameraElevationReference="sea",f.recenterOnTerrain(),f.cameraElevationReference="ground",L!==f.zoom&&this._map._update(!0)}if(f._isCameraConstrained&&d._stop(!0),!hr(r))return void this._fireEvents(o,h,!0);let{panDelta:y,zoomDelta:v,bearingDelta:E,pitchDelta:T,around:A,aroundCoord:k,pinchAround:R}=r;f._isCameraConstrained&&(v>0&&(v=0),f._isCameraConstrained=!1),R!==void 0&&(A=R),(v||(L=>o[L]&&!this._eventsInProgress[L])("drag"))&&A&&(this._dragOrigin=g(f.pointCoordinate3D(A)),this._trackingEllipsoid.setup(f._camera.position,this._dragOrigin)),f.cameraElevationReference="sea",d._stop(!0),A=A||d.transform.centerPoint,E&&(f.bearing+=E),T&&(f.pitch+=T),f._updateCameraState();const O=[0,0,0];if(y)if(f.projection.name==="mercator"){const L=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(A).dir),N=this._trackingEllipsoid.projectRay(f.screenPointToMercatorRay(A.sub(y)).dir);O[0]=N[0]-L[0],O[1]=N[1]-L[1]}else{const L=f.pointCoordinate(A);if(f.projection.name==="globe"){y=y.rotate(-f.angle);const N=f._pixelsPerMercatorPixel/f.worldSize;O[0]=-y.x*a.mercatorScale(a.latFromMercatorY(L.y))*N,O[1]=-y.y*a.mercatorScale(f.center.lat)*N}else{const N=f.pointCoordinate(A.sub(y));L&&N&&(O[0]=N.x-L.x,O[1]=N.y-L.y)}}const B=f.zoom,F=[0,0,0];if(v){const L=g(k||f.pointCoordinate3D(A)),N={dir:a.normalize([],a.sub([],L,f._camera.position))};if(N.dir[2]<0){const j=f.zoomDeltaToMovement(L,v);a.scale$2(F,N.dir,j)}}const I=a.add(O,O,F);f._translateCameraConstrained(I),v&&Math.abs(f.zoom-B)>1e-4&&f.recenterOnTerrain(),f.cameraElevationReference="ground",this._map._update(),r.noInertia||this._inertia.record(r),this._fireEvents(o,h,!0)}_fireEvents(r,o,h){const d=Qi(this._eventsInProgress),f=Qi(r),g={};for(const T in r){const{originalEvent:A}=r[T];this._eventsInProgress[T]||(g[`${T}start`]=A),this._eventsInProgress[T]=r[T]}!d&&f&&this._fireEvent("movestart",f.originalEvent);for(const T in g)this._fireEvent(T,g[T]);f&&this._fireEvent("move",f.originalEvent);for(const T in r){const{originalEvent:A}=r[T];this._fireEvent(T,A)}const y={};let v;for(const T in this._eventsInProgress){const{handlerName:A,originalEvent:k}=this._eventsInProgress[T];this._handlersById[A].isActive()||(delete this._eventsInProgress[T],v=o[A]||k,y[`${T}end`]=v)}for(const T in y)this._fireEvent(T,y[T]);const E=Qi(this._eventsInProgress);if(h&&(d||f)&&!E){this._updatingCamera=!0;const T=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),A=k=>k!==0&&-this._bearingSnap<k&&k<this._bearingSnap;T?(A(T.bearing||this._map.getBearing())&&(T.bearing=0),this._map.easeTo(T,{originalEvent:v})):(this._map.fire(new a.Event("moveend",{originalEvent:v})),A(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(r,o){this._map.fire(new a.Event(r,o?{originalEvent:o}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(r=>{this._frameId=void 0,this.handleEvent(new jc("renderFrame",{timeStamp:r})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const An="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class ta extends a.Evented{constructor(r,o){super(),this._moving=!1,this._zooming=!1,this.transform=r,this._bearingSnap=o.bearingSnap,this._respectPrefersReducedMotion=o.respectPrefersReducedMotion!==!1,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(r,o){return this.jumpTo({center:r},o)}panBy(r,o,h){return r=a.Point.convert(r).mult(-1),this.panTo(this.transform.center,a.extend({offset:r},o),h)}panTo(r,o,h){return this.easeTo(a.extend({center:r},o),h)}getZoom(){return this.transform.zoom}setZoom(r,o){return this.jumpTo({zoom:r},o),this}zoomTo(r,o,h){return this.easeTo(a.extend({zoom:r},o),h)}zoomIn(r,o){return this.zoomTo(this.getZoom()+1,r,o),this}zoomOut(r,o){return this.zoomTo(this.getZoom()-1,r,o),this}getBearing(){return this.transform.bearing}setBearing(r,o){return this.jumpTo({bearing:r},o),this}getPadding(){return this.transform.padding}setPadding(r,o){return this.jumpTo({padding:r},o),this}rotateTo(r,o,h){return this.easeTo(a.extend({bearing:r},o),h)}resetNorth(r,o){return this.rotateTo(0,a.extend({duration:1e3},r),o),this}resetNorthPitch(r,o){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},r),o),this}snapToNorth(r,o){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(r,o):this}getPitch(){return this.transform.pitch}setPitch(r,o){return this.jumpTo({pitch:r},o),this}cameraForBounds(r,o){r=a.LngLatBounds.convert(r);const h=o&&o.bearing||0,d=o&&o.pitch||0,f=r.getNorthWest(),g=r.getSouthEast();return this._cameraForBounds(this.transform,f,g,h,d,o)}_extendCameraOptions(r){const o={top:0,bottom:0,right:0,left:0};if(typeof(r=a.extend({padding:o,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding=="number"){const h=r.padding;r.padding={top:h,bottom:h,right:h,left:h}}return r.padding=a.extend(o,r.padding),r}_minimumAABBFrustumDistance(r,o){const h=o.max[0]-o.min[0],d=o.max[1]-o.min[1];return h/d>r.aspect?h/(2*Math.tan(.5*r.fovX)*r.aspect):d/(2*Math.tan(.5*r.fovY)*r.aspect)}_cameraForBoundsOnGlobe(r,o,h,d,f,g){const y=r.clone(),v=this._extendCameraOptions(g);y.bearing=d,y.pitch=f;const E=a.LngLat.convert(o),T=a.LngLat.convert(h),A=.5*(E.lat+T.lat),k=.5*(E.lng+T.lng),R=a.latLngToECEF(A,k),O=a.normalize([],R),B=a.normalize([],a.cross([],O,[0,1,0])),F=a.cross([],B,O),I=[B[0],B[1],B[2],0,F[0],F[1],F[2],0,O[0],O[1],O[2],0,0,0,0,1],L=[R,a.latLngToECEF(E.lat,E.lng),a.latLngToECEF(T.lat,E.lng),a.latLngToECEF(T.lat,T.lng),a.latLngToECEF(E.lat,T.lng),a.latLngToECEF(A,E.lng),a.latLngToECEF(A,T.lng),a.latLngToECEF(E.lat,k),a.latLngToECEF(T.lat,k)];let N=a.Aabb.fromPoints(L.map(be=>[a.dot(B,be),a.dot(F,be),a.dot(O,be)]));const j=a.transformMat4([],N.center,I);a.squaredLength(j)===0&&a.set(j,0,0,1),a.normalize(j,j),a.scale$2(j,j,a.GLOBE_RADIUS),y.center=a.ecefToLatLng(j);const K=y.getWorldToCameraMatrix(),J=a.invert(new Float64Array(16),K);N=a.Aabb.applyTransform(N,a.multiply([],K,I)),a.transformMat4(j,j,K);const Y=.5*(N.max[2]-N.min[2]),ie=this._minimumAABBFrustumDistance(y,N),te=a.scale$2([],[0,0,1],Y),le=a.add(te,j,te),Ee=ie+(y.pitch===0?0:a.distance(j,le)),oe=y.globeCenterInViewSpace,ge=a.sub([],j,[oe[0],oe[1],oe[2]]);a.normalize(ge,ge),a.scale$2(ge,ge,Ee);const he=a.add([],j,ge);a.transformMat4(he,he,J);const Te=a.earthRadius/a.GLOBE_RADIUS,ae=a.length(he),_e=a.mercatorZfromAltitude(Math.max(ae*Te-a.earthRadius,Number.EPSILON),0),Me=Math.min(y.zoomFromMercatorZAdjusted(_e),v.maxZoom);return Me>.5*(a.GLOBE_ZOOM_THRESHOLD_MIN+a.GLOBE_ZOOM_THRESHOLD_MAX)?(y.setProjection({name:"mercator"}),y.zoom=Me,this._cameraForBounds(y,o,h,d,f,g)):{center:y.center,zoom:Me,bearing:d,pitch:f}}queryTerrainElevation(r,o){const h=this.transform.elevation;return h?(o=a.extend({},{exaggerated:!0},o),h.getAtPoint(a.MercatorCoordinate.fromLngLat(r),null,o.exaggerated)):null}_cameraForBounds(r,o,h,d,f,g){if(r.projection.name==="globe")return this._cameraForBoundsOnGlobe(r,o,h,d,f,g);const y=r.clone(),v=this._extendCameraOptions(g),E=y.padding;y.bearing=d,y.pitch=f;const T=a.LngLat.convert(o),A=a.LngLat.convert(h),k=new a.LngLat(T.lng,A.lat),R=new a.LngLat(A.lng,T.lat),O=y.project(T),B=y.project(A),F=this.queryTerrainElevation(T),I=this.queryTerrainElevation(A),L=this.queryTerrainElevation(k),N=this.queryTerrainElevation(R),j=[[O.x,O.y,Math.min(F||0,I||0,L||0,N||0)],[B.x,B.y,Math.max(F||0,I||0,L||0,N||0)]];let K=a.Aabb.fromPoints(j);const J=y.getWorldToCameraMatrix(),Y=a.invert(new Float64Array(16),J);K=a.Aabb.applyTransform(K,J);const ie=a.sub([],K.max,K.min),te=E.left||0,le=E.right||0,Ee=E.bottom||0,oe=E.top||0,{left:ge,right:he,top:Te,bottom:ae}=v.padding,_e=.5*(te+le),Me=.5*(oe+Ee),be=Math.min(y.scaleZoom(y.scale*Math.min((y.width-(te+le+ge+he))/ie[0],(y.height-(Ee+oe+ae+Te))/ie[1])),v.maxZoom),Ae=y.scale/y.zoomScale(be);K=new a.Aabb([K.min[0]-(ge+_e)*Ae,K.min[1]-(ae+Me)*Ae,K.min[2]],[K.max[0]+(he+_e)*Ae,K.max[1]+(Te+Me)*Ae,K.max[2]]);const Ge=.5*ie[2],He=this._minimumAABBFrustumDistance(y,K),Ve=[0,0,1,0];a.transformMat4$1(Ve,Ve,J),a.normalize$2(Ve,Ve);const qe=a.scale$2([],Ve,He+Ge),ht=a.add([],K.center,qe),at=(typeof v.offset.x=="number"&&typeof v.offset.y=="number"?new a.Point(v.offset.x,v.offset.y):a.Point.convert(v.offset)).rotate(-a.degToRad(d));K.center[0]-=at.x*Ae,K.center[1]+=at.y*Ae,a.transformMat4(K.center,K.center,Y),a.transformMat4(ht,ht,Y);const je=[K.center[0],K.center[1],ht[2]*y.pixelsPerMeter];a.scale$2(je,je,1/y.worldSize);const Et=a.lngFromMercatorX(je[0]),Mt=a.latFromMercatorY(je[1]),At=Math.min(y._zoomFromMercatorZ(je[2]),v.maxZoom),It=new a.LngLat(Et,Mt);return y.mercatorFromTransition&&At<.5*(a.GLOBE_ZOOM_THRESHOLD_MIN+a.GLOBE_ZOOM_THRESHOLD_MAX)?(y.setProjection({name:"globe"}),y.zoom=At,this._cameraForBounds(y,o,h,d,f,g)):{center:It,zoom:At,bearing:d,pitch:f}}fitBounds(r,o,h){const d=this.cameraForBounds(r,o);return this._fitInternal(d,o,h)}fitScreenCoordinates(r,o,h,d,f){const g=a.Point.convert(r),y=a.Point.convert(o),v=new a.Point(Math.min(g.x,y.x),Math.min(g.y,y.y)),E=new a.Point(Math.max(g.x,y.x),Math.max(g.y,y.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(g,y))return this;const T=this.transform.pointLocation3D(v),A=this.transform.pointLocation3D(E),k=this.transform.pointLocation3D(new a.Point(v.x,E.y)),R=this.transform.pointLocation3D(new a.Point(E.x,v.y)),O=[Math.min(T.lng,A.lng,k.lng,R.lng),Math.min(T.lat,A.lat,k.lat,R.lat)],B=[Math.max(T.lng,A.lng,k.lng,R.lng),Math.max(T.lat,A.lat,k.lat,R.lat)],F=d&&d.pitch?d.pitch:this.getPitch(),I=this._cameraForBounds(this.transform,O,B,h,F,d);return this._fitInternal(I,d,f)}_fitInternal(r,o,h){return r?(delete(o=a.extend(r,o)).padding,o.linear?this.easeTo(o,h):this.flyTo(o,h)):this}jumpTo(r,o){this.stop();const h=r.preloadOnly?this.transform.clone():this.transform;let d=!1,f=!1,g=!1;return"zoom"in r&&h.zoom!==+r.zoom&&(d=!0,h.zoom=+r.zoom),r.center!==void 0&&(h.center=a.LngLat.convert(r.center)),"bearing"in r&&h.bearing!==+r.bearing&&(f=!0,h.bearing=+r.bearing),"pitch"in r&&h.pitch!==+r.pitch&&(g=!0,h.pitch=+r.pitch),r.padding==null||h.isPaddingEqual(r.padding)||(h.padding=r.padding),r.preloadOnly?(this._preloadTiles(h),this):(this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),d&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),f&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),g&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.warnOnce(An),this.transform.getFreeCameraOptions()}setFreeCameraOptions(r,o){const h=this.transform;if(!h.projection.supportsFreeCamera)return a.warnOnce(An),this;this.stop();const d=h.zoom,f=h.pitch,g=h.bearing;h.setFreeCameraOptions(r);const y=d!==h.zoom,v=f!==h.pitch,E=g!==h.bearing;return this.fire(new a.Event("movestart",o)).fire(new a.Event("move",o)),y&&this.fire(new a.Event("zoomstart",o)).fire(new a.Event("zoom",o)).fire(new a.Event("zoomend",o)),E&&this.fire(new a.Event("rotatestart",o)).fire(new a.Event("rotate",o)).fire(new a.Event("rotateend",o)),v&&this.fire(new a.Event("pitchstart",o)).fire(new a.Event("pitch",o)).fire(new a.Event("pitchend",o)),this.fire(new a.Event("moveend",o)),this}easeTo(r,o){this._stop(!1,r.easeId),((r=a.extend({offset:[0,0],duration:500,easing:a.ease},r)).animate===!1||this._prefersReducedMotion(r))&&(r.duration=0);const h=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="zoom"in r?+r.zoom:d,E="bearing"in r?this._normalizeBearing(r.bearing,f):f,T="pitch"in r?+r.pitch:g,A="padding"in r?r.padding:h.padding,k=a.Point.convert(r.offset);let R,O,B;if(h.projection.name==="globe"){const te=a.MercatorCoordinate.fromLngLat(h.center),le=k.rotate(-h.angle);te.x+=le.x/h.worldSize,te.y+=le.y/h.worldSize;const Ee=te.toLngLat(),oe=a.LngLat.convert(r.center||Ee);this._normalizeCenter(oe),R=h.centerPoint.add(le),O=new a.Point(te.x,te.y).mult(h.worldSize),B=new a.Point(a.mercatorXfromLng(oe.lng),a.mercatorYfromLat(oe.lat)).mult(h.worldSize).sub(O)}else{R=h.centerPoint.add(k);const te=h.pointLocation(R),le=a.LngLat.convert(r.center||te);this._normalizeCenter(le),O=h.project(te),B=h.project(le).sub(O)}const F=h.zoomScale(v-d);let I,L;r.around&&(I=a.LngLat.convert(r.around),L=h.locationPoint(I));const N=this._zooming||v!==d,j=this._rotating||f!==E,K=this._pitching||T!==g,J=!h.isPaddingEqual(A),Y=te=>le=>{if(N&&(te.zoom=a.number(d,v,le)),j&&(te.bearing=a.number(f,E,le)),K&&(te.pitch=a.number(g,T,le)),J&&(te.interpolatePadding(y,A,le),R=te.centerPoint.add(k)),I)te.setLocationAtPoint(I,L);else{const Ee=te.zoomScale(te.zoom-d),oe=v>d?Math.min(2,F):Math.max(.5,F),ge=Math.pow(oe,1-le),he=te.unproject(O.add(B.mult(le*ge)).mult(Ee));te.setLocationAtPoint(te.renderWorldCopies?he.wrap():he,R)}return r.preloadOnly||this._fireMoveEvents(o),te};if(r.preloadOnly){const te=this._emulate(Y,r.duration,h);return this._preloadTiles(te),this}const ie={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=N,this._rotating=j,this._pitching=K,this._padding=J,this._easeId=r.easeId,this._prepareEase(o,r.noMoveStart,ie),this._ease(Y(h),te=>{h.recenterOnTerrain(),this._afterEase(o,te)},r),this}_prepareEase(r,o,h={}){this._moving=!0,this.transform.cameraElevationReference="sea",o||h.moving||this.fire(new a.Event("movestart",r)),this._zooming&&!h.zooming&&this.fire(new a.Event("zoomstart",r)),this._rotating&&!h.rotating&&this.fire(new a.Event("rotatestart",r)),this._pitching&&!h.pitching&&this.fire(new a.Event("pitchstart",r))}_fireMoveEvents(r){this.fire(new a.Event("move",r)),this._zooming&&this.fire(new a.Event("zoom",r)),this._rotating&&this.fire(new a.Event("rotate",r)),this._pitching&&this.fire(new a.Event("pitch",r))}_afterEase(r,o){if(this._easeId&&o&&this._easeId===o)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const h=this._zooming,d=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,h&&this.fire(new a.Event("zoomend",r)),d&&this.fire(new a.Event("rotateend",r)),f&&this.fire(new a.Event("pitchend",r)),this.fire(new a.Event("moveend",r))}flyTo(r,o){if(this._prefersReducedMotion(r)){const be=a.pick(r,["center","zoom","bearing","pitch","around"]);return this.jumpTo(be,o)}this.stop(),r=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},r);const h=this.transform,d=this.getZoom(),f=this.getBearing(),g=this.getPitch(),y=this.getPadding(),v="zoom"in r?a.clamp(+r.zoom,h.minZoom,h.maxZoom):d,E="bearing"in r?this._normalizeBearing(r.bearing,f):f,T="pitch"in r?+r.pitch:g,A="padding"in r?r.padding:h.padding,k=h.zoomScale(v-d),R=a.Point.convert(r.offset);let O=h.centerPoint.add(R);const B=h.pointLocation(O),F=a.LngLat.convert(r.center||B);this._normalizeCenter(F);const I=h.project(B),L=h.project(F).sub(I);let N=r.curve;const j=Math.max(h.width,h.height),K=j/k,J=L.mag();if("minZoom"in r){const be=a.clamp(Math.min(r.minZoom,d,v),h.minZoom,h.maxZoom),Ae=j/h.zoomScale(be-d);N=Math.sqrt(Ae/J*2)}const Y=N*N;function ie(be){const Ae=(K*K-j*j+(be?-1:1)*Y*Y*J*J)/(2*(be?K:j)*Y*J);return Math.log(Math.sqrt(Ae*Ae+1)-Ae)}function te(be){return(Math.exp(be)-Math.exp(-be))/2}function le(be){return(Math.exp(be)+Math.exp(-be))/2}const Ee=ie(0);let oe=function(be){return le(Ee)/le(Ee+N*be)},ge=function(be){return j*((le(Ee)*(te(Ae=Ee+N*be)/le(Ae))-te(Ee))/Y)/J;var Ae},he=(ie(1)-Ee)/N;if(Math.abs(J)<1e-6||!isFinite(he)){if(Math.abs(j-K)<1e-6)return this.easeTo(r,o);const be=K<j?-1:1;he=Math.abs(Math.log(K/j))/N,ge=function(){return 0},oe=function(Ae){return Math.exp(be*N*Ae)}}r.duration="duration"in r?+r.duration:1e3*he/("screenSpeed"in r?+r.screenSpeed/N:+r.speed),r.maxDuration&&r.duration>r.maxDuration&&(r.duration=0);const Te=f!==E,ae=T!==g,_e=!h.isPaddingEqual(A),Me=be=>Ae=>{const Ge=Ae*he,He=1/oe(Ge);be.zoom=Ae===1?v:d+be.scaleZoom(He),Te&&(be.bearing=a.number(f,E,Ae)),ae&&(be.pitch=a.number(g,T,Ae)),_e&&(be.interpolatePadding(y,A,Ae),O=be.centerPoint.add(R));const Ve=Ae===1?F:be.unproject(I.add(L.mult(ge(Ge))).mult(He));return be.setLocationAtPoint(be.renderWorldCopies?Ve.wrap():Ve,O),be._updateCameraOnTerrain(),r.preloadOnly||this._fireMoveEvents(o),be};if(r.preloadOnly){const be=this._emulate(Me,r.duration,h);return this._preloadTiles(be),this}return this._zooming=!0,this._rotating=Te,this._pitching=ae,this._padding=_e,this._prepareEase(o,!1),this._ease(Me(h),()=>this._afterEase(o),r),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(r,o){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const h=this._onEaseEnd;this._onEaseEnd=void 0,h.call(this,o)}if(!r){const h=this.handlers;h&&h.stop(!1)}return this}_ease(r,o,h){h.animate===!1||h.duration===0?(r(1),o()):(this._easeStart=a.exported.now(),this._easeOptions=h,this._onEaseFrame=r,this._onEaseEnd=o,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const r=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1),o=this._onEaseFrame;o&&o(this._easeOptions.easing(r)),r<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(r,o){r=a.wrap(r,-180,180);const h=Math.abs(r-o);return Math.abs(r-360-o)<h&&(r-=360),Math.abs(r+360-o)<h&&(r+=360),r}_normalizeCenter(r){const o=this.transform;if(!o.renderWorldCopies||o.maxBounds)return;const h=r.lng-o.center.lng;r.lng+=h>180?-360:h<-180?360:0}_prefersReducedMotion(r){return this._respectPrefersReducedMotion&&a.exported.prefersReducedMotion&&!(r&&r.essential)}_emulate(r,o,h){const d=Math.ceil(15*o/1e3),f=[],g=r(h.clone());for(let y=0;y<=d;y++){const v=g(y/d);f.push(v.clone())}return f}}class Ue{constructor(r={}){this.options=r,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(r){const o=this.options&&this.options.compact;return this._map=r,this._container=nt("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=nt("button","mapboxgl-ctrl-attrib-button",this._container),nt("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=nt("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),o&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),o===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(r,o){const h=this._map._getUIString(`AttributionControl.${o}`);r.setAttribute("aria-label",h),r.removeAttribute("title"),r.firstElementChild&&r.firstElementChild.setAttribute("title",h)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let r=this._editLink;r||(r=this._editLink=this._container.querySelector(".mapbox-improve-map"));const o=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN}];if(r){const h=o.reduce((d,f,g)=>(f.value&&(d+=`${f.key}=${f.value}${g<o.length-1?"&":""}`),d),"?");r.href=`${a.config.FEEDBACK_URL}/${h}#${Jo(this._map,!0)}`,r.rel="noopener nofollow",this._setElementTitle(r,"MapFeedback")}}_updateData(r){!r||r.sourceDataType!=="metadata"&&r.sourceDataType!=="visibility"&&r.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let r=[];if(this._map.style.stylesheet){const d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}const o=this._map.style._sourceCaches;for(const d in o){const f=o[d];if(f.used){const g=f.getSource();g.attribution&&r.indexOf(g.attribution)<0&&r.push(g.attribution)}}r.sort((d,f)=>d.length-f.length),r=r.filter((d,f)=>{for(let g=f+1;g<r.length;g++)if(r[g].indexOf(d)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?r=[...this.options.customAttribution,...r]:r.unshift(this.options.customAttribution));const h=r.join(" | ");h!==this._attribHTML&&(this._attribHTML=h,r.length?(this._innerContainer.innerHTML=h,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class _l{constructor(){a.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(r){this._map=r,this._container=nt("div","mapboxgl-ctrl");const o=nt("a","mapboxgl-ctrl-logo");return o.target="_blank",o.rel="noopener nofollow",o.href="https://www.mapbox.com/",o.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),o.setAttribute("rel","noopener nofollow"),this._container.appendChild(o),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(r){r&&r.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const r=this._map.style._sourceCaches;if(Object.entries(r).length===0)return!0;for(const o in r){const h=r[o].getSource();if(h.hasOwnProperty("mapbox_logo")&&!h.mapbox_logo)return!1}return!0}_updateCompact(){const r=this._container.children;if(r.length){const o=r[0];this._map.getCanvasContainer().offsetWidth<250?o.classList.add("mapboxgl-compact"):o.classList.remove("mapboxgl-compact")}}}class gl{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(r){const o=++this._id;return this._queue.push({callback:r,id:o,cancelled:!1}),o}remove(r){const o=this._currentlyRunning,h=o?this._queue.concat(o):this._queue;for(const d of h)if(d.id===r)return void(d.cancelled=!0)}run(r=0){const o=this._currentlyRunning=this._queue;this._queue=[];for(const h of o)if(!h.cancelled&&(h.callback(r),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function po(l,r,o){if(l=new a.LngLat(l.lng,l.lat),r){const h=new a.LngLat(l.lng-360,l.lat),d=new a.LngLat(l.lng+360,l.lat),f=360*Math.ceil(Math.abs(l.lng-o.center.lng)/360),g=o.locationPoint(l).distSqr(r),y=r.x<0||r.y<0||r.x>o.width||r.y>o.height;o.locationPoint(h).distSqr(r)<g&&(y||Math.abs(h.lng-o.center.lng)<f)?l=h:o.locationPoint(d).distSqr(r)<g&&(y||Math.abs(d.lng-o.center.lng)<f)&&(l=d)}for(;Math.abs(l.lng-o.center.lng)>180;){const h=o.locationPoint(l);if(h.x>=0&&h.y>=0&&h.x<=o.width&&h.y<=o.height)break;l.lng>o.center.lng?l.lng-=360:l.lng+=360}return l}const In={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class Be extends a.Evented{constructor(r,o){if(super(),(r instanceof a.window.HTMLElement||o)&&(r=a.extend({element:r},o)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=r&&r.anchor||"center",this._color=r&&r.color||"#3FB1CE",this._scale=r&&r.scale||1,this._draggable=r&&r.draggable||!1,this._clickTolerance=r&&r.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=r&&r.rotation||0,this._rotationAlignment=r&&r.rotationAlignment||"auto",this._pitchAlignment=r&&r.pitchAlignment&&r.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=r&&r.occludedOpacity||.2,r&&r.element)this._element=r.element,this._offset=a.Point.convert(r&&r.offset||[0,0]);else{this._defaultMarker=!0,this._element=nt("div");const d=41,f=27,g=Si("svg",{display:"block",height:d*this._scale+"px",width:f*this._scale+"px",viewBox:`0 0 ${f} ${d}`},this._element),y=Si("radialGradient",{id:"shadowGradient"},Si("defs",{},g));Si("stop",{offset:"10%","stop-opacity":.4},y),Si("stop",{offset:"100%","stop-opacity":.05},y),Si("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},g),Si("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},g),Si("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},g),Si("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},g),this._offset=a.Point.convert(r&&r.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",d=>{d.preventDefault()}),this._element.addEventListener("mousedown",d=>{d.preventDefault()});const h=this._element.classList;for(const d in In)h.remove(`mapboxgl-marker-anchor-${d}`);h.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(r){return r===this._map||(this.remove(),this._map=r,r.getCanvasContainer().appendChild(this._element),r.on("move",this._updateMoving),r.on("moveend",this._update),r.on("remove",this._clearFadeTimer),r._addMarker(this),this.setDraggable(this._draggable),this._update(),r.on("click",this._onMapClick)),this}remove(){const r=this._map;return r&&(r.off("click",this._onMapClick),r.off("move",this._updateMoving),r.off("moveend",this._update),r.off("mousedown",this._addDragHandler),r.off("touchstart",this._addDragHandler),r.off("mouseup",this._onUp),r.off("touchend",this._onUp),r.off("mousemove",this._onMove),r.off("touchmove",this._onMove),r.off("remove",this._clearFadeTimer),r._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(r){return this._lngLat=a.LngLat.convert(r),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(r){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),r){if(!("offset"in r.options)){const d=Math.sqrt(Math.pow(13.5,2)/2);r.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[d,-1*(38.1-13.5+d)],"bottom-right":[-d,-1*(38.1-13.5+d)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=r,r._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(r){const o=r.code,h=r.charCode||r.keyCode;o!=="Space"&&o!=="Enter"&&h!==32&&h!==13||this.togglePopup()}_onMapClick(r){const o=r.originalEvent.target,h=this._element;this._popup&&(o===h||h.contains(o))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const r=this._popup;return r?(r.isOpen()?(r.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(r.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const r=this._map,o=this._pos;if(!r||!o)return!1;const h=r.unproject(o),d=r.getFreeCameraOptions();if(!d.position)return!1;const f=d.position.toLngLat();return f.distanceTo(h)<.9*f.distanceTo(this._lngLat)}_evaluateOpacity(){const r=this._map;if(!r)return;const o=this._pos;if(!o||o.x<0||o.x>r.transform.width||o.y<0||o.y>r.transform.height)return void this._clearFadeTimer();const h=r.unproject(o);let d;r._showingGlobe()&&a.isLngLatBehindGlobe(r.transform,this._lngLat)?d=0:(d=1-r._queryFogOpacity(h),r.transform._terrainEnabled()&&r.getTerrain()&&this._behindTerrain()&&(d*=this._occludedOpacity)),this._element.style.opacity=`${d}`,this._element.style.pointerEvents=d>0?"auto":"none",this._popup&&this._popup._setOpacity(d),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const r=this._pos;if(!r||!this._map)return;const o=this._offset.mult(this._scale);this._element.style.transform=`
1312
+ translate(${r.x}px,${r.y}px)
1313
+ ${In[this._anchor]}
1314
+ ${this._calculateXYTransform()} ${this._calculateZTransform()}
1315
+ translate(${o.x}px,${o.y}px)
1316
+ `}_calculateXYTransform(){const r=this._pos,o=this._map,h=this.getPitchAlignment();if(!o||!r||h!=="map")return"";if(!o._showingGlobe()){const v=o.getPitch();return v?`rotateX(${v}deg)`:""}const d=a.radToDeg(a.globeTiltAtLngLat(o.transform,this._lngLat)),f=r.sub(a.globeCenterToScreenPoint(o.transform)),g=Math.abs(f.x)+Math.abs(f.y);if(g===0)return"";const y=d/g;return`rotateX(${-f.y*y}deg) rotateY(${f.x*y}deg)`}_calculateZTransform(){const r=this._pos,o=this._map;if(!o||!r)return"";let h=0;const d=this.getRotationAlignment();if(d==="map")if(o._showingGlobe()){const f=o.project(new a.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),g=o.project(new a.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(f);h=a.radToDeg(Math.atan2(g.y,g.x))-90}else h=-o.getBearing();else if(d==="horizon"){const f=a.smoothstep(4,6,o.getZoom()),g=a.globeCenterToScreenPoint(o.transform);g.y+=f*o.transform.height;const y=r.sub(g),v=a.radToDeg(Math.atan2(y.y,y.x));h=(v>90?v-270:v+90)*(1-f)}return h+=this._rotation,h?`rotateZ(${h}deg)`:""}_update(r){a.window.cancelAnimationFrame(this._updateFrameId);const o=this._map;o&&(o.transform.renderWorldCopies&&(this._lngLat=po(this._lngLat,this._pos,o.transform)),this._pos=o.project(this._lngLat),r===!0?this._updateFrameId=a.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),o._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(o._showingGlobe()||o.getTerrain()||o.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(r){return this._offset=a.Point.convert(r),this._update(),this}_onMove(r){const o=this._map;if(!o)return;const h=this._pointerdownPos,d=this._positionDelta;if(h&&d){if(!this._isDragging){const f=this._clickTolerance||o._clickTolerance;if(r.point.dist(h)<f)return;this._isDragging=!0}this._pos=r.point.sub(d),this._lngLat=o.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new a.Event("dragstart"))),this.fire(new a.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const r=this._map;r&&(r.off("mousemove",this._onMove),r.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new a.Event("dragend")),this._state="inactive"}_addDragHandler(r){const o=this._map,h=this._pos;o&&h&&this._element.contains(r.originalEvent.target)&&(r.preventDefault(),this._positionDelta=r.point.sub(h),this._pointerdownPos=r.point,this._state="pending",o.on("mousemove",this._onMove),o.on("touchmove",this._onMove),o.once("mouseup",this._onUp),o.once("touchend",this._onUp))}setDraggable(r){this._draggable=!!r;const o=this._map;return o&&(r?(o.on("mousedown",this._addDragHandler),o.on("touchstart",this._addDragHandler)):(o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(r){return this._rotation=r||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(r){return this._rotationAlignment=r||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(r){return this._pitchAlignment=r||"auto",this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(r){return this._occludedOpacity=r||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const yl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Jh=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Gc(l=new a.Point(0,0),r="bottom"){if(typeof l=="number"){const o=Math.round(Math.sqrt(.5*Math.pow(l,2)));switch(r){case"top":return new a.Point(0,l);case"top-left":return new a.Point(o,o);case"top-right":return new a.Point(-o,o);case"bottom":return new a.Point(0,-l);case"bottom-left":return new a.Point(o,-o);case"bottom-right":return new a.Point(-o,-o);case"left":return new a.Point(l,0);case"right":return new a.Point(-l,0)}return new a.Point(0,0)}return l instanceof a.Point||Array.isArray(l)?a.Point.convert(l):a.Point.convert(l[r]||[0,0])}class xl{constructor(r){this.jumpTo(r)}getValue(r){if(r<=this._startTime)return this._start;if(r>=this._endTime)return this._end;const o=a.easeCubicInOut((r-this._startTime)/(this._endTime-this._startTime));return this._start*(1-o)+this._end*o}isEasing(r){return r>=this._startTime&&r<=this._endTime}jumpTo(r){this._startTime=-1/0,this._endTime=-1/0,this._start=r,this._end=r}easeTo(r,o,h){this._start=this.getValue(o),this._end=r,this._startTime=o,this._endTime=o+h}}const $c={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},Zc={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},Qh={showCompass:!0,showZoom:!0,visualizePitch:!1};class eu{constructor(r,o,h=!1){this._clickTolerance=10,this.element=o,this.mouseRotate=new ul({clickTolerance:r.dragRotate._mouseRotate._clickTolerance}),this.map=r,h&&(this.mousePitch=new dl({clickTolerance:r.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),o.addEventListener("mousedown",this.mousedown),o.addEventListener("touchstart",this.touchstart,{passive:!1}),o.addEventListener("touchmove",this.touchmove),o.addEventListener("touchend",this.touchend),o.addEventListener("touchcancel",this.reset)}down(r,o){this.mouseRotate.mousedown(r,o),this.mousePitch&&this.mousePitch.mousedown(r,o),Mo()}move(r,o){const h=this.map,d=this.mouseRotate.mousemoveWindow(r,o),f=d&&d.bearingDelta;if(f&&h.setBearing(h.getBearing()+f),this.mousePitch){const g=this.mousePitch.mousemoveWindow(r,o),y=g&&g.pitchDelta;y&&h.setPitch(h.getPitch()+y)}}off(){const r=this.element;r.removeEventListener("mousedown",this.mousedown),r.removeEventListener("touchstart",this.touchstart,{passive:!1}),r.removeEventListener("touchmove",this.touchmove),r.removeEventListener("touchend",this.touchend),r.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Un(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(r){this.down(a.extend({},r,{ctrlKey:!0,preventDefault:()=>r.preventDefault()}),sr(this.element,r)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(r){this.move(r,sr(this.element,r))}mouseup(r){this.mouseRotate.mouseupWindow(r),this.mousePitch&&this.mousePitch.mouseupWindow(r),this.offTemp()}touchstart(r){r.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=pn(this.element,r.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>r.preventDefault()},this._startPos))}touchmove(r){r.targetTouches.length!==1?this.reset():(this._lastPos=pn(this.element,r.targetTouches)[0],this.move({preventDefault:()=>r.preventDefault()},this._lastPos))}touchend(r){r.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const vl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},bl={maxWidth:100,unit:"metric"},wl={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},fo={version:a.version,supported:ui,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends ta{constructor(l){if(a.LivePerformanceUtils.mark(a.PerformanceMarkers.create),(l=a.extend({},Zc,l)).minZoom!=null&&l.maxZoom!=null&&l.minZoom>l.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(l.minPitch!=null&&l.maxPitch!=null&&l.minPitch>l.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(l.minPitch!=null&&l.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(l.maxPitch!=null&&l.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(l.antialias&&a.isSafariWithAntialiasingBug(a.window)&&(l.antialias=!1,a.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new lo(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),l),this._interactive=l.interactive,this._minTileCacheSize=l.minTileCacheSize,this._maxTileCacheSize=l.maxTileCacheSize,this._failIfMajorPerformanceCaveat=l.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=l.preserveDrawingBuffer,this._antialias=l.antialias,this._useWebGL2=l.useWebGL2,this._trackResize=l.trackResize,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles,this._fadeDuration=l.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=l.crossSourceCollisions,this._collectResourceTiming=l.collectResourceTiming,this._optimizeForTerrain=l.optimizeForTerrain,this._language=this._parseLanguage(l.language),this._worldview=l.worldview,this._renderTaskQueue=new gl,this._domRenderTaskQueue=new gl,this._controls=[],this._markers=[],this._popups=[],this._mapId=a.uniqueId(),this._locale=a.extend({},$c,l.locale),this._clickTolerance=l.clickTolerance,this._cooperativeGestures=l.cooperativeGestures,this._performanceMetricsCollection=l.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new xl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new a.RequestManager(l.transformRequest,l.accessToken,l.testMode),this._silenceAuthErrors=!!l.testMode,typeof l.container=="string"){if(this._container=a.window.document.getElementById(l.container),!this._container)throw new Error(`Container '${l.container}' not found.`)}else{if(!(l.container instanceof a.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(this._container.childNodes.length>0&&a.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),l.maxBounds&&this.setMaxBounds(l.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),a.window!==void 0&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),a.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new xr(this,l),this._localFontFamily=l.localFontFamily,this._localIdeographFontFamily=l.localIdeographFontFamily,l.style&&this.setStyle(l.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),l.projection&&this.setProjection(l.projection),this._hash=l.hash&&new al(typeof l.hash=="string"&&l.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch}),l.bounds&&(this.resize(),this.fitBounds(l.bounds,a.extend({},l.fitBoundsOptions,{duration:0})))),this.resize(),l.attributionControl&&this.addControl(new Ue({customAttribution:l.customAttribution})),this._logoControl=new _l,this.addControl(this._logoControl,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",r=>{this._update(r.dataType==="style"),this.fire(new a.Event(`${r.dataType}data`,r))}),this.on("dataloading",r=>{this.fire(new a.Event(`${r.dataType}dataloading`,r))})}_getMapId(){return this._mapId}addControl(l,r){if(r===void 0&&(r=l.getDefaultPosition?l.getDefaultPosition():"top-right"),!l||!l.onAdd)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const o=l.onAdd(this);this._controls.push(l);const h=this._controlPositions[r];return r.indexOf("bottom")!==-1?h.insertBefore(o,h.firstChild):h.appendChild(o),this}removeControl(l){if(!l||!l.onRemove)return this.fire(new a.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const r=this._controls.indexOf(l);return r>-1&&this._controls.splice(r,1),l.onRemove(this),this}hasControl(l){return this._controls.indexOf(l)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(l){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const r=!this._moving;return r&&this.fire(new a.Event("movestart",l)).fire(new a.Event("move",l)),this.fire(new a.Event("resize",l)),r&&this.fire(new a.Event("moveend",l)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(l){return this.transform.setMaxBounds(a.LngLatBounds.convert(l)),this._update()}setMinZoom(l){if((l=l??-2)>=-2&&l<=this.transform.maxZoom)return this.transform.minZoom=l,this._update(),this.getZoom()<l?this.setZoom(l):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(l){if((l=l??22)>=this.transform.minZoom)return this.transform.maxZoom=l,this._update(),this.getZoom()>l?this.setZoom(l):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(l){if((l=l??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(l>=0&&l<=this.transform.maxPitch)return this.transform.minPitch=l,this._update(),this.getPitch()<l?this.setPitch(l):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(l){if((l=l??85)>85)throw new Error("maxPitch must be less than or equal to 85");if(l>=this.transform.minPitch)return this.transform.maxPitch=l,this._update(),this.getPitch()>l?this.setPitch(l):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(l){return this.transform.renderWorldCopies=l,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(l){return l==="auto"?a.window.navigator.language:Array.isArray(l)?l.length===0?void 0:l.map(r=>r==="auto"?a.window.navigator.language:r):l}setLanguage(l){const r=this._parseLanguage(l);if(!this.style||r===this._language)return this;this._language=r,this.style._reloadSources();for(const o of this._controls)o._setLanguage&&o._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(l){return this.style&&l!==this._worldview?(this._worldview=l,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(l){return this._lazyInitEmptyStyle(),l?typeof l=="string"&&(l={name:l}):l=null,this._useExplicitProjection=!!l,this._prioritizeAndUpdateProjection(l,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const l=this.transform,r=l.projection.name;let o;r==="globe"&&l.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX?(l.setMercatorFromTransition(),o=!0):r==="mercator"&&l.zoom<a.GLOBE_ZOOM_THRESHOLD_MAX&&(l.setProjection({name:"globe"}),o=!0),o&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(l,r){return this._updateProjection(l||r||{name:"mercator"})}_updateProjection(l){let r;if(r=l.name==="globe"&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(l),this.style.applyProjectionUpdate(),r){this.painter.clearBackgroundTiles();for(const o in this.style._sourceCaches)this.style._sourceCaches[o].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(l){return this.transform.locationPoint3D(a.LngLat.convert(l))}unproject(l){return this.transform.pointLocation3D(a.Point.convert(l))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(l,r,o){if(l==="mouseenter"||l==="mouseover"){let h=!1;const d=g=>{const y=r.filter(E=>this.getLayer(E)),v=y.length?this.queryRenderedFeatures(g.point,{layers:y}):[];v.length?h||(h=!0,o.call(this,new yi(l,this,g.originalEvent,{features:v}))):h=!1},f=()=>{h=!1};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}if(l==="mouseleave"||l==="mouseout"){let h=!1;const d=g=>{const y=r.filter(v=>this.getLayer(v));(y.length?this.queryRenderedFeatures(g.point,{layers:y}):[]).length?h=!0:h&&(h=!1,o.call(this,new yi(l,this,g.originalEvent)))},f=g=>{h&&(h=!1,o.call(this,new yi(l,this,g.originalEvent)))};return{layers:new Set(r),listener:o,delegates:{mousemove:d,mouseout:f}}}{const h=d=>{const f=r.filter(y=>this.getLayer(y)),g=f.length?this.queryRenderedFeatures(d.point,{layers:f}):[];g.length&&(d.features=g,o.call(this,d),delete d.features)};return{layers:new Set(r),listener:o,delegates:{[l]:h}}}}on(l,r,o){if(o===void 0)return super.on(l,r);Array.isArray(r)||(r=[r]);const h=this._createDelegatedListener(l,r,o);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[l]=this._delegatedListeners[l]||[],this._delegatedListeners[l].push(h);for(const d in h.delegates)this.on(d,h.delegates[d]);return this}once(l,r,o){if(o===void 0)return super.once(l,r);Array.isArray(r)||(r=[r]);const h=this._createDelegatedListener(l,r,o);for(const d in h.delegates)this.once(d,h.delegates[d]);return this}off(l,r,o){if(o===void 0)return super.off(l,r);r=new Set(Array.isArray(r)?r:[r]);const h=(f,g)=>{if(f.size!==g.size)return!1;for(const y of f)if(!g.has(y))return!1;return!0},d=this._delegatedListeners?this._delegatedListeners[l]:void 0;return d&&(f=>{for(let g=0;g<f.length;g++){const y=f[g];if(y.listener===o&&h(y.layers,r)){for(const v in y.delegates)this.off(v,y.delegates[v]);return f.splice(g,1),this}}})(d),this}queryRenderedFeatures(l,r){return this.style?(r!==void 0||l===void 0||l instanceof a.Point||Array.isArray(l)||(r=l,l=void 0),this.style.queryRenderedFeatures(l=l||[[0,0],[this.transform.width,this.transform.height]],r=r||{},this.transform)):[]}querySourceFeatures(l,r){return this.style.querySourceFeatures(l,r)}isPointOnSurface(l){const{name:r}=this.transform.projection;return r!=="globe"&&r!=="mercator"&&a.warnOnce(`${r} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(a.Point.convert(l))}setStyle(l,r){return(r=a.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},r)).diff!==!1&&r.localIdeographFontFamily===this._localIdeographFontFamily&&r.localFontFamily===this._localFontFamily&&this.style&&l?(this._diffStyle(l,r),this):(this._localIdeographFontFamily=r.localIdeographFontFamily,this._localFontFamily=r.localFontFamily,this._updateStyle(l,r))}_getUIString(l){const r=this._locale[l];if(r==null)throw new Error(`Missing UI string '${l}'`);return r}_updateStyle(l,r){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),l&&(this.style=new gr(this,r||{}),this.style.setEventedParent(this,{style:this.style}),typeof l=="string"?this.style.loadURL(l):this.style.loadJSON(l)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new gr(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(l,r){if(typeof l=="string"){const o=this._requestManager.normalizeStyleURL(l),h=this._requestManager.transformRequest(o,a.ResourceType.Style);a.getJSON(h,(d,f)=>{d?this.fire(new a.ErrorEvent(d)):f&&this._updateDiff(f,r)})}else typeof l=="object"&&this._updateDiff(l,r)}_updateDiff(l,r){try{this.style.setState(l)&&this._update(!0)}catch(o){a.warnOnce(`Unable to perform style diff: ${o.message||o.error||o}. Rebuilding the style from scratch.`),this._updateStyle(l,r)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(a.warnOnce("There is no style added to the map."),!1)}addSource(l,r){return this._lazyInitEmptyStyle(),this.style.addSource(l,r),this._update(!0)}isSourceLoaded(l){return!!this.style&&this.style._isSourceCacheLoaded(l)}areTilesLoaded(){const l=this.style&&this.style._sourceCaches;for(const r in l){const o=l[r]._tiles;for(const h in o){const d=o[h];if(d.state!=="loaded"&&d.state!=="errored")return!1}}return!0}addSourceType(l,r,o){this._lazyInitEmptyStyle(),this.style.addSourceType(l,r,o)}removeSource(l){return this.style.removeSource(l),this._updateTerrain(),this._update(!0)}getSource(l){return this.style.getSource(l)}addImage(l,r,{pixelRatio:o=1,sdf:h=!1,stretchX:d,stretchY:f,content:g}={}){if(this._lazyInitEmptyStyle(),r instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&r instanceof a.window.ImageBitmap){const{width:y,height:v,data:E}=a.exported.getImageData(r);this.style.addImage(l,{data:new a.RGBAImage({width:y,height:v},E),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:h,version:0})}else if(r.width===void 0||r.height===void 0)this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:y,height:v}=r,E=r;this.style.addImage(l,{data:new a.RGBAImage({width:y,height:v},new Uint8Array(E.data)),pixelRatio:o,stretchX:d,stretchY:f,content:g,sdf:h,version:0,userImage:E}),E.onAdd&&E.onAdd(this,l)}}updateImage(l,r){const o=this.style.getImage(l);if(!o)return void this.fire(new a.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const h=r instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&r instanceof a.window.ImageBitmap?a.exported.getImageData(r):r,{width:d,height:f}=h;d!==void 0&&f!==void 0?d===o.data.width&&f===o.data.height?(o.data.replace(h.data,!(r instanceof a.window.HTMLImageElement||a.window.ImageBitmap&&r instanceof a.window.ImageBitmap)),this.style.updateImage(l,o)):this.fire(new a.ErrorEvent(new Error(`The width and height of the updated image (${d}, ${f})
1317
+ must be that same as the previous version of the image
1318
+ (${o.data.width}, ${o.data.height})`))):this.fire(new a.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(l){return l?!!this.style.getImage(l):(this.fire(new a.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(l){this.style.removeImage(l)}loadImage(l,r){a.getImage(this._requestManager.transformRequest(l,a.ResourceType.Image),(o,h)=>{r(o,h instanceof a.window.HTMLImageElement?a.exported.getImageData(h):h)})}listImages(){return this.style.listImages()}addLayer(l,r){return this._lazyInitEmptyStyle(),this.style.addLayer(l,r),this._update(!0)}moveLayer(l,r){return this.style.moveLayer(l,r),this._update(!0)}removeLayer(l){return this.style.removeLayer(l),this._update(!0)}getLayer(l){return this.style.getLayer(l)}setLayerZoomRange(l,r,o){return this.style.setLayerZoomRange(l,r,o),this._update(!0)}setFilter(l,r,o={}){return this.style.setFilter(l,r,o),this._update(!0)}getFilter(l){return this.style.getFilter(l)}setPaintProperty(l,r,o,h={}){return this.style.setPaintProperty(l,r,o,h),this._update(!0)}getPaintProperty(l,r){return this.style.getPaintProperty(l,r)}setLayoutProperty(l,r,o,h={}){return this.style.setLayoutProperty(l,r,o,h),this._update(!0)}getLayoutProperty(l,r){return this.style.getLayoutProperty(l,r)}setLight(l,r={}){return this._lazyInitEmptyStyle(),this.style.setLight(l,r),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(l){return this._lazyInitEmptyStyle(),!l&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(l),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(l){return this._lazyInitEmptyStyle(),this.style.setFog(l),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(l){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(l),this.transform):0}setFeatureState(l,r){return this.style.setFeatureState(l,r),this._update()}removeFeatureState(l,r){return this.style.removeFeatureState(l,r),this._update()}getFeatureState(l){return this.style.getFeatureState(l)}_updateContainerDimensions(){if(!this._container)return;const l=this._container.getBoundingClientRect().width||400,r=this._container.getBoundingClientRect().height||300;let o,h,d,f=this._container;for(;f&&(!h||!d);){const g=a.window.getComputedStyle(f).transform;g&&g!=="none"&&(o=g.match(/matrix.*\((.+)\)/)[1].split(", "),o[0]&&o[0]!=="0"&&o[0]!=="1"&&(h=o[0]),o[3]&&o[3]!=="0"&&o[3]!=="1"&&(d=o[3])),f=f.parentElement}this._containerWidth=h?Math.abs(l/h):l,this._containerHeight=d?Math.abs(r/d):r}_detectMissingCSS(){a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&a.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const l=this._container;l.classList.add("mapboxgl-map"),(this._missingCSSCanary=nt("div","mapboxgl-canary",l)).style.visibility="hidden",this._detectMissingCSS();const r=this._canvasContainer=nt("div","mapboxgl-canvas-container",l);this._interactive&&r.classList.add("mapboxgl-interactive"),this._canvas=nt("canvas","mapboxgl-canvas",r),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const o=this._controlContainer=nt("div","mapboxgl-control-container",l),h=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(d=>{h[d]=nt("div",`mapboxgl-ctrl-${d}`,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(l,r){const o=a.exported.devicePixelRatio||1;this._canvas.width=o*Math.ceil(l),this._canvas.height=o*Math.ceil(r),this._canvas.style.width=`${l}px`,this._canvas.style.height=`${r}px`}_addMarker(l){this._markers.push(l)}_removeMarker(l){const r=this._markers.indexOf(l);r!==-1&&this._markers.splice(r,1)}_addPopup(l){this._popups.push(l)}_removePopup(l){const r=this._popups.indexOf(l);r!==-1&&this._popups.splice(r,1)}_setupPainter(){const l=a.extend({},ui.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._useWebGL2&&this._canvas.getContext("webgl2",l),o=r||this._canvas.getContext("webgl",l)||this._canvas.getContext("experimental-webgl",l);o?(this._useWebGL2&&!r&&a.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),a.storeAuthState(o,!0),this.painter=new so(o,this.transform,!!r),this.on("data",h=>{h.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(o)):this.fire(new a.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(l){l.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:l}))}_contextRestored(l){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:l}))}_onMapScroll(l){if(l.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(l){return this.style?(this._styleDirty=this._styleDirty||l,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(l){return this._update(),this._renderTaskQueue.add(l)}_cancelRenderFrame(l){this._renderTaskQueue.remove(l)}_requestDomTask(l){!this.loaded()||this.loaded()&&!this.isMoving()?l():this._domRenderTaskQueue.add(l)}_render(l){let r;const o=this.painter.context.extTimerQuery,h=a.exported.now();if(this.listens("gpu-timing-frame")&&(r=o.createQueryEXT(),o.beginQueryEXT(o.TIME_ELAPSED_EXT,r)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],a.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],a.window.performance.now())),this._renderTaskQueue.run(l),this._domRenderTaskQueue.run(l),this._removed)return;this._updateProjectionTransition();const d=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const y=this.transform.zoom,v=this.transform.pitch,E=a.exported.now(),T=new a.EvaluationParameters(y,{now:E,fadeDuration:d,pitch:v,transition:this.style.getTransition()});this.style.update(T)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let f=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),f=this._updateAverageElevation(h),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):f=this._updateAverageElevation(h),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,d,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:d,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const y=a.exported.now()-h;o.endQueryEXT(o.TIME_ELAPSED_EXT,r),setTimeout(()=>{const v=o.getQueryObjectEXT(r,o.QUERY_RESULT_EXT)/1e6;o.deleteQueryEXT(r),this.fire(new a.Event("gpu-timing-frame",{cpuTime:y,gpuTime:v})),a.window.performance.mark("frame-gpu",{startTime:h,detail:{gpuTime:v}})},50)}if(this.listens("gpu-timing-layer")){const y=this.painter.collectGpuTimers();setTimeout(()=>{const v=this.painter.queryGpuTimers(y);this.fire(new a.Event("gpu-timing-layer",{layerTimes:v}))},50)}if(this.listens("gpu-timing-deferred-render")){const y=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const v=this.painter.queryGpuTimeDeferredRender(y);this.fire(new a.Event("gpu-timing-deferred-render",{gpuTime:v}))},50)}const g=this._sourcesDirty||this._styleDirty||this._placementDirty||f;if(g||this._repaint)this.triggerRepaint();else{const y=!this.isMoving()&&this.loaded();if(y&&(f=this._updateAverageElevation(h,!0)),f)this.triggerRepaint();else if(this._triggerFrame(!1),y&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const v=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:v})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||g||(this._fullyLoaded=!0,a.LivePerformanceUtils.mark(a.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&a.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(l){for(const r of this._markers)l&&!this.getRenderWorldCopies()&&(r._lngLat=r._lngLat.wrap()),r._update();for(const r of this._popups)!l||this.getRenderWorldCopies()||r._trackPointer||(r._lngLat=r._lngLat.wrap()),r._update()}_updateAverageElevation(l,r=!1){const o=h=>(this.transform.averageElevation=h,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&o(0);if((r||l-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(l)){const h=this.transform.averageElevation;let d=this.transform.sampleAverageElevation(),f=!1;this.transform.elevation&&(f=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(d)?d=0:this._averageElevationLastSampledAt=l;const g=Math.abs(h-d);if(g>1){if(this._isInitialLoad||f)return this._averageElevation.jumpTo(d),o(d);this._averageElevation.easeTo(d,l,300)}else if(g>1e-4)return this._averageElevation.jumpTo(d),o(d)}return!!this._averageElevation.isEasing(l)&&o(this._averageElevation.getValue(l))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,l=>{if(l&&(l.message===a.AUTH_ERR_MSG||l.status===401)){const r=this.painter.context.gl;a.storeAuthState(r,!1),this._logoControl instanceof _l&&this._logoControl._updateLogo(),r&&r.clear(r.DEPTH_BUFFER_BIT|r.COLOR_BUFFER_BIT|r.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const l=this._isDragging();this.painter.updateTerrain(this.style,l)}_calculateSpeedIndex(){const l=this.painter.canvasCopy(),r=this.painter.getCanvasCopiesAndTimestamps();r.timeStamps.push(performance.now());const o=this.painter.context.gl,h=o.createFramebuffer();function d(f){o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,f,0);const g=new Uint8Array(o.drawingBufferWidth*o.drawingBufferHeight*4);return o.readPixels(0,0,o.drawingBufferWidth,o.drawingBufferHeight,o.RGBA,o.UNSIGNED_BYTE,g),g}return o.bindFramebuffer(o.FRAMEBUFFER,h),this._canvasPixelComparison(d(l),r.canvasCopies.map(d),r.timeStamps)}_canvasPixelComparison(l,r,o){let h=o[1]-o[0];const d=l.length/4;for(let f=0;f<r.length;f++){const g=r[f];let y=0;for(let v=0;v<g.length;v+=4)g[v]===l[v]&&g[v+1]===l[v+1]&&g[v+2]===l[v+2]&&g[v+3]===l[v+3]&&(y+=1);h+=(o[f+2]-o[f+1])*(1-y/d)}return h}remove(){this._hash&&this._hash.remove();for(const r of this._controls)r.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),a.window!==void 0&&(a.window.removeEventListener("resize",this._onWindowResize,!1),a.window.removeEventListener("orientationchange",this._onWindowResize,!1),a.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),a.window.removeEventListener("online",this._onWindowOnline,!1),a.window.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const l=this.painter.context.gl.getExtension("WEBGL_lose_context");l&&l.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),a.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new a.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(l){this._renderNextFrame=this._renderNextFrame||l,this.style&&!this._frame&&(this._frame=a.exported.frame(r=>{const o=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,o&&this._render(r)}))}_preloadTiles(l){const r=this.style?Object.values(this.style._sourceCaches):[];return a.asyncAll(r,(o,h)=>o._preloadTiles(l,h),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(l){this._trackResize&&this.resize({originalEvent:l})._update()}_onVisibilityChange(){a.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(l){this._showTileBoundaries!==l&&(this._showTileBoundaries=l,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(l){this._showTerrainWireframe!==l&&(this._showTerrainWireframe=l,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(l){this._speedIndexTiming!==l&&(this._speedIndexTiming=l,this._update())}get showPadding(){return!!this._showPadding}set showPadding(l){this._showPadding!==l&&(this._showPadding=l,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(l){this._showCollisionBoxes!==l&&(this._showCollisionBoxes=l,l?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(l){this._showOverdrawInspector!==l&&(this._showOverdrawInspector=l,this._update())}get repaint(){return!!this._repaint}set repaint(l){this._repaint!==l&&(this._repaint=l,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(l){this._vertices=l,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(l){this._showTileAABBs!==l&&(this._showTileAABBs=l,l&&this._update())}_setCacheLimits(l,r){a.setCacheLimits(l,r)}get version(){return a.version}},NavigationControl:class{constructor(l){this.options=a.extend({},Qh,l),this._container=nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",r=>r.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",r=>{this._map&&this._map.zoomIn({},{originalEvent:r})}),nt("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",r=>{this._map&&this._map.zoomOut({},{originalEvent:r})}),nt("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",r=>{const o=this._map;o&&(this.options.visualizePitch?o.resetNorthPitch({},{originalEvent:r}):o.resetNorth({},{originalEvent:r}))}),this._compassIcon=nt("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const l=this._map;if(!l)return;const r=l.getZoom(),o=r===l.getMaxZoom(),h=r===l.getMinZoom();this._zoomInButton.disabled=o,this._zoomOutButton.disabled=h,this._zoomInButton.setAttribute("aria-disabled",o.toString()),this._zoomOutButton.setAttribute("aria-disabled",h.toString())}_rotateCompassArrow(){const l=this._map;if(!l)return;const r=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(l.transform.pitch*(Math.PI/180)),.5)}) rotateX(${l.transform.pitch}deg) rotateZ(${l.transform.angle*(180/Math.PI)}deg)`:`rotate(${l.transform.angle*(180/Math.PI)}deg)`;l._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=r)})}onAdd(l){return this._map=l,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),l.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&l.on("pitch",this._rotateCompassArrow),l.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new eu(l,this._compass,this.options.visualizePitch)),this._container}onRemove(){const l=this._map;l&&(this._container.remove(),this.options.showZoom&&l.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&l.off("pitch",this._rotateCompassArrow),l.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(l,r){const o=nt("button",l,this._container);return o.type="button",o.addEventListener("click",r),o}_setButtonTitle(l,r){if(!this._map)return;const o=this._map._getUIString(`NavigationControl.${r}`);l.setAttribute("aria-label",o),l.firstElementChild&&l.firstElementChild.setAttribute("title",o)}},GeolocateControl:class extends a.Evented{constructor(l){super(),this.options=a.extend({geolocation:a.window.navigator.geolocation},vl,l),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=co(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(l){return this._map=l,this._container=nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(l){const r=(o=!!this.options.geolocation)=>{this._supportsGeolocation=o,l(o)};this._supportsGeolocation!==void 0?l(this._supportsGeolocation):a.window.navigator.permissions!==void 0?a.window.navigator.permissions.query({name:"geolocation"}).then(o=>r(o.state!=="denied")).catch(()=>r()):r()}_isOutOfMapMaxBounds(l){const r=this._map.getMaxBounds(),o=l.coords;return!!r&&(o.longitude<r.getWest()||o.longitude>r.getEast()||o.latitude<r.getSouth()||o.latitude>r.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(l){if(this._map){if(this._isOutOfMapMaxBounds(l))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",l)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=l,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(l),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(l),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",l)),this._finish()}}_updateCamera(l){const r=new a.LngLat(l.coords.longitude,l.coords.latitude),o=l.coords.accuracy,h=this._map.getBearing(),d=a.extend({bearing:h},this.options.fitBoundsOptions);this._map.fitBounds(r.toBounds(o),d,{geolocateSource:!0})}_updateMarker(l){if(l){const r=new a.LngLat(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(r).addTo(this._map),this._userLocationDotMarker.setLngLat(r).addTo(this._map),this._accuracy=l.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const l=this._map.transform,r=a.mercatorZfromAltitude(1,l._center.lat)*l.worldSize,o=Math.ceil(2*this._accuracy*r);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(l){if(this._map){if(this.options.trackUserLocation)if(l.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",l)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(l){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",r=>r.preventDefault()),this._geolocateButton=nt("button","mapboxgl-ctrl-geolocate",this._container),nt("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",l===!1){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const r=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}else{const r=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",r),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",r)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=nt("div","mapboxgl-user-location"),this._dotElement.appendChild(nt("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(nt("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Be({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=nt("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Be({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",r=>{r.geolocateSource||this._watchState!=="ACTIVE_LOCK"||r.originalEvent&&r.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}}_onDeviceOrientation(l){this._userLocationDotMarker&&(l.webkitCompassHeading?this._heading=l.webkitCompassHeading:l.absolute===!0&&(this._heading=-1*l.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.warnOnce("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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new a.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new a.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let l;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(l={maximumAge:6e5,timeout:0},this._noTimeout=!0):(l=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,l),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const l=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};a.window.DeviceMotionEvent!==void 0&&typeof a.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(r=>{r==="granted"&&l()}).catch(console.error):l()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientation),a.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ue,ScaleControl:class{constructor(l){this.options=a.extend({},bl,l),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),a.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const l=this.options.maxWidth||100,r=this._map,o=r._containerHeight/2,h=r._containerWidth/2-l/2,d=r.unproject([h,o]),f=r.unproject([h+l,o]),g=d.distanceTo(f);if(this.options.unit==="imperial"){const y=3.2808*g;y>5280?this._setScale(l,y/5280,"mile"):this._setScale(l,y,"foot")}else this.options.unit==="nautical"?this._setScale(l,g/1852,"nautical-mile"):g>=1e3?this._setScale(l,g/1e3,"kilometer"):this._setScale(l,g,"meter")}_setScale(l,r,o){this._map._requestDomTask(()=>{const h=function(f){const g=Math.pow(10,`${Math.floor(f)}`.length-1);let y=f/g;return y=y>=10?10:y>=5?5:y>=3?3:y>=2?2:y>=1?1:function(v){const E=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*E)/E}(y),g*y}(r),d=h/r;this._container.innerHTML=this._isNumberFormatSupported&&o!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:o}).format(h):`${h}&nbsp;${wl[o]}`,this._container.style.width=l*d+"px"})}onAdd(l){return this._map=l,this._language=l.getLanguage(),this._container=nt("div","mapboxgl-ctrl mapboxgl-ctrl-scale",l.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(l){this._language=l,this._update()}setUnit(l){this.options.unit=l,this._update()}},FullscreenControl:class{constructor(l){this._fullscreen=!1,l&&l.container&&(l.container instanceof a.window.HTMLElement?this._container=l.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(l){return this._map=l,this._container||(this._container=this._map.getContainer()),this._controlContainer=nt("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const l=this._fullscreenButton=nt("button","mapboxgl-ctrl-fullscreen",this._controlContainer);nt("span","mapboxgl-ctrl-icon",l).setAttribute("aria-hidden","true"),l.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const l=this._getTitle();this._fullscreenButton.setAttribute("aria-label",l),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",l)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(l){super(),this.options=a.extend(Object.create(yl),l),a.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(l&&l.className?l.className.trim().split(/\s+/):[])}addTo(l){return this._map&&this.remove(),this._map=l,this.options.closeOnClick&&l.on("preclick",this._onClose),this.options.closeOnMove&&l.on("move",this._onClose),l.on("remove",this.remove),this._update(),l._addPopup(this),this._focusFirstElement(),this._trackPointer?(l.on("mousemove",this._onMouseEvent),l.on("mouseup",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")):l.on("move",this._update),this.fire(new a.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const l=this._map;return l&&(l.off("move",this._update),l.off("move",this._onClose),l.off("preclick",this._onClose),l.off("click",this._onClose),l.off("remove",this.remove),l.off("mousemove",this._onMouseEvent),l.off("mouseup",this._onMouseEvent),l.off("drag",this._onMouseEvent),l._canvasContainer&&l._canvasContainer.classList.remove("mapboxgl-track-pointer"),l._removePopup(this),this._map=void 0),this.fire(new a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(l){this._lngLat=a.LngLat.convert(l),this._pos=null,this._trackPointer=!1,this._update();const r=this._map;return r&&(r.on("move",this._update),r.off("mousemove",this._onMouseEvent),r._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const l=this._map;return l&&(l.off("move",this._update),l.on("mousemove",this._onMouseEvent),l.on("drag",this._onMouseEvent),l._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(l){return this.setDOMContent(a.window.document.createTextNode(l))}setHTML(l){const r=a.window.document.createDocumentFragment(),o=a.window.document.createElement("body");let h;for(o.innerHTML=l;h=o.firstChild,h;)r.appendChild(h);return this.setDOMContent(r)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(l){return this.options.maxWidth=l,this._update(),this}setDOMContent(l){let r=this._content;if(r)for(;r.hasChildNodes();)r.firstChild&&r.removeChild(r.firstChild);else r=this._content=nt("div","mapboxgl-popup-content",this._container||void 0);if(r.appendChild(l),this.options.closeButton){const o=this._closeButton=nt("button","mapboxgl-popup-close-button",r);o.type="button",o.setAttribute("aria-label","Close popup"),o.setAttribute("aria-hidden","true"),o.innerHTML="&#215;",o.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(l){return this._classList.add(l),this._updateClassList(),this}removeClassName(l){return this._classList.delete(l),this._updateClassList(),this}setOffset(l){return this.options.offset=l,this._update(),this}toggleClassName(l){let r;return this._classList.delete(l)?r=!1:(this._classList.add(l),r=!0),this._updateClassList(),r}_onMouseEvent(l){this._update(l.point)}_getAnchor(l){if(this.options.anchor)return this.options.anchor;const r=this._map,o=this._container,h=this._pos;if(!r||!o||!h)return"bottom";const d=o.offsetWidth,f=o.offsetHeight,g=h.x<d/2,y=h.x>r.transform.width-d/2;if(h.y+l<f)return g?"top-left":y?"top-right":"top";if(h.y>r.transform.height-f){if(g)return"bottom-left";if(y)return"bottom-right"}return g?"left":y?"right":"bottom"}_updateClassList(){const l=this._container;if(!l)return;const r=[...this._classList];r.push("mapboxgl-popup"),this._anchor&&r.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&r.push("mapboxgl-popup-track-pointer"),l.className=r.join(" ")}_update(l){const r=this._map,o=this._content;if(!r||!this._lngLat&&!this._trackPointer||!o)return;let h=this._container;if(h||(h=this._container=nt("div","mapboxgl-popup",r.getContainer()),this._tip=nt("div","mapboxgl-popup-tip",h),h.appendChild(o)),this.options.maxWidth&&h.style.maxWidth!==this.options.maxWidth&&(h.style.maxWidth=this.options.maxWidth),r.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=po(this._lngLat,this._pos,r.transform)),!this._trackPointer||l){const d=this._pos=this._trackPointer&&l?l:r.project(this._lngLat),f=Gc(this.options.offset),g=this._anchor=this._getAnchor(f.y),y=Gc(this.options.offset,g),v=d.add(y).round();r._requestDomTask(()=>{this._container&&g&&(this._container.style.transform=`${In[g]} translate(${v.x}px,${v.y}px)`)})}if(!this._marker&&r._showingGlobe()){const d=a.isLngLatBehindGlobe(r.transform,this._lngLat)?0:1;this._setOpacity(d)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const l=this._container.querySelector(Jh);l&&l.focus()}_onClose(){this.remove()}_setOpacity(l){this._container&&(this._container.style.opacity=`${l}`),this._content&&(this._content.style.pointerEvents=l?"auto":"none")}},Marker:Be,Style:gr,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.Point,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:Ic,Evented:a.Evented,config:a.config,prewarm:function(){Hn().acquire(fr)},clearPrewarmedResources:function(){const l=Pi;l&&(l.isPreloaded()&&l.numActive()===1?(l.release(fr),Pi=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.config.ACCESS_TOKEN},set accessToken(l){a.config.ACCESS_TOKEN=l},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(l){a.config.API_URL=l},get workerCount(){return _i.workerCount},set workerCount(l){_i.workerCount=l},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(l){a.config.MAX_PARALLEL_IMAGE_REQUESTS=l},clearStorage(l){a.clearTileCache(l)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return fo});var Di=jt;return Di})})(Xf);var Rg=Xf.exports;dd.extend(Mg);const Bg=Fn.memo(({longitude:St,latitude:qt,altitude:dt=0,frameloop:rt="always",...jt})=>{const Kt=Fn.useMemo(()=>Cg({latitude:qt,longitude:St,altitude:dt,fromLngLat:Rg.MercatorCoordinate.fromLngLat}),[qt,St,dt]);return zh.jsx(Wf,{frameloop:rt,m4:Kt,...jt})});exports.Canvas=Bg;